diff --git a/dashboard/src/components/app/Updates.vue b/dashboard/src/components/app/Updates.vue index b91ec443a..90cd6145c 100644 --- a/dashboard/src/components/app/Updates.vue +++ b/dashboard/src/components/app/Updates.vue @@ -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); diff --git a/dashboard/src/models/AppsModel.js b/dashboard/src/models/AppsModel.js index 0ab63ad64..c7a579257 100644 --- a/dashboard/src/models/AppsModel.js +++ b/dashboard/src/models/AppsModel.js @@ -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]; } diff --git a/dashboard/src/models/UpdaterModel.js b/dashboard/src/models/UpdaterModel.js index b7cf781a9..94d20fa98 100644 --- a/dashboard/src/models/UpdaterModel.js +++ b/dashboard/src/models/UpdaterModel.js @@ -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]; + }, + }; } diff --git a/dashboard/src/views/AppsView.vue b/dashboard/src/views/AppsView.vue index 213c6157d..e87b14372 100644 --- a/dashboard/src/views/AppsView.vue +++ b/dashboard/src/views/AppsView.vue @@ -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(() => {
- +
@@ -311,7 +297,7 @@ onUnmounted(() => {