Skip to content

Commit 1c05c37

Browse files
authored
Optimize legacy app import experience. (#123)
1 parent 1d8ecea commit 1c05c37

File tree

9 files changed

+74
-38
lines changed

9 files changed

+74
-38
lines changed

.env.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# .env.dev
22
NODE_ENV=dev
33
#VUE_APP_DEV_IP=demo.casaos.io
4-
VUE_APP_DEV_IP=10.0.0.73
4+
VUE_APP_DEV_IP=10.0.0.83
55
# VUE_APP_DEV_IP=10.147.20.1
66
# VUE_APP_DEV_IP=192.168.2.15
77
# VUE_APP_DEV_IP=192.168.2.219

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"packageManager": "pnpm@8.7.0",
2121
"dependencies": {
2222
"@fontsource/roboto": "^4.5.8",
23-
"@icewhale/casaos-appmanagement-openapi": "0.4.9-alpha7",
23+
"@icewhale/zimaos-appmanagement-openapi": "latest",
2424
"@icewhale/casaos-openapi": "latest",
2525
"@icewhale/icewhale-files-openapi": "1.2.2-alpha4",
2626
"@icewhale/zimaos-localstorage-openapi": "1.2.2-alpha7",

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/AppHost/AppHost.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<section :class="{ _hideOverflow: !isCasa }" class="modal-card-body pt-3">
2+
<section :class="{ _hideOverflow: !isCasa }" class="pt-3 modal-card-body">
33
<!-- 导入"已存在的容器",进行初始化操作 -->
44
<ValidationObserver ref="containerValida">
55
<ValidationProvider v-slot="{ errors, valid }" name="appName" rules="required">
@@ -92,14 +92,23 @@ export default {
9292
required: true,
9393
},
9494
},
95+
mounted() {
96+
this.settingData.port_map = this.settingData.ports[0].host;
97+
},
9598
methods: {
9699
async updateAppHost() {
97100
try {
98101
const is_validate = await this.$refs.containerValida.validate();
99102
if (is_validate === true) {
100-
const result = await this.$api.container.update(this.appId, this.settingData);
101-
if (result.data.success !== 200) {
102-
return new Error(result.data.message);
103+
try {
104+
const res = await this.$api.container.update(this.appId, this.settingData);
105+
return res.data.data.name;
106+
} catch (error) {
107+
this.$buefy.toast.open({
108+
message: this.$t("Rebuild failed, please try again."),
109+
type: "is-warning",
110+
duration: 3000
111+
});
103112
}
104113
}
105114
} catch (error) {

src/components/Apps/AppCard.vue

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="common-card is-flex is-align-items-center is-justify-content-center app-card aspect-square"
33
@mouseleave="hover = true" @mouseover="hover = true">
44
<!-- 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">
66
<b-dropdown ref="dro" v-on-click-outside="() => ($refs.dro.isActive = false)" :mobile-modal="false"
77
:triggers="['contextmenu', 'click']" animation="fade1" aria-role="list" class="app-card-drop"
88
:position="dropdownPosition" @active-change="setDropState">
@@ -13,7 +13,7 @@
1313
</template>
1414

1515
<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)">
1717
{{ $t("Open") }}
1818
</b-button>
1919
<b-button v-if="isV2App" expanded icon-pack="casa" icon-right="question-outline" size="is-16" type="is-text"
@@ -38,7 +38,7 @@
3838
{{ $t("Export as Compose") }}
3939
</b-button>
4040

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)">
4242
{{ $t("Rebuild") }}
4343
</b-button>
4444

@@ -74,7 +74,7 @@
7474
</b-loading>
7575
</b-button>
7676

77-
<div v-if="!isLinkApp" class="gap">
77+
<div v-if="!isLinkApp && !isV1App" class="gap">
7878
<div class="columns is-gapless _b-bor is-flex">
7979
<div class="column is-flex is-justify-content-center is-align-items-center">
8080
<b-button :loading="isRestarting" expanded type="is-text" @click="restartApp">
@@ -187,6 +187,8 @@ export default {
187187
tooltipLabel() {
188188
if (this.isContainerApp) {
189189
return this.$t("Import to CasaOS");
190+
} else if(this.item.app_type === "v1app"){
191+
return this.$t("Rebuild");
190192
} else {
191193
if (this.item.app_type === "system") {
192194
return this.$t("Open");
@@ -265,6 +267,15 @@ export default {
265267
},
266268
},
267269
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+
},
268279
methods: {
269280
calculateDropdownPosition(event) {
270281
const app1 = document.getElementById('app1');
@@ -293,13 +304,17 @@ export default {
293304
*/
294305
openApp(item) {
295306
296-
297307
if (this.isContainerApp) {
298308
this.$emit("importApp", item, false);
299309
return false;
300310
}
301311
// TODO: logic
302312
313+
if (this.isV1App){
314+
this.rebuild(item.name);
315+
return;
316+
}
317+
303318
if (item.app_type === "system") {
304319
this.openSystemApps(item);
305320
} else if (item.app_type === "mircoApp") {
@@ -435,7 +450,7 @@ export default {
435450
message: this.$t(
436451
`Data cannot be recovered after deletion! <br/>Continue on to uninstall this application?<br/>{divS}Delete userdata ( config folder ){divE}`,
437452
{
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">`,
439454
divE: `</input></div>`,
440455
}
441456
),
@@ -688,26 +703,28 @@ export default {
688703
});
689704
},
690705
691-
async rebuild(app) {
706+
async rebuild(appName) {
692707
this.isRebuilding = true;
693708
try {
694709
// 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);
696711
// 2. archive
697-
await this.$api.container.archive(app.name);
712+
await this.$api.container.archive(appName);
698713
// 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 {
701718
this.isRebuilding = false;
702-
console.error("rebuild Error:", e);
703719
this.$buefy.toast.open({
704720
message: this.$t(`Rebulid error`),
705721
type: "is-danger",
722+
duration:3000
706723
});
707724
}
708725
// 4.sockiet :: install-end :: change UI status.
709726
// this.isRebuilding = false;
710-
this.$refs.dro.isActive = false;
727+
// this.$refs.dro.isActive = false;
711728
},
712729
713730
checkAppVersion(name) {
@@ -879,6 +896,7 @@ export default {
879896
if (res.Properties["dry_run.name"] === this.item.name) {
880897
// 4.sockiet :: install-end :: change UI status.
881898
this.isRebuilding = false;
899+
this.uninstallApp(false);
882900
// 5.message toast
883901
this.$buefy.toast.open({
884902
message: this.$t("{title} rebulid completed", { title: ice_i18n(this.item.title) }),

src/components/Apps/AppPanel.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
<button class="icon-button mdi mdi-export-variant" type="button" @click="exportYAML" />
4141
</b-tooltip>
4242
<div v-if="currentSlide !== APP_INSTALLING_PANEL"
43-
class="is-flex is-align-items-center modal-close-container modal-close-container-line">
43+
class="is-flex is-align-items-center modal-close-container"
44+
:class="{'modal-close-container-line': isCasa }">
4445
<b-icon class="_polymorphic close" icon="close-outline" pack="casa" @click.native="$emit('close')" />
4546
</div>
4647
<div v-else-if="currentSlide === APP_INSTALLING_PANEL" class="is-flex is-align-items-center">
@@ -144,6 +145,7 @@ import { AppConditionSelector, AppDetail, AppRecommend, AppStoreContent } from "
144145
import { AppInstallLoadingFooter, AppInstallLoadingPanel } from "@/components/AppInstallLoadingPanel";
145146
import { AppSettingPanelFooter } from "@/components/AppSetting";
146147
import { AppHost } from "@/components/AppHost";
148+
import events from "@/events/events";
147149
148150
const data = [
149151
"AUDIT_CONTROL",
@@ -365,10 +367,10 @@ export default {
365367
return this.currentSlide == APP_SETTING_PANEL && this.state == "install";
366368
},
367369
showExportButton() {
368-
return this.currentSlide == APP_SETTING_PANEL && this.state == "update";
370+
return this.currentSlide == APP_SETTING_PANEL && this.state == "update" && this.isCasa;
369371
},
370372
showTerminalButton() {
371-
return this.currentSlide == APP_SETTING_PANEL && this.state == "update" && this.runningStatus == "running";
373+
return this.currentSlide == APP_SETTING_PANEL && this.state == "update" && this.runningStatus == "running" && this.isCasa;
372374
},
373375
panelTitle() {
374376
if (this.currentSlide == APP_STORE_PANEL) {
@@ -702,14 +704,15 @@ export default {
702704
async updateContainer() {
703705
this.isLoading = true;
704706
try {
705-
console.log(0);
706-
await this.$refs.apphost.updateAppHost();
707-
this.$emit("updateState");
707+
const appId = await this.$refs.apphost.updateAppHost();
708+
localStorage.setItem("rebuild_appid", appId);
708709
this.$emit("close");
709-
} catch (e) {
710+
this.$emit("updateState");
711+
} catch (err) {
710712
this.$buefy.toast.open({
711-
message: err.response.data.message,
713+
message: this.$t("Rebuild failed, please try again."),
712714
type: "is-warning",
715+
duration: 3000
713716
});
714717
}
715718
this.isLoading = false;

src/components/Apps/AppSection.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ export default {
318318
// Container app does not have icon.
319319
item.icon = item.icon || require(`@/assets/img/app/default.svg`);
320320
if (item.app_type === "v1app" || item.app_type === "container") {
321+
// if(item.status === "running") {
322+
323+
// }
321324
orgOldAppList.push(item);
322325
} else {
323326
orgNewAppList.push(item);
@@ -613,6 +616,9 @@ export default {
613616
updateState: () => {
614617
this.getList();
615618
},
619+
updateCompose: (res) => {
620+
console.log("updateCompose",res);
621+
},
616622
close: () => {
617623
window.parent?.document.body.classList.remove("p-overflow-hidden");
618624
},

src/service/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
ComposeMethodsApiFactory,
1515
Configuration,
1616
InternalMethodsApiFactory
17-
} from '@icewhale/casaos-appmanagement-openapi'
17+
} from '@icewhale/zimaos-appmanagement-openapi'
1818
import { ZerotierMethodsApi } from '@icewhale/casaos-openapi'
1919
import { FileApiFactory, FolderApiFactory, PinMethodsApi } from '@icewhale/icewhale-files-openapi'
2020
import { GPUMethodsApi } from '@icewhale/zimaos-openapi'

vue.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ module.exports = {
103103
port: 8080,
104104
hot: true,
105105
proxy: {
106-
"/": {
106+
'^(?!/ws).*': {
107107
target: `http://${process.env.VUE_APP_DEV_IP}:${process.env.VUE_APP_DEV_PORT}`,
108108
changeOrigin: true,
109109
}

0 commit comments

Comments
 (0)