Skip to content

Commit

Permalink
Accept Merge Request #100: (testing -> master)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankwei98 committed Aug 25, 2021
2 parents d5e7d9a + 8dc721b commit 4940a55
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 27 deletions.
2 changes: 1 addition & 1 deletion frontend-ng/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"@tinymce/tinymce-vue": "^3.2.1",
"axios": "0.18.1",
"axios": "^0.21.1",
"dayjs": "^1.10.4",
"echarts": "^4.7.0",
"element-ui": "2.13.0",
Expand Down
2 changes: 1 addition & 1 deletion frontend-ng/src/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getToken } from '@/utils/auth' // getToken from cookie

NProgress.configure({ showSpinner: false })// NProgress configuration

const whiteList = ['/login'] // 不重定向白名单
const whiteList = ['/login', '/reboot'] // 不重定向白名单
router.beforeEach((to, from, next) => {
NProgress.start()
if (getToken()) {
Expand Down
5 changes: 5 additions & 0 deletions frontend-ng/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ export const constantRouterMap = [
}
]
},
{
path: '/reboot',
name: 'Reboot',
component: () => import('@/views/reboot')
},
{ path: '*', redirect: '/404', hidden: true }
]

Expand Down
67 changes: 67 additions & 0 deletions frontend-ng/src/views/reboot/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<template>
<div class="reboot-page">
<h1 class="title">重启服务</h1>
<el-alert
title="仅在无法完成后端交互时使用"
type="warning">
</el-alert>
<p>先 Stop ,等待停止完成且返回结果无异常后,再操作 Start。</p>
<el-button
:disabled="isSendingCmd"
type="danger"
@click="trigger('start')"
>Start</el-button>
<el-button
:disabled="isSendingCmd"
type="danger"
@click="trigger('stop')"
>Stop</el-button>
<div v-if="apiResult" class="output">
<h2 class="subtitle">操作结果</h2>
<pre class="cmd-output">{{ apiResult }}</pre>
</div>
</div>
</template>

<script>
import axios from 'axios'
export default {
name: 'Reboot',
data: () => ({
apiResult: null,
isSendingCmd: false
}),
methods: {
async trigger(scriptName) {
try {
this.isSendingCmd = true
const result = await axios.get('/_switch_status_api/', {
params: {
scriptName
}
})
this.apiResult = result.cmdExecResult
} catch (error) {
if (axios.isAxiosError(error)) {
this.$message.error(`Server Error: ${error.response.data}`)
} else {
this.$message.error(`Error when switching server: ${error}`)
}
} finally {
this.isSendingCmd = false
}
}
}
}
</script>

<style scoped>
.reboot-page {
margin: 2rem;
}
.cmd-output {
background: black;
color: gray;
}
</style>
35 changes: 10 additions & 25 deletions frontend-ng/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1879,13 +1879,12 @@ aws4@^1.8.0:
resolved "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz#7e33d8f7d449b3f673cd72deb9abdc552dbe528e"
integrity sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==

axios@0.18.1:
version "0.18.1"
resolved "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz#ff3f0de2e7b5d180e757ad98000f1081b87bcea3"
integrity sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==
axios@^0.21.1:
version "0.21.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==
dependencies:
follow-redirects "1.5.10"
is-buffer "^2.0.2"
follow-redirects "^1.10.0"

babel-code-frame@^6.22.0, babel-code-frame@^6.26.0:
version "6.26.0"
Expand Down Expand Up @@ -3431,13 +3430,6 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9:
dependencies:
ms "2.0.0"

debug@=3.1.0:
version "3.1.0"
resolved "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
dependencies:
ms "2.0.0"

debug@^3.0.0, debug@^3.1.0, debug@^3.1.1, debug@^3.2.5:
version "3.2.6"
resolved "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
Expand Down Expand Up @@ -4630,20 +4622,18 @@ flush-write-stream@^1.0.0:
inherits "^2.0.3"
readable-stream "^2.3.6"

follow-redirects@1.5.10:
version "1.5.10"
resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
dependencies:
debug "=3.1.0"

follow-redirects@^1.0.0:
version "1.11.0"
resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.11.0.tgz#afa14f08ba12a52963140fe43212658897bc0ecb"
integrity sha512-KZm0V+ll8PfBrKwMzdo5D13b1bur9Iq9Zd/RMmAoQQcl2PxxFml8cxXPaaPYVbV0RjNjq1CU7zIzAOqtUPudmA==
dependencies:
debug "^3.0.0"

follow-redirects@^1.10.0:
version "1.14.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.2.tgz#cecb825047c00f5e66b142f90fed4f515dec789b"
integrity sha512-yLR6WaE2lbF0x4K2qE2p9PEXKLDjUjnR/xmjS3wHAYxtlsI9MLLBJUZirAHKzUZDGLxje7w/cXR49WOUo4rbsA==

for-in@^1.0.1, for-in@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
Expand Down Expand Up @@ -5548,11 +5538,6 @@ is-buffer@^1.1.5:
resolved "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==

is-buffer@^2.0.2:
version "2.0.4"
resolved "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz#3e572f23c8411a5cfd9557c849e3665e0b290623"
integrity sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==

is-callable@^1.1.4, is-callable@^1.1.5:
version "1.1.5"
resolved "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab"
Expand Down

0 comments on commit 4940a55

Please sign in to comment.