mirror of https://github.com/Requarks/wiki.git
Nicolas Giard
6 years ago
15 changed files with 549 additions and 68 deletions
Split View
Diff Options
-
158client/components/admin/admin-logging.vue
-
163client/components/admin/admin-search.vue
-
12client/graph/admin/logging/logging-mutation-save-loggers.gql
-
17client/graph/admin/logging/logging-query-loggers.gql
-
12client/graph/admin/search/search-mutation-save-engines.gql
-
16client/graph/admin/search/search-query-engines.gql
-
59server/graph/resolvers/logging.js
-
58server/graph/resolvers/search.js
-
7server/graph/schemas/common.graphql
-
54server/graph/schemas/logging.graphql
-
52server/graph/schemas/search.graphql
-
2server/modules/logging/eventlog/definition.yml
-
2server/modules/search/aws/definition.yml
-
2server/modules/search/db/definition.yml
-
3server/setup.js
@ -0,0 +1,12 @@ |
|||
mutation($loggers: [LoggerInput]) { |
|||
logging { |
|||
updateLoggers(loggers: $loggers) { |
|||
responseResult { |
|||
succeeded |
|||
errorCode |
|||
slug |
|||
message |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
query { |
|||
logging { |
|||
loggers(orderBy: "title ASC") { |
|||
isEnabled |
|||
key |
|||
title |
|||
description |
|||
logo |
|||
website |
|||
level |
|||
config { |
|||
key |
|||
value |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
mutation($searchEngines: [SearchEngineInput]) { |
|||
search { |
|||
updateSearchEngines(searchEngines: $searchEngines) { |
|||
responseResult { |
|||
succeeded |
|||
errorCode |
|||
slug |
|||
message |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
query { |
|||
search { |
|||
searchEngines(orderBy: "title ASC") { |
|||
isEnabled |
|||
key |
|||
title |
|||
description |
|||
logo |
|||
website |
|||
config { |
|||
key |
|||
value |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,59 @@ |
|||
const _ = require('lodash') |
|||
const graphHelper = require('../../helpers/graph') |
|||
|
|||
/* global WIKI */ |
|||
|
|||
module.exports = { |
|||
Query: { |
|||
async logging() { return {} } |
|||
}, |
|||
Mutation: { |
|||
async logging() { return {} } |
|||
}, |
|||
LoggingQuery: { |
|||
async loggers(obj, args, context, info) { |
|||
let loggers = await WIKI.models.loggers.getLoggers() |
|||
loggers = loggers.map(logger => { |
|||
const loggerInfo = _.find(WIKI.data.loggers, ['key', logger.key]) || {} |
|||
return { |
|||
...loggerInfo, |
|||
...logger, |
|||
config: _.sortBy(_.transform(logger.config, (res, value, key) => { |
|||
const configData = _.get(loggerInfo.props, key, {}) |
|||
res.push({ |
|||
key, |
|||
value: JSON.stringify({ |
|||
...configData, |
|||
value |
|||
}) |
|||
}) |
|||
}, []), 'key') |
|||
} |
|||
}) |
|||
if (args.filter) { loggers = graphHelper.filter(loggers, args.filter) } |
|||
if (args.orderBy) { loggers = graphHelper.orderBy(loggers, args.orderBy) } |
|||
return loggers |
|||
} |
|||
}, |
|||
LoggingMutation: { |
|||
async updateLoggers(obj, args, context) { |
|||
try { |
|||
for (let logger of args.loggers) { |
|||
await WIKI.models.loggers.query().patch({ |
|||
isEnabled: logger.isEnabled, |
|||
level: logger.level, |
|||
config: _.reduce(logger.config, (result, value, key) => { |
|||
_.set(result, `${value.key}`, value.value) |
|||
return result |
|||
}, {}) |
|||
}).where('key', logger.key) |
|||
} |
|||
return { |
|||
responseResult: graphHelper.generateSuccess('Loggers updated successfully') |
|||
} |
|||
} catch (err) { |
|||
return graphHelper.generateError(err) |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,58 @@ |
|||
const _ = require('lodash') |
|||
const graphHelper = require('../../helpers/graph') |
|||
|
|||
/* global WIKI */ |
|||
|
|||
module.exports = { |
|||
Query: { |
|||
async search() { return {} } |
|||
}, |
|||
Mutation: { |
|||
async search() { return {} } |
|||
}, |
|||
SearchQuery: { |
|||
async searchEngines(obj, args, context, info) { |
|||
let searchEngines = await WIKI.models.searchEngines.getSearchEngines() |
|||
searchEngines = searchEngines.map(searchEngine => { |
|||
const searchEngineInfo = _.find(WIKI.data.searchEngines, ['key', searchEngine.key]) || {} |
|||
return { |
|||
...searchEngineInfo, |
|||
...searchEngine, |
|||
config: _.sortBy(_.transform(searchEngine.config, (res, value, key) => { |
|||
const configData = _.get(searchEngineInfo.props, key, {}) |
|||
res.push({ |
|||
key, |
|||
value: JSON.stringify({ |
|||
...configData, |
|||
value |
|||
}) |
|||
}) |
|||
}, []), 'key') |
|||
} |
|||
}) |
|||
if (args.filter) { searchEngines = graphHelper.filter(searchEngines, args.filter) } |
|||
if (args.orderBy) { searchEngines = graphHelper.orderBy(searchEngines, args.orderBy) } |
|||
return searchEngines |
|||
} |
|||
}, |
|||
SearchMutation: { |
|||
async updateSearchEngines(obj, args, context) { |
|||
try { |
|||
for (let searchEngine of args.searchEngines) { |
|||
await WIKI.models.searchEngines.query().patch({ |
|||
isEnabled: searchEngine.isEnabled, |
|||
config: _.reduce(searchEngine.config, (result, value, key) => { |
|||
_.set(result, `${value.key}`, value.value) |
|||
return result |
|||
}, {}) |
|||
}).where('key', searchEngine.key) |
|||
} |
|||
return { |
|||
responseResult: graphHelper.generateSuccess('Search Engines updated successfully') |
|||
} |
|||
} catch (err) { |
|||
return graphHelper.generateError(err) |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,54 @@ |
|||
# =============================================== |
|||
# LOGGING |
|||
# =============================================== |
|||
|
|||
extend type Query { |
|||
logging: LoggingQuery |
|||
} |
|||
|
|||
extend type Mutation { |
|||
logging: LoggingMutation |
|||
} |
|||
|
|||
# ----------------------------------------------- |
|||
# QUERIES |
|||
# ----------------------------------------------- |
|||
|
|||
type LoggingQuery { |
|||
loggers( |
|||
filter: String |
|||
orderBy: String |
|||
): [Logger] |
|||
} |
|||
|
|||
# ----------------------------------------------- |
|||
# MUTATIONS |
|||
# ----------------------------------------------- |
|||
|
|||
type LoggingMutation { |
|||
updateLoggers( |
|||
loggers: [LoggerInput] |
|||
): DefaultResponse |
|||
} |
|||
|
|||
# ----------------------------------------------- |
|||
# TYPES |
|||
# ----------------------------------------------- |
|||
|
|||
type Logger { |
|||
isEnabled: Boolean! |
|||
key: String! |
|||
title: String! |
|||
description: String |
|||
logo: String |
|||
website: String |
|||
level: String |
|||
config: [KeyValuePair] |
|||
} |
|||
|
|||
input LoggerInput { |
|||
isEnabled: Boolean! |
|||
key: String! |
|||
level: String! |
|||
config: [KeyValuePairInput] |
|||
} |
@ -0,0 +1,52 @@ |
|||
# =============================================== |
|||
# SEARCH |
|||
# =============================================== |
|||
|
|||
extend type Query { |
|||
search: SearchQuery |
|||
} |
|||
|
|||
extend type Mutation { |
|||
search: SearchMutation |
|||
} |
|||
|
|||
# ----------------------------------------------- |
|||
# QUERIES |
|||
# ----------------------------------------------- |
|||
|
|||
type SearchQuery { |
|||
searchEngines( |
|||
filter: String |
|||
orderBy: String |
|||
): [SearchEngine] |
|||
} |
|||
|
|||
# ----------------------------------------------- |
|||
# MUTATIONS |
|||
# ----------------------------------------------- |
|||
|
|||
type SearchMutation { |
|||
updateSearchEngines( |
|||
searchEngines: [SearchEngineInput] |
|||
): DefaultResponse |
|||
} |
|||
|
|||
# ----------------------------------------------- |
|||
# TYPES |
|||
# ----------------------------------------------- |
|||
|
|||
type SearchEngine { |
|||
isEnabled: Boolean! |
|||
key: String! |
|||
title: String! |
|||
description: String |
|||
logo: String |
|||
website: String |
|||
config: [KeyValuePair] |
|||
} |
|||
|
|||
input SearchEngineInput { |
|||
isEnabled: Boolean! |
|||
key: String! |
|||
config: [KeyValuePairInput] |
|||
} |
Write
Preview
Loading…
Cancel
Save