Skip to content

Commit

Permalink
feat: 概览页重启按钮优化 (#2926)
Browse files Browse the repository at this point in the history
Refs #2921
  • Loading branch information
ssongliu committed Nov 13, 2023
1 parent 78576a3 commit fb556d6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 28 deletions.
2 changes: 1 addition & 1 deletion backend/app/service/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewIDashboardService() IDashboardService {
}

func (u *DashboardService) Restart(operation string) error {
if operation != "panel" && operation != "system" {
if operation != "1panel" && operation != "system" {
return fmt.Errorf("handle restart operation %s failed, err: nonsupport such operation", operation)
}
itemCmd := fmt.Sprintf("%s 1pctl restart", cmd.SudoHandleCmd())
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/confirm-dialog/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</div>
</template>
<div>
<span style="font-size: 12px">{{ operationInfo }}</span>
<div style="margin-top: 10px">
<span v-if="operationInfo" style="font-size: 12px">{{ operationInfo }}</span>
<div :style="{ 'margin-top': operationInfo ? '10px' : '0px' }">
<span style="font-size: 12px">{{ $t('commons.msg.operateConfirm') }}</span>
<span style="font-size: 12px; color: red; font-weight: 500">'{{ submitInputInfo }}'</span>
</div>
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,6 @@ const message = {
home: {
restart_1panel: 'Restart Panel',
restart_system: 'Restart Server',
panel: '1Panel',
system: '1Panel Server',
restartHelper: 'About to restart {0}, do you want to continue?',
operationSuccess: 'Operation successful! Restarting, please wait...',
overview: 'Overview',
entranceHelper:
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,6 @@ const message = {
home: {
restart_1panel: '重啟面板',
restart_system: '重啟服務器',
panel: '1Panel 面板',
system: '1Panel 服務器',
restartHelper: '即將重新啟動 {0},是否繼續?',
operationSuccess: '操作成功正在重啟請稍候...',
overview: '概',
entranceHelper: '設置安全入口有利於提高系統的安全性如有需要前往 面板設置-安全 啟用安全入口',
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,6 @@ const message = {
home: {
restart_1panel: '重启面板',
restart_system: '重启服务器',
panel: '1Panel 面板',
system: '1Panel 服务器',
restartHelper: '即将重新启动 {0},是否继续?',
operationSuccess: '操作成功正在重启请稍候...',
overview: '概',
entranceHelper: '设置安全入口有利于提高系统的安全性如有需要前往 面板设置-安全 启用安全入口',
Expand Down
36 changes: 20 additions & 16 deletions frontend/src/views/home/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
>
<template #route-button>
<div class="router-button">
<el-button link type="primary" @click="restart('panel')">
<el-button link type="primary" @click="onRestart('1panel')">
{{ $t('home.restart_1panel') }}
</el-button>
<el-divider direction="vertical" />
<el-button link type="primary" @click="restart('system')">
<el-button link type="primary" @click="onRestart('system')">
{{ $t('home.restart_system') }}
</el-button>
</div>
Expand Down Expand Up @@ -230,10 +230,13 @@
</CardWithHeader>
</el-col>
</el-row>

<ConfirmDialog ref="confirmDialogRef" @confirm="onSave"></ConfirmDialog>
</div>
</template>

<script lang="ts" setup>
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
import { onMounted, onBeforeUnmount, ref, reactive } from 'vue';
import Status from '@/views/home/status/index.vue';
import App from '@/views/home/app/index.vue';
Expand All @@ -252,6 +255,8 @@ const router = useRouter();
const globalStore = GlobalStore();

const statusRef = ref();
const restartType = ref();
const confirmDialogRef = ref();
const appRef = ref();

const isSafety = ref();
Expand Down Expand Up @@ -540,20 +545,19 @@ const loadSafeStatus = async () => {
isSafety.value = res.data.securityEntrance;
};

const restart = async (type: string) => {
ElMessageBox.confirm(
i18n.global.t('home.restartHelper', [i18n.global.t('home.' + type)]),
i18n.global.t('commons.msg.operate'),
{
confirmButtonText: i18n.global.t('commons.button.confirm'),
cancelButtonText: i18n.global.t('commons.button.cancel'),
type: 'info',
},
).then(async () => {
globalStore.isOnRestart = true;
MsgSuccess(i18n.global.t('home.operationSuccess'));
await systemRestart(type);
});
const onRestart = (type: string) => {
restartType.value = type;
let params = {
header: i18n.global.t('home.restart_' + type),
operationInfo: '',
submitInputInfo: i18n.global.t('database.restartNow'),
};
confirmDialogRef.value!.acceptParams(params);
};
const onSave = async () => {
globalStore.isOnRestart = true;
MsgSuccess(i18n.global.t('home.operationSuccess'));
await systemRestart(restartType.value);
};

const onFocus = () => {
Expand Down

0 comments on commit fb556d6

Please sign in to comment.