feat: admin group edit / assign / unassign
This commit is contained in:
@@ -21,15 +21,20 @@
|
||||
v-text-field(label='Site Description', :counter='255', prepend-icon='public')
|
||||
v-text-field(label='Site Keywords', :counter='255', prepend-icon='public')
|
||||
v-select(label='Meta Robots', chips, tags, :items='metaRobots', v-model='metaRobotsSelection', prepend-icon='public')
|
||||
v-divider
|
||||
.px-3.pb-3
|
||||
v-btn(color='primary') Save
|
||||
v-divider.my-0
|
||||
v-card-actions.grey.lighten-4
|
||||
v-spacer
|
||||
v-btn(color='primary')
|
||||
v-icon(left) chevron_right
|
||||
span Save
|
||||
v-flex(lg6 xs12)
|
||||
v-card
|
||||
v-toolbar(color='primary', dark, dense, flat)
|
||||
v-toolbar-title
|
||||
.subheading Site Branding
|
||||
v-card-text ---
|
||||
v-card-text
|
||||
v-text-field(label='Logo', prepend-icon='image')
|
||||
v-divider
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
v-card
|
||||
v-card(flat, color='grey lighten-5').pa-3.pt-4
|
||||
.headline.blue--text.text--darken-2 Edit Group
|
||||
.subheading.grey--text {{group.name}}
|
||||
.subheading.grey--text {{name}}
|
||||
v-btn(color='primary', fab, absolute, bottom, right, small, to='/groups'): v-icon arrow_upward
|
||||
v-tabs(v-model='tab', color='grey lighten-4', fixed-tabs, slider-color='primary', show-arrows)
|
||||
v-tab(key='properties') Properties
|
||||
@@ -12,9 +12,9 @@
|
||||
v-tab-item(key='properties', :transition='false', :reverse-transition='false')
|
||||
v-card
|
||||
v-card-text
|
||||
v-text-field(v-model='group.name', label='Group Name', counter='255', prepend-icon='people')
|
||||
v-text-field(v-model='name', label='Group Name', counter='255', prepend-icon='people')
|
||||
v-card-actions.pa-3
|
||||
v-btn(color='primary', @click='')
|
||||
v-btn(color='primary', @click='updateGroup')
|
||||
v-icon(left) check
|
||||
| Save Changes
|
||||
.caption.ml-4.grey--text ID: {{group.id}}
|
||||
@@ -25,7 +25,7 @@
|
||||
| Delete Group
|
||||
v-card
|
||||
.dialog-header.is-red Delete Group?
|
||||
v-card-text Are you sure you want to delete group #[strong {{ group.name }}]? All users will be unassigned from this group.
|
||||
v-card-text Are you sure you want to delete group #[strong {{ name }}]? All users will be unassigned from this group.
|
||||
v-card-actions
|
||||
v-spacer
|
||||
v-btn(flat, @click='deleteGroupDialog = false') Cancel
|
||||
@@ -78,7 +78,7 @@
|
||||
v-tab-item(key='users', :transition='false', :reverse-transition='false')
|
||||
v-card
|
||||
v-card-title.pb-0
|
||||
v-btn(color='primary', @click='assignUser')
|
||||
v-btn(color='primary', @click='searchUserDialog = true')
|
||||
v-icon(left) assignment_ind
|
||||
| Assign User
|
||||
v-data-table(
|
||||
@@ -98,7 +98,7 @@
|
||||
v-menu(bottom, right, min-width='200')
|
||||
v-btn(icon, slot='activator'): v-icon.grey--text.text--darken-1 more_horiz
|
||||
v-list
|
||||
v-list-tile(@click='deleteGroupConfirm(props.item)')
|
||||
v-list-tile(@click='unassignUser(props.item.id)')
|
||||
v-list-tile-action: v-icon(color='orange') highlight_off
|
||||
v-list-tile-content
|
||||
v-list-tile-title Unassign
|
||||
@@ -107,7 +107,7 @@
|
||||
.text-xs-center.py-2(v-if='users.length > 15')
|
||||
v-pagination(v-model='pagination.page', :length='pages')
|
||||
|
||||
user-search(v-model='searchUserDialog')
|
||||
user-search(v-model='searchUserDialog', @select='assignUser')
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -115,7 +115,10 @@ import Criterias from '../common/criterias.vue'
|
||||
import UserSearch from '../common/user-search.vue'
|
||||
|
||||
import groupQuery from 'gql/admin-groups-query-single.gql'
|
||||
import assignUserMutation from 'gql/admin-groups-mutation-assign.gql'
|
||||
import deleteGroupMutation from 'gql/admin-groups-mutation-delete.gql'
|
||||
import unassignUserMutation from 'gql/admin-groups-mutation-unassign.gql'
|
||||
import updateGroupMutation from 'gql/admin-groups-mutation-update.gql'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -125,10 +128,11 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
group: {
|
||||
id: 7,
|
||||
name: 'Editors',
|
||||
id: 0,
|
||||
name: '',
|
||||
users: []
|
||||
},
|
||||
name: '',
|
||||
deleteGroupDialog: false,
|
||||
searchUserDialog: false,
|
||||
pagination: {},
|
||||
@@ -152,10 +156,36 @@ export default {
|
||||
return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
group(newValue, oldValue) {
|
||||
this.name = newValue.name
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async deleteGroupConfirm(group) {
|
||||
this.deleteGroupDialog = true
|
||||
this.selectedGroup = group
|
||||
async updateGroup() {
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: updateGroupMutation,
|
||||
variables: {
|
||||
id: this.group.id,
|
||||
name: this.name
|
||||
},
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-update')
|
||||
}
|
||||
})
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'success',
|
||||
message: `Group changes have been saved.`,
|
||||
icon: 'check'
|
||||
})
|
||||
} catch (err) {
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'red',
|
||||
message: err.message,
|
||||
icon: 'warning'
|
||||
})
|
||||
}
|
||||
},
|
||||
async deleteGroup() {
|
||||
this.deleteGroupDialog = false
|
||||
@@ -183,8 +213,57 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
assignUser() {
|
||||
this.searchUserDialog = true
|
||||
async assignUser(id) {
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: assignUserMutation,
|
||||
variables: {
|
||||
groupId: this.group.id,
|
||||
userId: id
|
||||
},
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-assign')
|
||||
}
|
||||
})
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'success',
|
||||
message: `User has been assigned to ${this.group.name}.`,
|
||||
icon: 'assignment_ind'
|
||||
})
|
||||
this.$apollo.queries.group.refetch()
|
||||
} catch (err) {
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'red',
|
||||
message: err.message,
|
||||
icon: 'warning'
|
||||
})
|
||||
}
|
||||
},
|
||||
async unassignUser(id) {
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: unassignUserMutation,
|
||||
variables: {
|
||||
groupId: this.group.id,
|
||||
userId: id
|
||||
},
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-unassign')
|
||||
}
|
||||
})
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'success',
|
||||
message: `User has been unassigned from ${this.group.name}.`,
|
||||
icon: 'assignment_ind'
|
||||
})
|
||||
this.$apollo.queries.group.refetch()
|
||||
} catch (err) {
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'red',
|
||||
message: err.message,
|
||||
icon: 'warning'
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
apollo: {
|
||||
@@ -195,6 +274,7 @@ export default {
|
||||
id: this.$route.params.id
|
||||
}
|
||||
},
|
||||
fetchPolicy: 'network-only',
|
||||
update: (data) => data.groups.single,
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-refresh')
|
||||
|
||||
@@ -156,6 +156,7 @@ export default {
|
||||
apollo: {
|
||||
groups: {
|
||||
query: groupsQuery,
|
||||
fetchPolicy: 'network-only',
|
||||
update: (data) => data.groups.list,
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-refresh')
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
v-layout(row wrap)
|
||||
v-flex(lg6 xs12)
|
||||
v-card
|
||||
v-toolbar(color='grey darken-3', dark, dense, flat)
|
||||
v-toolbar(color='primary', dark, dense, flat)
|
||||
v-toolbar-title
|
||||
.subheading Locale Settings
|
||||
v-card-text
|
||||
@@ -38,8 +38,9 @@
|
||||
persistent-hint
|
||||
hint='Automatically download updates to this locale as they become available.'
|
||||
)
|
||||
v-divider
|
||||
.px-3.pb-3
|
||||
v-divider.my-0
|
||||
v-card-actions.grey.lighten-4
|
||||
v-spacer
|
||||
v-btn(color='primary', :loading='loading', @click='save')
|
||||
v-icon(left) chevron_right
|
||||
span Save
|
||||
@@ -49,7 +50,7 @@
|
||||
v-toolbar-title
|
||||
.subheading Download Locale
|
||||
v-list
|
||||
v-list-tile(v-for='lc in locales')
|
||||
v-list-tile(v-for='lc in locales', :key='lc.code')
|
||||
v-list-tile-avatar
|
||||
v-avatar.teal.white--text(tile, size='40') {{lc.code.toUpperCase()}}
|
||||
v-list-tile-content
|
||||
@@ -159,7 +160,3 @@ export default {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='scss'>
|
||||
|
||||
</style>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
v-layout(row wrap)
|
||||
v-flex(lg6 xs12)
|
||||
v-card
|
||||
v-toolbar(color='grey darken-3', dark, dense, flat)
|
||||
v-toolbar(color='primary', dark, dense, flat)
|
||||
v-toolbar-title
|
||||
.subheading Theme
|
||||
v-card-text
|
||||
@@ -21,9 +21,12 @@
|
||||
v-list-tile-sub-title(v-html='data.item.author')
|
||||
v-divider
|
||||
v-switch(v-model='darkMode', label='Dark Mode', color='primary', persistent-hint, hint='Not recommended for accessibility.')
|
||||
v-divider
|
||||
.px-3.pb-3
|
||||
v-btn(color='primary') Save
|
||||
v-divider.my-0
|
||||
v-card-actions.grey.lighten-4
|
||||
v-spacer
|
||||
v-btn(color='primary', :loading='loading', @click='save')
|
||||
v-icon(left) chevron_right
|
||||
span Save
|
||||
v-flex(lg6 xs12)
|
||||
v-card
|
||||
v-toolbar(color='teal', dark, dense, flat)
|
||||
|
||||
@@ -1,38 +1,66 @@
|
||||
<template lang="pug">
|
||||
v-dialog(v-model='dialogOpen', max-width='650')
|
||||
v-dialog(
|
||||
v-model='dialogOpen'
|
||||
max-width='650'
|
||||
)
|
||||
v-card
|
||||
.dialog-header Search User
|
||||
v-card-text
|
||||
v-select(
|
||||
:items='items'
|
||||
:loading='searchLoading'
|
||||
:search-input.sync='search'
|
||||
autocomplete
|
||||
autofocus
|
||||
cache-items
|
||||
chips
|
||||
clearable
|
||||
hide-details
|
||||
item-text='name',
|
||||
item-value='id',
|
||||
label='Search users...'
|
||||
light
|
||||
multiple
|
||||
v-model='selectedItems'
|
||||
)
|
||||
v-card-actions
|
||||
.dialog-header
|
||||
span Search User
|
||||
v-spacer
|
||||
v-btn(flat, @click='close', :disabled='loading') Cancel
|
||||
v-btn(color='primary', dark, @click='setUser', :loading='loading', :disabled='loading')
|
||||
v-icon(left) assignment_ind
|
||||
span Select User
|
||||
v-progress-circular(
|
||||
indeterminate
|
||||
color='white'
|
||||
:size='20'
|
||||
:width='2'
|
||||
v-show='searchLoading'
|
||||
)
|
||||
v-card-text
|
||||
v-text-field.blue.lighten-5(
|
||||
solo
|
||||
flat
|
||||
label='Search Users...'
|
||||
v-model='search'
|
||||
prepend-icon='search'
|
||||
color='primary'
|
||||
ref='searchIpt'
|
||||
)
|
||||
v-list(two-line)
|
||||
template(v-for='(usr, idx) in items')
|
||||
v-list-tile(:key='usr.id', @click='setUser(usr.id)')
|
||||
v-list-tile-avatar(size='40', color='primary')
|
||||
span.body-1.white--text {{usr.name | initials}}
|
||||
v-list-tile-content
|
||||
v-list-tile-title {{usr.name}}
|
||||
v-list-tile-sub-title {{usr.email}}
|
||||
v-list-tile-action
|
||||
v-icon(color='primary') arrow_forward
|
||||
v-divider.my-0(v-if='idx < items.length - 1')
|
||||
v-divider.my-0
|
||||
v-card-actions.grey.lighten-4
|
||||
v-spacer
|
||||
v-btn(
|
||||
flat
|
||||
@click='close'
|
||||
:disabled='loading'
|
||||
) Cancel
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
|
||||
import searchUsersQuery from 'gql/common-users-query-search.gql'
|
||||
|
||||
export default {
|
||||
filters: {
|
||||
initials(val) {
|
||||
return val.split(' ').map(v => v.substring(0, 1)).join()
|
||||
}
|
||||
},
|
||||
props: {
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
value: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -43,8 +71,7 @@ export default {
|
||||
loading: false,
|
||||
searchLoading: false,
|
||||
search: '',
|
||||
items: [],
|
||||
selectedItems: []
|
||||
items: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -53,12 +80,25 @@ export default {
|
||||
set(value) { this.$emit('input', value) }
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value(newValue, oldValue) {
|
||||
if (newValue && !oldValue) {
|
||||
this.search = ''
|
||||
this.selectedItems = null
|
||||
_.delay(() => { this.$refs.searchIpt.focus() }, 100)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
this.$emit('input', false)
|
||||
},
|
||||
setUser() {
|
||||
|
||||
setUser(id) {
|
||||
this.$emit('select', id)
|
||||
this.close()
|
||||
},
|
||||
searchFilter(item, queryText, itemText) {
|
||||
return _.includes(_.toLower(item.email), _.toLower(queryText)) || _.includes(_.toLower(item.name), _.toLower(queryText))
|
||||
}
|
||||
},
|
||||
apollo: {
|
||||
@@ -66,13 +106,13 @@ export default {
|
||||
query: searchUsersQuery,
|
||||
variables() {
|
||||
return {
|
||||
search: this.search
|
||||
query: this.search
|
||||
}
|
||||
},
|
||||
skip() {
|
||||
return !this.search || this.search.length < 2
|
||||
},
|
||||
update: (data) => data.upsells.segments,
|
||||
update: (data) => data.users.search,
|
||||
watchLoading (isLoading) {
|
||||
this.searchLoading = isLoading
|
||||
}
|
||||
|
||||
12
client/graph/admin-groups-mutation-assign.gql
Normal file
12
client/graph/admin-groups-mutation-assign.gql
Normal file
@@ -0,0 +1,12 @@
|
||||
mutation ($groupId: Int!, $userId: Int!) {
|
||||
groups {
|
||||
assignUser(groupId: $groupId, userId: $userId) {
|
||||
responseResult {
|
||||
succeeded
|
||||
errorCode
|
||||
slug
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
client/graph/admin-groups-mutation-unassign.gql
Normal file
12
client/graph/admin-groups-mutation-unassign.gql
Normal file
@@ -0,0 +1,12 @@
|
||||
mutation ($groupId: Int!, $userId: Int!) {
|
||||
groups {
|
||||
unassignUser(groupId: $groupId, userId: $userId) {
|
||||
responseResult {
|
||||
succeeded
|
||||
errorCode
|
||||
slug
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
client/graph/admin-groups-mutation-update.gql
Normal file
12
client/graph/admin-groups-mutation-update.gql
Normal file
@@ -0,0 +1,12 @@
|
||||
mutation ($id: Int!, $name: String!) {
|
||||
groups {
|
||||
update(id: $id, name: $name) {
|
||||
responseResult {
|
||||
succeeded
|
||||
errorCode
|
||||
slug
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ query ($query: String!) {
|
||||
id
|
||||
name
|
||||
email
|
||||
provider
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
48
package.json
48
package.json
@@ -61,15 +61,15 @@
|
||||
"express-brute": "1.0.1",
|
||||
"express-brute-redis": "0.0.1",
|
||||
"express-session": "1.15.6",
|
||||
"file-type": "7.6.0",
|
||||
"file-type": "7.7.1",
|
||||
"filesize.js": "1.0.2",
|
||||
"follow-redirects": "1.4.1",
|
||||
"fs-extra": "5.0.0",
|
||||
"fs-extra": "6.0.1",
|
||||
"getos": "3.1.0",
|
||||
"graphql": "0.13.2",
|
||||
"graphql-list-fields": "2.0.2",
|
||||
"graphql-tools": "3.0.0",
|
||||
"i18next": "11.2.3",
|
||||
"graphql-tools": "3.0.1",
|
||||
"i18next": "11.3.1",
|
||||
"i18next-express-middleware": "1.1.1",
|
||||
"i18next-localstorage-cache": "1.1.1",
|
||||
"i18next-node-fs-backend": "1.0.0",
|
||||
@@ -82,7 +82,7 @@
|
||||
"markdown-it": "8.4.1",
|
||||
"markdown-it-abbr": "1.0.4",
|
||||
"markdown-it-anchor": "4.0.0",
|
||||
"markdown-it-attrs": "1.2.1",
|
||||
"markdown-it-attrs": "2.0.0",
|
||||
"markdown-it-emoji": "1.4.0",
|
||||
"markdown-it-expand-tabs": "1.0.13",
|
||||
"markdown-it-external-links": "0.0.6",
|
||||
@@ -102,7 +102,7 @@
|
||||
"mysql2": "1.5.3",
|
||||
"node-2fa": "1.1.2",
|
||||
"oauth2orize": "1.11.0",
|
||||
"ora": "2.0.0",
|
||||
"ora": "2.1.0",
|
||||
"passport": "0.4.0",
|
||||
"passport-auth0": "0.6.1",
|
||||
"passport-azure-ad-oauth2": "0.0.4",
|
||||
@@ -123,45 +123,45 @@
|
||||
"pm2": "2.10.3",
|
||||
"pug": "2.0.3",
|
||||
"qr-image": "3.2.0",
|
||||
"raven": "2.6.0",
|
||||
"raven": "2.6.1",
|
||||
"read-chunk": "2.1.0",
|
||||
"remove-markdown": "0.2.2",
|
||||
"request": "2.85.0",
|
||||
"request-promise": "4.2.2",
|
||||
"scim-query-filter-parser": "1.1.0",
|
||||
"semver": "5.5.0",
|
||||
"sequelize": "4.37.6",
|
||||
"sequelize": "4.37.7",
|
||||
"serve-favicon": "2.5.0",
|
||||
"sqlite3": "4.0.0",
|
||||
"uuid": "3.2.1",
|
||||
"validator": "9.4.1",
|
||||
"validator": "10.2.0",
|
||||
"validator-as-promised": "1.0.2",
|
||||
"winston": "3.0.0-rc2",
|
||||
"yargs": "11.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@panter/vue-i18next": "0.9.1",
|
||||
"@vue/cli": "3.0.0-beta.9",
|
||||
"@vue/cli": "3.0.0-beta.10",
|
||||
"apollo-client-preset": "1.0.8",
|
||||
"apollo-fetch": "0.7.0",
|
||||
"apollo-link-batch-http": "1.2.2",
|
||||
"autoprefixer": "8.3.0",
|
||||
"autoprefixer": "8.4.1",
|
||||
"babel-cli": "6.26.0",
|
||||
"babel-core": "6.26.3",
|
||||
"babel-eslint": "8.2.3",
|
||||
"babel-jest": "23.0.0-alpha.0",
|
||||
"babel-loader": "7.1.4",
|
||||
"babel-plugin-graphql-tag": "1.5.0",
|
||||
"babel-plugin-graphql-tag": "1.6.0",
|
||||
"babel-plugin-lodash": "3.3.2",
|
||||
"babel-plugin-transform-imports": "1.5.0",
|
||||
"babel-polyfill": "6.26.0",
|
||||
"babel-preset-env": "1.6.1",
|
||||
"babel-preset-env": "1.7.0",
|
||||
"babel-preset-es2015": "6.24.1",
|
||||
"babel-preset-stage-2": "6.24.1",
|
||||
"brace": "0.11.1",
|
||||
"cache-loader": "1.2.2",
|
||||
"clean-webpack-plugin": "0.1.19",
|
||||
"colors": "1.2.1",
|
||||
"colors": "1.2.5",
|
||||
"copy-webpack-plugin": "4.5.1",
|
||||
"css-loader": "0.28.11",
|
||||
"cssnano": "4.0.0-rc.2",
|
||||
@@ -176,7 +176,7 @@
|
||||
"eslint-plugin-vue": "4.5.0",
|
||||
"file-loader": "1.1.11",
|
||||
"graphiql": "0.11.11",
|
||||
"graphql-tag": "^2.9.1",
|
||||
"graphql-tag": "^2.9.2",
|
||||
"graphql-voyager": "1.0.0-rc.15",
|
||||
"hammerjs": "2.0.8",
|
||||
"html-webpack-plugin": "3.2.0",
|
||||
@@ -189,13 +189,13 @@
|
||||
"lodash-webpack-plugin": "0.11.5",
|
||||
"mini-css-extract-plugin": "0.4.0",
|
||||
"node-sass": "4.9.0",
|
||||
"offline-plugin": "5.0.1",
|
||||
"optimize-css-assets-webpack-plugin": "4.0.0",
|
||||
"offline-plugin": "5.0.3",
|
||||
"optimize-css-assets-webpack-plugin": "4.0.1",
|
||||
"postcss-cssnext": "3.1.0",
|
||||
"postcss-flexbugs-fixes": "3.3.0",
|
||||
"postcss-flexbugs-fixes": "3.3.1",
|
||||
"postcss-flexibility": "2.0.0",
|
||||
"postcss-import": "11.1.0",
|
||||
"postcss-loader": "2.1.4",
|
||||
"postcss-loader": "2.1.5",
|
||||
"postcss-selector-parser": "4.0.0",
|
||||
"pug-lint": "2.5.0",
|
||||
"pug-loader": "2.4.0",
|
||||
@@ -211,14 +211,14 @@
|
||||
"stylus": "0.54.5",
|
||||
"stylus-loader": "3.0.2",
|
||||
"twemoji-awesome": "1.0.6",
|
||||
"vee-validate": "2.0.8",
|
||||
"vee-validate": "2.0.9",
|
||||
"velocity-animate": "1.5.1",
|
||||
"vue": "2.5.16",
|
||||
"vue-apollo": "3.0.0-beta.5",
|
||||
"vue-clipboards": "1.2.4",
|
||||
"vue-codemirror": "4.0.5",
|
||||
"vue-hot-reload-api": "2.3.0",
|
||||
"vue-loader": "15.0.4",
|
||||
"vue-loader": "15.0.10",
|
||||
"vue-material-design-icons": "1.4.0",
|
||||
"vue-moment": "3.2.0",
|
||||
"vue-router": "3.0.1",
|
||||
@@ -227,9 +227,9 @@
|
||||
"vuetify": "1.0.17",
|
||||
"vuex": "3.0.1",
|
||||
"vuex-persistedstate": "2.5.2",
|
||||
"webpack": "4.6.0",
|
||||
"webpack-bundle-analyzer": "2.11.1",
|
||||
"webpack-cli": "2.0.15",
|
||||
"webpack": "4.8.2",
|
||||
"webpack-bundle-analyzer": "2.11.2",
|
||||
"webpack-cli": "2.1.3",
|
||||
"webpack-dev-middleware": "3.1.3",
|
||||
"webpack-hot-middleware": "2.22.1",
|
||||
"webpack-merge": "4.1.2",
|
||||
|
||||
@@ -34,18 +34,19 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
GroupMutation: {
|
||||
assignUser(obj, args) {
|
||||
return WIKI.db.Group.findById(args.groupId).then(grp => {
|
||||
if (!grp) {
|
||||
throw new gql.GraphQLError('Invalid Group ID')
|
||||
}
|
||||
return WIKI.db.User.findById(args.userId).then(usr => {
|
||||
if (!usr) {
|
||||
throw new gql.GraphQLError('Invalid User ID')
|
||||
}
|
||||
return grp.addUser(usr)
|
||||
})
|
||||
})
|
||||
async assignUser(obj, args) {
|
||||
const grp = await WIKI.db.Group.findById(args.groupId)
|
||||
if (!grp) {
|
||||
throw new gql.GraphQLError('Invalid Group ID')
|
||||
}
|
||||
const usr = await WIKI.db.User.findById(args.userId)
|
||||
if (!usr) {
|
||||
throw new gql.GraphQLError('Invalid User ID')
|
||||
}
|
||||
await grp.addUser(usr)
|
||||
return {
|
||||
responseResult: graphHelper.generateSuccess('User has been assigned to group.')
|
||||
}
|
||||
},
|
||||
async create(obj, args) {
|
||||
const group = await WIKI.db.Group.create({
|
||||
@@ -67,25 +68,29 @@ module.exports = {
|
||||
responseResult: graphHelper.generateSuccess('Group has been deleted.')
|
||||
}
|
||||
},
|
||||
unassignUser(obj, args) {
|
||||
return WIKI.db.Group.findById(args.groupId).then(grp => {
|
||||
if (!grp) {
|
||||
throw new gql.GraphQLError('Invalid Group ID')
|
||||
}
|
||||
return WIKI.db.User.findById(args.userId).then(usr => {
|
||||
if (!usr) {
|
||||
throw new gql.GraphQLError('Invalid User ID')
|
||||
}
|
||||
return grp.removeUser(usr)
|
||||
})
|
||||
})
|
||||
async unassignUser(obj, args) {
|
||||
const grp = await WIKI.db.Group.findById(args.groupId)
|
||||
if (!grp) {
|
||||
throw new gql.GraphQLError('Invalid Group ID')
|
||||
}
|
||||
const usr = await WIKI.db.User.findById(args.userId)
|
||||
if (!usr) {
|
||||
throw new gql.GraphQLError('Invalid User ID')
|
||||
}
|
||||
await grp.removeUser(usr)
|
||||
return {
|
||||
responseResult: graphHelper.generateSuccess('User has been unassigned from group.')
|
||||
}
|
||||
},
|
||||
update(obj, args) {
|
||||
return WIKI.db.Group.update({
|
||||
async update(obj, args) {
|
||||
await WIKI.db.Group.update({
|
||||
name: args.name
|
||||
}, {
|
||||
where: { id: args.id }
|
||||
})
|
||||
return {
|
||||
responseResult: graphHelper.generateSuccess('Group has been updated.')
|
||||
}
|
||||
}
|
||||
},
|
||||
Group: {
|
||||
|
||||
@@ -3,15 +3,42 @@
|
||||
|
||||
module.exports = {
|
||||
Query: {
|
||||
users(obj, args, context, info) {
|
||||
return WIKI.db.User.findAll({ where: args })
|
||||
}
|
||||
async users() { return {} }
|
||||
},
|
||||
Mutation: {
|
||||
createUser(obj, args) {
|
||||
async users() { return {} }
|
||||
},
|
||||
UserQuery: {
|
||||
async list(obj, args, context, info) {
|
||||
return WIKI.db.User.findAll({
|
||||
attributes: {
|
||||
exclude: ['password', 'tfaSecret']
|
||||
},
|
||||
raw: true
|
||||
})
|
||||
},
|
||||
async search(obj, args, context, info) {
|
||||
return WIKI.db.User.findAll({
|
||||
where: {
|
||||
$or: [
|
||||
{ email: { $like: `%${args.query}%` } },
|
||||
{ name: { $like: `%${args.query}%` } }
|
||||
]
|
||||
},
|
||||
limit: 10,
|
||||
attributes: ['id', 'email', 'name', 'provider', 'role', 'createdAt', 'updatedAt'],
|
||||
raw: true
|
||||
})
|
||||
},
|
||||
async single(obj, args, context, info) {
|
||||
return WIKI.db.User.findById(args.id)
|
||||
}
|
||||
},
|
||||
UserMutation: {
|
||||
create(obj, args) {
|
||||
return WIKI.db.User.create(args)
|
||||
},
|
||||
deleteUser(obj, args) {
|
||||
delete(obj, args) {
|
||||
return WIKI.db.User.destroy({
|
||||
where: {
|
||||
id: args.id
|
||||
@@ -19,7 +46,7 @@ module.exports = {
|
||||
limit: 1
|
||||
})
|
||||
},
|
||||
modifyUser(obj, args) {
|
||||
update(obj, args) {
|
||||
return WIKI.db.User.update({
|
||||
email: args.email,
|
||||
name: args.name,
|
||||
@@ -30,10 +57,10 @@ module.exports = {
|
||||
where: { id: args.id }
|
||||
})
|
||||
},
|
||||
resetUserPassword(obj, args) {
|
||||
resetPassword(obj, args) {
|
||||
return false
|
||||
},
|
||||
setUserPassword(obj, args) {
|
||||
setPassword(obj, args) {
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
|
||||
# ENUMS
|
||||
|
||||
enum UserRole {
|
||||
guest
|
||||
user
|
||||
admin
|
||||
}
|
||||
|
||||
enum FileType {
|
||||
binary
|
||||
image
|
||||
@@ -134,19 +128,6 @@ type Translation {
|
||||
value: String!
|
||||
}
|
||||
|
||||
# A User
|
||||
type User implements Base {
|
||||
id: Int!
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
email: String!
|
||||
provider: String!
|
||||
providerId: String
|
||||
name: String
|
||||
role: UserRole!
|
||||
groups: [Group]
|
||||
}
|
||||
|
||||
type OperationResult {
|
||||
succeeded: Boolean!
|
||||
message: String
|
||||
@@ -164,7 +145,6 @@ type Query {
|
||||
settings(key: String): [Setting]
|
||||
tags(key: String): [Tag]
|
||||
translations(locale: String!, namespace: String!): [Translation]
|
||||
users(id: Int, email: String, provider: String, providerId: String, role: UserRole): [User]
|
||||
}
|
||||
|
||||
# Mutations (Create, Update, Delete)
|
||||
@@ -202,15 +182,6 @@ type Mutation {
|
||||
name: String!
|
||||
): Tag
|
||||
|
||||
createUser(
|
||||
email: String!
|
||||
name: String
|
||||
passwordRaw: String
|
||||
provider: String!
|
||||
providerId: String
|
||||
role: UserRole!
|
||||
): User
|
||||
|
||||
deleteComment(
|
||||
id: Int!
|
||||
): OperationResult
|
||||
@@ -231,10 +202,6 @@ type Mutation {
|
||||
id: Int!
|
||||
): OperationResult
|
||||
|
||||
deleteUser(
|
||||
id: Int!
|
||||
): OperationResult
|
||||
|
||||
modifyComment(
|
||||
id: Int!
|
||||
content: String!
|
||||
@@ -246,15 +213,6 @@ type Mutation {
|
||||
subtitle: String
|
||||
): Document
|
||||
|
||||
modifyUser(
|
||||
id: Int!
|
||||
email: String
|
||||
name: String
|
||||
provider: String
|
||||
providerId: String
|
||||
role: UserRole
|
||||
): User
|
||||
|
||||
modifyRight(
|
||||
id: Int!
|
||||
path: String
|
||||
@@ -297,20 +255,11 @@ type Mutation {
|
||||
rightId: Int!
|
||||
): OperationResult
|
||||
|
||||
resetUserPassword(
|
||||
id: Int!
|
||||
): OperationResult
|
||||
|
||||
setConfigEntry(
|
||||
key: String!
|
||||
value: String!
|
||||
): OperationResult
|
||||
|
||||
setUserPassword(
|
||||
id: Int!
|
||||
passwordRaw: String!
|
||||
): OperationResult
|
||||
|
||||
uploadFile(
|
||||
category: FileType!
|
||||
filename: String!
|
||||
|
||||
@@ -37,7 +37,7 @@ type GroupMutation {
|
||||
update(
|
||||
id: Int!
|
||||
name: String!
|
||||
): GroupResponse
|
||||
): DefaultResponse
|
||||
|
||||
delete(
|
||||
id: Int!
|
||||
|
||||
101
server/graph/schemas/user.graphql
Normal file
101
server/graph/schemas/user.graphql
Normal file
@@ -0,0 +1,101 @@
|
||||
# ===============================================
|
||||
# USERS
|
||||
# ===============================================
|
||||
|
||||
extend type Query {
|
||||
users: UserQuery
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
users: UserMutation
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# QUERIES
|
||||
# -----------------------------------------------
|
||||
|
||||
type UserQuery {
|
||||
list(
|
||||
filter: String
|
||||
orderBy: String
|
||||
): [UserMinimal]
|
||||
|
||||
search(
|
||||
query: String!
|
||||
): [UserMinimal]
|
||||
|
||||
single(
|
||||
id: Int!
|
||||
): User
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# MUTATIONS
|
||||
# -----------------------------------------------
|
||||
|
||||
type UserMutation {
|
||||
create(
|
||||
email: String!
|
||||
name: String
|
||||
passwordRaw: String
|
||||
provider: String!
|
||||
providerId: String
|
||||
role: UserRole!
|
||||
): UserResponse
|
||||
|
||||
update(
|
||||
id: Int!
|
||||
email: String
|
||||
name: String
|
||||
provider: String
|
||||
providerId: String
|
||||
role: UserRole
|
||||
): UserResponse
|
||||
|
||||
delete(
|
||||
id: Int!
|
||||
): DefaultResponse
|
||||
|
||||
resetPassword(
|
||||
id: Int!
|
||||
): DefaultResponse
|
||||
|
||||
setPassword(
|
||||
id: Int!
|
||||
passwordRaw: String!
|
||||
): DefaultResponse
|
||||
}
|
||||
|
||||
# -----------------------------------------------
|
||||
# TYPES
|
||||
# -----------------------------------------------
|
||||
|
||||
enum UserRole {
|
||||
guest
|
||||
user
|
||||
admin
|
||||
}
|
||||
|
||||
type UserResponse {
|
||||
responseResult: ResponseStatus!
|
||||
user: User
|
||||
}
|
||||
|
||||
type UserMinimal {
|
||||
id: Int!
|
||||
name: String!
|
||||
email: String!
|
||||
provider: String!
|
||||
}
|
||||
|
||||
type User {
|
||||
id: Int!
|
||||
name: String!
|
||||
email: String!
|
||||
provider: String!
|
||||
providerId: String
|
||||
role: UserRole!
|
||||
createdAt: Date!
|
||||
updatedAt: Date!
|
||||
groups: [Group]
|
||||
}
|
||||
Reference in New Issue
Block a user