diff --git a/src/components/IndicatorCell.vue b/src/components/IndicatorCell.vue
index 3e4a723..73f664a 100644
--- a/src/components/IndicatorCell.vue
+++ b/src/components/IndicatorCell.vue
@@ -5,7 +5,7 @@
{{ mdiEngineOff,
}}
- Disabled
+ {{ disableLabel }}
@@ -27,6 +27,7 @@
diff --git a/src/components/UserPasswordEdit.vue b/src/components/UserPasswordEdit.vue
index 67f2937..88cf02a 100644
--- a/src/components/UserPasswordEdit.vue
+++ b/src/components/UserPasswordEdit.vue
@@ -5,24 +5,26 @@
Change password
-
-
-
+
+
+
+
+
- this.$bus.$emit('status', {
+ this.$bus.$emit(this.editStatus ? 'edit-status' : 'status', {
type: 'success',
message: 'Password changed.' // TODO: Localize
})
)
.catch(({ message }) =>
- this.$bus.$emit('status', { type: 'error', message })
+ this.$bus.$emit(this.editStatus ? 'edit-status' : 'status', {
+ type: 'error',
+ message
+ })
)
}
}
diff --git a/src/components/UsersSearch.vue b/src/components/UsersSearch.vue
new file mode 100644
index 0000000..65b40b1
--- /dev/null
+++ b/src/components/UsersSearch.vue
@@ -0,0 +1,275 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.name }}{{ item.name || '--' }}
+
+
+
+ {{
+ (item.roles && item.roles.length && item.roles[0]) || '--'
+ }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/layouts/editor.vue b/src/layouts/editor.vue
index de387e4..7098fc7 100644
--- a/src/layouts/editor.vue
+++ b/src/layouts/editor.vue
@@ -19,12 +19,13 @@
Save
- Cancel
+ Cancel
@@ -98,7 +99,13 @@ export default {
}),
computed: {
- ...mapState('ux', ['editing', 'editorColor', 'editorDirty', 'editorTitle'])
+ ...mapState('ux', [
+ 'editing',
+ 'editorColor',
+ 'editorDirty',
+ 'editorTitle',
+ 'isLoading'
+ ])
},
watch: {
diff --git a/src/lib/edit.js b/src/lib/edit.js
index e4c0f11..d4a0a61 100644
--- a/src/lib/edit.js
+++ b/src/lib/edit.js
@@ -9,7 +9,8 @@ const arrays = [
'external_links',
'intervals',
'involved_parties',
- 'station_ids'
+ 'station_ids',
+ 'roles'
]
const booleans = [
'is_active',
@@ -23,10 +24,13 @@ const fields = [
'derivation_description',
'derivation_method',
'description',
+ 'email',
'full_name',
'model',
'name',
'oem_company_id',
+ 'password',
+ 'person_id',
'reseller_company_id',
'slug',
'source_type',
@@ -133,6 +137,17 @@ export function defaultThingType() {
}
}
+export function defaultUser() {
+ return {
+ email: '',
+ full_name: '',
+ name: '',
+ roles: [],
+ is_enabled: true,
+ password: ''
+ }
+}
+
export function setData(instance) {
const data = _pickBy(instance, (value, key) => {
return (
diff --git a/src/middleware/check-user.js b/src/middleware/check-user.js
new file mode 100644
index 0000000..4109fa2
--- /dev/null
+++ b/src/middleware/check-user.js
@@ -0,0 +1,26 @@
+export default async function ({ error, params, store }) {
+ const { userId } = params
+
+ try {
+ const res = await store.dispatch('users/find', {
+ query: {
+ _id: userId,
+ $limit: 1
+ }
+ })
+
+ if (!(res && res.data && res.data.length)) {
+ return error({
+ statusCode: 404,
+ message: 'User not found.'
+ })
+ }
+
+ store.commit('setUser', res.data[0])
+ } catch (err) {
+ error({
+ statusCode: err.statusCode || 500,
+ message: err.message
+ })
+ }
+}
diff --git a/src/pages/users/_userId/index.vue b/src/pages/users/_userId/index.vue
new file mode 100644
index 0000000..cc10186
--- /dev/null
+++ b/src/pages/users/_userId/index.vue
@@ -0,0 +1,179 @@
+
+
+
+
+ User details
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ mdiPencil }}
+
+
+
+
+
diff --git a/src/pages/users/create.vue b/src/pages/users/create.vue
new file mode 100644
index 0000000..02a9e72
--- /dev/null
+++ b/src/pages/users/create.vue
@@ -0,0 +1,171 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/users/index.vue b/src/pages/users/index.vue
new file mode 100644
index 0000000..5ba221e
--- /dev/null
+++ b/src/pages/users/index.vue
@@ -0,0 +1,79 @@
+
+
+
+
+
+ View
+
+
+
+
+
+
+ Users
+
+
+
+
+
+
+ {{
+ mdiOpenInNew
+ }}
+
+
+
+
+
+
+
+
+
+ {{ mdiPlus }}
+
+
+
+
+
diff --git a/src/plugins/ability.js b/src/plugins/ability.js
index 9811901..133fc63 100644
--- a/src/plugins/ability.js
+++ b/src/plugins/ability.js
@@ -55,7 +55,6 @@ export default ({ store }, inject) => {
inject('canPatch', (name, obj) =>
store.getters.isAbilityUpdated ? ability.can('patch', as(name, obj)) : false
)
-
inject('cannot', (...args) =>
store.getters.isAbilityUpdated ? ability.cannot(...args) : true
)
@@ -74,4 +73,9 @@ export default ({ store }, inject) => {
? ability.cannot('graph', as(name, obj))
: true
)
+ inject('cannotPatch', (name, obj) =>
+ store.getters.isAbilityUpdated
+ ? ability.cannot('patch', as(name, obj))
+ : true
+ )
}
diff --git a/src/store/index.js b/src/store/index.js
index 90d325d..510fa99 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -141,6 +141,9 @@ export const getters = {
},
annotationId(state) {
return state.annotationId
+ },
+ user(state, { 'users/get': get }) {
+ return state.userId && get(state.userId)
}
}
@@ -188,5 +191,8 @@ export const mutations = {
},
setAnnotation(state, value) {
state.annotationId = value && value._id
+ },
+ setUser(state, value) {
+ state.userId = value && value._id
}
}
diff --git a/src/store/ux.js b/src/store/ux.js
index d956db7..4fb4d6e 100644
--- a/src/store/ux.js
+++ b/src/store/ux.js
@@ -6,7 +6,8 @@ export const state = () => ({
editing: false,
editorColor: 'primary',
editorDirty: 0,
- editorTitle: ''
+ editorTitle: '',
+ isLoading: false
})
export const actions = {}
@@ -43,5 +44,8 @@ export const mutations = {
},
setEditorTitle(state, value) {
state.editorTitle = value
+ },
+ setIsLoading(state, value) {
+ state.isLoading = value
}
}