Show app configure menu items only when applicable

This commit is contained in:
Johannes Zellner
2025-02-25 15:21:32 +01:00
parent 9f8bde7078
commit 62b648c70f
2 changed files with 49 additions and 17 deletions
+27 -2
View File
@@ -1,5 +1,5 @@
import { APP_TYPES, HSTATES, ISTATES, RSTATES } from '../constants.js';
import { APP_TYPES, PROXY_APP_ID, HSTATES, ISTATES, RSTATES } from '../constants.js';
import { fetcher } from 'pankow';
import { sleep } from 'pankow/utils';
import moment from 'moment';
@@ -136,6 +136,7 @@ function create() {
for (const app of result.body.apps) {
app.ssoAuth = app.sso && (app.manifest.addons['ldap'] || app.manifest.addons['oidc'] || app.manifest.addons['proxyAuth']); // checking app.sso first ensures app.manifest.addons is not null
app.type = app.manifest.id === PROXY_APP_ID ? APP_TYPES.PROXIED : APP_TYPES.APP;
// only fetch if we have permissions and a taskId is set/active
if (!app.taskId || (app.accessLevel !== 'operator' && app.accessLevel !== 'admin')) {
@@ -168,7 +169,31 @@ function create() {
}
if (error || result.status !== 200) return [error || result];
return [null, result.body];
const app = result.body;
app.ssoAuth = app.sso && (app.manifest.addons['ldap'] || app.manifest.addons['oidc'] || app.manifest.addons['proxyAuth']); // checking app.sso first ensures app.manifest.addons is not null
app.type = app.manifest.id === PROXY_APP_ID ? APP_TYPES.PROXIED : APP_TYPES.APP;
// only fetch if we have permissions and a taskId is set/active
if (!app.taskId || (app.accessLevel !== 'operator' && app.accessLevel !== 'admin')) {
app.progress = 0;
app.message = '';
app.taskMinutesActive = 0;
} else {
const task = await getTask(app.id);
if (task) {
app.progress = task.percent;
app.message = task.message;
app.taskMinutesActive = moment.duration(moment.utc().diff(moment.utc(task.creationTime))).asMinutes();
} else {
app.progress = 0;
app.message = '';
app.taskMinutesActive = 0;
}
}
return [null, app];
},
async restart(id) {
let result;