2018-03-05 20:49:36 +00:00
|
|
|
<template lang='pug'>
|
2018-09-30 03:30:20 +00:00
|
|
|
v-container(fluid, grid-list-lg)
|
|
|
|
v-layout(row, wrap)
|
|
|
|
v-flex(xs12)
|
|
|
|
.admin-header
|
2019-04-07 16:37:33 +00:00
|
|
|
img.animated.fadeInUp(src='/svg/icon-cloud-storage.svg', alt='Storage', style='width: 80px;')
|
2018-09-30 03:30:20 +00:00
|
|
|
.admin-header-title
|
2019-06-10 03:39:37 +00:00
|
|
|
.headline.primary--text.animated.fadeInLeft {{$t('admin:storage.title')}}
|
|
|
|
.subheading.grey--text.animated.fadeInLeft.wait-p4s {{$t('admin:storage.subtitle')}}
|
2018-09-30 03:30:20 +00:00
|
|
|
v-spacer
|
2019-04-07 16:37:33 +00:00
|
|
|
v-btn.animated.fadeInDown.wait-p2s(outline, color='grey', @click='refresh', large)
|
2018-09-30 03:30:20 +00:00
|
|
|
v-icon refresh
|
2019-04-07 16:37:33 +00:00
|
|
|
v-btn.animated.fadeInDown(color='success', @click='save', depressed, large)
|
2019-01-01 06:40:31 +00:00
|
|
|
v-icon(left) check
|
|
|
|
span {{$t('common:actions.apply')}}
|
2018-06-26 02:04:47 +00:00
|
|
|
|
2019-04-21 00:49:05 +00:00
|
|
|
v-flex(lg3, xs12)
|
|
|
|
v-card.animated.fadeInUp
|
|
|
|
v-toolbar(flat, color='primary', dark, dense)
|
2019-06-10 03:39:37 +00:00
|
|
|
.subheading {{$t('admin:storage.targets')}}
|
2019-04-21 00:49:05 +00:00
|
|
|
v-list(two-line, dense).py-0
|
|
|
|
template(v-for='(tgt, idx) in targets')
|
|
|
|
v-list-tile(:key='tgt.key', @click='selectedTarget = tgt.key', :disabled='!tgt.isAvailable')
|
|
|
|
v-list-tile-avatar
|
|
|
|
v-icon(color='grey', v-if='!tgt.isAvailable') indeterminate_check_box
|
|
|
|
v-icon(color='primary', v-else-if='tgt.isEnabled', v-ripple, @click='tgt.key !== `local` && (tgt.isEnabled = false)') check_box
|
|
|
|
v-icon(color='grey', v-else, v-ripple, @click='tgt.isEnabled = true') check_box_outline_blank
|
|
|
|
v-list-tile-content
|
|
|
|
v-list-tile-title.body-2(:class='!tgt.isAvailable ? `grey--text` : (selectedTarget === tgt.key ? `primary--text` : ``)') {{ tgt.title }}
|
|
|
|
v-list-tile-sub-title.caption(:class='!tgt.isAvailable ? `grey--text text--lighten-1` : (selectedTarget === tgt.key ? `blue--text ` : ``)') {{ tgt.description }}
|
|
|
|
v-list-tile-avatar(v-if='selectedTarget === tgt.key')
|
|
|
|
v-icon.animated.fadeInLeft(color='primary') arrow_forward_ios
|
|
|
|
v-divider(v-if='idx < targets.length - 1')
|
2018-06-26 02:04:47 +00:00
|
|
|
|
2019-04-21 00:49:05 +00:00
|
|
|
v-card.mt-3.animated.fadeInUp.wait-p2s
|
|
|
|
v-toolbar(flat, :color='$vuetify.dark ? `grey darken-3-l5` : `grey darken-3`', dark, dense)
|
2019-06-10 03:39:37 +00:00
|
|
|
.subheading {{$t('admin:storage.status')}}
|
2019-04-21 00:49:05 +00:00
|
|
|
v-spacer
|
|
|
|
looping-rhombuses-spinner(
|
|
|
|
:animation-duration='5000'
|
|
|
|
:rhombus-size='10'
|
|
|
|
color='#FFF'
|
|
|
|
)
|
|
|
|
v-list.py-0(two-line, dense)
|
|
|
|
template(v-for='(tgt, n) in status')
|
|
|
|
v-list-tile(:key='tgt.key')
|
|
|
|
template(v-if='tgt.status === `pending`')
|
|
|
|
v-list-tile-avatar(color='purple')
|
|
|
|
v-icon(color='white') schedule
|
|
|
|
v-list-tile-content
|
|
|
|
v-list-tile-title.body-2 {{tgt.title}}
|
|
|
|
v-list-tile-sub-title.purple--text.caption {{tgt.status}}
|
|
|
|
v-list-tile-action
|
|
|
|
v-progress-circular(indeterminate, :size='20', :width='2', color='purple')
|
|
|
|
template(v-else-if='tgt.status === `operational`')
|
|
|
|
v-list-tile-avatar(color='green')
|
|
|
|
v-icon(color='white') check_circle
|
|
|
|
v-list-tile-content
|
|
|
|
v-list-tile-title.body-2 {{tgt.title}}
|
2019-06-10 03:39:37 +00:00
|
|
|
v-list-tile-sub-title.green--text.caption {{$t('admin:storage.lastSync', { time: $options.filters.moment(tgt.lastAttempt, 'from') })}}
|
2019-04-21 00:49:05 +00:00
|
|
|
template(v-else)
|
|
|
|
v-list-tile-avatar(color='red')
|
|
|
|
v-icon(color='white') highlight_off
|
|
|
|
v-list-tile-content
|
|
|
|
v-list-tile-title.body-2 {{tgt.title}}
|
2019-06-10 03:39:37 +00:00
|
|
|
v-list-tile-sub-title.red--text.caption {{$t('admin:storage.lastSyncAttempt', { time: $options.filters.moment(tgt.lastAttempt, 'from') })}}
|
2019-04-21 00:49:05 +00:00
|
|
|
v-list-tile-action
|
|
|
|
v-menu
|
|
|
|
v-btn(slot='activator', icon)
|
|
|
|
v-icon(color='red') info
|
|
|
|
v-card(width='450')
|
2019-06-10 03:39:37 +00:00
|
|
|
v-toolbar(flat, color='red', dark, dense) {{$t('admin:storage.errorMsg')}}
|
2019-04-21 00:49:05 +00:00
|
|
|
v-card-text {{tgt.message}}
|
2018-03-05 20:49:36 +00:00
|
|
|
|
2019-04-21 00:49:05 +00:00
|
|
|
v-divider(v-if='n < status.length - 1')
|
|
|
|
v-list-tile(v-if='status.length < 1')
|
2019-06-10 03:39:37 +00:00
|
|
|
em {{$t('admin:storage.noTarget')}}
|
2019-02-17 06:32:35 +00:00
|
|
|
|
2019-04-21 00:49:05 +00:00
|
|
|
v-flex(xs12, lg9)
|
|
|
|
v-card.wiki-form.animated.fadeInUp.wait-p2s
|
|
|
|
v-toolbar(color='primary', dense, flat, dark)
|
|
|
|
.subheading {{target.title}}
|
|
|
|
v-card-text
|
|
|
|
v-form
|
|
|
|
.targetlogo
|
|
|
|
img(:src='target.logo', :alt='target.title')
|
|
|
|
v-subheader.pl-0 {{target.title}}
|
|
|
|
.caption {{target.description}}
|
|
|
|
.caption: a(:href='target.website') {{target.website}}
|
|
|
|
v-divider.mt-3
|
2019-06-10 03:39:37 +00:00
|
|
|
v-subheader.pl-0 {{$t('admin:storage.targetConfig')}}
|
|
|
|
.body-1.ml-3(v-if='!target.config || target.config.length < 1') {{$t('admin:storage.noConfigOption')}}
|
2019-04-21 00:49:05 +00:00
|
|
|
template(v-else, v-for='cfg in target.config')
|
|
|
|
v-select(
|
|
|
|
v-if='cfg.value.type === "string" && cfg.value.enum'
|
|
|
|
outline
|
|
|
|
background-color='grey lighten-2'
|
|
|
|
:items='cfg.value.enum'
|
|
|
|
:key='cfg.key'
|
|
|
|
:label='cfg.value.title'
|
|
|
|
v-model='cfg.value.value'
|
|
|
|
prepend-icon='settings_applications'
|
|
|
|
:hint='cfg.value.hint ? cfg.value.hint : ""'
|
|
|
|
persistent-hint
|
|
|
|
:class='cfg.value.hint ? "mb-2" : ""'
|
|
|
|
)
|
|
|
|
v-switch.mb-3(
|
|
|
|
v-else-if='cfg.value.type === "boolean"'
|
|
|
|
:key='cfg.key'
|
|
|
|
:label='cfg.value.title'
|
|
|
|
v-model='cfg.value.value'
|
|
|
|
color='primary'
|
|
|
|
prepend-icon='settings_applications'
|
|
|
|
:hint='cfg.value.hint ? cfg.value.hint : ""'
|
|
|
|
persistent-hint
|
|
|
|
)
|
2019-07-14 22:55:12 +00:00
|
|
|
v-textarea(
|
|
|
|
v-else-if='cfg.value.type === "string" && cfg.value.multiline'
|
|
|
|
outline
|
|
|
|
background-color='grey lighten-2'
|
|
|
|
:key='cfg.key'
|
|
|
|
:label='cfg.value.title'
|
|
|
|
v-model='cfg.value.value'
|
|
|
|
prepend-icon='settings_applications'
|
|
|
|
:hint='cfg.value.hint ? cfg.value.hint : ""'
|
|
|
|
persistent-hint
|
|
|
|
:class='cfg.value.hint ? "mb-2" : ""'
|
|
|
|
)
|
2019-04-21 00:49:05 +00:00
|
|
|
v-text-field(
|
|
|
|
v-else
|
|
|
|
outline
|
|
|
|
background-color='grey lighten-2'
|
|
|
|
:key='cfg.key'
|
|
|
|
:label='cfg.value.title'
|
|
|
|
v-model='cfg.value.value'
|
|
|
|
prepend-icon='settings_applications'
|
|
|
|
:hint='cfg.value.hint ? cfg.value.hint : ""'
|
|
|
|
persistent-hint
|
|
|
|
:class='cfg.value.hint ? "mb-2" : ""'
|
|
|
|
)
|
|
|
|
v-divider.mt-3
|
2019-06-10 03:39:37 +00:00
|
|
|
v-subheader.pl-0 {{$t('admin:storage.syncDirection')}}
|
|
|
|
.body-1.ml-3 {{$t('admin:storage.syncDirectionSubtitle')}}
|
2019-04-21 00:49:05 +00:00
|
|
|
.pr-3.pt-3
|
|
|
|
v-radio-group.ml-3.py-0(v-model='target.mode')
|
|
|
|
v-radio(
|
2019-06-10 03:39:37 +00:00
|
|
|
:label='$t(`admin:storage.syncDirBi`)'
|
2019-04-21 00:49:05 +00:00
|
|
|
color='primary'
|
|
|
|
value='sync'
|
|
|
|
:disabled='target.supportedModes.indexOf(`sync`) < 0'
|
|
|
|
)
|
|
|
|
v-radio(
|
2019-06-10 03:39:37 +00:00
|
|
|
:label='$t(`admin:storage.syncDirPush`)'
|
2019-04-21 00:49:05 +00:00
|
|
|
color='primary'
|
|
|
|
value='push'
|
|
|
|
:disabled='target.supportedModes.indexOf(`push`) < 0'
|
|
|
|
)
|
|
|
|
v-radio(
|
2019-06-10 03:39:37 +00:00
|
|
|
:label='$t(`admin:storage.syncDirPull`)'
|
2019-04-21 00:49:05 +00:00
|
|
|
color='primary'
|
|
|
|
value='pull'
|
|
|
|
:disabled='target.supportedModes.indexOf(`pull`) < 0'
|
|
|
|
)
|
|
|
|
.body-1.ml-3
|
2019-06-10 03:39:37 +00:00
|
|
|
strong {{$t('admin:storage.syncDirBi')}} #[em.red--text.text--lighten-2(v-if='target.supportedModes.indexOf(`sync`) < 0') {{$t('admin:storage.unsupported')}}]
|
|
|
|
.pb-3 {{$t('admin:storage.syncDirBiHint')}}
|
|
|
|
strong {{$t('admin:storage.syncDirPush')}} #[em.red--text.text--lighten-2(v-if='target.supportedModes.indexOf(`push`) < 0') {{$t('admin:storage.unsupported')}}]
|
|
|
|
.pb-3 {{$t('admin:storage.syncDirPushHint')}}
|
|
|
|
strong {{$t('admin:storage.syncDirPull')}} #[em.red--text.text--lighten-2(v-if='target.supportedModes.indexOf(`pull`) < 0') {{$t('admin:storage.unsupported')}}]
|
|
|
|
.pb-3 {{$t('admin:storage.syncDirPullHint')}}
|
2019-02-17 06:32:35 +00:00
|
|
|
|
2019-04-21 00:49:05 +00:00
|
|
|
template(v-if='target.hasSchedule')
|
|
|
|
v-divider.mt-3
|
2019-06-10 03:39:37 +00:00
|
|
|
v-subheader.pl-0 {{$t('admin:storage.syncSchedule')}}
|
|
|
|
.body-1.ml-3 {{$t('admin:storage.syncScheduleHint')}}
|
2019-04-21 00:49:05 +00:00
|
|
|
.pa-3
|
|
|
|
duration-picker(v-model='target.syncInterval')
|
2019-06-10 03:39:37 +00:00
|
|
|
i18next.caption.mt-3(path='admin:storage.syncScheduleCurrent', tag='div')
|
|
|
|
strong(place='schedule') {{getDefaultSchedule(target.syncInterval)}}
|
|
|
|
i18next.caption(path='admin:storage.syncScheduleDefault', tag='div')
|
2019-06-23 22:35:14 +00:00
|
|
|
strong(place='schedule') {{getDefaultSchedule(target.syncIntervalDefault)}}
|
2019-04-21 00:49:05 +00:00
|
|
|
|
|
|
|
template(v-if='target.actions && target.actions.length > 0')
|
|
|
|
v-divider.mt-3
|
2019-06-10 03:39:37 +00:00
|
|
|
v-subheader.pl-0 {{$t('admin:storage.actions')}}
|
2019-04-21 00:49:05 +00:00
|
|
|
v-container.pt-0(grid-list-xl, fluid)
|
|
|
|
v-layout(row, wrap, fill-height)
|
|
|
|
v-flex(xs12, lg6, xl4, v-for='act of target.actions', :key='act.handler')
|
|
|
|
v-card.radius-7.grey(flat, :class='$vuetify.dark ? `darken-3-d5` : `lighten-3`', height='100%')
|
|
|
|
v-card-text
|
|
|
|
.subheading(v-html='act.label')
|
|
|
|
.body-1.mt-2(v-html='act.hint')
|
|
|
|
v-btn.mx-0.mt-3(
|
|
|
|
@click='executeAction(target.key, act.handler)'
|
|
|
|
outline
|
|
|
|
:color='$vuetify.dark ? `blue` : `primary`'
|
|
|
|
:disabled='runningAction'
|
|
|
|
:loading='runningActionHandler === act.handler'
|
2019-06-10 03:39:37 +00:00
|
|
|
) {{$t('admin:storage.actionRun')}}
|
2019-04-06 23:05:47 +00:00
|
|
|
|
2018-03-05 20:49:36 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-06-26 02:04:47 +00:00
|
|
|
import _ from 'lodash'
|
2019-02-18 02:48:48 +00:00
|
|
|
import moment from 'moment'
|
|
|
|
import momentDurationFormatSetup from 'moment-duration-format'
|
2018-06-26 02:04:47 +00:00
|
|
|
|
2019-02-17 06:32:35 +00:00
|
|
|
import DurationPicker from '../common/duration-picker.vue'
|
|
|
|
import { LoopingRhombusesSpinner } from 'epic-spinners'
|
|
|
|
|
|
|
|
import statusQuery from 'gql/admin/storage/storage-query-status.gql'
|
2018-06-26 02:04:47 +00:00
|
|
|
import targetsQuery from 'gql/admin/storage/storage-query-targets.gql'
|
2019-04-06 23:05:47 +00:00
|
|
|
import targetExecuteActionMutation from 'gql/admin/storage/storage-mutation-executeaction.gql'
|
2018-06-26 02:04:47 +00:00
|
|
|
import targetsSaveMutation from 'gql/admin/storage/storage-mutation-save-targets.gql'
|
|
|
|
|
2019-02-18 02:48:48 +00:00
|
|
|
momentDurationFormatSetup(moment)
|
|
|
|
|
2018-03-05 20:49:36 +00:00
|
|
|
export default {
|
2019-02-17 06:32:35 +00:00
|
|
|
components: {
|
|
|
|
DurationPicker,
|
|
|
|
LoopingRhombusesSpinner
|
|
|
|
},
|
2018-07-01 23:50:42 +00:00
|
|
|
filters: {
|
|
|
|
startCase(val) { return _.startCase(val) }
|
|
|
|
},
|
2018-03-05 20:49:36 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2019-04-06 23:05:47 +00:00
|
|
|
runningAction: false,
|
|
|
|
runningActionHandler: '',
|
2019-04-21 00:49:05 +00:00
|
|
|
selectedTarget: '',
|
2019-06-23 22:35:14 +00:00
|
|
|
target: {
|
|
|
|
supportedModes: []
|
|
|
|
},
|
2019-02-17 06:32:35 +00:00
|
|
|
targets: [],
|
|
|
|
status: []
|
2018-06-26 02:04:47 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
activeTargets() {
|
|
|
|
return _.filter(this.targets, 'isEnabled')
|
|
|
|
}
|
|
|
|
},
|
2019-04-21 00:49:05 +00:00
|
|
|
watch: {
|
|
|
|
selectedTarget(newValue, oldValue) {
|
|
|
|
this.target = _.find(this.targets, ['key', newValue]) || {}
|
|
|
|
},
|
|
|
|
targets(newValue, oldValue) {
|
|
|
|
this.selectedTarget = _.get(_.find(this.targets, ['isEnabled', true]), 'key', 'disk')
|
|
|
|
}
|
|
|
|
},
|
2018-06-26 02:04:47 +00:00
|
|
|
methods: {
|
|
|
|
async refresh() {
|
|
|
|
await this.$apollo.queries.targets.refetch()
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: 'List of storage targets has been refreshed.',
|
|
|
|
style: 'success',
|
|
|
|
icon: 'cached'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
async save() {
|
|
|
|
this.$store.commit(`loadingStart`, 'admin-storage-savetargets')
|
|
|
|
await this.$apollo.mutate({
|
|
|
|
mutation: targetsSaveMutation,
|
|
|
|
variables: {
|
|
|
|
targets: this.targets.map(tgt => _.pick(tgt, [
|
2019-04-06 23:05:47 +00:00
|
|
|
'isEnabled',
|
|
|
|
'key',
|
|
|
|
'config',
|
|
|
|
'mode',
|
|
|
|
'syncInterval'
|
|
|
|
])).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.stringify({ v: cfg.value.value })}))}))
|
2018-06-26 02:04:47 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: 'Storage configuration saved successfully.',
|
|
|
|
style: 'success',
|
|
|
|
icon: 'check'
|
|
|
|
})
|
|
|
|
this.$store.commit(`loadingStop`, 'admin-storage-savetargets')
|
2019-02-17 06:32:35 +00:00
|
|
|
},
|
2019-02-18 02:48:48 +00:00
|
|
|
getDefaultSchedule(val) {
|
2019-06-23 22:35:14 +00:00
|
|
|
if (!val) { return 'N/A' }
|
2019-02-18 02:48:48 +00:00
|
|
|
return moment.duration(val).format('y [years], M [months], d [days], h [hours], m [minutes]')
|
2019-04-06 23:05:47 +00:00
|
|
|
},
|
|
|
|
async executeAction(targetKey, handler) {
|
|
|
|
this.$store.commit(`loadingStart`, 'admin-storage-executeaction')
|
|
|
|
this.runningAction = true
|
|
|
|
this.runningActionHandler = handler
|
|
|
|
try {
|
|
|
|
await this.$apollo.mutate({
|
|
|
|
mutation: targetExecuteActionMutation,
|
|
|
|
variables: {
|
|
|
|
targetKey,
|
|
|
|
handler
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: 'Action completed.',
|
|
|
|
style: 'success',
|
|
|
|
icon: 'check'
|
|
|
|
})
|
|
|
|
} catch (err) {
|
|
|
|
console.warn(err)
|
|
|
|
}
|
|
|
|
this.runningAction = false
|
|
|
|
this.runningActionHandler = ''
|
|
|
|
this.$store.commit(`loadingStop`, 'admin-storage-executeaction')
|
2018-06-26 02:04:47 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
targets: {
|
|
|
|
query: targetsQuery,
|
|
|
|
fetchPolicy: 'network-only',
|
2019-02-03 22:08:06 +00:00
|
|
|
update: (data) => _.cloneDeep(data.storage.targets).map(str => ({
|
|
|
|
...str,
|
|
|
|
config: _.sortBy(str.config.map(cfg => ({
|
|
|
|
...cfg,
|
|
|
|
value: JSON.parse(cfg.value)
|
|
|
|
})), [t => t.value.order])
|
|
|
|
})),
|
2018-06-26 02:04:47 +00:00
|
|
|
watchLoading (isLoading) {
|
2019-02-17 06:32:35 +00:00
|
|
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-storage-targets-refresh')
|
2018-06-26 02:04:47 +00:00
|
|
|
}
|
2019-02-17 06:32:35 +00:00
|
|
|
},
|
|
|
|
status: {
|
|
|
|
query: statusQuery,
|
|
|
|
fetchPolicy: 'network-only',
|
|
|
|
update: (data) => data.storage.status,
|
|
|
|
watchLoading (isLoading) {
|
|
|
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-storage-status-refresh')
|
|
|
|
},
|
|
|
|
pollInterval: 3000
|
2018-03-05 20:49:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2018-08-05 15:27:46 +00:00
|
|
|
<style lang='scss' scoped>
|
|
|
|
|
|
|
|
.targetlogo {
|
|
|
|
width: 250px;
|
|
|
|
height: 85px;
|
|
|
|
float:right;
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-end;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
img {
|
|
|
|
max-width: 100%;
|
|
|
|
max-height: 50px;
|
|
|
|
}
|
|
|
|
}
|
2018-03-05 20:49:36 +00:00
|
|
|
|
|
|
|
</style>
|