feat: core improvements + local fs provider + UI fixes

This commit is contained in:
NGPixel
2018-07-29 22:23:33 -04:00
parent 803d86ff63
commit 2817c72ec3
65 changed files with 482 additions and 264 deletions

View File

@@ -12,13 +12,24 @@ module.exports = {
},
StorageQuery: {
async targets(obj, args, context, info) {
let targets = await WIKI.db.storage.getTargets()
targets = targets.map(tgt => ({
...tgt,
config: _.sortBy(_.transform(tgt.config, (res, value, key) => {
res.push({ key, value: JSON.stringify(value) })
}, []), 'key')
}))
let targets = await WIKI.models.storage.getTargets()
targets = targets.map(tgt => {
const targetInfo = _.find(WIKI.data.storage, ['key', tgt.key]) || {}
console.info(targetInfo)
return {
...tgt,
config: _.sortBy(_.transform(tgt.config, (res, value, key) => {
const configData = _.get(targetInfo.props, key, {})
res.push({
key,
value: JSON.stringify({
...configData,
value
})
})
}, []), 'key')
}
})
if (args.filter) { targets = graphHelper.filter(targets, args.filter) }
if (args.orderBy) { targets = graphHelper.orderBy(targets, args.orderBy) }
return targets
@@ -28,11 +39,11 @@ module.exports = {
async updateTargets(obj, args, context) {
try {
for (let tgt of args.targets) {
await WIKI.db.storage.query().patch({
await WIKI.models.storage.query().patch({
isEnabled: tgt.isEnabled,
mode: tgt.mode,
config: _.reduce(tgt.config, (result, value, key) => {
_.set(result, `${value.key}.value`, value.value)
_.set(result, `${value.key}`, value.value)
return result
}, {})
}).where('key', tgt.key)