diff --git a/client/app.js b/client/app.js index 1f5914e2..9091a7ee 100644 --- a/client/app.js +++ b/client/app.js @@ -1,7 +1,5 @@ 'use strict' -import CONSTANTS from './constants' - import Vue from 'vue' import VueRouter from 'vue-router' import VueClipboards from 'vue-clipboards' @@ -35,7 +33,6 @@ import helpers from './helpers' window.WIKI = null window.boot = boot -window.CONSTANTS = CONSTANTS window.Hammer = Hammer // ==================================== @@ -78,7 +75,6 @@ Vue.component('admin', () => import(/* webpackChunkName: "admin" */ './component Vue.component('editor', () => import(/* webpackChunkName: "editor" */ './components/editor.vue')) Vue.component('login', () => import(/* webpackMode: "eager" */ './components/login.vue')) Vue.component('nav-header', () => import(/* webpackMode: "eager" */ './components/nav-header.vue')) -Vue.component('navigator', () => import(/* webpackMode: "eager" */ './components/navigator.vue')) Vue.component('setup', () => import(/* webpackChunkName: "setup" */ './components/setup.vue')) let bootstrap = () => { diff --git a/client/components/admin-auth.vue b/client/components/admin-auth.vue index cd1a2ef2..2e02e106 100644 --- a/client/components/admin-auth.vue +++ b/client/components/admin-auth.vue @@ -66,8 +66,7 @@ diff --git a/client/constants/graphql.js b/client/constants/graphql.js deleted file mode 100644 index 94cb8b0b..00000000 --- a/client/constants/graphql.js +++ /dev/null @@ -1,103 +0,0 @@ -import gql from 'graphql-tag' - -export default { - AUTHENTICATION: { - QUERY_PROVIDERS: gql` - query { - authentication { - providers { - isEnabled - key - props - title - useForm - config { - key - value - } - } - } - } - `, - QUERY_LOGIN_PROVIDERS: gql` - query { - authentication { - providers( - filter: "isEnabled eq true", - orderBy: "title ASC" - ) { - key - title - useForm - icon - } - } - } - `, - MUTATION_LOGIN: gql` - mutation($username: String!, $password: String!, $provider: String!) { - authentication { - login(username: $username, password: $password, provider: $provider) { - operation { - succeeded - code - slug - message - } - tfaRequired - tfaLoginToken - } - } - } - `, - MUTATION_LOGINTFA: gql` - mutation($loginToken: String!, $securityCode: String!) { - authentication { - loginTFA(loginToken: $loginToken, securityCode: $securityCode) { - operation { - succeeded - code - slug - message - } - } - } - } - ` - }, - SYSTEM: { - QUERY_INFO: gql` - query { - system { - info { - currentVersion - latestVersion - latestVersionReleaseDate - operatingSystem - hostname - cpuCores - ramTotal - workingDirectory - nodeVersion - redisVersion - redisUsedRAM - redisTotalRAM - redisHost - postgreVersion - postgreHost - } - } - } - ` - }, - TRANSLATIONS: { - QUERY_NAMESPACE: gql` - query($locale: String!, $namespace: String!) { - translations(locale:$locale, namespace:$namespace) { - key - value - } - } - ` - } -} diff --git a/client/constants/index.js b/client/constants/index.js deleted file mode 100644 index 267f49dd..00000000 --- a/client/constants/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import GRAPH from './graphql' - -export default { - GRAPH -} diff --git a/client/modules/localization.js b/client/modules/localization.js index 26e36c9c..47f32519 100644 --- a/client/modules/localization.js +++ b/client/modules/localization.js @@ -2,9 +2,10 @@ import i18next from 'i18next' import i18nextXHR from 'i18next-xhr-backend' import i18nextCache from 'i18next-localstorage-cache' import VueI18Next from '@panter/vue-i18next' -import loSet from 'lodash/set' +import _ from 'lodash' +import gql from 'graphql-tag' -/* global siteConfig, graphQL, CONSTANTS */ +/* global siteConfig, graphQL */ module.exports = { VueI18Next, @@ -19,7 +20,14 @@ module.exports = { ajax: (url, opts, cb, data) => { let langParams = url.split('/') graphQL.query({ - query: CONSTANTS.GRAPH.TRANSLATIONS.QUERY_NAMESPACE, + query: gql` + query($locale: String!, $namespace: String!) { + translations(locale:$locale, namespace:$namespace) { + key + value + } + } + `, variables: { locale: langParams[0], namespace: langParams[1] @@ -28,7 +36,7 @@ module.exports = { let ns = {} if (resp.data.translations.length > 0) { resp.data.translations.forEach(entry => { - loSet(ns, entry.key, entry.value) + _.set(ns, entry.key, entry.value) }) } return cb(ns, {status: '200'}) diff --git a/client/scss/pages/_welcome.scss b/client/scss/pages/_welcome.scss index e8c72cf2..fe72345b 100644 --- a/client/scss/pages/_welcome.scss +++ b/client/scss/pages/_welcome.scss @@ -44,6 +44,7 @@ } } h1 { + font-size: 1.5rem; margin-bottom: 1rem; z-index: 2; } diff --git a/server/graph/resolvers/folder.js b/server/graph/resolvers/folder.js index f1e341dd..5a28f603 100644 --- a/server/graph/resolvers/folder.js +++ b/server/graph/resolvers/folder.js @@ -11,7 +11,7 @@ module.exports = { createFolder(obj, args) { return WIKI.db.Folder.create(args) }, - deleteGroup(obj, args) { + deleteFolder(obj, args) { return WIKI.db.Folder.destroy({ where: { id: args.id diff --git a/server/graph/resolvers/group.js b/server/graph/resolvers/group.js index ee4852de..f27d1b96 100644 --- a/server/graph/resolvers/group.js +++ b/server/graph/resolvers/group.js @@ -5,12 +5,18 @@ const gql = require('graphql') module.exports = { Query: { - groups(obj, args, context, info) { + async groups() { return {} } + }, + Mutation: { + async groups() { return {} } + }, + GroupQuery: { + list(obj, args, context, info) { return WIKI.db.Group.findAll({ where: args }) } }, - Mutation: { - assignUserToGroup(obj, args) { + GroupMutation: { + assignUser(obj, args) { return WIKI.db.Group.findById(args.groupId).then(grp => { if (!grp) { throw new gql.GraphQLError('Invalid Group ID') @@ -23,10 +29,10 @@ module.exports = { }) }) }, - createGroup(obj, args) { + create(obj, args) { return WIKI.db.Group.create(args) }, - deleteGroup(obj, args) { + delete(obj, args) { return WIKI.db.Group.destroy({ where: { id: args.id @@ -34,7 +40,7 @@ module.exports = { limit: 1 }) }, - removeUserFromGroup(obj, args) { + unassignUser(obj, args) { return WIKI.db.Group.findById(args.groupId).then(grp => { if (!grp) { throw new gql.GraphQLError('Invalid Group ID') @@ -47,7 +53,7 @@ module.exports = { }) }) }, - renameGroup(obj, args) { + update(obj, args) { return WIKI.db.Group.update({ name: args.name }, { diff --git a/server/graph/schemas/common.graphql b/server/graph/schemas/common.graphql index ce687589..bd79e557 100644 --- a/server/graph/schemas/common.graphql +++ b/server/graph/schemas/common.graphql @@ -95,15 +95,6 @@ type Folder implements Base { files: [File] } -type Group implements Base { - id: Int! - createdAt: Date - updatedAt: Date - name: String! - users: [User] - rights: [Right] -} - type Right implements Base { id: Int! createdAt: Date @@ -168,7 +159,6 @@ type Query { documents(id: Int, path: String): [Document] files(id: Int): [File] folders(id: Int, name: String): [Folder] - groups(id: Int, name: String): [Group] rights(id: Int): [Right] search(q: String, tags: [String]): [SearchResult] settings(key: String): [Setting] @@ -192,11 +182,6 @@ type Mutation { documentId: Int! ): OperationResult - assignUserToGroup( - userId: Int! - groupId: Int! - ): OperationResult - createComment( userId: Int! documentId: Int! @@ -213,10 +198,6 @@ type Mutation { name: String! ): Folder - createGroup( - name: String! - ): Group - createTag( name: String! ): Tag @@ -246,10 +227,6 @@ type Mutation { id: Int! ): OperationResult - deleteGroup( - id: Int! - ): OperationResult - deleteTag( id: Int! ): OperationResult @@ -306,11 +283,6 @@ type Mutation { name: String! ): OperationResult - renameGroup( - id: Int! - name: String! - ): OperationResult - renameTag( id: Int! key: String! @@ -325,11 +297,6 @@ type Mutation { rightId: Int! ): OperationResult - removeUserFromGroup( - userId: Int! - groupId: Int! - ): OperationResult - resetUserPassword( id: Int! ): OperationResult diff --git a/server/graph/schemas/group.graphql b/server/graph/schemas/group.graphql new file mode 100644 index 00000000..082f0bd5 --- /dev/null +++ b/server/graph/schemas/group.graphql @@ -0,0 +1,69 @@ +# =============================================== +# GROUPS +# =============================================== + +extend type Query { + groups: GroupQuery +} + +extend type Mutation { + groups: GroupMutation +} + +# ----------------------------------------------- +# QUERIES +# ----------------------------------------------- + +type GroupQuery { + list( + filter: String + orderBy: String + ): [Group] +} + +# ----------------------------------------------- +# MUTATIONS +# ----------------------------------------------- + +type GroupMutation { + create( + name: String! + ): GroupResponse + + update( + id: Int! + name: String! + ): GroupResponse + + delete( + id: Int! + ): DefaultResponse + + assignUser( + groupId: Int! + userId: Int! + ): DefaultResponse + + unassignUser( + groupId: Int! + userId: Int! + ): DefaultResponse +} + +# ----------------------------------------------- +# TYPES +# ----------------------------------------------- + +type GroupResponse { + operation: ResponseStatus! + group: Group +} + +type Group { + id: Int! + name: String! + rights: [String] + users: [User] + createdAt: Date! + updatedAt: Date! +}