Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bc6c05a
Add workflowengine
MorrisJobke Jul 26, 2016
6eabcf1
create an operation based on the correct model
MorrisJobke Jul 26, 2016
497954c
Move template to workflowengine app
MorrisJobke Jul 26, 2016
80eeedc
Add app to provisioning output
nickvergessen Jul 26, 2016
b2e4a8c
fix unit tests
MorrisJobke Jul 26, 2016
01ec62e
fix enabled apps tests
MorrisJobke Jul 27, 2016
155e4ce
Generate the checks list in JS
nickvergessen Jul 26, 2016
6a21289
Remove php side of check registration
nickvergessen Jul 27, 2016
34f46c8
Fix morris comments
nickvergessen Jul 27, 2016
0ebc3bb
Fix default value of operator
nickvergessen Jul 27, 2016
ec8ec17
Allow to reuse the template
nickvergessen Jul 27, 2016
2a4a127
Allow DI of the workflow manager by the OCP interface
nickvergessen Jul 27, 2016
8e0e85c
Fix loading icon for workflowengine
MorrisJobke Jul 27, 2016
f814ef6
Add L10N support
nickvergessen Jul 27, 2016
c425a67
Add workflowengine to check-code call
MorrisJobke Aug 3, 2016
df3ca56
Make sure each plugin is only added once
nickvergessen Jul 27, 2016
7b73c0f
Add the systemtag js files
nickvergessen Jul 27, 2016
7b87935
Add system tag check
nickvergessen Jul 27, 2016
627f243
Add file size as check
nickvergessen Jul 27, 2016
d146df5
Add file mime type
nickvergessen Jul 28, 2016
45c74cd
User agent check
nickvergessen Jul 28, 2016
01d269b
Add Request URL
nickvergessen Jul 28, 2016
af3eaa8
Add remote address
nickvergessen Jul 28, 2016
f1869cd
Add request time
nickvergessen Jul 28, 2016
e978c39
add a UI to render proper time picker
MorrisJobke Jul 29, 2016
66fd216
Load the timezones via select2
nickvergessen Aug 1, 2016
cc719c9
Translate the errors
nickvergessen Aug 1, 2016
c12c083
Tags need to be loaded before
nickvergessen Aug 1, 2016
7d71535
Allow to define the operation
nickvergessen Aug 2, 2016
065763f
No multi support, less magic
nickvergessen Aug 2, 2016
8d23405
Ooops
nickvergessen Aug 2, 2016
fc7bd03
Add access control and automated tagging as shipped
nickvergessen Aug 3, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Generate the checks list in JS
  • Loading branch information
nickvergessen committed Jul 27, 2016
commit 155e4ced3f3955e91d6e4cd41bec3c8d911c0724
74 changes: 39 additions & 35 deletions apps/workflowengine/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,27 @@
});

Handlebars.registerHelper('getOperators', function(classname) {
return OCA.WorkflowEngine.availableChecks
.getOperatorsByClassName(classname);
var check = OCA.WorkflowEngine.getCheckByClass(classname);
if (!_.isUndefined(check)) {
return check['operators'];
}
return [];
});

OCA.WorkflowEngine = OCA.WorkflowEngine || {};
OCA.WorkflowEngine = OCA.WorkflowEngine || {
availablePlugins: [],
availableChecks: [],

getCheckByClass: function(className) {
var length = OCA.WorkflowEngine.availableChecks.length;
for (var i = 0; i < length; i++) {
if (OCA.WorkflowEngine.availableChecks[i]['class'] === className) {
return OCA.WorkflowEngine.availableChecks[i];
}
}
return undefined;
}
};

/**
* 888b d888 888 888
Expand Down Expand Up @@ -86,22 +102,6 @@
url: OC.generateUrl('apps/workflowengine/operations')
});

/**
* @class OCA.WorkflowEngine.AvailableChecksCollection
*
* collection for all available checks
*/
OCA.WorkflowEngine.AvailableChecksCollection =
OC.Backbone.Collection.extend({
model: OCA.WorkflowEngine.AvailableCheck,
url: OC.generateUrl('apps/workflowengine/checks'),
getOperatorsByClassName: function(classname) {
return OCA.WorkflowEngine.availableChecks
.findWhere({'class': classname})
.get('operators');
}
});

