fix(admin): sites save / activate / delete mutations

parent 4bfd9f52
......@@ -8,7 +8,7 @@ const path = require('path')
module.exports = {
Query: {
async sites () {
const sites = await WIKI.models.sites.query()
const sites = await WIKI.models.sites.query().orderBy('hostname')
return sites.map(s => ({
...s.config,
id: s.id,
......@@ -69,10 +69,11 @@ module.exports = {
title: args.title
})
return {
status: graphHelper.generateSuccess('Site created successfully'),
operation: graphHelper.generateSuccess('Site created successfully'),
site: newSite
}
} catch (err) {
WIKI.logger.warn(err)
return graphHelper.generateError(err)
}
},
......@@ -109,7 +110,7 @@ module.exports = {
})
return {
status: graphHelper.generateSuccess('Site updated successfully')
operation: graphHelper.generateSuccess('Site updated successfully')
}
} catch (err) {
WIKI.logger.warn(err)
......@@ -129,7 +130,7 @@ module.exports = {
// -> Delete site
await WIKI.models.sites.deleteSite(args.id)
return {
status: graphHelper.generateSuccess('Site deleted successfully')
operation: graphHelper.generateSuccess('Site deleted successfully')
}
} catch (err) {
WIKI.logger.warn(err)
......@@ -161,7 +162,7 @@ module.exports = {
})
WIKI.logger.info('New site logo processed successfully.')
return {
status: graphHelper.generateSuccess('Site logo uploaded successfully')
operation: graphHelper.generateSuccess('Site logo uploaded successfully')
}
} catch (err) {
return graphHelper.generateError(err)
......@@ -174,7 +175,7 @@ module.exports = {
const { filename, mimetype, createReadStream } = await args.image
console.info(filename, mimetype)
return {
status: graphHelper.generateSuccess('Site favicon uploaded successfully')
operation: graphHelper.generateSuccess('Site favicon uploaded successfully')
}
}
}
......
......@@ -78,6 +78,8 @@ module.exports = class Site extends Model {
})
})
WIKI.logger.debug(`Creating new DB storage for site ${newSite.id}`)
await WIKI.models.storage.query().insert({
module: 'db',
siteId: newSite.id,
......
......@@ -12,7 +12,7 @@ const commonHelper = require('../helpers/common')
*/
module.exports = class Storage extends Model {
static get tableName() { return 'storage' }
static get idColumn() { return 'key' }
static get idColumn() { return 'id' }
static get jsonSchema () {
return {
......@@ -21,8 +21,7 @@ module.exports = class Storage extends Model {
properties: {
module: {type: 'string'},
isEnabled: {type: 'boolean'},
SVGAnimatedInteger: {type: 'string'}
isEnabled: {type: 'boolean'}
}
}
}
......
......@@ -11,8 +11,8 @@
"lint": "eslint --ext .js,.vue ./"
},
"dependencies": {
"@apollo/client": "3.6.5",
"@codemirror/autocomplete": "0.20.2",
"@apollo/client": "3.6.8",
"@codemirror/autocomplete": "0.20.3",
"@codemirror/basic-setup": "0.20.0",
"@codemirror/closebrackets": "0.19.2",
"@codemirror/commands": "0.20.0",
......@@ -23,15 +23,15 @@
"@codemirror/history": "0.19.2",
"@codemirror/lang-css": "0.20.0",
"@codemirror/lang-html": "0.20.0",
"@codemirror/lang-javascript": "0.20.0",
"@codemirror/lang-javascript": "0.20.1",
"@codemirror/lang-json": "0.20.0",
"@codemirror/lang-markdown": "0.20.1",
"@codemirror/matchbrackets": "0.19.4",
"@codemirror/search": "0.20.1",
"@codemirror/state": "0.20.0",
"@codemirror/state": "0.20.1",
"@codemirror/tooltip": "0.19.16",
"@codemirror/view": "0.20.6",
"@lezer/common": "0.16.0",
"@codemirror/view": "0.20.7",
"@lezer/common": "0.16.1",
"@quasar/extras": "1.14.0",
"@tiptap/core": "2.0.0-beta.176",
"@tiptap/extension-code-block": "2.0.0-beta.37",
......@@ -59,9 +59,9 @@
"@tiptap/vue-3": "2.0.0-beta.91",
"@vue/apollo-option": "4.0.0-alpha.17",
"apollo-upload-client": "17.0.0",
"browser-fs-access": "0.29.5",
"browser-fs-access": "0.29.6",
"clipboard": "2.0.11",
"filesize": "9.0.0",
"filesize": "9.0.9",
"filesize-parser": "1.5.0",
"graphql": "16.5.0",
"graphql-tag": "2.12.6",
......@@ -74,11 +74,11 @@
"quasar": "2.7.1",
"tippy.js": "6.3.7",
"uuid": "8.3.2",
"v-network-graph": "0.5.17",
"v-network-graph": "0.5.19",
"vue": "3.2.31",
"vue-codemirror": "5.0.1",
"vue-codemirror": "5.1.0",
"vue-i18n": "9.1.10",
"vue-router": "4.0.15",
"vue-router": "4.0.16",
"vuedraggable": "4.1.0",
"zxcvbn": "4.4.2"
},
......@@ -87,12 +87,12 @@
"@quasar/app-vite": "1.0.1",
"@types/lodash": "4.14.182",
"autoprefixer": "10.4.7",
"eslint": "8.16.0",
"eslint": "8.17.0",
"eslint-config-standard": "17.0.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-n": "15.2.0",
"eslint-plugin-n": "15.2.3",
"eslint-plugin-promise": "6.0.0",
"eslint-plugin-vue": "9.0.1"
"eslint-plugin-vue": "9.1.1"
},
"engines": {
"node": "^18 || ^16",
......
......@@ -3,10 +3,10 @@ q-dialog(ref='dialogRef', @hide='onDialogHide')
q-card(style='min-width: 350px; max-width: 450px;')
q-card-section.card-header
q-icon(name='img:/_assets/icons/fluent-shutdown.svg', left, size='sm')
span {{modelValue ? t(`admin.sites.activate`) : t(`admin.sites.deactivate`)}}
span {{props.targetState ? t(`admin.sites.activate`) : t(`admin.sites.deactivate`)}}
q-card-section
.text-body2
i18n-t(:keypath='modelValue ? `admin.sites.activateConfirm` : `admin.sites.deactivateConfirm`')
i18n-t(:keypath='props.targetState ? `admin.sites.activateConfirm` : `admin.sites.deactivateConfirm`')
template(v-slot:siteTitle)
strong {{props.site.title}}
q-card-actions.card-actions
......@@ -20,8 +20,8 @@ q-dialog(ref='dialogRef', @hide='onDialogHide')
)
q-btn(
unelevated
:label='modelValue ? t(`common.actions.activate`) : t(`common.actions.deactivate`)'
:color='modelValue ? `positive` : `negative`'
:label='props.targetState ? t(`common.actions.activate`) : t(`common.actions.deactivate`)'
:color='props.targetState ? `positive` : `negative`'
padding='xs md'
@click='confirm'
:loading='state.isLoading'
......@@ -44,7 +44,7 @@ const props = defineProps({
type: Object,
required: true
},
modelValue: {
targetState: {
type: Boolean,
default: false
}
......@@ -101,19 +101,19 @@ async function confirm () {
`,
variables: {
id: props.site.id,
newState: props.modelValue
newState: props.targetState
}
})
if (resp?.data?.updateSite?.operation?.succeeded) {
$q.notify({
type: 'positive',
message: this.$t('admin.sites.updateSuccess')
message: t('admin.sites.updateSuccess')
})
adminStore.$patch({
sites: adminStore.sites.map(s => {
if (s.id === props.site.id) {
const ns = cloneDeep(s)
ns.isEnabled = props.modelValue
ns.isEnabled = props.targetState
return ns
} else {
return s
......
......@@ -156,11 +156,12 @@ function editSite (st) {
})
}
function toggleSiteState (st, newState) {
console.info(newState)
$q.dialog({
component: SiteActivateDialog,
componentProps: {
site: st,
value: newState
targetState: newState
}
})
}
......
This diff was suppressed by a .gitattributes entry.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment