Skip to content

Commit

Permalink
Merge pull request #9 from vidar-team/dev
Browse files Browse the repository at this point in the history
v0.5.2
  • Loading branch information
wuhan005 authored Jun 12, 2020
2 parents 88c3eb8 + 353ae9d commit f2b464d
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 87 deletions.
148 changes: 74 additions & 74 deletions dist/dist_gen.go

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions src/assets/languages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"operate": "Options",
"edit": "Edit",
"delete": "Delete",
"export": "Export"
"export": "Export",
"success": "Success",
"fail": "Fail"
},
"header": {
"panel": "Dashboard",
Expand Down Expand Up @@ -41,7 +43,7 @@
"new": "New Challenge",
"edit": "Edit Challenge",
"auto_refresh_flag": "Update Flag Automatically",
"command": "Update Flag Command",
"command": "Update Flag Shell Command",
"flag_placeholder": "Flag Placeholder "
},
"panel": {
Expand Down Expand Up @@ -98,7 +100,10 @@
"ssh_user": "Flag SSH User Name",
"ssh_password": "Flag SSH Password",
"test_ssh": "Test SSH Connection",
"test_ssh_success": "SSH Connect Successfully!"
"test_ssh_success": "SSH Connect Successfully!",
"test_ssh_fail": "Fail to Connect the SSH.",
"input_shell_command": "Please input the shell command to test",
"refresh_flag": "Refresh all the flags"
},
"login": {
"account": "Account",
Expand Down
11 changes: 8 additions & 3 deletions src/assets/languages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"operate": "操作",
"edit": "编辑",
"delete": "删除",
"export": "导出"
"export": "导出",
"success": "成功",
"fail": "失败"
},
"header": {
"panel": "数据大屏",
Expand Down Expand Up @@ -41,7 +43,7 @@
"new": "添加 Challenge",
"edit": "编辑题目",
"auto_refresh_flag": "自动更新 Flag",
"command": "更新 Flag 命令",
"command": "更新 Flag Shell 命令",
"flag_placeholder": "Flag 占位符 "
},
"panel": {
Expand Down Expand Up @@ -98,7 +100,10 @@
"ssh_user": "Flag SSH 用户名",
"ssh_password": "Flag SSH 密码",
"test_ssh": "测试 SSH 连接",
"test_ssh_success": "SSH 连接全部成功!"
"test_ssh_fail": "SSH 连接失败",
"test_ssh_success": "SSH 连接全部成功!",
"input_shell_command": "请输入需要测试的 Shell 命令",
"refresh_flag": "更新所有 Flag"
},
"login": {
"account": "账号",
Expand Down
48 changes: 41 additions & 7 deletions src/views/GameBox.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<div>
<el-button type="primary" @click="newGameBoxDialogVisible = true">{{$t('gamebox.publish')}}</el-button>
<el-button type="primary" @click="testSSH" :loading="sshTesting">{{$t('gamebox.test_ssh')}}</el-button>
<el-button type="primary" @click="testAllSSH" :loading="sshTesting">{{$t('gamebox.test_ssh')}}</el-button>
<el-button @click="refreshFlag">{{$t('gamebox.refresh_flag')}}</el-button>
<el-table :data="gameBoxList" style="width: 100%" stripe v-loading="gameBoxList === null">
<el-table-column width="80" prop="ID" label="ID"/>
<el-table-column prop="ChallengeTitle" :label="$t('gamebox.challenge')"/>
Expand Down Expand Up @@ -179,6 +180,18 @@
</el-form-item>
</el-form>
<el-button type="primary" @click="onEditGameBox">{{$t('gamebox.edit')}}</el-button>
<el-button
@click="testGameBoxSSH(editGameBoxForm.IP, editGameBoxForm.SSHPort, editGameBoxForm.SSHUser, editGameBoxForm.SSHPassword)">
{{$t('gamebox.test_ssh')}}
</el-button>
</el-dialog>

<!-- SSH -->
<el-dialog :title="$t('gamebox.test_ssh_fail')" :visible.sync="sshFailDialogVisible">
<div v-html="sshFailContent"></div>
<div slot="footer" class="dialog-footer">
<el-button @click="sshFailDialogVisible = false">{{$t('general.apply')}}</el-button>
</div>
</el-dialog>

</div>
Expand All @@ -191,6 +204,7 @@
newGameBoxDialogVisible: false,
editGameBoxDialogVisible: false,
mutliGameBoxDialogVisible: false,
sshFailDialogVisible: false,
sshTesting: false,
gameBoxList: null,
Expand All @@ -210,6 +224,7 @@
},
mutliGameBoxJSON: '',
sshFailContent: '',
page: 1,
per: 10,
Expand Down Expand Up @@ -326,21 +341,40 @@
return result
},
testSSH() {
testAllSSH() {
this.sshTesting = true
this.utils.GET("/manager/gameboxes/sshTest").then(res => {
this.sshTesting = false
if (res === null) {
return this.$message.success(this.$i18n.t("gamebox.test_ssh_success"))
}
let content = ''
this.sshFailContent = ''
res.forEach(item => {
content += `<p><strong>TeamID:</strong>${item.TeamID}<br><strong>ChallengeID:</strong>${item.ChallengeID}<br><strong>GameBoxID:</strong>${item.GameBoxID}<br><strong>Error:</strong>${item.Error}<hr></p>`
this.sshFailContent += `<strong>TeamID:</strong>${item.TeamID}<br><strong>ChallengeID:</strong>${item.ChallengeID}<br><strong>GameBoxID:</strong>${item.GameBoxID}<br><strong>Error:</strong>${item.Error}<hr>`
})
this.$alert(content, '测试失败', {
dangerouslyUseHTMLString: true
});
this.sshFailDialogVisible = true
})
},
testGameBoxSSH(IP, Port, User, Password) {
this.$prompt(this.$t('gamebox.input_shell_command'), '', {
confirmButtonText: this.$t('general.apply'),
cancelButtonText: this.$t('general.cancel'),
}).then(({value: Command}) => {
this.utils.POST('/manager/gameboxes/sshTest', {
IP, Port, User, Password, Command
}).then(res => this.$alert(res, this.$t('general.success'))
).catch(err => this.$alert(err, this.$t('general.fail'))
)
}).catch(() => {
});
},
refreshFlag() {
this.utils.GET('/manager/gameboxes/refreshFlag')
.then(res => this.$message.success(res))
.catch(err => this.$message.error(err))
}
}
}
Expand Down

0 comments on commit f2b464d

Please sign in to comment.