/**
* 888 888 d8b
* 888 888 Y8P
Expand Down Expand Up @@ -154,7 +154,6 @@
message: '',
errorMessage: '',
saving: false,
plugins: [],
initialize: function() {
// this creates a new copy of the object to definitely have a new reference and being able to reset the model
this.originalModel = JSON.parse(JSON.stringify(this.model));
Expand All @@ -167,13 +166,6 @@
if (this.model.get('id') === undefined) {
this.hasChanged = true;
}

this.plugins = OC.Plugins.getPlugins('OCA.WorkflowEngine.CheckPlugins');
_.each(this.plugins, function(plugin) {
if (_.isFunction(plugin.initialize)) {
plugin.initialize();
}
});
},
delete: function() {
this.model.destroy();
Expand Down Expand Up @@ -209,9 +201,8 @@
},
add: function() {
var checks = _.clone(this.model.get('checks')),
classname = OCA.WorkflowEngine.availableChecks.at(0).get('class'),
operators = OCA.WorkflowEngine.availableChecks
.getOperatorsByClassName(classname);
classname = OCA.WorkflowEngine.availableChecks[0]['class'],
operators = OCA.WorkflowEngine.availableChecks[0]['operators'];

checks.push({
'class': classname,
Expand Down Expand Up @@ -249,9 +240,10 @@
// if the class is changed most likely also the operators have changed
// with this we set the operator to the first possible operator
if (key === 'class') {
var operators = OCA.WorkflowEngine.availableChecks
.getOperatorsByClassName(value);
checks[id]['operator'] = operators[0];
var check = OCA.WorkflowEngine.getCheckByClass(value);
if (!_.isUndefined(check)) {
checks[id]['operator'] = check['operators'][0];
}
}
// model change will trigger render
this.model.set({'checks': checks});
Expand Down Expand Up @@ -294,7 +286,7 @@
render: function() {
this.$el.html(this.template({
operation: this.model.toJSON(),
classes: OCA.WorkflowEngine.availableChecks.toJSON(),
classes: OCA.WorkflowEngine.availableChecks,
hasChanged: this.hasChanged,
message: this.message,
errorMessage: this.errorMessage,
Expand All @@ -308,7 +300,7 @@
check = checks[id],
valueElement = $element.find('.check-value').first();

_.each(this.plugins, function(plugin) {
_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
if (_.isFunction(plugin.render)) {
plugin.render(valueElement, check['class'], check['value']);
}
Expand All @@ -334,13 +326,25 @@
OCA.WorkflowEngine.OperationsView =
OCA.WorkflowEngine.TemplateView.extend({
templateId: '#operations-template',
collection: null,
$el: null,
events: {
'click .button-add-operation': 'add'
},
initialize: function() {
this._initialize('OCA\\WorkflowEngine\\Operation');
},
_initialize: function(classname) {
OCA.WorkflowEngine.availablePlugins = OC.Plugins.getPlugins('OCA.WorkflowEngine.CheckPlugins');
_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
if (_.isFunction(plugin.initialize)) {
plugin.initialize();
}
if (_.isFunction(plugin.getCheck)) {
OCA.WorkflowEngine.availableChecks.push(plugin.getCheck());
}
});

this.collection.fetch({data: {
'class': classname
}});
Expand Down
10 changes: 10 additions & 0 deletions apps/workflowengine/js/usergroupmembershipplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
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, classname, value) {
if (classname !== 'OCA\\WorkflowEngine\\Check\\UserGroupMembership') {
return;
Expand Down
2 changes: 1 addition & 1 deletion apps/workflowengine/templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</select>
<select class="check-operator">
{{#each (getOperators class)}}
<option value="{{this}}" {{selectItem this ../operator}}>{{this}}</option>
<option value="{{operator}}" {{selectItem this.operator ../operator}}>{{name}}</option>
{{/each}}
</select>
<input type="text" class="check-value" value="{{value}}">
Expand Down