From af32f65015e4681f377b23a7eb682bb3f3ede62c Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Wed, 10 Sep 2025 17:10:24 +0200 Subject: [PATCH] store routeinfo and advanced search info in db --- .../controllers/api/frontend/v1/RouteInfo.php | 50 +++++++++++++++++++ .../controllers/api/frontend/v1/Searchbar.php | 13 +++++ public/js/api/factory/routeinfo.js | 29 +++++++++++ public/js/apps/Dashboard/Fhc.js | 6 +++ 4 files changed, 98 insertions(+) create mode 100644 application/controllers/api/frontend/v1/RouteInfo.php create mode 100644 public/js/api/factory/routeinfo.js diff --git a/application/controllers/api/frontend/v1/RouteInfo.php b/application/controllers/api/frontend/v1/RouteInfo.php new file mode 100644 index 000000000..f9b4df7f3 --- /dev/null +++ b/application/controllers/api/frontend/v1/RouteInfo.php @@ -0,0 +1,50 @@ +. + */ +if (!defined('BASEPATH')) + exit('No direct script access allowed'); + +class RouteInfo extends FHCAPI_Controller +{ + + public function __construct() + { + parent::__construct([ + 'info' => self::PERM_LOGGED, + ]); + + $this->load->model('system/Webservicelog_model', 'WebservicelogModel'); + } + + public function info() + { + $payload = json_decode($this->input->raw_input_stream); + + if (isset($payload->app) && isset($payload->path)) + { + $this->WebservicelogModel->insert(array( + 'webservicetyp_kurzbz' => 'content', + 'beschreibung' => $payload->app, + 'request_data' => $payload->path, + 'execute_user' => getAuthUID(), + 'execute_time' => 'NOW()' + )); + } + $this->terminateWithSuccess(true); + } +} diff --git a/application/controllers/api/frontend/v1/Searchbar.php b/application/controllers/api/frontend/v1/Searchbar.php index 363b6e534..b4c251555 100644 --- a/application/controllers/api/frontend/v1/Searchbar.php +++ b/application/controllers/api/frontend/v1/Searchbar.php @@ -39,6 +39,8 @@ class Searchbar extends FHCAPI_Controller 'searchCis' => self::PERM_LOGGED, 'searchStv' => self::PERM_LOGGED ]); + + $this->load->model('system/Webservicelog_model', 'WebservicelogModel'); } //------------------------------------------------------------------------------------------------------------------ @@ -103,6 +105,17 @@ class Searchbar extends FHCAPI_Controller // Convert to json the result from searchlib->search $result = $this->searchlib->search($this->input->post(self::SEARCHSTR_PARAM), $this->input->post(self::TYPES_PARAM)); + $this->WebservicelogModel->insert(array( + 'webservicetyp_kurzbz' => 'content', + 'beschreibung' => $config['config'], + 'request_data' => json_encode(array( + self::SEARCHSTR_PARAM => $this->input->post(self::SEARCHSTR_PARAM), + self::TYPES_PARAM => $this->input->post(self::TYPES_PARAM) + )), + 'execute_user' => getAuthUID(), + 'execute_time' => 'NOW()' + )); + $data = $this->getDataOrTerminateWithError($result); $this->addMeta('time', $result->meta['time']); diff --git a/public/js/api/factory/routeinfo.js b/public/js/api/factory/routeinfo.js new file mode 100644 index 000000000..9ec2ad2a0 --- /dev/null +++ b/public/js/api/factory/routeinfo.js @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + info(app, path) { + return { + method: 'post', + url: '/api/frontend/v1/RouteInfo/info', + params: { + app: app, + path: path + } + }; + } +}; \ No newline at end of file diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index 473e1cf67..870d9d1d6 100644 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -18,6 +18,7 @@ import DeadlineOverview from "../../components/Cis/Abgabetool/DeadlineOverview.j import Studium from "../../components/Cis/Studium/Studium.js"; import ApiRenderers from '../../api/factory/renderers.js'; +import ApiRouteInfo from '../../api/factory/routeinfo.js'; const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router; @@ -319,6 +320,7 @@ const app = Vue.createApp({ // kind of a bandaid for bad css on some pages to avoid horizontal scroll setScrollbarWidth(); + app.use(router); app.use(primevue.config.default, { zIndex: { @@ -331,3 +333,7 @@ app.use(PluginsPhrasen); app.use(Theme); app.directive('contrast', contrast); app.mount('#fhccontent'); + +router.afterEach((to, from, failure) => { + app.config.globalProperties.$api.call(ApiRouteInfo.info('cis4', to.fullPath)); +}); \ No newline at end of file