feat: user edit UI + admin UI improvements + fixes

This commit is contained in:
Nicolas Giard
2018-12-15 17:15:13 -05:00
parent 366a835278
commit 17244a0cb3
70 changed files with 1272 additions and 231 deletions

View File

@@ -39,6 +39,9 @@ defaults:
darkMode: false
# System defaults
setup: false
paths:
content: ./content
data: ./data
cors:
credentials: true
maxAge: 600

View File

@@ -184,6 +184,7 @@ exports.up = knex => {
table.string('location').defaultTo('')
table.string('pictureUrl')
table.string('timezone').notNullable().defaultTo('America/New_York')
table.boolean('isSystem').notNullable().defaultTo(false)
table.string('createdAt').notNullable()
table.string('updatedAt').notNullable()
})

View File

@@ -11,7 +11,7 @@ module.exports = {
UserQuery: {
async list(obj, args, context, info) {
return WIKI.models.users.query()
.select('id', 'email', 'name', 'providerKey', 'createdAt')
.select('id', 'email', 'name', 'providerKey', 'isSystem', 'createdAt')
},
async search(obj, args, context, info) {
return WIKI.models.users.query()
@@ -22,6 +22,7 @@ module.exports = {
},
async single(obj, args, context, info) {
let usr = await WIKI.models.users.query().findById(args.id)
console.info(usr)
usr.password = ''
usr.tfaSecret = ''
return usr
@@ -39,8 +40,7 @@ module.exports = {
email: args.email,
name: args.name,
provider: args.provider,
providerId: args.providerId,
role: args.role
providerId: args.providerId
}).where('id', args.id)
},
resetPassword(obj, args) {
@@ -52,7 +52,7 @@ module.exports = {
},
User: {
groups(usr) {
return usr.getGroups()
return usr.$relatedQuery('groups')
}
}
}

View File

@@ -38,18 +38,16 @@ type UserMutation {
email: String!
name: String
passwordRaw: String
provider: String!
providerKey: String!
providerId: String
role: UserRole!
): UserResponse @auth(requires: ["write:users", "manage:users", "manage:system"])
update(
id: Int!
email: String
name: String
provider: String
providerKey: String
providerId: String
role: UserRole
): UserResponse @auth(requires: ["manage:users", "manage:system"])
delete(
@@ -70,12 +68,6 @@ type UserMutation {
# TYPES
# -----------------------------------------------
enum UserRole {
guest
user
admin
}
type UserResponse {
responseResult: ResponseStatus!
user: User
@@ -86,6 +78,7 @@ type UserMinimal {
name: String!
email: String!
providerKey: String!
isSystem: Boolean!
createdAt: Date!
}
@@ -95,8 +88,11 @@ type User {
email: String!
providerKey: String!
providerId: String
role: UserRole!
isSystem: Boolean!
location: String!
jobTitle: String!
timezone: String!
createdAt: Date!
updatedAt: Date!
groups: [Group]
groups: [Group]!
}

View File

@@ -32,6 +32,7 @@ module.exports = class User extends Model {
jobTitle: {type: 'string'},
location: {type: 'string'},
pictureUrl: {type: 'string'},
isSystem: {type: 'boolean'},
createdAt: {type: 'string'},
updatedAt: {type: 'string'}
}

View File

@@ -94,7 +94,7 @@ module.exports = () => {
WIKI.logger.info('Creating data directories...')
const dataPath = path.join(process.cwd(), 'data')
await fs.ensureDir(dataPath)
await fs.ensureDir(path.join(dataPath, 'cache'))
await fs.emptyDir(path.join(dataPath, 'cache'))
await fs.ensureDir(path.join(dataPath, 'uploads'))
// Set config
@@ -221,7 +221,8 @@ module.exports = () => {
password: '',
locale: 'en',
defaultEditor: 'markdown',
tfaIsActive: false
tfaIsActive: false,
isSystem: true
})
await guestUser.$relatedQuery('groups').relate(guestGroup.id)

View File

@@ -5,12 +5,12 @@ block body
v-app
.newpage
.newpage-content
img.animated.fadeIn(src='/svg/henry-thinking.svg', alt='Henry')
img.animated.fadeIn(src='/svg/icon-close-window.svg', alt='Henry')
.headline= t('newpage.title')
.subheading.mt-3= t('newpage.subtitle')
v-btn.mt-5(href='/e' + pagePath, large)
v-icon(left) add
span= t('newpage.create')
v-btn.mt-2(color='blue lighten-4', href='javascript:window.history.go(-1);', large, outline)
v-btn.mt-2(color='purple lighten-3', href='javascript:window.history.go(-1);', large, outline)
v-icon(left) arrow_back
span= t('newpage.goback')