diff --git a/nezha-fronted/src/components/common/language/cn.js b/nezha-fronted/src/components/common/language/cn.js index 7861abe6c..7dad46c82 100644 --- a/nezha-fronted/src/components/common/language/cn.js +++ b/nezha-fronted/src/components/common/language/cn.js @@ -570,7 +570,8 @@ const cn = { inputConfirmPwd: "请再次输入密码", invalidPwd: "无效的密码,最少6个字符", confirmPwdErr: "两次密码输入不一致", - reinputPwd: "请再次输入密码" + reinputPwd: "请再次输入密码", + notification: "通知" }, promServer: { promServerList: "Prometheus服务", diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js index 904098b66..ddc078072 100644 --- a/nezha-fronted/src/components/common/language/en.js +++ b/nezha-fronted/src/components/common/language/en.js @@ -574,7 +574,8 @@ const en = { inputConfirmPwd:'Please input confirm password', invalidPwd:'invalide password,the length at least 6', confirmPwdErr:'The two passwords are inconsistent', - reinputPwd:'Enter password again' + reinputPwd:'Enter password again', + notification: 'Notification' }, promServer: { promServerList: 'Prometheus server',//"Prometheus Server" diff --git a/nezha-fronted/src/components/common/rightBox/accountBox.vue b/nezha-fronted/src/components/common/rightBox/accountBox.vue index 18ddb578f..287fcc1f3 100644 --- a/nezha-fronted/src/components/common/rightBox/accountBox.vue +++ b/nezha-fronted/src/components/common/rightBox/accountBox.vue @@ -41,6 +41,22 @@
{{editUser.createTime}}
+ +
{{$t('config.account.notification')}} + +
+ +
+ + + + + + + + @@ -68,10 +84,15 @@ return function(username) { return localStorage.getItem('nz-username') == username; } + }, + addDisabled() { + let enabled = this.selectableScripts.filter(item => {return !item.disabled}); + return enabled.length === 0; } }, data() { return { + scriptIds: [], rules: { //表单校验规则 username: [ {required: true, message: this.$t('validate.required'), trigger: 'blur'} @@ -84,7 +105,9 @@ {type: 'email', message: this.$t('validate.email')} ] }, - editUser: {} + editUser: {}, + scripts: [], + selectableScripts: [] } }, methods: { @@ -140,6 +163,49 @@ }); }); }, + + getScripts() { + /*this.$get("/alert/script?pageNo=1&pageSize=-1").then(response => { + this.scripts = response.data.list; + this.getSelectableScripts(); + });*/ + this.scripts = [ + {id: 1, name: "DOLBY"}, + {id: 2, name: "IMAX"}, + {id: 3, name: "CGS"}, + {id: 4, name: "LUXE"}, + {id: 5, name: "DST:X"}, + ]; + this.getSelectableScripts(); + }, + + getSelectableScripts() { + this.selectableScripts = this.scripts.map(item => { + let exist = this.editUser.notifications.some(n => { + return item.id === n.scriptId; + }); + if (exist) { + this.$set(item, "disabled", true); + } else { + this.$set(item, "disabled", false); + } + return item; + }); + }, + + addNotification() { + let scripts = this.selectableScripts.find(item => { + return item.disabled === false; + }); + scripts && this.editUser.notifications.push({scriptId: scripts.id, account: ""}); + }, + + removeNotification(index) { + this.editUser.notifications.splice(index, 1); + } + }, + mounted() { + this.getScripts(); }, watch: { //将prop里的user转为组件内部对象 @@ -149,7 +215,40 @@ handler(n) { this.editUser = JSON.parse(JSON.stringify(n)); } + }, + "editUser.notifications": { + deep: true, + immediate: true, + handler(n) { + this.getSelectableScripts(); + } } }, } + diff --git a/nezha-fronted/src/components/page/config/account.vue b/nezha-fronted/src/components/page/config/account.vue index 2efe9ad8b..407013a35 100644 --- a/nezha-fronted/src/components/page/config/account.vue +++ b/nezha-fronted/src/components/page/config/account.vue @@ -61,6 +61,10 @@ :prop="item.prop" :sort-orders="['ascending', 'descending']" > +