diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-08-29 16:50:33 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-09-10 09:01:23 +0200 |
commit | bd281daa47152dc09c0f6c2bbc9e5a308d1748bd (patch) | |
tree | 73227cf96161871a259688624b5d4f78637fc3d6 /apps/workflowengine/src/legacy | |
parent | aa00f401b39c2b63cba7e5e8f6cdec8528466069 (diff) | |
download | nextcloud-server-bd281daa47152dc09c0f6c2bbc9e5a308d1748bd.tar.gz nextcloud-server-bd281daa47152dc09c0f6c2bbc9e5a308d1748bd.zip |
Move to vuex store
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/workflowengine/src/legacy')
9 files changed, 881 insertions, 0 deletions
diff --git a/apps/workflowengine/src/legacy/filemimetypeplugin.js b/apps/workflowengine/src/legacy/filemimetypeplugin.js new file mode 100644 index 00000000000..2b29c4fcbb8 --- /dev/null +++ b/apps/workflowengine/src/legacy/filemimetypeplugin.js @@ -0,0 +1,77 @@ +/** + * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> + * + * @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/>. + * + */ +import FileMimeType from './../components/Values/FileMimeType' + +(function() { + + OCA.WorkflowEngine = OCA.WorkflowEngine || {} + OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {} + + OCA.WorkflowEngine.Plugins.FileMimeTypePlugin = { + getCheck: function() { + return { + class: 'OCA\\WorkflowEngine\\Check\\FileMimeType', + name: t('workflowengine', 'File MIME type'), + operators: [ + { operator: 'is', name: t('workflowengine', 'is') }, + { operator: '!is', name: t('workflowengine', 'is not') }, + { operator: 'matches', name: t('workflowengine', 'matches') }, + { operator: '!matches', name: t('workflowengine', 'does not match') } + ] + } + }, + render: function(element, check) { + if (check.class !== 'OCA\\WorkflowEngine\\Check\\FileMimeType') { + return + } + + var placeholder = 'text/plain' + if (check.operator === 'matches' || check.operator === '!matches') { + placeholder = '/^text\\/(plain|html)$/i' + + if (this._validateRegex(check.value)) { + $(element).removeClass('invalid-input') + } else { + $(element).addClass('invalid-input') + } + } + + $(element).css('width', '250px') + .attr('placeholder', placeholder) + .attr('title', t('workflowengine', 'Example: {placeholder}', { placeholder: placeholder })) + .addClass('has-tooltip') + .tooltip({ + placement: 'bottom' + }) + }, + + _validateRegex: function(string) { + var regexRegex = /^\/(.*)\/([gui]{0,3})$/ + var result = regexRegex.exec(string) + return result !== null + }, + + component: function() { + return FileMimeType + } + } +})() + +OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileMimeTypePlugin) diff --git a/apps/workflowengine/src/legacy/filenameplugin.js b/apps/workflowengine/src/legacy/filenameplugin.js new file mode 100644 index 00000000000..637e08ccbea --- /dev/null +++ b/apps/workflowengine/src/legacy/filenameplugin.js @@ -0,0 +1,78 @@ +/** + * @copyright Copyright (c) 2018 Daniel Kesselberg <mail@danielkesselberg.de> + * + * @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/>. + * + */ + +(function() { + + OCA.WorkflowEngine = OCA.WorkflowEngine || {} + OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {} + + OCA.WorkflowEngine.Plugins.FileNamePlugin = { + getCheck: function() { + return { + class: 'OCA\\WorkflowEngine\\Check\\FileName', + name: t('workflowengine', 'File name'), + operators: [ + { operator: 'is', name: t('workflowengine', 'is') }, + { operator: '!is', name: t('workflowengine', 'is not') }, + { + operator: 'matches', + name: t('workflowengine', 'matches') + }, + { + operator: '!matches', + name: t('workflowengine', 'does not match') + } + ] + } + }, + render: function(element, check) { + if (check.class !== 'OCA\\WorkflowEngine\\Check\\FileName') { + return + } + + var placeholder = 'dummy.jpg' + if (check.operator === 'matches' || check.operator === '!matches') { + placeholder = '/^dummy-.+$/i' + + if (this._validateRegex(check.value)) { + $(element).removeClass('invalid-input') + } else { + $(element).addClass('invalid-input') + } + } + + $(element).css('width', '250px') + .attr('placeholder', placeholder) + .attr('title', t('workflowengine', 'Example: {placeholder}', { placeholder: placeholder })) + .addClass('has-tooltip') + .tooltip({ + placement: 'bottom' + }) + }, + + _validateRegex: function(string) { + var regexRegex = /^\/(.*)\/([gui]{0,3})$/ + var result = regexRegex.exec(string) + return result !== null + } + } +})() + +OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileNamePlugin) diff --git a/apps/workflowengine/src/legacy/filesizeplugin.js b/apps/workflowengine/src/legacy/filesizeplugin.js new file mode 100644 index 00000000000..fcb81bd3397 --- /dev/null +++ b/apps/workflowengine/src/legacy/filesizeplugin.js @@ -0,0 +1,59 @@ +/** + * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> + * + * @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/>. + * + */ +import SizeValue from './../components/Values/SizeValue' +(function() { + + OCA.WorkflowEngine = OCA.WorkflowEngine || {} + OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {} + + OCA.WorkflowEngine.Plugins.FileSizePlugin = { + getCheck: function() { + return { + class: 'OCA\\WorkflowEngine\\Check\\FileSize', + name: t('workflowengine', 'File size (upload)'), + operators: [ + { operator: 'less', name: t('workflowengine', 'less') }, + { operator: '!greater', name: t('workflowengine', 'less or equals') }, + { operator: '!less', name: t('workflowengine', 'greater or equals') }, + { operator: 'greater', name: t('workflowengine', 'greater') } + ] + } + }, + render: function(element, check) { + if (check.class !== 'OCA\\WorkflowEngine\\Check\\FileSize') { + return + } + + var placeholder = '12 MB' // Do not translate!!! + $(element).css('width', '250px') + .attr('placeholder', placeholder) + .attr('title', t('workflowengine', 'Example: {placeholder}', { placeholder: placeholder })) + .addClass('has-tooltip') + .tooltip({ + placement: 'bottom' + }) + }, + component: function() { + return SizeValue + } + } +})() + +OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileSizePlugin) diff --git a/apps/workflowengine/src/legacy/filesystemtagsplugin.js b/apps/workflowengine/src/legacy/filesystemtagsplugin.js new file mode 100644 index 00000000000..e945c79195c --- /dev/null +++ b/apps/workflowengine/src/legacy/filesystemtagsplugin.js @@ -0,0 +1,78 @@ +/** + * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> + * + * @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/>. + * + */ + +(function() { + + OCA.WorkflowEngine = OCA.WorkflowEngine || {} + OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {} + + OCA.WorkflowEngine.Plugins.FileSystemTagsPlugin = { + getCheck: function() { + this.collection = OC.SystemTags.collection + + return { + class: 'OCA\\WorkflowEngine\\Check\\FileSystemTags', + name: t('workflowengine', 'File system tag'), + operators: [ + { operator: 'is', name: t('workflowengine', 'is tagged with') }, + { operator: '!is', name: t('workflowengine', 'is not tagged with') } + ] + } + }, + render: function(element, check) { + if (check.class !== 'OCA\\WorkflowEngine\\Check\\FileSystemTags') { + return + } + + $(element).css('width', '400px') + + $(element).select2({ + allowClear: false, + multiple: false, + placeholder: t('workflowengine', 'Select tag…'), + query: _.debounce(function(query) { + query.callback({ + results: OC.SystemTags.collection.filterByName(query.term) + }) + }, 100, true), + id: function(element) { + return element.get('id') + }, + initSelection: function(element, callback) { + callback($(element).val()) + }, + formatResult: function(tag) { + return OC.SystemTags.getDescriptiveTag(tag) + }, + formatSelection: function(tagId) { + var tag = OC.SystemTags.collection.get(tagId) + if (!_.isUndefined(tag)) { + return OC.SystemTags.getDescriptiveTag(tag) + } + }, + escapeMarkup: function(m) { + return m + } + }) + } + } +})() + +OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileSystemTagsPlugin) diff --git a/apps/workflowengine/src/legacy/requestremoteaddressplugin.js b/apps/workflowengine/src/legacy/requestremoteaddressplugin.js new file mode 100644 index 00000000000..b6f7d02dd46 --- /dev/null +++ b/apps/workflowengine/src/legacy/requestremoteaddressplugin.js @@ -0,0 +1,83 @@ +/** + * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> + * + * @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/>. + * + */ + +(function() { + + OCA.WorkflowEngine = OCA.WorkflowEngine || {} + OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {} + + OCA.WorkflowEngine.Plugins.RequestRemoteAddressPlugin = { + getCheck: function() { + return { + class: 'OCA\\WorkflowEngine\\Check\\RequestRemoteAddress', + name: t('workflowengine', 'Request remote address'), + operators: [ + { operator: 'matchesIPv4', name: t('workflowengine', 'matches IPv4') }, + { operator: '!matchesIPv4', name: t('workflowengine', 'does not match IPv4') }, + { operator: 'matchesIPv6', name: t('workflowengine', 'matches IPv6') }, + { operator: '!matchesIPv6', name: t('workflowengine', 'does not match IPv6') } + ] + } + }, + render: function(element, check) { + if (check.class !== 'OCA\\WorkflowEngine\\Check\\RequestRemoteAddress') { + return + } + + var placeholder = '127.0.0.1/32' // Do not translate!!! + if (check.operator === 'matchesIPv6' || check.operator === '!matchesIPv6') { + placeholder = '::1/128' // Do not translate!!! + if (this._validateIPv6(check.value)) { + $(element).removeClass('invalid-input') + } else { + $(element).addClass('invalid-input') + } + } else { + if (this._validateIPv4(check.value)) { + $(element).removeClass('invalid-input') + } else { + $(element).addClass('invalid-input') + } + } + + $(element).css('width', '300px') + .attr('placeholder', placeholder) + .attr('title', t('workflowengine', 'Example: {placeholder}', { placeholder: placeholder })) + .addClass('has-tooltip') + .tooltip({ + placement: 'bottom' + }) + }, + + _validateIPv4: function(string) { + var regexRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(3[0-2]|[1-2][0-9]|[1-9])$/ + var result = regexRegex.exec(string) + return result !== null + }, + + _validateIPv6: function(string) { + var regexRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9])$/ + var result = regexRegex.exec(string) + return result !== null + } + } +})() + +OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.RequestRemoteAddressPlugin) diff --git a/apps/workflowengine/src/legacy/requesttimeplugin.js b/apps/workflowengine/src/legacy/requesttimeplugin.js new file mode 100644 index 00000000000..eaeae287da4 --- /dev/null +++ b/apps/workflowengine/src/legacy/requesttimeplugin.js @@ -0,0 +1,196 @@ +/** + * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> + * + * @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/>. + * + */ + +(function() { + + OCA.WorkflowEngine = OCA.WorkflowEngine || {} + OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {} + + OCA.WorkflowEngine.Plugins.RequestTimePlugin = { + timezones: [ + 'Europe/Berlin', + 'Europe/London' + ], + _$element: null, + getCheck: function() { + return { + class: 'OCA\\WorkflowEngine\\Check\\RequestTime', + name: t('workflowengine', 'Request time'), + operators: [ + { operator: 'in', name: t('workflowengine', 'between') }, + { operator: '!in', name: t('workflowengine', 'not between') } + ] + } + }, + render: function(element, check) { + if (check.class !== 'OCA\\WorkflowEngine\\Check\\RequestTime') { + return + } + + var startTime = '09:00' + var endTime = '18:00' + var timezone = jstz.determine().name() + var $element = $(element) + + if (_.isString(check.value) && check.value !== '') { + var value = JSON.parse(check.value) + var splittedStart = value[0].split(' ', 2) + var splittedEnd = value[1].split(' ', 2) + + startTime = splittedStart[0] + endTime = splittedEnd[0] + timezone = splittedStart[1] + } + + var valueJSON = JSON.stringify([startTime + ' ' + timezone, endTime + ' ' + timezone]) + if (check.value !== valueJSON) { + check.value = valueJSON + $element.val(valueJSON) + } + + $element.css('display', 'none') + + $('<input>') + .attr('type', 'text') + .attr('placeholder', t('workflowengine', 'Start')) + .attr('title', t('workflowengine', 'Example: {placeholder}', { placeholder: '16:00' })) + .addClass('has-tooltip') + .tooltip({ + placement: 'bottom' + }) + .addClass('start') + .val(startTime) + .insertBefore($element) + $('<input>') + .attr('type', 'text') + .attr('placeholder', t('workflowengine', 'End')) + .attr('title', t('workflowengine', 'Example: {placeholder}', { placeholder: '16:00' })) + .addClass('has-tooltip') + .tooltip({ + placement: 'bottom' + }) + .addClass('end') + .val(endTime) + .insertBefore($element) + + var timezoneInput = $('<input>') + .attr('type', 'hidden') + .css('width', '250px') + .insertBefore($element) + .val(timezone) + + timezoneInput.select2({ + allowClear: false, + multiple: false, + placeholder: t('workflowengine', 'Select timezone…'), + ajax: { + url: OC.generateUrl('apps/workflowengine/timezones'), + dataType: 'json', + quietMillis: 100, + data: function(term) { + if (term === '') { + // Default search in the same continent... + term = jstz.determine().name().split('/') + term = term[0] + } + return { + search: term + } + }, + results: function(response) { + var results = [] + $.each(response, function(timezone) { + results.push({ id: timezone }) + }) + + return { + results: results, + more: false + } + } + }, + initSelection: function(element, callback) { + callback(element.val()) + }, + formatResult: function(element) { + return '<span>' + element.id + '</span>' + }, + formatSelection: function(element) { + if (!_.isUndefined(element.id)) { + element = element.id + } + return '<span>' + element + '</span>' + } + }) + + // Has to be added after select2 for `event.target.classList` + timezoneInput.addClass('timezone') + + $element.parent() + .on('change', '.start', _.bind(this.update, this)) + .on('change', '.end', _.bind(this.update, this)) + .on('change', '.timezone', _.bind(this.update, this)) + + this._$element = $element + }, + update: function(event) { + var value = event.target.value + var key = null + + for (var i = 0; i < event.target.classList.length; i++) { + key = event.target.classList[i] + } + + if (key === null) { + console.warn('update triggered but element doesn\'t have any class') + return + } + + var data = JSON.parse(this._$element.val()) + var startTime = moment(data[0].split(' ', 2)[0], 'H:m Z') + var endTime = moment(data[1].split(' ', 2)[0], 'H:m Z') + var timezone = data[0].split(' ', 2)[1] + + if (key === 'start' || key === 'end') { + var parsedDate = moment(value, ['H:m', 'h:m a'], true).format('HH:mm') + + if (parsedDate === 'Invalid date') { + return + } + + var indexValue = 0 + if (key === 'end') { + indexValue = 1 + } + data[indexValue] = parsedDate + ' ' + timezone + } + + if (key === 'timezone') { + data[0] = startTime.format('HH:mm') + ' ' + value + data[1] = endTime.format('HH:mm') + ' ' + value + } + + this._$element.val(JSON.stringify(data)) + this._$element.trigger('change') + } + } +})() + +OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.RequestTimePlugin) diff --git a/apps/workflowengine/src/legacy/requesturlplugin.js b/apps/workflowengine/src/legacy/requesturlplugin.js new file mode 100644 index 00000000000..7e13422387f --- /dev/null +++ b/apps/workflowengine/src/legacy/requesturlplugin.js @@ -0,0 +1,116 @@ +/** + * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> + * + * @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/>. + * + */ + +(function() { + + OCA.WorkflowEngine = OCA.WorkflowEngine || {} + OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {} + + OCA.WorkflowEngine.Plugins.RequestURLPlugin = { + predefinedValues: ['webdav'], + getCheck: function() { + return { + class: 'OCA\\WorkflowEngine\\Check\\RequestURL', + name: t('workflowengine', 'Request URL'), + operators: [ + { operator: 'is', name: t('workflowengine', 'is') }, + { operator: '!is', name: t('workflowengine', 'is not') }, + { operator: 'matches', name: t('workflowengine', 'matches') }, + { operator: '!matches', name: t('workflowengine', 'does not match') } + ] + } + }, + render: function(element, check) { + if (check.class !== 'OCA\\WorkflowEngine\\Check\\RequestURL') { + return + } + + var placeholder = 'https://localhost/index.php' + + if (check.operator === 'matches' || check.operator === '!matches') { + placeholder = '/^https\\:\\/\\/localhost\\/index\\.php$/i' + } + + $(element).css('width', '250px') + .attr('placeholder', placeholder) + .attr('title', t('workflowengine', 'Example: {placeholder}', { placeholder: placeholder })) + .addClass('has-tooltip') + .tooltip({ + placement: 'bottom' + }) + + if (check.operator === 'matches' || check.operator === '!matches') { + if (this._validateRegex(check.value)) { + $(element).removeClass('invalid-input') + } else { + $(element).addClass('invalid-input') + } + } else { + var self = this + var data = [ + { + text: t('workflowengine', 'Predefined URLs'), + children: [ + { id: 'webdav', text: t('workflowengine', 'Files WebDAV') } + ] + } + ] + if (this.predefinedValues.indexOf(check.value) === -1) { + data.unshift({ + id: check.value, + text: check.value + }) + } + + $(element).select2({ + data: data, + createSearchChoice: function(term) { + if (self.predefinedValues.indexOf(check.value) === -1) { + return { + id: term, + text: term + } + } + }, + id: function(element) { + return element.id + }, + formatResult: function(tag) { + return tag.text + }, + formatSelection: function(tag) { + return tag.text + }, + escapeMarkup: function(m) { + return m + } + }) + } + }, + + _validateRegex: function(string) { + var regexRegex = /^\/(.*)\/([gui]{0,3})$/ + var result = regexRegex.exec(string) + return result !== null + } + } +})() + +OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.RequestURLPlugin) diff --git a/apps/workflowengine/src/legacy/requestuseragentplugin.js b/apps/workflowengine/src/legacy/requestuseragentplugin.js new file mode 100644 index 00000000000..5480e4ccc8b --- /dev/null +++ b/apps/workflowengine/src/legacy/requestuseragentplugin.js @@ -0,0 +1,119 @@ +/** + * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> + * + * @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/>. + * + */ + +(function() { + + OCA.WorkflowEngine = OCA.WorkflowEngine || {} + OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {} + + OCA.WorkflowEngine.Plugins.RequestUserAgentPlugin = { + predefinedValues: ['android', 'ios', 'desktop'], + getCheck: function() { + return { + class: 'OCA\\WorkflowEngine\\Check\\RequestUserAgent', + name: t('workflowengine', 'Request user agent'), + operators: [ + { operator: 'is', name: t('workflowengine', 'is') }, + { operator: '!is', name: t('workflowengine', 'is not') }, + { operator: 'matches', name: t('workflowengine', 'matches') }, + { operator: '!matches', name: t('workflowengine', 'does not match') } + ] + } + }, + render: function(element, check) { + if (check.class !== 'OCA\\WorkflowEngine\\Check\\RequestUserAgent') { + return + } + + var placeholder = 'Mozilla/5.0 User Agent' + + if (check.operator === 'matches' || check.operator === '!matches') { + placeholder = '/^Mozilla\\/5\\.0 (.*)$/i' + } + + $(element).css('width', '250px') + .attr('placeholder', placeholder) + .attr('title', t('workflowengine', 'Example: {placeholder}', { placeholder: placeholder })) + .addClass('has-tooltip') + .tooltip({ + placement: 'bottom' + }) + + if (check.operator === 'matches' || check.operator === '!matches') { + if (this._validateRegex(check.value)) { + $(element).removeClass('invalid-input') + } else { + $(element).addClass('invalid-input') + } + } else { + var self = this + var data = [ + { + text: t('workflowengine', 'Sync clients'), + children: [ + { id: 'android', text: t('workflowengine', 'Android client') }, + { id: 'ios', text: t('workflowengine', 'iOS client') }, + { id: 'desktop', text: t('workflowengine', 'Desktop client') }, + { id: 'mail', text: t('workflowengine', 'Thunderbird & Outlook addons') } + ] + } + ] + if (this.predefinedValues.indexOf(check.value) === -1) { + data.unshift({ + id: check.value, + text: check.value + }) + } + + $(element).select2({ + data: data, + createSearchChoice: function(term) { + if (self.predefinedValues.indexOf(check.value) === -1) { + return { + id: term, + text: term + } + } + }, + id: function(element) { + return element.id + }, + formatResult: function(tag) { + return tag.text + }, + formatSelection: function(tag) { + return tag.text + }, + escapeMarkup: function(m) { + return m + } + }) + } + }, + + _validateRegex: function(string) { + var regexRegex = /^\/(.*)\/([gui]{0,3})$/ + var result = regexRegex.exec(string) + return result !== null + } + } +})() + +OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.RequestUserAgentPlugin) diff --git a/apps/workflowengine/src/legacy/usergroupmembershipplugin.js b/apps/workflowengine/src/legacy/usergroupmembershipplugin.js new file mode 100644 index 00000000000..6d60e9e4d66 --- /dev/null +++ b/apps/workflowengine/src/legacy/usergroupmembershipplugin.js @@ -0,0 +1,75 @@ +/** + * @copyright Copyright (c) 2016 Morris Jobke <hey@morrisjobke.de> + * + * @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/>. + * + */ + +(function() { + + OCA.WorkflowEngine = OCA.WorkflowEngine || {} + OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {} + + OCA.WorkflowEngine.Plugins.UserGroupMembershipPlugin = { + getCheck: function() { + return { + class: 'OCA\\WorkflowEngine\\Check\\UserGroupMembership', + name: t('workflowengine', 'User group membership'), + operators: [ + { operator: 'is', name: t('workflowengine', 'is member of') }, + { operator: '!is', name: t('workflowengine', 'is not member of') } + ] + } + }, + render: function(element, check, groups) { + if (check.class !== 'OCA\\WorkflowEngine\\Check\\UserGroupMembership') { + return + } + + $(element).css('width', '400px') + + $(element).select2({ + data: { results: groups, text: 'displayname' }, + initSelection: function(element, callback) { + var groupId = element.val() + if (groupId && groups.length > 0) { + callback({ + id: groupId, + displayname: groups.find(function(group) { + return group.id === groupId + }).displayname + }) + } else if (groupId) { + callback({ + id: groupId, + displayname: groupId + }) + } else { + callback() + } + }, + formatResult: function(element) { + return '<span>' + escapeHTML(element.displayname) + '</span>' + }, + formatSelection: function(element) { + return '<span title="' + escapeHTML(element.id) + '">' + escapeHTML(element.displayname) + '</span>' + } + }) + } + } +})() + +OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.UserGroupMembershipPlugin) |