feat: timezone + dateFOrmat + appearance profile settings
This commit is contained in:
15
server/db/migrations-sqlite/2.4.13.js
Normal file
15
server/db/migrations-sqlite/2.4.13.js
Normal file
@@ -0,0 +1,15 @@
|
||||
exports.up = knex => {
|
||||
return knex.schema
|
||||
.alterTable('pages', table => {
|
||||
table.json('extra').notNullable().defaultTo('{}')
|
||||
})
|
||||
.alterTable('pageHistory', table => {
|
||||
table.json('extra').notNullable().defaultTo('{}')
|
||||
})
|
||||
.alterTable('users', table => {
|
||||
table.string('dateFormat').notNullable().defaultTo('')
|
||||
table.string('appearance').notNullable().defaultTo('')
|
||||
})
|
||||
}
|
||||
|
||||
exports.down = knex => { }
|
15
server/db/migrations/2.4.13.js
Normal file
15
server/db/migrations/2.4.13.js
Normal file
@@ -0,0 +1,15 @@
|
||||
exports.up = knex => {
|
||||
return knex.schema
|
||||
.alterTable('pages', table => {
|
||||
table.json('extra').notNullable().defaultTo('{}')
|
||||
})
|
||||
.alterTable('pageHistory', table => {
|
||||
table.json('extra').notNullable().defaultTo('{}')
|
||||
})
|
||||
.alterTable('users', table => {
|
||||
table.string('dateFormat').notNullable().defaultTo('')
|
||||
table.string('appearance').notNullable().defaultTo('')
|
||||
})
|
||||
}
|
||||
|
||||
exports.down = knex => { }
|
@@ -147,12 +147,22 @@ module.exports = {
|
||||
throw new WIKI.Error.AuthAccountNotVerified()
|
||||
}
|
||||
|
||||
if (!['', 'DD/MM/YYYY', 'DD.MM.YYYY', 'MM/DD/YYYY', 'YYYY-MM-DD', 'YYYY/MM/DD'].includes(args.dateFormat)) {
|
||||
throw new WIKI.Error.InputInvalid()
|
||||
}
|
||||
|
||||
if (!['', 'light', 'dark'].includes(args.appearance)) {
|
||||
throw new WIKI.Error.InputInvalid()
|
||||
}
|
||||
|
||||
await WIKI.models.users.updateUser({
|
||||
id: usr.id,
|
||||
name: _.trim(args.name),
|
||||
jobTitle: _.trim(args.jobTitle),
|
||||
location: _.trim(args.location),
|
||||
timezone: args.timezone
|
||||
timezone: args.timezone,
|
||||
dateFormat: args.dateFormat,
|
||||
appearance: args.appearance
|
||||
})
|
||||
|
||||
const newToken = await WIKI.models.users.refreshToken(usr.id)
|
||||
|
@@ -57,6 +57,8 @@ type UserMutation {
|
||||
location: String
|
||||
jobTitle: String
|
||||
timezone: String
|
||||
dateFormat: String
|
||||
appearance: String
|
||||
): DefaultResponse @auth(requires: ["manage:users", "manage:system"])
|
||||
|
||||
delete(
|
||||
@@ -84,6 +86,8 @@ type UserMutation {
|
||||
location: String!
|
||||
jobTitle: String!
|
||||
timezone: String!
|
||||
dateFormat: String!
|
||||
appearance: String!
|
||||
): UserTokenResponse
|
||||
|
||||
changePassword(
|
||||
@@ -128,6 +132,8 @@ type User {
|
||||
location: String!
|
||||
jobTitle: String!
|
||||
timezone: String!
|
||||
dateFormat: String!
|
||||
appearance: String!
|
||||
createdAt: Date!
|
||||
updatedAt: Date!
|
||||
lastLoginAt: Date
|
||||
@@ -145,6 +151,8 @@ type UserProfile {
|
||||
location: String!
|
||||
jobTitle: String!
|
||||
timezone: String!
|
||||
dateFormat: String!
|
||||
appearance: String!
|
||||
createdAt: Date!
|
||||
updatedAt: Date!
|
||||
lastLoginAt: Date
|
||||
|
@@ -350,10 +350,12 @@ module.exports = class User extends Model {
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
name: user.name,
|
||||
pictureUrl: user.pictureUrl,
|
||||
timezone: user.timezone,
|
||||
localeCode: user.localeCode,
|
||||
defaultEditor: user.defaultEditor,
|
||||
av: user.pictureUrl,
|
||||
tz: user.timezone,
|
||||
lc: user.localeCode,
|
||||
df: user.dateFormat,
|
||||
ap: user.appearance,
|
||||
// defaultEditor: user.defaultEditor,
|
||||
permissions: user.getGlobalPermissions(),
|
||||
groups: user.getGroups()
|
||||
}, {
|
||||
@@ -548,7 +550,7 @@ module.exports = class User extends Model {
|
||||
*
|
||||
* @param {Object} param0 User ID and fields to update
|
||||
*/
|
||||
static async updateUser ({ id, email, name, newPassword, groups, location, jobTitle, timezone }) {
|
||||
static async updateUser ({ id, email, name, newPassword, groups, location, jobTitle, timezone, dateFormat, appearance }) {
|
||||
const usr = await WIKI.models.users.query().findById(id)
|
||||
if (usr) {
|
||||
let usrData = {}
|
||||
@@ -594,6 +596,12 @@ module.exports = class User extends Model {
|
||||
if (!_.isEmpty(timezone) && timezone !== usr.timezone) {
|
||||
usrData.timezone = timezone
|
||||
}
|
||||
if (!_.isNil(dateFormat) && dateFormat !== usr.dateFormat) {
|
||||
usrData.dateFormat = dateFormat
|
||||
}
|
||||
if (!_.isNil(appearance) && appearance !== usr.appearance) {
|
||||
usrData.appearance = appearance
|
||||
}
|
||||
await WIKI.models.users.query().patch(usrData).findById(id)
|
||||
} else {
|
||||
throw new WIKI.Error.UserNotFound()
|
||||
|
Reference in New Issue
Block a user