diff --git a/src/i18n/langs/cn.json b/src/i18n/langs/cn.json
index d5eda7662..b46543cb0 100644
--- a/src/i18n/langs/cn.json
+++ b/src/i18n/langs/cn.json
@@ -538,7 +538,10 @@
"terminate": "终断",
"test": "测试",
"type": "类型",
- "user": "用户"
+ "user": "用户",
+ "riskLevels": {
+ "common": "普通"
+ }
},
"setting": {
"Secret": "密钥",
diff --git a/src/i18n/langs/en.json b/src/i18n/langs/en.json
index 8edb98331..73401cc90 100644
--- a/src/i18n/langs/en.json
+++ b/src/i18n/langs/en.json
@@ -533,7 +533,10 @@
"terminate": "Terminate",
"test": "Test",
"type": "Type",
- "user": "Use"
+ "user": "Use",
+ "riskLevels": {
+ "common": "common"
+ }
},
"setting": {
"Basic": "Basic setting",
diff --git a/src/layout/components/GenericCreateUpdateForm/index.vue b/src/layout/components/GenericCreateUpdateForm/index.vue
index a64a02cf7..491ecda72 100644
--- a/src/layout/components/GenericCreateUpdateForm/index.vue
+++ b/src/layout/components/GenericCreateUpdateForm/index.vue
@@ -4,8 +4,7 @@
ref="form"
:method="method"
:form="form"
- :fields="fields"
- :url="totalUrl"
+ :url="iUrl"
:is-submitting="isSubmitting"
v-bind="$attrs"
v-on="$listeners"
@@ -24,12 +23,6 @@ export default {
type: String,
default: ''
},
- fields: {
- type: Array,
- default: () => {
- return []
- }
- },
object: {
type: Object,
default: null
@@ -48,7 +41,9 @@ export default {
},
performSubmit: {
type: Function,
- default: null
+ default(validValues) {
+ return this.$axios[this.method](this.iUrl, validValues)
+ }
},
createSuccessMsg: {
type: String,
@@ -76,6 +71,12 @@ export default {
return { name: routeName }
}
},
+ getNextRoute: {
+ type: Function,
+ default(res, method) {
+ return method === 'post' ? this.createSuccessNextRoute : this.updateSuccessNextRoute
+ }
+ },
getMethod: {
type: Function,
default: function() {
@@ -87,12 +88,6 @@ export default {
}
}
},
- getNextRoute: {
- type: Function,
- default(res, method) {
- return method === 'post' ? this.createSuccessNextRoute : this.updateSuccessNextRoute
- }
- },
getUrl: {
type: Function,
default: function() {
@@ -103,6 +98,33 @@ export default {
}
return url
}
+ },
+ onPerformSuccess: {
+ type: Function,
+ default(res, method, vm) {
+ const msg = method === 'post' ? this.createSuccessMsg : this.updateSuccessMsg
+ const route = this.getNextRoute(res, method)
+ this.$emit('submitSuccess', res)
+ this.$message.success(msg)
+ setTimeout(() => this.$router.push(route), 100)
+ }
+ },
+ onPerformError: {
+ type: Function,
+ default(error, method, vm) {
+ this.$emit('submitError', error)
+ const response = error.response
+ const data = response.data
+ if (response.status === 400) {
+ for (const key of Object.keys(data)) {
+ let value = data[key]
+ if (value instanceof Array) {
+ value = value.join(';')
+ }
+ this.$refs.form.setFieldError(key, value)
+ }
+ }
+ }
}
},
data() {
@@ -116,11 +138,11 @@ export default {
method() {
return this.getMethod(this)
},
- totalUrl() {
+ iUrl() {
return this.getUrl()
}
},
- async mounted() {
+ async created() {
this.loading = true
try {
const values = await this.getFormValue()
@@ -136,36 +158,12 @@ export default {
values = this.cleanFormValue(values)
return handler(values)
},
- defaultPerformSubmit(validValues) {
- return this.$axios[this.method](this.totalUrl, validValues)
- },
defaultOnSubmit(validValues) {
- const performSubmit = this.performSubmit || this.defaultPerformSubmit
- const msg = this.method === 'post' ? this.createSuccessMsg : this.updateSuccessMsg
- const event = this.method === 'post' ? 'createSuccess' : 'updateSuccess'
this.isSubmitting = true
- performSubmit(validValues).then((res) => {
- const route = this.getNextRoute(res, this.method)
- this.$emit(event, res)
- this.$emit('submitSuccess', res)
- this.$message.success(msg)
- setTimeout(() => this.$router.push(route), 100)
- }).catch(error => {
- this.$emit('submitError', error)
- const response = error.response
- const data = response.data
- if (response.status === 400) {
- for (const key of Object.keys(data)) {
- let value = data[key]
- if (value instanceof Array) {
- value = value.join(';')
- }
- this.$refs.form.setFieldError(key, value)
- }
- }
- }).finally(() => {
- this.isSubmitting = false
- })
+ this.performSubmit(validValues)
+ .then((res) => this.onPerformSuccess.bind(this)(res, this.method, this))
+ .catch((error) => this.onPerformError(error, this.method, this))
+ .finally(() => { this.isSubmitting = false })
},
async getFormValue() {
if (this.method !== 'put') {
@@ -174,11 +172,12 @@ export default {
let object = this.object
if (object === null) {
object = await this.getObjectDetail()
+ this.$emit('update:object', object)
}
return object
},
async getObjectDetail() {
- return this.$axios.get(this.totalUrl)
+ return this.$axios.get(this.iUrl)
}
}
}
diff --git a/src/store/modules/users.js b/src/store/modules/users.js
index aa120f1c8..f30f90ba4 100644
--- a/src/store/modules/users.js
+++ b/src/store/modules/users.js
@@ -37,6 +37,9 @@ const mutations = {
SET_ORGS: (state, orgs) => {
state.orgs = orgs
},
+ ADD_ORG: (state, org) => {
+ state.orgs.push(org)
+ },
SET_ROLES(state, roles) {
state.roles = roles
},
@@ -119,6 +122,9 @@ const actions = {
}).catch((e) => reject(e))
})
},
+ addAdminOrg({ commit, state }, org) {
+ commit('ADD_ORG', org)
+ },
// user logout
logout({ commit, state }) {
return new Promise((resolve, reject) => {
diff --git a/src/userviews/users/UserProfile/ProfileInfo.vue b/src/userviews/users/UserProfile/ProfileInfo.vue
index b562de63c..d89a1df17 100644
--- a/src/userviews/users/UserProfile/ProfileInfo.vue
+++ b/src/userviews/users/UserProfile/ProfileInfo.vue
@@ -9,7 +9,7 @@
a
-
diff --git a/src/views/sessions/CommandList.vue b/src/views/sessions/CommandList.vue
index fdd8e40a8..024e93ebd 100644
--- a/src/views/sessions/CommandList.vue
+++ b/src/views/sessions/CommandList.vue
@@ -6,7 +6,7 @@
import { GenericListPage } from '@/layout/components'
import { getDaysAgo, toSafeLocalDateStr } from '@/utils/common'
import { OutputExpandFormatter } from './formatters'
-import { DetailFormatter } from '@/components/ListTable/formatters'
+import { DetailFormatter, BooleanFormatter } from '@/components/ListTable/formatters'
export default {
components: {
@@ -38,7 +38,19 @@ export default {
label: this.$t('sessions.command')
},
risk_level: {
- label: this.$t('sessions.riskLevel')
+ label: this.$t('sessions.riskLevel'),
+ formatter: BooleanFormatter,
+ formatterArgs: {
+ hasTips: true,
+ tips(val) {
+ switch (val) {
+ case 0:
+ return vm.$t('sessions.riskLevels.common')
+ default:
+ return vm.$t('sessions.riskLevels.common')
+ }
+ }
+ }
},
user: {
label: this.$t('sessions.user')
@@ -75,6 +87,7 @@ export default {
headerActions: {
hasLeftActions: false,
hasExport: false,
+ hasImport: false,
hasDatePicker: true,
datePicker: {
dateStart: dateFrom,
diff --git a/src/views/xpack/InterfaceSettings.vue b/src/views/xpack/InterfaceSettings.vue
index 29b1c4035..e63859dcf 100644
--- a/src/views/xpack/InterfaceSettings.vue
+++ b/src/views/xpack/InterfaceSettings.vue
@@ -1,5 +1,5 @@
-
+
-
+