|
2 | 2 | <div class="common-card is-flex is-align-items-center is-justify-content-center app-card aspect-square" |
3 | 3 | @mouseleave="hover = true" @mouseover="hover = true"> |
4 | 4 | <!-- Action Button Start --> |
5 | | - <div v-if="item.app_type !== 'system' && !isMircoApp && !isContainerApp && !isUninstalling" class="action-btn"> |
| 5 | + <div v-if="item.app_type !== 'system' && !isMircoApp && !isContainerApp && !isUninstalling && !isRebuilding" class="action-btn"> |
6 | 6 | <b-dropdown ref="dro" v-on-click-outside="() => ($refs.dro.isActive = false)" :mobile-modal="false" |
7 | 7 | :triggers="['contextmenu', 'click']" animation="fade1" aria-role="list" class="app-card-drop" |
8 | 8 | :position="dropdownPosition" @active-change="setDropState"> |
|
13 | 13 | </template> |
14 | 14 |
|
15 | 15 | <b-dropdown-item :focusable="false" aria-role="menu-item" custom> |
16 | | - <b-button expanded tag="a" type="is-text" @click="openApp(item)"> |
| 16 | + <b-button v-if="!isV1App" expanded tag="a" type="is-text" @click="openApp(item)"> |
17 | 17 | {{ $t("Open") }} |
18 | 18 | </b-button> |
19 | 19 | <b-button v-if="isV2App" expanded icon-pack="casa" icon-right="question-outline" size="is-16" type="is-text" |
|
38 | 38 | {{ $t("Export as Compose") }} |
39 | 39 | </b-button> |
40 | 40 |
|
41 | | - <b-button v-if="isV1App" :loading="isRebuilding" expanded type="is-text" @click="rebuild(item)"> |
| 41 | + <b-button v-if="isV1App" :loading="isRebuilding" expanded type="is-text" @click="rebuild(item.name)"> |
42 | 42 | {{ $t("Rebuild") }} |
43 | 43 | </b-button> |
44 | 44 |
|
|
74 | 74 | </b-loading> |
75 | 75 | </b-button> |
76 | 76 |
|
77 | | - <div v-if="!isLinkApp" class="gap"> |
| 77 | + <div v-if="!isLinkApp && !isV1App" class="gap"> |
78 | 78 | <div class="columns is-gapless _b-bor is-flex"> |
79 | 79 | <div class="column is-flex is-justify-content-center is-align-items-center"> |
80 | 80 | <b-button :loading="isRestarting" expanded type="is-text" @click="restartApp"> |
@@ -187,6 +187,8 @@ export default { |
187 | 187 | tooltipLabel() { |
188 | 188 | if (this.isContainerApp) { |
189 | 189 | return this.$t("Import to CasaOS"); |
| 190 | + } else if(this.item.app_type === "v1app"){ |
| 191 | + return this.$t("Rebuild"); |
190 | 192 | } else { |
191 | 193 | if (this.item.app_type === "system") { |
192 | 194 | return this.$t("Open"); |
@@ -265,6 +267,15 @@ export default { |
265 | 267 | }, |
266 | 268 | }, |
267 | 269 |
|
| 270 | + mounted() { |
| 271 | + const localAppId = localStorage.getItem("rebuild_appid"); |
| 272 | + if (localAppId) { |
| 273 | + localStorage.removeItem("rebuild_appid") |
| 274 | + if(localAppId === this.item.name){ |
| 275 | + this.rebuild(localAppId); |
| 276 | + } |
| 277 | + } |
| 278 | + }, |
268 | 279 | methods: { |
269 | 280 | calculateDropdownPosition(event) { |
270 | 281 | const app1 = document.getElementById('app1'); |
@@ -293,13 +304,17 @@ export default { |
293 | 304 | */ |
294 | 305 | openApp(item) { |
295 | 306 |
|
296 | | -
|
297 | 307 | if (this.isContainerApp) { |
298 | 308 | this.$emit("importApp", item, false); |
299 | 309 | return false; |
300 | 310 | } |
301 | 311 | // TODO: logic |
302 | 312 |
|
| 313 | + if (this.isV1App){ |
| 314 | + this.rebuild(item.name); |
| 315 | + return; |
| 316 | + } |
| 317 | +
|
303 | 318 | if (item.app_type === "system") { |
304 | 319 | this.openSystemApps(item); |
305 | 320 | } else if (item.app_type === "mircoApp") { |
@@ -435,7 +450,7 @@ export default { |
435 | 450 | message: this.$t( |
436 | 451 | `Data cannot be recovered after deletion! <br/>Continue on to uninstall this application?<br/>{divS}Delete userdata ( config folder ){divE}`, |
437 | 452 | { |
438 | | - divS: `<div class="mt-4 is-flex is-align-items-center"><input type="checkbox" checked id="checkDelConfig">`, |
| 453 | + divS: `<div class="mt-4 is-flex is-align-items-center"><input type="checkbox" id="checkDelConfig">`, |
439 | 454 | divE: `</input></div>`, |
440 | 455 | } |
441 | 456 | ), |
@@ -688,26 +703,28 @@ export default { |
688 | 703 | }); |
689 | 704 | }, |
690 | 705 |
|
691 | | - async rebuild(app) { |
| 706 | + async rebuild(appName) { |
692 | 707 | this.isRebuilding = true; |
693 | 708 | try { |
694 | 709 | // 1. get yaml |
695 | | - const file = await this.$api.container.exportAsCompose(app.name).then((res) => res.data); |
| 710 | + const file = await this.$api.container.exportAsCompose(appName).then((res) => res.data); |
696 | 711 | // 2. archive |
697 | | - await this.$api.container.archive(app.name); |
| 712 | + await this.$api.container.archive(appName); |
698 | 713 | // 3.install compose |
699 | | - await this.$openAPI.appManagement.compose.installComposeApp(file, { name: app.name }); |
700 | | - } catch (e) { |
| 714 | + await this.$openAPI.appManagement.compose.installComposeApp(file, { name: appName }); |
| 715 | + // 4. uninstall |
| 716 | + // this.uninstallApp(false); |
| 717 | + } catch { |
701 | 718 | this.isRebuilding = false; |
702 | | - console.error("rebuild Error:", e); |
703 | 719 | this.$buefy.toast.open({ |
704 | 720 | message: this.$t(`Rebulid error`), |
705 | 721 | type: "is-danger", |
| 722 | + duration:3000 |
706 | 723 | }); |
707 | 724 | } |
708 | 725 | // 4.sockiet :: install-end :: change UI status. |
709 | 726 | // this.isRebuilding = false; |
710 | | - this.$refs.dro.isActive = false; |
| 727 | + // this.$refs.dro.isActive = false; |
711 | 728 | }, |
712 | 729 |
|
713 | 730 | checkAppVersion(name) { |
@@ -879,6 +896,7 @@ export default { |
879 | 896 | if (res.Properties["dry_run.name"] === this.item.name) { |
880 | 897 | // 4.sockiet :: install-end :: change UI status. |
881 | 898 | this.isRebuilding = false; |
| 899 | + this.uninstallApp(false); |
882 | 900 | // 5.message toast |
883 | 901 | this.$buefy.toast.open({ |
884 | 902 | message: this.$t("{title} rebulid completed", { title: ice_i18n(this.item.title) }), |
|
0 commit comments