Skip to content

Commit

Permalink
minor ui fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Borysenko <[email protected]>
  • Loading branch information
andrey18106 committed Feb 19, 2024
1 parent 848f070 commit 800cfc0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
6 changes: 5 additions & 1 deletion lib/Controller/ExAppsPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ private function getAppsForCategory(string $requestedCategory = ''): array {
'daemon' => $daemon,
'systemApp' => $exApp !== null && $this->exAppUsersService->exAppUserExists($exApp->getAppid(), ''),
'status' => $exApp !== null ? $exApp->getStatus() : [],
'error' => $exApp !== null ? $exApp->getStatus()['error'] ?? '' : '',
];
}

Expand Down Expand Up @@ -288,7 +289,9 @@ public function listApps(): JSONResponse {
}))[0]['releases'][0]['version'];
}

$appData['canUnInstall'] = !$appData['active'] && $appData['removable'];
$exApp = $this->exAppService->getExApp($appData['id']);
$appData['canUnInstall'] = !$appData['active'] && $appData['removable']

Check failure on line 293 in lib/Controller/ExAppsPageController.php

View workflow job for this annotation

GitHub Actions / php-psalm-analysis (8.1)

InvalidArgument

lib/Controller/ExAppsPageController.php:293:31: InvalidArgument: Isset only works with variables and array elements (see https://psalm.dev/004)
&& $exApp !== null && in_array($exApp->getStatus()['type'], ['install', 'update']) ?? false;

// fix licence vs license
if (isset($appData['license']) && !isset($appData['licence'])) {
Expand Down Expand Up @@ -383,6 +386,7 @@ private function buildLocalAppsList(array $apps, array $exApps): array {
'releases' => [],
'update' => null,
'status' => $exApp->getStatus(),
'error' => $exApp->getStatus()['error'] ?? '',
];
}
}
Expand Down
41 changes: 29 additions & 12 deletions src/store/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ const mutations = {

setAppStatus(state, { appId, status }) {
const app = state.apps.find(app => app.id === appId)
if (status.type === 'install' && status.deploy === 100) {
if (status.type === 'install' && status.deploy === 100 && status.action === '') {
console.debug('catching intermediate state deploying -> initializing')
// catching moment when app is deployed but initialization status not started yet
status.action = 'init'
}
Expand Down Expand Up @@ -367,27 +368,43 @@ const actions = {
context.commit('setAppStatus', { appId, status: response.data })
if (!Object.hasOwn(response.data, 'progress') || response.data?.progress === 100) {
const initializingOrDeployingApps = context.getters.getInitializingOrDeployingApps
console.debug('initializingOrDeployingApps after setAppStatus', initializingOrDeployingApps)
if (initializingOrDeployingApps.length === 0) {
console.debug('clearing interval')
clearInterval(context.getters.getStatusUpdater)
context.commit('setIntervalUpdater', null)
}
if (Object.hasOwn(response.data, 'error')
&& response.data.error !== ''
&& initializingOrDeployingApps.length === 1) {
clearInterval(context.getters.getStatusUpdater)
context.commit('setIntervalUpdater', null)
}
}
})
.catch((error) => context.commit('API_FAILURE', error))
.catch((error) => {
context.commit('API_FAILURE', error)
context.commit('unregisterApp', { appId })
context.dispatch('updateAppsStatus')
})
},

updateAppsStatus(context) {
clearInterval(context.getters.getStatusUpdater) // clear previous interval if exists
context.commit('setIntervalUpdater', setInterval(() => {
const initializingOrDeployingApps = context.getters.getInitializingOrDeployingApps
Array.from(initializingOrDeployingApps).forEach(app => {
context.dispatch('getAppStatus', { appId: app.id })
if ((app.status.deploy === 100 && app.status.init === 0) || app.status.type === 'update') {
// get ExApp info once app is deployed or during update
context.dispatch('getExAppInfo', { appId: app.id })
}
})
}, 2000))
if (context.getters.getInitializingOrDeployingApps.length > 0) {
context.commit('setIntervalUpdater', setInterval(() => {
const initializingOrDeployingApps = context.getters.getInitializingOrDeployingApps
console.debug('initializingOrDeployingApps', initializingOrDeployingApps)
Array.from(initializingOrDeployingApps).forEach(app => {
context.dispatch('getAppStatus', { appId: app.id })
if ((app.status.deploy === 100 && app.status.init === 0) || app.status.type === 'update') {
console.debug('getExAppInfo', app.id)
// get ExApp info once app is deployed or during update
context.dispatch('getExAppInfo', { appId: app.id })
}
})
}, 2000))
}
},

}
Expand Down

0 comments on commit 800cfc0

Please sign in to comment.