修改配置

pull/1/head
Doflatango 2017-03-09 14:42:59 +08:00 committed by miraclesu
parent 174e3baee5
commit f0f33f4a91
4 changed files with 13 additions and 26 deletions

View File

@ -73,11 +73,11 @@ type Security struct {
// 所执行的命令只能是机器上的脚本,仅支持配置项里的扩展名
// 执行用户只能选择配置里的用户
// false 关闭,命令和用户可以用动填写
Open bool
Open bool `json:"open"`
// 配置执行用户
Users []string
Users []string `json:"users"`
// 支持的执行的脚本扩展名
Ext []string
Ext []string `json:"ext"`
}
// 返回前后包含斜杆的 /a/b/ 的前缀

View File

@ -1,9 +1,9 @@
{
"Open": false,
"Users": [
"open": false,
"users": [
"www", "db"
],
"Ext": [
"ext": [
".sh", ".py"
]
}

View File

@ -7,25 +7,12 @@ import (
)
type Configuration struct {
Security *securityCnf `json:"security"`
}
type securityCnf struct {
Enable bool `json:"enable"`
AllowUsers []string `json:"allowUsers,omitempty"`
AllowSuffixs []string `json:"allowSuffixs,omitempty"`
Security *conf.Security `json:"security"`
}
func NewConfiguration() *Configuration {
cnf := &Configuration{
Security: &securityCnf{
Enable: conf.Config.Security.Open,
},
}
if conf.Config.Security.Open {
cnf.Security.AllowUsers = conf.Config.Security.Users
cnf.Security.AllowSuffixs = conf.Config.Security.Ext
Security: conf.Config.Security,
}
return cnf

View File

@ -26,8 +26,8 @@
<input type="text" v-model="job.cmd" placeholder="任务脚本">
</div>
<div class="four wide field">
<label>用户({{$appConfig.security.enable ? '必选' : '可选'}})</label>
<Dropdown v-if="$appConfig.security.enable" title="指定执行用户" v-bind:items="$appConfig.security.allowUsers" v-bind:selected="job.user" v-on:change="changeUser"></Dropdown>
<label>用户({{$appConfig.security.open ? '必选' : '可选'}})</label>
<Dropdown v-if="$appConfig.security.open" title="指定执行用户" v-bind:items="$appConfig.security.users" v-bind:selected="job.user" v-on:change="changeUser"></Dropdown>
<input v-else type="text" v-model="job.user" placeholder="指定执行用户">
</div>
</div>
@ -136,9 +136,9 @@ export default {
mounted: function(){
var vm = this;
var secCnf = this.$appConfig.security;
if (secCnf.enable) {
if (secCnf.allowSuffixs && secCnf.allowSuffixs.length > 0) {
this.allowSuffixsTip = '(当前限制只允许添加此类后缀脚本:' + secCnf.allowSuffixs.join(' ') + '';
if (secCnf.open) {
if (secCnf.ext && secCnf.ext.length > 0) {
this.allowSuffixsTip = '(当前限制只允许添加此类后缀脚本:' + secCnf.ext.join(' ') + '';
}
}