summaryrefslogtreecommitdiffstats
path: root/apps/workflowengine/src/components/Checks
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-09-09 16:52:11 +0200
committerJulius Härtl <jus@bitgrid.net>2019-09-10 09:01:26 +0200
commit99e1063a5715dcfe3451e8d9d00c013f30d852b1 (patch)
treeb3b2c8c40d49a15f3033331e509e829fdf24f5c0 /apps/workflowengine/src/components/Checks
parent370242cf6d4bcfa3a1cdf6d1a6f436de24c3b8c4 (diff)
downloadnextcloud-server-99e1063a5715dcfe3451e8d9d00c013f30d852b1.tar.gz
nextcloud-server-99e1063a5715dcfe3451e8d9d00c013f30d852b1.zip
Add user group selector
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/workflowengine/src/components/Checks')
-rw-r--r--apps/workflowengine/src/components/Checks/FileMimeType.vue3
-rw-r--r--apps/workflowengine/src/components/Checks/FileSystemTag.vue86
-rw-r--r--apps/workflowengine/src/components/Checks/MultiselectTag/api.js10
-rw-r--r--apps/workflowengine/src/components/Checks/RequestTime.vue4
-rw-r--r--apps/workflowengine/src/components/Checks/RequestURL.vue12
-rw-r--r--apps/workflowengine/src/components/Checks/RequestUserAgent.vue7
-rw-r--r--apps/workflowengine/src/components/Checks/RequestUserGroup.vue77
-rw-r--r--apps/workflowengine/src/components/Checks/file.js2
-rw-r--r--apps/workflowengine/src/components/Checks/request.js5
9 files changed, 143 insertions, 63 deletions
diff --git a/apps/workflowengine/src/components/Checks/FileMimeType.vue b/apps/workflowengine/src/components/Checks/FileMimeType.vue
index a3e3798304d..e99bf679f00 100644
--- a/apps/workflowengine/src/components/Checks/FileMimeType.vue
+++ b/apps/workflowengine/src/components/Checks/FileMimeType.vue
@@ -16,7 +16,8 @@
<span class="option__title">{{ props.option.label }}</span>
</template>
</Multiselect>
- <input type="text" :value="currentValue.pattern" @input="updateCustom" v-if="!isPredefined">
+ <input v-if="!isPredefined" type="text" :value="currentValue.pattern"
+ @input="updateCustom">
</div>
</template>
diff --git a/apps/workflowengine/src/components/Checks/FileSystemTag.vue b/apps/workflowengine/src/components/Checks/FileSystemTag.vue
index ead4edf60c2..2875b64d48e 100644
--- a/apps/workflowengine/src/components/Checks/FileSystemTag.vue
+++ b/apps/workflowengine/src/components/Checks/FileSystemTag.vue
@@ -22,59 +22,59 @@
<template>
<MultiselectTag v-model="newValue" :multiple="false"
- label="Select a tag"
- @input="update" />
+ label="Select a tag"
+ @input="update" />
</template>
<script>
- import { MultiselectTag } from './MultiselectTag'
+import { MultiselectTag } from './MultiselectTag'
- export default {
- name: 'SizeValue',
- components: {
- MultiselectTag
- },
- props: {
- value: {
- type: String,
- default: ''
- }
- },
- data() {
- return {
- valid: false,
- newValue: []
- }
- },
- beforeMount() {
+export default {
+ name: 'FileSystemTag',
+ components: {
+ MultiselectTag
+ },
+ props: {
+ value: {
+ type: String,
+ default: ''
+ }
+ },
+ data() {
+ return {
+ valid: false,
+ newValue: []
+ }
+ },
+ watch: {
+ value() {
this.updateValue()
- },
- watch: {
- value() {
- this.updateValue()
+ }
+ },
+ beforeMount() {
+ this.updateValue()
+ },
+ methods: {
+ updateValue() {
+ if (this.value !== '') {
+ this.newValue = this.value
+ } else {
+ this.newValue = null
}
},
- methods: {
- updateValue() {
- if (this.value !== "") {
- this.newValue = this.value
- } else {
- this.newValue = null
- }
- },
- validate() {
- return true
- },
- update() {
- if (this.validate()) {
- this.$emit('input', this.newValue || '')
- this.valid = false
- } else {
- this.valid = false
- }
+ validate() {
+ return true
+ },
+ update() {
+ if (this.validate()) {
+ this.$emit('input', this.newValue || '')
+ this.valid = false
+ } else {
+ this.valid = false
}
}
}
+}
</script>
<style scoped>
diff --git a/apps/workflowengine/src/components/Checks/MultiselectTag/api.js b/apps/workflowengine/src/components/Checks/MultiselectTag/api.js
index f371a4b71de..bdbab2b974f 100644
--- a/apps/workflowengine/src/components/Checks/MultiselectTag/api.js
+++ b/apps/workflowengine/src/components/Checks/MultiselectTag/api.js
@@ -46,11 +46,11 @@ const parseXml = (xml) => {
}
const xmlToTagList = (xml) => {
- let json = xmlToJson(parseXml(xml))
- let list = json['d:multistatus']['d:response']
- let result = []
- for (let index in list) {
- let tag = list[index]['d:propstat']
+ const json = xmlToJson(parseXml(xml))
+ const list = json['d:multistatus']['d:response']
+ const result = []
+ for (const index in list) {
+ const tag = list[index]['d:propstat']
if (tag['d:status']['#text'] !== 'HTTP/1.1 200 OK') {
continue
diff --git a/apps/workflowengine/src/components/Checks/RequestTime.vue b/apps/workflowengine/src/components/Checks/RequestTime.vue
index b150e67b004..d41f76c2c21 100644
--- a/apps/workflowengine/src/components/Checks/RequestTime.vue
+++ b/apps/workflowengine/src/components/Checks/RequestTime.vue
@@ -1,6 +1,6 @@
<template>
<div class="timeslot">
- <Multiselect v-model="newValue.timezone" :options="timezones" />
+ <Multiselect v-model="newValue.timezone" :options="timezones" @input="update" />
<input v-model="newValue.startTime" type="text" class="timeslot--start"
placeholder="08:00" @input="update">
<input v-model="newValue.endTime" type="text" placeholder="18:00"
@@ -11,7 +11,7 @@
<script>
import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
import moment from 'moment-timezone'
-import valueMixin from '../../mixins/valueMixin';
+import valueMixin from '../../mixins/valueMixin'
const zones = moment.tz.names()
export default {
diff --git a/apps/workflowengine/src/components/Checks/RequestURL.vue b/apps/workflowengine/src/components/Checks/RequestURL.vue
index 8f3bb766581..7de8b0637ff 100644
--- a/apps/workflowengine/src/components/Checks/RequestURL.vue
+++ b/apps/workflowengine/src/components/Checks/RequestURL.vue
@@ -40,15 +40,15 @@
<span class="option__title">{{ props.option.label }} {{ props.option.$groupLabel }}</span>
</template>
</Multiselect>
- <input type="text" :value="currentValue.pattern"
- :placeholder="placeholder"
- @input="updateCustom" v-if="!isPredefined">
+ <input v-if="!isPredefined" type="text"
+ :value="currentValue.pattern"
+ :placeholder="placeholder" @input="updateCustom">
</div>
</template>
<script>
import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
-import valueMixin from '../../mixins/valueMixin';
+import valueMixin from '../../mixins/valueMixin'
export default {
name: 'RequestURL',
@@ -65,7 +65,7 @@ export default {
{
label: t('workflowengine', 'Predefined URLs'),
children: [
- { pattern: 'webdav', label: t('workflowengine', 'Files WebDAV')},
+ { pattern: 'webdav', label: t('workflowengine', 'Files WebDAV') }
]
}
]
@@ -108,7 +108,7 @@ export default {
return {
icon: 'icon-settings-dark',
label: t('workflowengine', 'Custom URL'),
- pattern: this.newValue,
+ pattern: this.newValue
}
}
},
diff --git a/apps/workflowengine/src/components/Checks/RequestUserAgent.vue b/apps/workflowengine/src/components/Checks/RequestUserAgent.vue
index c5ea6bd4eec..c65bba50353 100644
--- a/apps/workflowengine/src/components/Checks/RequestUserAgent.vue
+++ b/apps/workflowengine/src/components/Checks/RequestUserAgent.vue
@@ -40,13 +40,14 @@
<span class="option__title">{{ props.option.label }} {{ props.option.$groupLabel }}</span>
</template>
</Multiselect>
- <input type="text" :value="currentValue.pattern" @input="updateCustom" v-if="!isPredefined">
+ <input v-if="!isPredefined" type="text" :value="currentValue.pattern"
+ @input="updateCustom">
</div>
</template>
<script>
import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
-import valueMixin from '../../mixins/valueMixin';
+import valueMixin from '../../mixins/valueMixin'
export default {
name: 'RequestUserAgent',
@@ -103,7 +104,7 @@ export default {
return {
icon: 'icon-settings-dark',
label: t('workflowengine', 'Custom user agent'),
- pattern: this.newValue,
+ pattern: this.newValue
}
}
},
diff --git a/apps/workflowengine/src/components/Checks/RequestUserGroup.vue b/apps/workflowengine/src/components/Checks/RequestUserGroup.vue
new file mode 100644
index 00000000000..843bbf127e0
--- /dev/null
+++ b/apps/workflowengine/src/components/Checks/RequestUserGroup.vue
@@ -0,0 +1,77 @@
+<!--
+ - @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
+ -
+ - @author Julius Härtl <jus@bitgrid.net>
+ -
+ - @license GNU AGPL version 3 or any later version
+ -
+ - This program is free software: you can redistribute it and/or modify
+ - it under the terms of the GNU Affero General Public License as
+ - published by the Free Software Foundation, either version 3 of the
+ - License, or (at your option) any later version.
+ -
+ - This program is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ - GNU Affero General Public License for more details.
+ -
+ - You should have received a copy of the GNU Affero General Public License
+ - along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -
+ -->
+
+<template>
+ <div>
+ <Multiselect v-model="newValue"
+ :class="{'icon-loading-small': groups.length === 0}" :options="groups"
+ :multiple="false"
+ label="displayname" track-by="id"
+ @input="setValue" />
+ </div>
+</template>
+
+<script>
+import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
+import valueMixin from '../../mixins/valueMixin'
+import axios from 'nextcloud-axios'
+export default {
+ name: 'RequestUserGroup',
+ components: {
+ Multiselect
+ },
+ mixins: [
+ valueMixin
+ ],
+ data() {
+ return {
+ groups: []
+ }
+ },
+ beforeMount() {
+ axios.get(OC.linkToOCS('cloud', 2) + 'groups').then((response) => {
+ this.groups = response.data.ocs.data.groups.reduce((obj, item) => {
+ obj.push({
+ id: item,
+ displayname: item
+ })
+ return obj
+ }, [])
+ this.updateInternalValue(this.value)
+ }, (error) => {
+ console.error('Error while loading group list', error.response)
+ })
+ },
+ methods: {
+ updateInternalValue() {
+ this.newValue = this.groups.find(group => group.id === this.value) || null
+ },
+ setValue(value) {
+ if (value !== null) {
+ this.$emit('input', this.newValue.id)
+ }
+ }
+ }
+}
+</script>
+
+<style scoped src="./../../css/multiselect.css"></style>
diff --git a/apps/workflowengine/src/components/Checks/file.js b/apps/workflowengine/src/components/Checks/file.js
index 431a3f93580..80bd120079f 100644
--- a/apps/workflowengine/src/components/Checks/file.js
+++ b/apps/workflowengine/src/components/Checks/file.js
@@ -22,7 +22,7 @@
import FileMimeType from './FileMimeType'
import { stringValidator, validateIPv4, validateIPv6 } from './../../helpers/validators'
-import FileSystemTag from './FileSystemTag';
+import FileSystemTag from './FileSystemTag'
const FileChecks = [
{
class: 'OCA\\WorkflowEngine\\Check\\FileName',
diff --git a/apps/workflowengine/src/components/Checks/request.js b/apps/workflowengine/src/components/Checks/request.js
index ee574f9de90..1059bf45b5a 100644
--- a/apps/workflowengine/src/components/Checks/request.js
+++ b/apps/workflowengine/src/components/Checks/request.js
@@ -23,6 +23,7 @@
import RequestUserAgent from './RequestUserAgent'
import RequestTime from './RequestTime'
import RequestURL from './RequestURL'
+import RequestUserGroup from './RequestUserGroup'
const RequestChecks = [
{
@@ -62,8 +63,8 @@ const RequestChecks = [
operators: [
{ operator: 'is', name: t('workflowengine', 'is member of') },
{ operator: '!is', name: t('workflowengine', 'is not member of') }
- ]
- // TODO: implement component
+ ],
+ component: RequestUserGroup
}
]