diff --git a/application/controllers/components/LRT.php b/application/controllers/components/LRT.php new file mode 100644 index 000000000..11f98a396 --- /dev/null +++ b/application/controllers/components/LRT.php @@ -0,0 +1,38 @@ + self::PERM_LOGGED, + ) + ); + + // Loads libraries + $this->load->library('LongRunTaskLib'); + } + + /** + * + */ + public function getRunningLRTs() + { + $runningLrtsResult = $this->longruntasklib->getRunningLRTsUser(getAuthUID()); + + if (isError($runningLrtsResult)) $this->terminateWithJsonError($runningLrtsResult); + + $this->outputJson($runningLrtsResult); + } +} + diff --git a/application/controllers/lrts/LRTDummy.php b/application/controllers/lrts/LRTDummy.php index 45c3e1c2f..b277ead0a 100644 --- a/application/controllers/lrts/LRTDummy.php +++ b/application/controllers/lrts/LRTDummy.php @@ -9,7 +9,7 @@ if (!defined("BASEPATH")) exit("No direct script access allowed"); class LRTDummy extends LRT_Controller { /** - * This method must be implemented! + * */ public function run($jobid) { diff --git a/application/libraries/LongRunTaskLib.php b/application/libraries/LongRunTaskLib.php index b6cf99247..0f96643ba 100644 --- a/application/libraries/LongRunTaskLib.php +++ b/application/libraries/LongRunTaskLib.php @@ -280,6 +280,27 @@ class LongRunTaskLib extends JobsQueueLib return success('LRT added to the queue'); } + /** + * Get all the LRT that are currently running for the given user + */ + public function getRunningLRTsUser($uid) + { + // Return the result of the query + return $this->_ci->JobsQueueModel->execReadOnlyQuery(' + SELECT jq.* + FROM system.tbl_jobsqueue jq + WHERE jq.type IN ? + AND jq.status = ? + AND jq.uid = ? + ORDER BY jq.creationtime DESC', + array( + $this->_ci->config->item(self::CFG_LRT_TYPES), + JobsQueueLib::STATUS_RUNNING, + $uid + ) + ); + } + //------------------------------------------------------------------------------------------------------------------ // Public methods used by the LRT implementation (controllers/ltrs/*, ex. controllers/ltrs/LRTDummy) diff --git a/public/js/api/lrt.js b/public/js/api/lrt.js new file mode 100644 index 000000000..fb46062cd --- /dev/null +++ b/public/js/api/lrt.js @@ -0,0 +1,25 @@ +/** + * 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 { + load() { + return { + method: 'get', + url: '/components/LRT/getRunningLRTs' + }; + } +}; diff --git a/public/js/components/LRT.js b/public/js/components/LRT.js new file mode 100644 index 000000000..8141da941 --- /dev/null +++ b/public/js/components/LRT.js @@ -0,0 +1,69 @@ +/** + * Copyright (C) 2026 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 . + */ + +import ApiLRT from '../api/lrt.js'; + +export default { + name: 'LRTComponent', + props: { + appIdentifier: { + type: String, + required: true + }, + navigationPage: { + type: String, + default: 'apps' + } + }, + data() { + return { + items: [] + }; + }, + watch: { + navigationPage() { + this.getItems(); + } + }, + methods: { + getItems() { + this.$api + .call(ApiNavigation.getMenu(this.navigationPage)) + .then(result => { + this.items = result.data; + }) + .catch(this.$fhcAlert.handleSystemError); + } + }, + created() { + this.getItems(); + }, + template: /* html */` + ` +};