mirror of https://github.com/Requarks/wiki.git
19 changed files with 313 additions and 69 deletions
Split View
Diff Options
-
1BACKERS.md
-
2client/client-app.js
-
92client/components/admin/admin-storage.vue
-
15client/components/admin/admin-system.vue
-
114client/components/common/duration-picker.vue
-
2client/graph/admin/storage/storage-mutation-save-targets.gql
-
10client/graph/admin/storage/storage-query-status.gql
-
3client/graph/admin/storage/storage-query-targets.gql
-
2client/themes/default/components/page.vue
-
3server/app/data.yml
-
14server/core/scheduler.js
-
15server/db/migrations/2.0.0-beta.38.js
-
5server/graph/directives/rate-limit.js
-
7server/graph/index.js
-
22server/graph/resolvers/storage.js
-
15server/graph/schemas/storage.graphql
-
6server/helpers/config.js
-
28server/jobs/sync-storage.js
-
26server/models/storage.js
@ -0,0 +1,114 @@ |
|||
<template lang='pug'> |
|||
v-toolbar(flat, :color='$vuetify.dark ? "grey darken-4-l3" : "grey lighten-3"') |
|||
.body-2.mr-3 Every |
|||
v-text-field( |
|||
solo |
|||
hide-details |
|||
flat |
|||
reverse |
|||
v-model='minutes' |
|||
) |
|||
.body-2.mx-3 Minute(s) |
|||
v-divider.mr-3() |
|||
v-text-field( |
|||
solo |
|||
hide-details |
|||
flat |
|||
reverse |
|||
v-model='hours' |
|||
) |
|||
.body-2.mx-3 Hour(s) |
|||
v-divider.mr-3() |
|||
v-text-field( |
|||
solo |
|||
hide-details |
|||
flat |
|||
reverse |
|||
v-model='days' |
|||
) |
|||
.body-2.mx-3 Day(s) |
|||
v-divider.mr-3() |
|||
v-text-field( |
|||
solo |
|||
hide-details |
|||
flat |
|||
reverse |
|||
v-model='months' |
|||
) |
|||
.body-2.mx-3 Month(s) |
|||
v-divider.mr-3() |
|||
v-text-field( |
|||
solo |
|||
hide-details |
|||
flat |
|||
reverse |
|||
v-model='years' |
|||
) |
|||
.body-2.mx-3 Year(s) |
|||
</template> |
|||
|
|||
<script> |
|||
import _ from 'lodash' |
|||
import moment from 'moment' |
|||
|
|||
export default { |
|||
props: { |
|||
value: { |
|||
type: String, |
|||
default: 'PT5M' |
|||
} |
|||
}, |
|||
data() { |
|||
return { |
|||
duration: moment.duration(0) |
|||
} |
|||
}, |
|||
computed: { |
|||
years: { |
|||
get() { return this.duration.years() || 0 }, |
|||
set(val) { this.rebuild(_.toNumber(val), 'years') } |
|||
}, |
|||
months: { |
|||
get() { return this.duration.months() || 0 }, |
|||
set(val) { this.rebuild(_.toNumber(val), 'months') } |
|||
}, |
|||
days: { |
|||
get() { return this.duration.days() || 0 }, |
|||
set(val) { this.rebuild(_.toNumber(val), 'days') } |
|||
}, |
|||
hours: { |
|||
get() { return this.duration.hours() || 0 }, |
|||
set(val) { this.rebuild(_.toNumber(val), 'hours') } |
|||
}, |
|||
minutes: { |
|||
get() { return this.duration.minutes() || 0 }, |
|||
set(val) { this.rebuild(_.toNumber(val), 'minutes') } |
|||
} |
|||
}, |
|||
watch: { |
|||
value(newValue, oldValue) { |
|||
this.duration = moment.duration(newValue) |
|||
} |
|||
}, |
|||
methods: { |
|||
rebuild(val, unit) { |
|||
if (!_.isFinite(val) || val < 0) { |
|||
val = 0 |
|||
} |
|||
const newDuration = { |
|||
minutes: this.duration.minutes(), |
|||
hours: this.duration.hours(), |
|||
days: this.duration.days(), |
|||
months: this.duration.months(), |
|||
years: this.duration.years() |
|||
} |
|||
_.set(newDuration, unit, val) |
|||
this.duration = moment.duration(newDuration) |
|||
this.$emit('input', this.duration.toISOString()) |
|||
} |
|||
}, |
|||
mounted() { |
|||
this.duration = moment.duration(this.value) |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,10 @@ |
|||
query { |
|||
storage { |
|||
status { |
|||
key |
|||
title |
|||
status |
|||
message |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
exports.up = knex => { |
|||
return knex.schema |
|||
.table('storage', table => { |
|||
table.string('syncInterval') |
|||
table.json('state') |
|||
}) |
|||
} |
|||
|
|||
exports.down = knex => { |
|||
return knex.schema |
|||
.table('storage', table => { |
|||
table.dropColumn('syncInterval') |
|||
table.dropColumn('state') |
|||
}) |
|||
} |
@ -0,0 +1,5 @@ |
|||
const { createRateLimitDirective } = require('graphql-rate-limit-directive') |
|||
|
|||
module.exports = createRateLimitDirective({ |
|||
keyGenerator: (directiveArgs, source, args, context, info) => `${context.req.ip}:${info.parentType}.${info.fieldName}` |
|||
}) |
@ -1,20 +1,18 @@ |
|||
require('../core/worker') |
|||
|
|||
/* global WIKI */ |
|||
|
|||
module.exports = async (job) => { |
|||
module.exports = async ({ target }) => { |
|||
WIKI.logger.info(`Syncing with storage provider ${job.data.target.title}...`) |
|||
|
|||
try { |
|||
const target = require(`../modules/storage/${job.data.target.key}/storage.js`) |
|||
target[job.data.event].call({ |
|||
config: job.data.target.config, |
|||
mode: job.data.target.mode, |
|||
page: job.data.page |
|||
}) |
|||
WIKI.logger.info(`Syncing with storage provider ${job.data.target.title}: [ COMPLETED ]`) |
|||
} catch (err) { |
|||
WIKI.logger.error(`Syncing with storage provider ${job.data.target.title}: [ FAILED ]`) |
|||
WIKI.logger.error(err.message) |
|||
} |
|||
// try {
|
|||
// const target = require(`../modules/storage/${job.data.target.key}/storage.js`)
|
|||
// target[job.data.event].call({
|
|||
// config: job.data.target.config,
|
|||
// mode: job.data.target.mode,
|
|||
// page: job.data.page
|
|||
// })
|
|||
// WIKI.logger.info(`Syncing with storage provider ${job.data.target.title}: [ COMPLETED ]`)
|
|||
// } catch (err) {
|
|||
// WIKI.logger.error(`Syncing with storage provider ${job.data.target.title}: [ FAILED ]`)
|
|||
// WIKI.logger.error(err.message)
|
|||
// }
|
|||
} |
Write
Preview
Loading…
Cancel
Save