mirror of https://github.com/requarks/wiki
parent
10940ca230
commit
edb97b832d
@ -0,0 +1,203 @@
|
||||
<template lang="pug">
|
||||
v-card.wiki-form(flat)
|
||||
v-card-text
|
||||
v-text-field(
|
||||
outline
|
||||
background-color='grey lighten-3'
|
||||
v-model='group.name'
|
||||
label='Group Name'
|
||||
counter='255'
|
||||
prepend-icon='people'
|
||||
)
|
||||
v-alert.radius-7(
|
||||
v-if='group.isSystem'
|
||||
color='orange darken-2'
|
||||
:class='$vuetify.dark ? "grey darken-4" : "orange lighten-5"'
|
||||
outline
|
||||
:value='true'
|
||||
icon='lock_outline'
|
||||
) This is a system group. Some permissions cannot be modified.
|
||||
v-container.px-3.pb-3.pt-0(fluid, grid-list-md)
|
||||
v-layout(row, wrap)
|
||||
v-flex(xs12, md6, lg4, v-for='pmGroup in permissions')
|
||||
v-card.md2(flat, :class='$vuetify.dark ? "grey darken-3-d5" : "white"')
|
||||
v-subheader {{pmGroup.category}}
|
||||
v-card-text.pt-0
|
||||
template(v-for='(pm, idx) in pmGroup.items')
|
||||
v-checkbox.pt-0(
|
||||
:key='pm.permission'
|
||||
:label='pm.permission'
|
||||
:hint='pm.hint'
|
||||
persistent-hint
|
||||
color='primary'
|
||||
v-model='group.permissions'
|
||||
:value='pm.permission'
|
||||
:append-icon='pm.warning ? "warning" : null',
|
||||
:disabled='(group.isSystem && pm.restrictedForSystem) || group.id === 1 || pm.disabled'
|
||||
)
|
||||
v-divider.mt-3(v-if='idx < pmGroup.items.length - 1')
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
permissions: [
|
||||
{
|
||||
category: 'Content',
|
||||
items: [
|
||||
{
|
||||
permission: 'read:pages',
|
||||
hint: 'Can view pages, as specified in the Page Rules',
|
||||
warning: false,
|
||||
restrictedForSystem: false,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'write:pages',
|
||||
hint: 'Can view and create new pages, as specified in the Page Rules',
|
||||
warning: false,
|
||||
restrictedForSystem: false,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'manage:pages',
|
||||
hint: 'Can view, create, edit and move existing pages as specified in the Page Rules',
|
||||
warning: false,
|
||||
restrictedForSystem: false,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'delete:pages',
|
||||
hint: 'Can delete existing pages, as specified in the Page Rules',
|
||||
warning: false,
|
||||
restrictedForSystem: false,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'read:assets',
|
||||
hint: 'Can view / use assets (such as images and files), as specified in the Page Rules',
|
||||
warning: false,
|
||||
restrictedForSystem: false,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'write:assets',
|
||||
hint: 'Can upload new assets (such as images and files), as specified in the Page Rules',
|
||||
warning: false,
|
||||
restrictedForSystem: false,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'manage:assets',
|
||||
hint: 'Can edit and delete assets (such as images and files), as specified in the Page Rules',
|
||||
warning: false,
|
||||
restrictedForSystem: false,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'read:comments',
|
||||
hint: 'Can view comments, as specified in the Page Rules',
|
||||
warning: false,
|
||||
restrictedForSystem: false,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'write:comments',
|
||||
hint: 'Can post new comments, as specified in the Page Rules',
|
||||
warning: false,
|
||||
restrictedForSystem: false,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'manage:comments',
|
||||
hint: 'Can edit and delete comments, as specified in the Page Rules',
|
||||
warning: false,
|
||||
restrictedForSystem: false,
|
||||
disabled: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
category: 'Users',
|
||||
items: [
|
||||
{
|
||||
permission: 'write:users',
|
||||
hint: 'Can create or authorize new users, but not modify existing ones',
|
||||
warning: false,
|
||||
restrictedForSystem: true,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'manage:users',
|
||||
hint: 'Can manage all users (but not users with administrative permissions)',
|
||||
warning: false,
|
||||
restrictedForSystem: true,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'write:groups',
|
||||
hint: 'Can manage groups and assign CONTENT permissions / page rules',
|
||||
warning: false,
|
||||
restrictedForSystem: true,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'manage:groups',
|
||||
hint: 'Can manage groups and assign ANY permissions (but not manage:system) / page rules',
|
||||
warning: true,
|
||||
restrictedForSystem: true,
|
||||
disabled: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
category: 'Administration',
|
||||
items: [
|
||||
{
|
||||
permission: 'manage:navigation',
|
||||
hint: 'Can manage the site navigation',
|
||||
warning: false,
|
||||
restrictedForSystem: true,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'manage:theme',
|
||||
hint: 'Can manage and modify themes',
|
||||
warning: false,
|
||||
restrictedForSystem: true,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'manage:api',
|
||||
hint: 'Can generate and revoke API keys',
|
||||
warning: true,
|
||||
restrictedForSystem: true,
|
||||
disabled: false
|
||||
},
|
||||
{
|
||||
permission: 'manage:system',
|
||||
hint: 'Can manage and access everything. Root administrator.',
|
||||
warning: true,
|
||||
restrictedForSystem: true,
|
||||
disabled: true
|
||||
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
group: {
|
||||
get() { return this.value },
|
||||
set(val) { this.$set('input', val) }
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,302 @@
|
||||
<template lang="pug">
|
||||
v-card.wiki-form
|
||||
v-card-text(v-if='group.id === 1')
|
||||
v-alert.radius-7(
|
||||
:class='$vuetify.dark ? "grey darken-4" : "orange lighten-5"'
|
||||
color='orange darken-2'
|
||||
outline
|
||||
:value='true'
|
||||
icon='lock_outline'
|
||||
) This group has access to everything.
|
||||
template(v-else)
|
||||
v-card-title(:class='$vuetify.dark ? `grey darken-3-d5` : `grey lighten-5`')
|
||||
v-alert.radius-7(
|
||||
:class='$vuetify.dark ? `grey darken-3-d3` : `white`'
|
||||
:value='true'
|
||||
color='grey'
|
||||
outline
|
||||
icon='info'
|
||||
) You must enable global content permissions (under Permissions tab) for page rules to have any effect.
|
||||
v-spacer
|
||||
v-btn(depressed, color='primary', @click='addRule')
|
||||
v-icon(left) add
|
||||
| Add Rule
|
||||
v-menu(
|
||||
right
|
||||
offset-y
|
||||
nudge-left='115'
|
||||
)
|
||||
v-btn.is-icon(slot='activator', flat, outline, color='primary')
|
||||
v-icon more_horiz
|
||||
v-list(dense)
|
||||
v-list-tile(@click='comingSoon')
|
||||
v-list-tile-avatar
|
||||
v-icon keyboard_capslock
|
||||
v-list-tile-title Load Preset
|
||||
v-divider
|
||||
v-list-tile(@click='comingSoon')
|
||||
v-list-tile-avatar
|
||||
v-icon publish
|
||||
v-list-tile-title Save As Preset
|
||||
v-divider
|
||||
v-list-tile(@click='comingSoon')
|
||||
v-list-tile-avatar
|
||||
v-icon cloud_upload
|
||||
v-list-tile-title Import Rules
|
||||
v-divider
|
||||
v-list-tile(@click='comingSoon')
|
||||
v-list-tile-avatar
|
||||
v-icon cloud_download
|
||||
v-list-tile-title Export Rules
|
||||
v-card-text(:class='$vuetify.dark ? `grey darken-4-l5` : `white`')
|
||||
.rules
|
||||
.caption(v-if='group.pageRules.length === 0')
|
||||
em(:class='$vuetify.dark ? `grey--text` : `blue-grey--text`') This group has no page rules yet.
|
||||
.rule(v-for='rule of group.pageRules', :key='rule.id')
|
||||
v-btn.ma-0.rule-deny-btn(
|
||||
solo
|
||||
:color='rule.deny ? "red" : "green"'
|
||||
dark
|
||||
@click='rule.deny = !rule.deny'
|
||||
)
|
||||
v-icon(v-if='rule.deny') block
|
||||
v-icon(v-else) check_circle
|
||||
//- Roles
|
||||
v-select.ml-1(
|
||||
solo
|
||||
:items='roles'
|
||||
v-model='rule.roles'
|
||||
placeholder='Select Role(s)...'
|
||||
hide-details
|
||||
multiple
|
||||
chips
|
||||
deletable-chips
|
||||
small-chips
|
||||
style='flex: 0 1 440px;'
|
||||
:menu-props='{ "maxHeight": 500 }'
|
||||
clearable
|
||||
dense
|
||||
)
|
||||
template(slot='selection', slot-scope='{ item, index }')
|
||||
v-chip.white--text.ml-0(v-if='index <= 2', small, label, :color='rule.deny ? `red` : `green`').caption {{ item.value }}
|
||||
v-chip.white--text.ml-0(v-if='index === 3', small, label, :color='rule.deny ? `red lighten-2` : `green lighten-2`').caption + {{ rule.roles.length - 3 }} more
|
||||
template(slot='item', slot-scope='props')
|
||||
v-list-tile-action(style='min-width: 30px;')
|
||||
v-checkbox(
|
||||
v-model='props.tile.props.value'
|
||||
hide-details
|
||||
color='primary'
|
||||
)
|
||||
v-icon.mr-2(:color='rule.deny ? `red` : `green`') {{props.item.icon}}
|
||||
v-list-tile-content
|
||||
v-list-tile-title.body-2 {{props.item.text}}
|
||||
v-chip.mr-2.grey--text(label, small, :color='$vuetify.dark ? `grey darken-4` : `grey lighten-4`').caption {{props.item.value}}
|
||||
|
||||
//- Match
|
||||
v-select.ml-1.mr-1(
|
||||
solo
|
||||
:items='matches'
|
||||
v-model='rule.match'
|
||||
placeholder='Match...'
|
||||
hide-details
|
||||
style='flex: 0 1 250px;'
|
||||
dense
|
||||
)
|
||||
template(slot='selection', slot-scope='{ item, index }')
|
||||
.body-1 {{item.text}}
|
||||
template(slot='item', slot-scope='data')
|
||||
v-list-tile-avatar
|
||||
v-avatar.white--text.radius-4(color='blue', size='30', tile) {{ data.item.icon }}
|
||||
v-list-tile-content
|
||||
v-list-tile-title(v-html='data.item.text')
|
||||
//- Locales
|
||||
v-select.mr-1(
|
||||
:background-color='$vuetify.dark ? `grey darken-3-d5` : `blue-grey lighten-5`'
|
||||
solo
|
||||
:items='locales'
|
||||
v-model='rule.locales'
|
||||
placeholder='Any Locale'
|
||||
multiple
|
||||
hide-details
|
||||
dense
|
||||
:menu-props='{ "minWidth": 250 }'
|
||||
style='flex: 0 1 150px;'
|
||||
)
|
||||
template(slot='selection', slot-scope='{ item, index }')
|
||||
v-chip.white--text.ml-0(v-if='rule.locales.length === 1', small, label, :color='rule.deny ? `red` : `green`').caption {{ item.value.toUpperCase() }}
|
||||
v-chip.white--text.ml-0(v-else-if='index === 0', small, label, :color='rule.deny ? `red` : `green`').caption {{ rule.locales.length }} locales
|
||||
v-list-tile(slot='prepend-item', @click='rule.locales = []')
|
||||
v-list-tile-action(style='min-width: 30px;')
|
||||
v-checkbox(
|
||||
:input-value='rule.locales.length === 0'
|
||||
hide-details
|
||||
color='primary'
|
||||
readonly
|
||||
)
|
||||
v-icon.mr-2(:color='rule.deny ? `red` : `green`') public
|
||||
v-list-tile-content
|
||||
v-list-tile-title.body-2 Any Locale
|
||||
v-divider(slot='prepend-item')
|
||||
template(slot='item', slot-scope='props')
|
||||
v-list-tile-action(style='min-width: 30px;')
|
||||
v-checkbox(
|
||||
v-model='props.tile.props.value'
|
||||
hide-details
|
||||
color='primary'
|
||||
)
|
||||
v-icon.mr-2(:color='rule.deny ? `red` : `green`') language
|
||||
v-list-tile-content
|
||||
v-list-tile-title.body-2 {{props.item.text}}
|
||||
v-chip.mr-2.grey--text(label, small, :color='$vuetify.dark ? `grey darken-4` : `grey lighten-4`').caption {{props.item.value.toUpperCase()}}
|
||||
|
||||
//- Path
|
||||
v-text-field(
|
||||
solo
|
||||
v-model='rule.path'
|
||||
label='Path'
|
||||
:prefix='rule.match !== `END` ? `/` : null'
|
||||
:placeholder='rule.match === `REGEX` ? `Regular Expression` : `Path`'
|
||||
:suffix='rule.match === `REGEX` ? `/` : null'
|
||||
hide-details
|
||||
:color='$vuetify.dark ? `grey` : `blue-grey`'
|
||||
)
|
||||
|
||||
v-btn(icon, @click='removeRule(rule.id)')
|
||||
v-icon(:color='$vuetify.dark ? `grey` : `blue-grey`') clear
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
import nanoid from 'nanoid/non-secure/generate'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
roles: [
|
||||
{ text: 'Read Pages', value: 'READ', icon: 'insert_drive_file' },
|
||||
{ text: 'Create Pages', value: 'WRITE', icon: 'insert_drive_file' },
|
||||
{ text: 'Edit + Move Pages', value: 'MANAGE', icon: 'insert_drive_file' },
|
||||
{ text: 'Delete Pages', value: 'DELETE', icon: 'insert_drive_file' },
|
||||
{ text: 'Read / Use Assets', value: 'AS_READ', icon: 'camera' },
|
||||
{ text: 'Upload Assets', value: 'AS_WRITE', icon: 'camera' },
|
||||
{ text: 'Edit + Delete Assets', value: 'AS_MANAGE', icon: 'camera' },
|
||||
{ text: 'Read Comments', value: 'CM_READ', icon: 'insert_comment' },
|
||||
{ text: 'Create Comments', value: 'CM_WRITE', icon: 'insert_comment' },
|
||||
{ text: 'Edit + Delete Comments', value: 'CM_MANAGE', icon: 'insert_comment' }
|
||||
],
|
||||
matches: [
|
||||
{ text: 'Path Starts With...', value: 'START', icon: '/...' },
|
||||
{ text: 'Path is Exactly...', value: 'EXACT', icon: '=' },
|
||||
{ text: 'Path Ends With...', value: 'END', icon: '.../' },
|
||||
{ text: 'Path Matches Regex...', value: 'REGEX', icon: '$.*' }
|
||||
],
|
||||
locales: [
|
||||
{ text: 'English', value: 'en' },
|
||||
{ text: 'Français', value: 'fr' },
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
group: {
|
||||
get() { return this.value },
|
||||
set(val) { this.$set('input', val) }
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addRule(group) {
|
||||
this.group.pageRules.push({
|
||||
id: nanoid('1234567890abcdef', 10),
|
||||
path: '',
|
||||
roles: [],
|
||||
match: 'START',
|
||||
deny: false,
|
||||
locales: []
|
||||
})
|
||||
},
|
||||
removeRule(rule) {
|
||||
this.group.pageRules.splice(_.findIndex(this.group.pageRules, ['id', rule.id]), 1)
|
||||
},
|
||||
comingSoon() {
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'indigo',
|
||||
message: `Coming soon...`,
|
||||
icon: 'directions_boat'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.rules {
|
||||
background-color: mc('blue-grey', '50');
|
||||
border-radius: 4px;
|
||||
padding: 1rem;
|
||||
position: relative;
|
||||
|
||||
@at-root .theme--dark & {
|
||||
background-color: mc('grey', '800');
|
||||
}
|
||||
}
|
||||
|
||||
.rule {
|
||||
display: flex;
|
||||
background-color: mc('blue-grey', '100');
|
||||
border-radius: 4px;
|
||||
padding: .5rem;
|
||||
|
||||
&-enter-active, &-leave-active {
|
||||
transition: all .5s ease;
|
||||
}
|
||||
&-enter, &-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
@at-root .theme--dark & {
|
||||
background-color: mc('grey', '700');
|
||||
}
|
||||
|
||||
& + .rule {
|
||||
margin-top: .5rem;
|
||||
position: relative;
|
||||
|
||||
&::before {
|
||||
content: '+';
|
||||
position: absolute;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-weight: 600;
|
||||
color: mc('blue-grey', '700');
|
||||
font-size: 1.25rem;
|
||||
background-color: mc('blue-grey', '50');
|
||||
left: -2rem;
|
||||
top: -1.3rem;
|
||||
|
||||
@at-root .theme--dark & {
|
||||
background-color: mc('grey', '800');
|
||||
color: mc('grey', '600');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.input-group + * {
|
||||
margin-left: .5rem;
|
||||
}
|
||||
|
||||
&-deny-btn {
|
||||
height: 48px;
|
||||
border-radius: 2px 0 0 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
@ -0,0 +1,147 @@
|
||||
<template lang="pug">
|
||||
v-card.wiki-form
|
||||
v-card-title(:class='$vuetify.dark ? `grey darken-3-d3` : `grey lighten-5`')
|
||||
v-text-field(
|
||||
outline
|
||||
flat
|
||||
prepend-inner-icon='search'
|
||||
v-model='search'
|
||||
label='Search Group Users...'
|
||||
hide-details
|
||||
)
|
||||
v-spacer
|
||||
v-btn(color='primary', depressed, @click='searchUserDialog = true', :disabled='group.id === 2')
|
||||
v-icon(left) assignment_ind
|
||||
| Assign User
|
||||
v-data-table(
|
||||
:items='group.users',
|
||||
:headers='headers',
|
||||
:search='search'
|
||||
:pagination.sync='pagination',
|
||||
:rows-per-page-items='[15]'
|
||||
hide-actions
|
||||
)
|
||||
template(slot='items', slot-scope='props')
|
||||
tr(:active='props.selected')
|
||||
td.text-xs-right {{ props.item.id }}
|
||||
td {{ props.item.name }}
|
||||
td {{ props.item.email }}
|
||||
td
|
||||
v-menu(bottom, right, min-width='200')
|
||||
v-btn(icon, slot='activator'): v-icon.grey--text.text--darken-1 more_horiz
|
||||
v-list
|
||||
v-list-tile(:to='`/users/` + props.item.id')
|
||||
v-list-tile-action: v-icon(color='primary') person
|
||||
v-list-tile-content
|
||||
v-list-tile-title View User Profile
|
||||
template(v-if='props.item.id !== 2')
|
||||
v-divider
|
||||
v-list-tile(@click='unassignUser(props.item.id)')
|
||||
v-list-tile-action: v-icon(color='orange') highlight_off
|
||||
v-list-tile-content
|
||||
v-list-tile-title Unassign
|
||||
template(slot='no-data')
|
||||
v-alert.ma-3(icon='warning', :value='true', outline) No users to display.
|
||||
.text-xs-center.py-2(v-if='group.users.length > 15')
|
||||
v-pagination(v-model='pagination.page', :length='pages')
|
||||
|
||||
user-search(v-model='searchUserDialog', @select='assignUser')
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UserSearch from '../common/user-search.vue'
|
||||
|
||||
import assignUserMutation from 'gql/admin/groups/groups-mutation-assign.gql'
|
||||
import unassignUserMutation from 'gql/admin/groups/groups-mutation-unassign.gql'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
components: {
|
||||
UserSearch
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
headers: [
|
||||
{ text: 'ID', value: 'id', width: 50, align: 'right' },
|
||||
{ text: 'Name', value: 'name' },
|
||||
{ text: 'Email', value: 'email' },
|
||||
{ text: '', value: 'actions', sortable: false, width: 50 }
|
||||
],
|
||||
searchUserDialog: false,
|
||||
pagination: {},
|
||||
search: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
group: {
|
||||
get() { return this.value },
|
||||
set(val) { this.$set('input', val) }
|
||||
},
|
||||
pages () {
|
||||
if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
|
||||
return 0
|
||||
}
|
||||
|
||||
return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async assignUser(id) {
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: assignUserMutation,
|
||||
variables: {
|
||||
groupId: this.group.id,
|
||||
userId: id
|
||||
},
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-assign')
|
||||
}
|
||||
})
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'success',
|
||||
message: `User has been assigned to ${this.group.name}.`,
|
||||
icon: 'assignment_ind'
|
||||
})
|
||||
this.$emit('refresh')
|
||||
} catch (err) {
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'red',
|
||||
message: err.message,
|
||||
icon: 'warning'
|
||||
})
|
||||
}
|
||||
},
|
||||
async unassignUser(id) {
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: unassignUserMutation,
|
||||
variables: {
|
||||
groupId: this.group.id,
|
||||
userId: id
|
||||
},
|
||||
watchLoading (isLoading) {
|
||||
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-groups-unassign')
|
||||
}
|
||||
})
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'success',
|
||||
message: `User has been unassigned from ${this.group.name}.`,
|
||||
icon: 'assignment_ind'
|
||||
})
|
||||
this.$emit('refresh')
|
||||
} catch (err) {
|
||||
this.$store.commit('showNotification', {
|
||||
style: 'red',
|
||||
message: err.message,
|
||||
icon: 'warning'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,211 +0,0 @@
|
||||
<template lang="pug">
|
||||
.criterias-item
|
||||
//- Type
|
||||
v-select(
|
||||
solo
|
||||
:items='filteredCriteriaTypes'
|
||||
v-model='item.type'
|
||||
placeholder='Rule Type'
|
||||
ref='typeSelect'
|
||||
hide-details
|
||||
)
|
||||
template(slot='item', slot-scope='data')
|
||||
v-list-tile-avatar
|
||||
v-avatar(:color='data.item.color', size='40', tile): v-icon(color='white') {{ data.item.icon }}
|
||||
v-list-tile-content
|
||||
v-list-tile-title(v-html='data.item.text')
|
||||
v-list-tile-sub-title.caption(v-html='data.item.description')
|
||||
|
||||
//- Operator
|
||||
v-select(
|
||||
solo
|
||||
:items='filteredCriteriaOperators'
|
||||
v-model='item.operator'
|
||||
placeholder='Operator'
|
||||
:disabled='!item.type'
|
||||
:class='!item.type ? "blue-grey lighten-4" : ""'
|
||||
hide-details
|
||||
)
|
||||
template(slot='item', slot-scope='data')
|
||||
v-list-tile-avatar
|
||||
v-avatar.white--text(color='blue', size='30', tile) {{ data.item.icon }}
|
||||
v-list-tile-content
|
||||
v-list-tile-title(v-html='data.item.text')
|
||||
|
||||
//- Value
|
||||
v-select(
|
||||
v-if='item.type === "country"'
|
||||
solo
|
||||
:items='countries'
|
||||
v-model='item.value'
|
||||
placeholder='Countries...'
|
||||
multiple
|
||||
item-text='name'
|
||||
item-value='code'
|
||||
hide-details
|
||||
)
|
||||
v-text-field(
|
||||
v-else-if='item.type === "path"'
|
||||
solo
|
||||
v-model='item.value'
|
||||
label='Path (e.g. /section)'
|
||||
hide-details
|
||||
)
|
||||
v-text-field(
|
||||
v-else-if='item.type === "date"'
|
||||
solo
|
||||
@click.native.stop='dateActivator = true'
|
||||
v-model='item.value'
|
||||
label='YYYY-MM-DD'
|
||||
readonly
|
||||
hide-details
|
||||
)
|
||||
v-text-field(
|
||||
v-else-if='item.type === "time"'
|
||||
solo
|
||||
@click.native.stop='timeActivator = true'
|
||||
v-model='item.value'
|
||||
label='HH:MM'
|
||||
readonly
|
||||
hide-details
|
||||
)
|
||||
v-select(
|
||||
v-else-if='item.type === "group"'
|
||||
solo
|
||||
:items='groups'
|
||||
v-model='item.value'
|
||||
placeholder='Group...'
|
||||
item-text='name'
|
||||
item-value='id'
|
||||
hide-details
|
||||
)
|
||||
v-text-field.blue-grey.lighten-4(
|
||||
v-else
|
||||
solo
|
||||
disabled
|
||||
hide-details
|
||||
)
|
||||
|
||||
v-dialog(lazy, v-model='dateActivator', width='290px', ref='dateDialog')
|
||||
v-date-picker(v-model='item.value', scrollable, color='primary')
|
||||
v-btn(flat, color='primary' @click='$refs.dateDialog.save(date)', block) ok
|
||||
|
||||
v-dialog(lazy, v-model='timeActivator', width='300px', ref='timeDialog')
|
||||
v-time-picker(v-model='item.value', scrollable, color='primary')
|
||||
v-btn(flat, color='primary' @click='$refs.timeDialog.save(time)', block) ok
|
||||
|
||||
v-btn(icon, @click='remove'): v-icon(color='blue-grey') clear
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import _ from 'lodash'
|
||||
|
||||
// import countriesQuery from 'gql/upsells-query-countries.gql'
|
||||
|
||||
export default {
|
||||
inject: ['allowedCriteriaTypes'],
|
||||
props: {
|
||||
value: {
|
||||
type: Object,
|
||||
default() { return {} }
|
||||
},
|
||||
groupIndex: {
|
||||
type: Number,
|
||||
default() { return 0 }
|
||||
},
|
||||
itemIndex: {
|
||||
type: Number,
|
||||
default() { return 0 }
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
item: {
|
||||
operator: '',
|
||||
type: '',
|
||||
value: ''
|
||||
},
|
||||
dateActivator: false,
|
||||
dateDialog: false,
|
||||
timeActivator: false,
|
||||
timeDialog: false,
|
||||
countries: [],
|
||||
groups: [],
|
||||
criteriaTypes: [
|
||||
{ text: 'Path', value: 'path', icon: 'space_bar', color: 'blue', description: 'Match the path of the document being viewed.' },
|
||||
{ text: 'Date', value: 'date', icon: 'date_range', color: 'blue', description: 'Match the current calendar day.' },
|
||||
{ text: 'Time', value: 'time', icon: 'access_time', color: 'blue', description: 'Match the current time of day.' },
|
||||
{ text: 'User Country', value: 'country', icon: 'public', color: 'red', description: `Match the user's country.` },
|
||||
{ text: 'User Group', value: 'group', icon: 'group', color: 'orange', description: 'Match the user group assignments.' }
|
||||
],
|
||||
criteriaOperators: {
|
||||
country: [
|
||||
{ text: 'In', value: 'in', icon: '[...]' },
|
||||
{ text: 'Not In', value: 'notIn', icon: '[ x ]' }
|
||||
],
|
||||
path: [
|
||||
{ text: 'Matches Exactly', value: 'eq', icon: '=' },
|
||||
{ text: 'NOT Matches Exactly', value: 'ne', icon: '!=' },
|
||||
{ text: 'Starts With', value: 'sw', icon: 'x...' },
|
||||
{ text: 'NOT Starts With', value: 'nsw', icon: '!x...' },
|
||||
{ text: 'Ends With', value: 'ew', icon: '...x' },
|
||||
{ text: 'NOT Ends With', value: 'new', icon: '!...x' },
|
||||
{ text: 'Matches Regex', value: 'regexp', icon: '^x$' }
|
||||
],
|
||||
date: [
|
||||
{ text: 'On or After', value: 'gte', icon: '>=' },
|
||||
{ text: 'On or Before', value: 'lte', icon: '<=' }
|
||||
],
|
||||
time: [
|
||||
{ text: 'At or Later Than', value: 'gte', icon: '>=' },
|
||||
{ text: 'At or Before', value: 'lte', icon: '<=' }
|
||||
],
|
||||
group: [
|
||||
{ text: 'Is Part Of', value: 'in', icon: '[...]' },
|
||||
{ text: 'Is Not Part Of', value: 'notIn', icon: '[ x ]' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
filteredCriteriaOperators() {
|
||||
return _.get(this.criteriaOperators, this.item.type, [])
|
||||
},
|
||||
filteredCriteriaTypes() {
|
||||
console.info(this.allowedCriteriaTypes)
|
||||
return _.filter(this.criteriaTypes, c => _.includes(this.allowedCriteriaTypes, c.value))
|
||||
},
|
||||
itemType() {
|
||||
return this.item.type
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
itemType(newValue, oldValue) {
|
||||
this.item.operator = _.head(this.criteriaOperators[newValue]).value
|
||||
this.item.value = ''
|
||||
},
|
||||
item: {
|
||||
handler(newValue, oldValue) {
|
||||
this.$emit('update', this.groupIndex, this.itemIndex, this.item)
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.item.type) {
|
||||
this.$refs.typeSelect.showMenu()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
remove() {
|
||||
this.$emit('remove', this.groupIndex, this.itemIndex)
|
||||
}
|
||||
}
|
||||
// apollo: {
|
||||
// countries: {
|
||||
// query: countriesQuery,
|
||||
// update: (data) => data.location.countries
|
||||
// }
|
||||
// }
|
||||
}
|
||||
</script>
|
@ -1,173 +0,0 @@
|
||||
<template lang="pug">
|
||||
.criterias
|
||||
transition-group(name='criterias-group', tag='div')
|
||||
.criterias-group(v-for='(group, g) in groups', :key='g')
|
||||
transition-group(name='criterias-item', tag='div')
|
||||
criterias-item(v-for='(item, i) in group', :key='i', :item='item', :group-index='g', :item-index='i', @update='updateItem', @remove='removeItem')
|
||||
.criterias-item-more
|
||||
v-btn.ml-0(@click='addItem(group)', small, color='blue-grey lighten-2', dark, depressed)
|
||||
v-icon(color='white', left) add
|
||||
| Add condition
|
||||
.criterias-group-more
|
||||
v-btn(@click='addGroup', small, color='blue-grey lighten-1', dark, depressed)
|
||||
v-icon(color='white', left) add
|
||||
| Add condition group
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CriteriasItem from './criterias-item.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CriteriasItem
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
type: Array,
|
||||
default() { return [] }
|
||||
},
|
||||
types: {
|
||||
type: Array,
|
||||
default() {
|
||||
return ['country', 'path', 'date', 'time', 'group']
|
||||
}
|
||||
}
|
||||
},
|
||||
provide () {
|
||||
return {
|
||||
allowedCriteriaTypes: this.types
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dataGroups: this.value || []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
groups: {
|
||||
get() { return this.dataGroups },
|
||||
set(grp) {
|
||||
this.dataGroups = grp
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dataGroups(newValue, oldValue) {
|
||||
if (newValue !== oldValue) {
|
||||
this.$emit('input', newValue)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addGroup() {
|
||||
this.dataGroups.push([{}])
|
||||
},
|
||||
addItem(group) {
|
||||
group.push({})
|
||||
},
|
||||
updateItem(groupIndex, itemIndex, item) {
|
||||
console.info(item)
|
||||
this.$set(this.dataGroups[groupIndex], itemIndex, item)
|
||||
},
|
||||
removeItem(groupIndex, itemIndex) {
|
||||
this.dataGroups[groupIndex].splice(itemIndex, 1)
|
||||
if (this.dataGroups[groupIndex].length < 1) {
|
||||
this.dataGroups.splice(groupIndex, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.criterias {
|
||||
&-group {
|
||||
background-color: mc('blue-grey', '100');
|
||||
border-radius: 4px;
|
||||
padding: 1rem;
|
||||
position: relative;
|
||||
|
||||
&-enter-active, &-leave-active {
|
||||
transition: all .5s ease;
|
||||
}
|
||||
&-enter, &-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
& + .criterias-group {
|
||||
margin-top: 1rem;
|
||||
|
||||
&::before {
|
||||
content: 'OR';
|
||||
position: absolute;
|
||||
display: inline-flex;
|
||||
padding: 0 2rem;
|
||||
top: -1.25rem;
|
||||
left: 2rem;
|
||||
background-color: mc('blue-grey', '100');
|
||||
color: mc('blue-grey', '700');
|
||||
font-weight: 600;
|
||||
font-size: .9rem;
|
||||
}
|
||||
}
|
||||
|
||||
&-more {
|
||||
margin: .5rem 0 0 .4rem;
|
||||
}
|
||||
}
|
||||
|
||||
&-item {
|
||||
display: flex;
|
||||
background-color: mc('blue-grey', '200');
|
||||
border-radius: 4px;
|
||||
padding: .5rem;
|
||||
|
||||
&-enter-active, &-leave-active {
|
||||
transition: all .5s ease;
|
||||
}
|
||||
&-enter, &-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
& + .criterias-item {
|
||||
margin-top: .5rem;
|
||||
position: relative;
|
||||
|
||||
&::before {
|
||||
content: 'AND';
|
||||
position: absolute;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-weight: 600;
|
||||
color: mc('blue-grey', '700');
|
||||
font-size: .7rem;
|
||||
background-color: mc('blue-grey', '100');
|
||||
left: -2rem;
|
||||
top: -1.3rem;
|
||||
}
|
||||
}
|
||||
|
||||
.input-group {
|
||||
&:nth-child(1) {
|
||||
flex: 0 1 350px;
|
||||
}
|
||||
|
||||
&:nth-child(2) {
|
||||
flex: 0 1 250px;
|
||||
}
|
||||
|
||||
& + * {
|
||||
margin-left: .5rem;
|
||||
}
|
||||
}
|
||||
|
||||
&-more {
|
||||
margin-top: .15rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
After Width: | Height: | Size: 962 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 337 B |
@ -0,0 +1,35 @@
|
||||
const { Client } = require('pg')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const yaml = require('js-yaml')
|
||||
|
||||
let config = {}
|
||||
|
||||
try {
|
||||
conf = yaml.safeLoad(
|
||||
cfgHelper.parseConfigValue(
|
||||
fs.readFileSync(path.join(process.cwd(), 'dev/docker/config.yml'), 'utf8')
|
||||
)
|
||||
)
|
||||
} catch (err) {
|
||||
console.error(err.message)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const client = new Client({
|
||||
user: config.db.username,
|
||||
host: config.db.host,
|
||||
database: config.db.database,
|
||||
password: config.db.password,
|
||||
port: config.db.port,
|
||||
})
|
||||
|
||||
async function main () {
|
||||
await client.connect()
|
||||
await client.query('DROP SCHEMA public CASCADE;')
|
||||
await client.query('CREATE SCHEMA public;')
|
||||
await client.end()
|
||||
console.info('Success.')
|
||||
}
|
||||
|
||||
main()
|
Loading…
Reference in new issue