feat: admin - save locale settings + system info linux os
This commit is contained in:
@@ -39,9 +39,13 @@ module.exports = {
|
||||
LocalizationMutation: {
|
||||
async updateLocale(obj, args, context) {
|
||||
try {
|
||||
let authResult = await WIKI.db.User.login(args, context)
|
||||
WIKI.config.site.lang = args.locale
|
||||
WIKI.config.site.langAutoUpdate = args.autoUpdate
|
||||
await WIKI.configSvc.saveToDb(['site'])
|
||||
|
||||
await WIKI.lang.setCurrentLocale(args.locale)
|
||||
|
||||
return {
|
||||
...authResult,
|
||||
responseResult: graphHelper.generateSuccess('Login success')
|
||||
}
|
||||
} catch (err) {
|
||||
|
@@ -1,9 +1,18 @@
|
||||
const _ = require('lodash')
|
||||
const Promise = require('bluebird')
|
||||
const getos = Promise.promisify(require('getos'))
|
||||
const os = require('os')
|
||||
const filesize = require('filesize')
|
||||
const path = require('path')
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
const dbTypes = {
|
||||
mysql: 'MySQL / MariaDB',
|
||||
postgres: 'PostgreSQL',
|
||||
sqlite: 'SQLite'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Query: {
|
||||
async system() { return {} }
|
||||
@@ -13,11 +22,21 @@ module.exports = {
|
||||
},
|
||||
SystemQuery: {
|
||||
async info(obj, args, context, info) {
|
||||
let osLabel = `${os.type()} (${os.platform()}) ${os.release()} ${os.arch()}`
|
||||
if (os.platform() === 'linux') {
|
||||
const osInfo = await getos()
|
||||
osLabel = `${os.type()} - ${osInfo.dist} (${osInfo.codename || os.platform()}) ${osInfo.release || os.release()} ${os.arch()}`
|
||||
}
|
||||
|
||||
return {
|
||||
configFile: path.join(process.cwd(), 'config.yml'),
|
||||
currentVersion: WIKI.version,
|
||||
dbType: _.get(dbTypes, WIKI.config.db.type, 'Unknown DB'),
|
||||
dbVersion: WIKI.db.inst.options.databaseVersion,
|
||||
dbHost: WIKI.db.inst.options.host,
|
||||
latestVersion: WIKI.version, // TODO
|
||||
latestVersionReleaseDate: new Date(), // TODO
|
||||
operatingSystem: `${os.type()} (${os.platform()}) ${os.release()} ${os.arch()}`,
|
||||
operatingSystem: osLabel,
|
||||
hostname: os.hostname(),
|
||||
cpuCores: os.cpus().length,
|
||||
ramTotal: filesize(os.totalmem()),
|
||||
@@ -26,9 +45,7 @@ module.exports = {
|
||||
redisVersion: WIKI.redis.serverInfo.redis_version,
|
||||
redisUsedRAM: WIKI.redis.serverInfo.used_memory_human,
|
||||
redisTotalRAM: _.get(WIKI.redis.serverInfo, 'total_system_memory_human', 'N/A'),
|
||||
redisHost: WIKI.redis.options.host,
|
||||
postgreVersion: WIKI.db.inst.options.databaseVersion,
|
||||
postgreHost: WIKI.db.inst.options.host
|
||||
redisHost: WIKI.redis.options.host
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user