From ad976c66fd9a78e6d90224091634b04a25a08f40 Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Tue, 6 Aug 2019 17:40:30 +0200 Subject: Unified workflow management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/workflowengine/src/admin.js | 2 +- apps/workflowengine/src/components/Check.vue | 104 ++++++++++ apps/workflowengine/src/components/Event.vue | 84 +++++++++ apps/workflowengine/src/components/Operation.vue | 83 ++++++++ .../src/components/Operations/ConvertToPdf.vue | 45 +++++ .../src/components/Operations/Tag.vue | 29 +++ apps/workflowengine/src/components/Rule.vue | 209 +++++++++++++++++++++ .../src/components/Values/FileMimeType.vue | 39 ++++ .../src/components/Values/SizeValue.vue | 28 +++ apps/workflowengine/src/components/Workflow.vue | 146 ++++++++++++++ apps/workflowengine/src/filemimetypeplugin.js | 5 + apps/workflowengine/src/filesizeplugin.js | 5 +- apps/workflowengine/src/services/Operation.js | 141 ++++++++++++++ apps/workflowengine/src/workflowengine.js | 9 +- 14 files changed, 926 insertions(+), 3 deletions(-) create mode 100644 apps/workflowengine/src/components/Check.vue create mode 100644 apps/workflowengine/src/components/Event.vue create mode 100644 apps/workflowengine/src/components/Operation.vue create mode 100644 apps/workflowengine/src/components/Operations/ConvertToPdf.vue create mode 100644 apps/workflowengine/src/components/Operations/Tag.vue create mode 100644 apps/workflowengine/src/components/Rule.vue create mode 100644 apps/workflowengine/src/components/Values/FileMimeType.vue create mode 100644 apps/workflowengine/src/components/Values/SizeValue.vue create mode 100644 apps/workflowengine/src/components/Workflow.vue create mode 100644 apps/workflowengine/src/services/Operation.js (limited to 'apps/workflowengine/src') diff --git a/apps/workflowengine/src/admin.js b/apps/workflowengine/src/admin.js index 92f485a8b4c..fb2af941436 100644 --- a/apps/workflowengine/src/admin.js +++ b/apps/workflowengine/src/admin.js @@ -382,4 +382,4 @@ import OperationsTemplate from './templates/operations.handlebars'; this.collection.each(this.renderOperation, this); } }); -})(); +})(); \ No newline at end of file diff --git a/apps/workflowengine/src/components/Check.vue b/apps/workflowengine/src/components/Check.vue new file mode 100644 index 00000000000..c8c7c46aa87 --- /dev/null +++ b/apps/workflowengine/src/components/Check.vue @@ -0,0 +1,104 @@ + + + + + \ No newline at end of file diff --git a/apps/workflowengine/src/components/Event.vue b/apps/workflowengine/src/components/Event.vue new file mode 100644 index 00000000000..fd5097cecfc --- /dev/null +++ b/apps/workflowengine/src/components/Event.vue @@ -0,0 +1,84 @@ + + + + + \ No newline at end of file diff --git a/apps/workflowengine/src/components/Operation.vue b/apps/workflowengine/src/components/Operation.vue new file mode 100644 index 00000000000..f7a8f56cede --- /dev/null +++ b/apps/workflowengine/src/components/Operation.vue @@ -0,0 +1,83 @@ + + + + + \ No newline at end of file diff --git a/apps/workflowengine/src/components/Operations/ConvertToPdf.vue b/apps/workflowengine/src/components/Operations/ConvertToPdf.vue new file mode 100644 index 00000000000..62c53a4ee6c --- /dev/null +++ b/apps/workflowengine/src/components/Operations/ConvertToPdf.vue @@ -0,0 +1,45 @@ + + + + + \ No newline at end of file diff --git a/apps/workflowengine/src/components/Operations/Tag.vue b/apps/workflowengine/src/components/Operations/Tag.vue new file mode 100644 index 00000000000..74e4e4f977b --- /dev/null +++ b/apps/workflowengine/src/components/Operations/Tag.vue @@ -0,0 +1,29 @@ + + + + + \ No newline at end of file diff --git a/apps/workflowengine/src/components/Rule.vue b/apps/workflowengine/src/components/Rule.vue new file mode 100644 index 00000000000..818e15610fa --- /dev/null +++ b/apps/workflowengine/src/components/Rule.vue @@ -0,0 +1,209 @@ + + + + + \ No newline at end of file diff --git a/apps/workflowengine/src/components/Values/FileMimeType.vue b/apps/workflowengine/src/components/Values/FileMimeType.vue new file mode 100644 index 00000000000..70b8f0d984b --- /dev/null +++ b/apps/workflowengine/src/components/Values/FileMimeType.vue @@ -0,0 +1,39 @@ + + + + + \ No newline at end of file diff --git a/apps/workflowengine/src/components/Values/SizeValue.vue b/apps/workflowengine/src/components/Values/SizeValue.vue new file mode 100644 index 00000000000..bc4378702e1 --- /dev/null +++ b/apps/workflowengine/src/components/Values/SizeValue.vue @@ -0,0 +1,28 @@ + + + + + \ No newline at end of file diff --git a/apps/workflowengine/src/components/Workflow.vue b/apps/workflowengine/src/components/Workflow.vue new file mode 100644 index 00000000000..9993b328827 --- /dev/null +++ b/apps/workflowengine/src/components/Workflow.vue @@ -0,0 +1,146 @@ + + + + + \ No newline at end of file diff --git a/apps/workflowengine/src/filemimetypeplugin.js b/apps/workflowengine/src/filemimetypeplugin.js index 17c092d209f..6b929b2aad5 100644 --- a/apps/workflowengine/src/filemimetypeplugin.js +++ b/apps/workflowengine/src/filemimetypeplugin.js @@ -17,6 +17,7 @@ * along with this program. If not, see . * */ +import FileMimeType from './components/Values/FileMimeType' (function() { @@ -65,6 +66,10 @@ var regexRegex = /^\/(.*)\/([gui]{0,3})$/, result = regexRegex.exec(string); return result !== null; + }, + + component: function () { + return FileMimeType } }; })(); diff --git a/apps/workflowengine/src/filesizeplugin.js b/apps/workflowengine/src/filesizeplugin.js index 0efa9d00edf..ebd72dcd2f4 100644 --- a/apps/workflowengine/src/filesizeplugin.js +++ b/apps/workflowengine/src/filesizeplugin.js @@ -17,7 +17,7 @@ * along with this program. If not, see . * */ - +import SizeValue from './components/Values/SizeValue' (function() { OCA.WorkflowEngine = OCA.WorkflowEngine || {}; @@ -49,6 +49,9 @@ .tooltip({ placement: 'bottom' }); + }, + component: function () { + return SizeValue } }; })(); diff --git a/apps/workflowengine/src/services/Operation.js b/apps/workflowengine/src/services/Operation.js new file mode 100644 index 00000000000..1de7d2a95ad --- /dev/null +++ b/apps/workflowengine/src/services/Operation.js @@ -0,0 +1,141 @@ +import ConvertToPdf from './../components/Operations/ConvertToPdf' +import Tag from './../components/Operations/Tag' +class OperationService { + + constructor() { + this.operations = {} + } + registerOperation (operation) { + this.operations[operation.class] = Object.assign({ + color: 'var(--color-primary)' + }, operation) + } + + getAll() { + return this.operations + } + + get(className) { + return this.operations[className] + } + +} + +class EventService { + + constructor() { + this.events = {} + } + registerEvent(event) { + this.events[event.id] = event + } + + getAll() { + return this.events + } + + get(id) { + return this.events[id] + } + +} + +const operationService = new OperationService() +const eventService = new EventService() + + +const ALL_CHECKS = [ + 'OCA\\WorkflowEngine\\Check\\FileMimeType', + 'OCA\\WorkflowEngine\\Check\\FileName', + 'OCA\\WorkflowEngine\\Check\\FileSize', + 'OCA\\WorkflowEngine\\Check\\FileSystemTags', + 'OCA\\WorkflowEngine\\Check\\RequestRemoteAddress', + 'OCA\\WorkflowEngine\\Check\\RequestTime', + 'OCA\\WorkflowEngine\\Check\\RequestURL', + 'OCA\\WorkflowEngine\\Check\\RequestUserAgent', + 'OCA\\WorkflowEngine\\Check\\UserGroupMembership' +] + +/** + * TODO: move to separate apps + * TODO: fetch from initial state api + **/ +const EVENT_FILE_ACCESS = 'EVENT_FILE_ACCESS' +const EVENT_FILE_CHANGED = 'EVENT_FILE_CHANGED' +const EVENT_FILE_TAGGED = 'EVENT_FILE_TAGGED' + +eventService.registerEvent({ + id: EVENT_FILE_ACCESS, + name: 'File is accessed', + icon: 'icon-desktop', + checks: ALL_CHECKS, +}) + +eventService.registerEvent({ + id: EVENT_FILE_CHANGED, + name: 'File was updated', + icon: 'icon-folder', + checks: ALL_CHECKS, +}) + + +eventService.registerEvent({ + id: EVENT_FILE_TAGGED, + name: 'File was tagged', + icon: 'icon-tag', + checks: ALL_CHECKS, +}) + +operationService.registerOperation({ + class: 'OCA\\FilesAccessControl\\Operation', + title: 'Block access', + description: 'todo', + icon: 'icon-block', + color: 'var(--color-error)', + events: [ + EVENT_FILE_ACCESS + ], + operation: 'deny' +}) + +operationService.registerOperation({ + class: 'OCA\\FilesAutomatedTagging\\Operation', + title: 'Tag a file', + description: 'todo', + icon: 'icon-tag', + events: [ + EVENT_FILE_CHANGED, + EVENT_FILE_TAGGED + ], + options: Tag + +}) + +operationService.registerOperation({ + class: 'OCA\\WorkflowPDFConverter\\Operation', + title: 'Convert to PDF', + description: 'todo', + color: '#dc5047', + icon: 'icon-convert-pdf', + events: [ + EVENT_FILE_CHANGED, + //EVENT_FILE_TAGGED + ], + options: ConvertToPdf +}) + + +const legacyChecks = Object.values(OCA.WorkflowEngine.Plugins).map((plugin) => { + if (plugin.component) { + return {...plugin.getCheck(), component: plugin.component} + } + return plugin.getCheck() +}).reduce((obj, item) => { + obj[item.class] = item + return obj +}, {}) + +export { + eventService, + operationService +} \ No newline at end of file diff --git a/apps/workflowengine/src/workflowengine.js b/apps/workflowengine/src/workflowengine.js index 207d2311bcc..6c7af2a446e 100644 --- a/apps/workflowengine/src/workflowengine.js +++ b/apps/workflowengine/src/workflowengine.js @@ -1,4 +1,3 @@ -import './admin' import './filemimetypeplugin' import './filenameplugin' import './filesizeplugin' @@ -10,3 +9,11 @@ import './requestuseragentplugin' import './usergroupmembershipplugin' window.OCA.WorkflowEngine = OCA.WorkflowEngine + +import Vue from 'vue'; + +Vue.prototype.t = t; + +import Settings from './components/Workflow'; +const View = Vue.extend(Settings) +new View({}).$mount('#workflowengine') \ No newline at end of file -- cgit v1.2.3