Added examples

This commit is contained in:
Paolo
2026-08-13 10:40:45 +02:00
parent 61982b1199
commit 4defb96147
5 changed files with 154 additions and 1 deletions
@@ -0,0 +1,38 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
class LRT extends Auth_Controller
{
/**
* Object initialization
*/
public function __construct()
{
parent::__construct(
array(
'getRunningLRTs' => 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);
}
}
+1 -1
View File
@@ -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)
{
+21
View File
@@ -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)
+25
View File
@@ -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 <https://www.gnu.org/licenses/>.
*/
export default {
load() {
return {
method: 'get',
url: '/components/LRT/getRunningLRTs'
};
}
};
+69
View File
@@ -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 <https://www.gnu.org/licenses/>.
*/
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 */`
<ul class="fhc-app-menu">
<li v-for="(menu, key) in items" :key="key">
<a
:href="menu.link"
@click="menu.onClickCall"
:class="{ active: key === appIdentifier }"
>
<i v-if="menu.icon" class="fa fa-fw" :class="'fa-'+ menu.icon" />
{{ menu.description }}
</a>
</li>
<slot />
</ul>`
};