AppsView: updateInfo is now part of app object
This commit is contained in:
@@ -37,21 +37,16 @@ async function onAutoUpdatesEnabledChange(value) {
|
||||
}
|
||||
|
||||
async function refreshUpdates() {
|
||||
const [error, result] = await updaterModel.info();
|
||||
const [error, result] = await updaterModel.checkAppUpdate(props.app.id);
|
||||
if (error) return console.error(error);
|
||||
|
||||
const appUpdate = result[props.app.id] || null;
|
||||
if (!appUpdate) update.value = null;
|
||||
else if (!appUpdate.manifest) update.value = null;
|
||||
else if (!appUpdate.manifest.version) update.value = null;
|
||||
else if (appUpdate.manifest.version === props.app.manifest.version) update.value = null;
|
||||
else update.value = appUpdate;
|
||||
update.value = result;
|
||||
}
|
||||
|
||||
async function onCheck() {
|
||||
busyCheck.value = true;
|
||||
|
||||
const [error] = await appsModel.checkForUpdates(props.app.id);
|
||||
const [error] = await appsModel.checkUpdate(props.app.id);
|
||||
if (error) return console.error(error);
|
||||
|
||||
await refreshUpdates();
|
||||
@@ -74,7 +69,7 @@ async function onUpdate() {
|
||||
|
||||
dialog.value.close();
|
||||
|
||||
[error] = await appsModel.checkForUpdates(props.app.id);
|
||||
[error] = await appsModel.checkUpdate(props.app.id);
|
||||
if (error) return console.error(error);
|
||||
}
|
||||
|
||||
@@ -91,7 +86,7 @@ onMounted(async () => {
|
||||
busyUpdate.value = false;
|
||||
busyCheck.value = false;
|
||||
autoUpdatesEnabled.value = props.app.enableAutomaticUpdate;
|
||||
await refreshUpdates();
|
||||
update.value = props.app.updateInfo;
|
||||
|
||||
const [error, result] = await profileModel.get();
|
||||
if (error) return console.error(error);
|
||||
|
||||
@@ -324,10 +324,10 @@ function create() {
|
||||
if (result.status !== 200) return [result];
|
||||
return [null, result.body.eventlogs];
|
||||
},
|
||||
async checkForUpdates(id) {
|
||||
async checkUpdate(id) {
|
||||
let result;
|
||||
try {
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/apps/${id}/check_for_updates`, {}, { access_token: accessToken });
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/apps/${id}/check_update`, {}, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
return [e];
|
||||
}
|
||||
|
||||
@@ -50,6 +50,18 @@ function create() {
|
||||
if (error || result.status !== 200) return [error || result];
|
||||
return [null];
|
||||
},
|
||||
async checkAppUpdate(id) {
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.post(`${API_ORIGIN}/api/v1/apps/${id}/check_update`, {}, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
if (error || result.status !== 200) return [error || result];
|
||||
return [null];
|
||||
},
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import AppsModel from '../models/AppsModel.js';
|
||||
import ApplinksModel from '../models/ApplinksModel.js';
|
||||
import DomainsModel from '../models/DomainsModel.js';
|
||||
import ProfileModel from '../models/ProfileModel.js';
|
||||
import UpdaterModel from '../models/UpdaterModel.js';
|
||||
import ApplinkDialog from '../components/ApplinkDialog.vue';
|
||||
import PostInstallDialog from '../components/PostInstallDialog.vue';
|
||||
|
||||
@@ -15,7 +14,6 @@ const appsModel = AppsModel.create();
|
||||
const domainsModel = DomainsModel.create();
|
||||
const applinksModel = ApplinksModel.create();
|
||||
const profileModel = ProfileModel.create();
|
||||
const updaterModel = UpdaterModel.create();
|
||||
|
||||
const VIEW_TYPE = {
|
||||
LIST: 'list',
|
||||
@@ -115,14 +113,12 @@ const filteredApps = computed(() => {
|
||||
|
||||
if (stateFilter.value === 'running') return a.runState === RSTATES.RUNNING && a.health === HSTATES.HEALTHY && a.installationState === ISTATES.INSTALLED;
|
||||
if (stateFilter.value === 'stopped') return a.runState === RSTATES.STOPPED;
|
||||
if (stateFilter.value === 'update_available') return a.updateAvailable;
|
||||
if (stateFilter.value === 'update_available') return a.updateInfo;
|
||||
|
||||
return a.runState === RSTATES.RUNNING && (a.health !== HSTATES.HEALTHY || a.installationState !== ISTATES.INSTALLED); // not responding
|
||||
});
|
||||
});
|
||||
|
||||
const updateInfo = ref({});
|
||||
|
||||
const applinkDialog = useTemplateRef('applinkDialog');
|
||||
const postInstallDialog = useTemplateRef('postInstallDialog');
|
||||
|
||||
@@ -170,11 +166,6 @@ async function refreshApps() {
|
||||
const [error, result] = await appsModel.list();
|
||||
if (error) return console.error(error);
|
||||
|
||||
// amend update info
|
||||
result.forEach((a) => {
|
||||
a.updateAvailable = !!(updateInfo.value[a.id] && updateInfo.value[a.id].manifest.version && updateInfo.value[a.id].manifest.version !== a.manifest.version);
|
||||
});
|
||||
|
||||
const [applinkError, applinks] = await applinksModel.list();
|
||||
if (applinkError) return console.error(applinkError);
|
||||
|
||||
@@ -205,12 +196,7 @@ function toggleView() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
let [error, result] = await updaterModel.info();
|
||||
if (error) return console.error(error);
|
||||
|
||||
updateInfo.value = result;
|
||||
|
||||
[error, result] = await profileModel.get();
|
||||
let [error, result] = await profileModel.get();
|
||||
if (error) return console.error(error);
|
||||
|
||||
profile.value = result;
|
||||
@@ -264,7 +250,7 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<a class="config" v-show="isOperator(app)" @click="openAppEdit(app, $event)" :href="`#/app/${app.id}/info`" :title="$t('app.configureTooltip')"><Icon icon="fa-solid fa-cog" /></a>
|
||||
<div class="grid-item-indictors">
|
||||
<a class="grid-item-update-indicator" v-if="app.updateAvailable" @click.stop :href="isOperator(app) ? `#/app/${app.id}/updates` : null" v-tooltip="$t('app.updateAvailableTooltip')"><i class="fa-fw fa-solid fa-arrow-up"/></a>
|
||||
<a class="grid-item-update-indicator" v-if="app.updateInfo" @click.stop :href="isOperator(app) ? `#/app/${app.id}/updates` : null" v-tooltip="$t('app.updateAvailableTooltip')"><i class="fa-fw fa-solid fa-arrow-up"/></a>
|
||||
<a class="grid-item-checklist-indicator" v-if="AppsModel.pendingChecklistItems(app)" @click.stop :href="isOperator(app) ? `#/app/${app.id}/info` : null"><Icon icon="fa-solid fa-triangle-exclamation"/></a>
|
||||
</div>
|
||||
</a>
|
||||
@@ -311,7 +297,7 @@ onUnmounted(() => {
|
||||
</template>
|
||||
<template #actions="app">
|
||||
<div class="table-actions">
|
||||
<Button small success tool v-if="app.updateAvailable" :href="`#/app/${app.id}/updates`" v-tooltip="$t('app.updateAvailableTooltip')" icon="fa-fw fa-solid fa-arrow-up"></Button>
|
||||
<Button small success tool v-if="app.updateInfo" :href="`#/app/${app.id}/updates`" v-tooltip="$t('app.updateAvailableTooltip')" icon="fa-fw fa-solid fa-arrow-up"></Button>
|
||||
|
||||
<ButtonGroup>
|
||||
<Button small secondary tool v-if="app.type !== APP_TYPES.LINK" :href="'/logs.html?appId=' + app.id" target="_blank" v-tooltip="$t('app.logsActionTooltip')" icon="fa-fw fa-solid fa-align-left"></Button>
|
||||
|
||||
Reference in New Issue
Block a user