diff --git a/application/controllers/api/frontend/v1/Bookmark.php b/application/controllers/api/frontend/v1/Bookmark.php new file mode 100644 index 000000000..a811843ce --- /dev/null +++ b/application/controllers/api/frontend/v1/Bookmark.php @@ -0,0 +1,109 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +class Bookmark extends FHCAPI_Controller +{ + + /** + * Object initialization + */ + public function __construct() + { + parent::__construct([ + 'getBookmarks' => self::PERM_LOGGED, + 'delete' => self::PERM_LOGGED, + 'insert' => self::PERM_LOGGED, + ]); + + $this->load->model('dashboard/Bookmark_model', 'BookmarkModel'); + + $this->uid = getAuthUID(); + $this->pid = getAuthPersonID(); + + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + + /** + * gets the bookmarks associated to a user + * @access public + * @return void + */ + public function getBookmarks() + { + $bookmarks = $this->BookmarkModel->loadWhere(["uid"=>$this->uid]); + + $bookmarks = $this->getDataOrTerminateWithError($bookmarks); + + $this->terminateWithSuccess($bookmarks); + } + + /** + * deletes bookmark from associated user + * @access public + * @return void + */ + public function delete($bookmark_id) + { + $bookmark = $this->BookmarkModel->load($bookmark_id); + + $bookmark = current($this->getDataOrTerminateWithError($bookmark)); + + // only delete bookmark if the user is the owner of the bookmark + if($bookmark->uid == $this->uid || $this->permissionlib->isBerechtigt('admin')){ + + $delete_result = $this->BookmarkModel->delete($bookmark_id); + + $delete_result = $this->getDataOrTerminateWithError($delete_result); + + $this->terminateWithSuccess($delete_result); + }else{ + $this->_outputAuthError(['delete' => ['admin:rw']]); + } + } + + /** + * inserts new bookmark into the bookmark table + * @access public + * @return void + */ + public function insert() + { + // form validation + $this->load->library('form_validation'); + $this->form_validation->set_rules('url', 'URL', 'required|valid_url|max_length[511]'); + $this->form_validation->set_rules('title', 'Title', 'required|max_length[255]'); + if($this->form_validation->run() == FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $url = $this->input->post('url',true); + $title = $this->input->post('title',true); + $tag = $this->input->post('tag', true); + + $insert_into_result = $this->BookmarkModel->insert(['uid'=>$this->uid, 'url'=>$url, 'title'=>$title,'tag'=>$tag, 'insertvon'=>$this->uid, 'updateamum'=>NULL, 'updatevon'=>NULL]); + + $insert_into_result = $this->getDataOrTerminateWithError($insert_into_result); + + $this->terminateWithSuccess($insert_into_result); + + } +} + diff --git a/application/models/dashboard/Bookmark_model.php b/application/models/dashboard/Bookmark_model.php new file mode 100644 index 000000000..5efacc26b --- /dev/null +++ b/application/models/dashboard/Bookmark_model.php @@ -0,0 +1,18 @@ +dbTable = 'dashboard.tbl_bookmark'; + $this->pk = 'bookmark_id'; + } + + + + +} diff --git a/public/js/api/bookmark.js b/public/js/api/bookmark.js new file mode 100644 index 000000000..30e49d50d --- /dev/null +++ b/public/js/api/bookmark.js @@ -0,0 +1,27 @@ +export default { + + getBookmarks: function () { + return this.$fhcApi.get( + `/api/frontend/v1/Bookmark/getBookmarks` + ,{} + ); + }, + + delete: function (bookmark_id) { + return this.$fhcApi.get( + `/api/frontend/v1/Bookmark/delete/${bookmark_id}` + ,{} + ); + }, + + insert: function ({url, title, tag}) { + return this.$fhcApi.post( + `/api/frontend/v1/Bookmark/insert` + ,{ + url: url, + title: title, + tag: tag + } + ); + }, +} \ No newline at end of file diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index 73ce0dd7f..99f154992 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -22,6 +22,7 @@ import filter from "./filter.js"; import studstatus from "./studstatus.js"; import profil from "./profil.js"; import profilUpdate from "./profilUpdate.js"; +import bookmark from "./bookmark.js"; export default { search, @@ -31,4 +32,5 @@ export default { studstatus, profil, profilUpdate, + bookmark, }; diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index ebcbb4b78..a20bb5b64 100755 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -1,4 +1,5 @@ import FhcDashboard from '../../components/Dashboard/Dashboard.js'; +import Phrasen from "../../plugin/Phrasen.js"; const app = Vue.createApp({ data: () => ({ @@ -9,4 +10,5 @@ const app = Vue.createApp({ } }); app.config.unwrapInjectedRef = true; +app.use(Phrasen); app.mount('#content'); diff --git a/public/js/components/Dashboard/Item.js b/public/js/components/Dashboard/Item.js index 43e03ebc7..484171857 100755 --- a/public/js/components/Dashboard/Item.js +++ b/public/js/components/Dashboard/Item.js @@ -3,22 +3,23 @@ import CachedWidgetLoader from "../../composables/Dashboard/CachedWidgetLoader.j export default { components: { - BsModal + BsModal, }, data: () => ({ - component: '', + component: "", arguments: null, target: false, widget: null, tmpConfig: {}, isLoading: false, - hasConfig: true + hasConfig: true, + sharedData: null, }), emits: [ "change", "remove", "dragstart", - "resizestart", + "resizestart" ], props: [ "id", @@ -28,17 +29,16 @@ export default { "custom", "hidden", "editMode", - "loading" + "loading", ], computed: { isResizeable() { - if (!this.widget) - return false; + if (!this.widget) return false; return this.widget.setup.width.max || this.widget.setup.height.max; }, ready() { - return this.component && this.arguments !== null - } + return this.component && this.arguments !== null; + }, }, methods: { mouseDown(e) { @@ -46,18 +46,19 @@ export default { }, startDrag(e) { if (this.$refs.dragHandle.contains(this.target)) { - this.$emit('dragstart', e); - } else if (this.isResizeable && this.$refs.resizeHandle.contains(this.target)) { - if (this.isResizeable) - this.$emit('resizestart', e); - else - e.preventDefault(); + this.$emit("dragstart", e); + } else if ( + this.isResizeable && + this.$refs.resizeHandle.contains(this.target) + ) { + if (this.isResizeable) this.$emit("resizestart", e); + else e.preventDefault(); } else { e.preventDefault(); } }, openConfig() { - this.tmpConfig = {...this.arguments}; + this.tmpConfig = { ...this.arguments }; this.$refs.config.show(); }, setConfig(hasConfig) { @@ -65,39 +66,39 @@ export default { }, changeConfig() { this.isLoading = true; - let config = {...this.tmpConfig}; + let config = { ...this.tmpConfig }; this.sendChangeConfig(config); }, changeConfigManually() { - let config = {...this.arguments}; + let config = { ...this.arguments }; this.sendChangeConfig(config); }, sendChangeConfig(config) { for (var k in config) { if (this.widget.arguments[k] == config[k]) { - delete config[k]; + delete config[k]; } } - this.$emit('change', config); - } + this.$emit("change", config); + }, }, watch: { config() { - this.arguments = {...this.widget.arguments, ...this.config}; - this.tmpConfig = {...this.arguments}; + this.arguments = { ...this.widget.arguments, ...this.config }; + this.tmpConfig = { ...this.arguments }; this.$refs.config.hide(); this.isLoading = false; - } + }, }, async created() { this.widget = await CachedWidgetLoader.loadWidget(this.id); - let component = (await import('../' + this.widget.setup.file)).default; - this.$options.components['widget' + this.widget.widget_id] = component; - this.component = 'widget' + this.widget.widget_id; - this.arguments = {...this.widget.arguments, ...this.config}; - this.tmpConfig = {...this.arguments}; + let component = (await import("../" + this.widget.setup.file)).default; + this.$options.components["widget" + this.widget.widget_id] = component; + this.component = "widget" + this.widget.widget_id; + this.arguments = { ...this.widget.arguments, ...this.config }; + this.tmpConfig = { ...this.arguments }; }, - template: ` + template: /*html*/ `
@@ -116,7 +117,7 @@ export default {
- +
@@ -124,10 +125,10 @@ export default { {{ widget ? 'Config for ' + widget.setup.name : '' }} -