-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add more checks #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add more checks #611
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6430164
Make sure each plugin is only added once
nickvergessen 306d725
Add the systemtag js files
nickvergessen c6bf641
Add system tag check
nickvergessen 136a1a4
Add file size as check
nickvergessen 8a75334
Add file mime type
nickvergessen 477e79c
User agent check
nickvergessen 1091cbb
Add Request URL
nickvergessen 2cfd67e
Add remote address
nickvergessen e0b5949
Add request time
nickvergessen 2734ff7
add a UI to render proper time picker
MorrisJobke ea4c6bd
Load the timezones via select2
nickvergessen 6aa5d67
Translate the errors
nickvergessen 7c1560d
Tags need to be loaded before
nickvergessen 62d009a
Allow to define the operation
nickvergessen 248020f
No multi support, less magic
nickvergessen bcf022c
Ooops
nickvergessen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,3 +46,7 @@ | |
| margin-right: 5px; | ||
| } | ||
|
|
||
| .workflowengine .invalid-input { | ||
| border-color: #aa0000; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /** | ||
| * @copyright Copyright (c) 2016 Joas Schilling <[email protected]> | ||
| * | ||
| * @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.FileMimeTypePlugin = { | ||
| getCheck: function() { | ||
| return { | ||
| 'class': 'OCA\\WorkflowEngine\\Check\\FileMimeType', | ||
| 'name': t('workflowengine', 'File mime type (upload)'), | ||
| '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 = t('workflowengine', 'text/plain'); | ||
| if (check['operator'] === 'matches' || check['operator'] === '!matches') { | ||
| placeholder = t('workflowengine', '/^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})$/, | ||
| result = regexRegex.exec(string); | ||
| return result !== null; | ||
| } | ||
| }; | ||
| })(); | ||
|
|
||
| OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileMimeTypePlugin); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /** | ||
| * @copyright Copyright (c) 2016 Joas Schilling <[email protected]> | ||
| * | ||
| * @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.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' | ||
| }); | ||
| } | ||
| }; | ||
| })(); | ||
|
|
||
| OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileSizePlugin); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /** | ||
| * @copyright Copyright (c) 2016 Joas Schilling <[email protected]> | ||
| * | ||
| * @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); | ||
| return OC.SystemTags.getDescriptiveTag(tag); | ||
| }, | ||
| escapeMarkup: function(m) { | ||
| return m; | ||
| } | ||
| }); | ||
| } | ||
| }; | ||
| })(); | ||
|
|
||
| OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileSystemTagsPlugin); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice 👍