Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8089A173D7 for ; Tue, 26 Jan 2016 11:25:23 +0000 (UTC) Received: (qmail 51429 invoked by uid 500); 26 Jan 2016 11:25:23 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 51392 invoked by uid 500); 26 Jan 2016 11:25:23 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 51335 invoked by uid 99); 26 Jan 2016 11:25:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Jan 2016 11:25:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 16F3AE02D3; Tue, 26 Jan 2016 11:25:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anovikov@apache.org To: commits@ignite.apache.org Date: Tue, 26 Jan 2016 11:25:26 -0000 Message-Id: <8cb55f65c75c4a11a04fc6d3aa5dad73@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [5/5] ignite git commit: IGNITE-2253 refactoring fields on clusters page - Fixes #411. IGNITE-2253 refactoring fields on clusters page - Fixes #411. Signed-off-by: Andrey Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b9e62281 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b9e62281 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b9e62281 Branch: refs/heads/ignite-843-rc2 Commit: b9e62281a85241717dc62fcb74e3f685097b2c28 Parents: 1dccb65 Author: Dmitriyff Authored: Tue Jan 26 18:25:32 2016 +0700 Committer: Andrey Committed: Tue Jan 26 18:25:32 2016 +0700 ---------------------------------------------------------------------- .../control-center-web/src/main/js/.gitignore | 4 +- .../src/main/js/app/data/java-classes.json | 15 + .../main/js/app/data/java-fullname-classes.json | 15 + .../src/main/js/app/data/java-keywords.json | 55 + .../form-field-java-class.directive.js | 54 + .../form-field-java-class.jade | 35 + .../ui-ace-pojos/ui-ace-pojos.controller.js | 4 +- .../control-center-web/src/main/js/app/index.js | 2 + .../js/app/modules/Form/field/down.directive.js | 45 + .../modules/Form/field/dropdown.directive.js | 29 +- .../js/app/modules/Form/field/dropdown.jade | 30 +- .../main/js/app/modules/Form/field/field.css | 6 + .../app/modules/Form/field/field.directive.js | 10 +- .../main/js/app/modules/Form/field/field.jade | 13 +- .../Form/field/input/autofocus.directive.js | 30 + .../Form/field/input/checkbox.directive.js | 60 + .../app/modules/Form/field/input/checkbox.jade | 28 + .../Form/field/input/datalist.directive.js | 57 + .../app/modules/Form/field/input/datalist.jade | 33 + .../Form/field/input/number.directive.js | 20 +- .../js/app/modules/Form/field/input/number.jade | 15 +- .../js/app/modules/Form/field/input/text.css | 24 + .../modules/Form/field/input/text.directive.js | 75 + .../js/app/modules/Form/field/input/text.jade | 39 + .../app/modules/Form/field/label.directive.js | 36 + .../app/modules/Form/field/tooltip.directive.js | 44 + .../js/app/modules/Form/field/up.directive.js | 46 + .../js/app/modules/Form/group/add.directive.js | 40 + .../app/modules/Form/group/group.directive.js | 57 + .../main/js/app/modules/Form/group/group.jade | 21 + .../app/modules/Form/group/table.directive.js | 29 + .../main/js/app/modules/Form/group/table.jade | 17 + .../app/modules/Form/group/tooltip.directive.js | 40 + .../src/main/js/app/modules/Form/index.js | 56 + .../app/modules/Form/panel/chevron.directive.js | 53 + .../app/modules/Form/panel/panel.directive.js | 37 + .../app/modules/Form/panel/revert.directive.js | 52 + .../validator/java-built-in-class.directive.js | 31 + .../Form/validator/java-identifier.directive.js | 31 + .../Form/validator/java-keywords.directive.js | 31 + .../validator/java-package-name.directive.js | 31 + .../java-package-specified.directive.js | 33 + .../modules/Form/validator/unique.directive.js | 36 + .../src/main/js/app/modules/JavaTypes/index.js | 56 +- .../configuration/clusters/atomic.directive.js | 27 + .../states/configuration/clusters/atomic.jade | 86 + .../configuration/clusters/binary.directive.js | 27 + .../states/configuration/clusters/binary.jade | 142 ++ .../clusters/communication.directive.js | 27 + .../configuration/clusters/communication.jade | 340 +++ .../clusters/connector.directive.js | 27 + .../configuration/clusters/connector.jade | 281 +++ .../clusters/deployment.directive.js | 27 + .../configuration/clusters/deployment.jade | 189 ++ .../clusters/discovery.directive.js | 27 + .../configuration/clusters/discovery.jade | 314 +++ .../configuration/clusters/events.directive.js | 27 + .../states/configuration/clusters/events.jade | 59 + .../configuration/clusters/general.directive.js | 27 + .../states/configuration/clusters/general.jade | 111 + .../general/discovery/cloud.directive.js | 27 + .../clusters/general/discovery/cloud.jade | 233 +++ .../general/discovery/google.directive.js | 27 + .../clusters/general/discovery/google.jade | 70 + .../general/discovery/jdbc.directive.js | 27 + .../clusters/general/discovery/jdbc.jade | 29 + .../general/discovery/multicast.directive.js | 27 + .../clusters/general/discovery/multicast.jade | 177 ++ .../clusters/general/discovery/s3.directive.js | 27 + .../clusters/general/discovery/s3.jade | 33 + .../general/discovery/shared.directive.js | 27 + .../clusters/general/discovery/shared.jade | 29 + .../clusters/general/discovery/vm.directive.js | 27 + .../clusters/general/discovery/vm.jade | 113 + .../configuration/clusters/igfs.directive.js | 27 + .../states/configuration/clusters/igfs.jade | 59 + .../clusters/marshaller.directive.js | 27 + .../configuration/clusters/marshaller.jade | 137 ++ .../configuration/clusters/metrics.directive.js | 27 + .../states/configuration/clusters/metrics.jade | 92 + .../configuration/clusters/ssl.directive.js | 27 + .../states/configuration/clusters/ssl.jade | 236 +++ .../configuration/clusters/swap.directive.js | 27 + .../states/configuration/clusters/swap.jade | 134 ++ .../configuration/clusters/thread.directive.js | 27 + .../states/configuration/clusters/thread.jade | 94 + .../configuration/clusters/time.directive.js | 27 + .../states/configuration/clusters/time.jade | 96 + .../clusters/transactions.directive.js | 27 + .../configuration/clusters/transactions.jade | 128 ++ .../app/modules/states/configuration/index.js | 60 + .../configuration/summary/summary.controller.js | 4 +- .../main/js/controllers/caches-controller.js | 7 +- .../main/js/controllers/clusters-controller.js | 207 +- .../main/js/controllers/domains-controller.js | 4 +- .../src/main/js/controllers/igfs-controller.js | 4 +- .../src/main/js/controllers/models/caches.json | 4 +- .../main/js/controllers/models/clusters.json | 1934 ------------------ .../src/main/js/controllers/models/domains.json | 2 +- .../src/main/js/controllers/models/igfs.json | 2 +- .../src/main/js/gulpfile.js/tasks/connect.js | 2 + .../src/main/js/public/stylesheets/style.scss | 2 +- .../main/js/views/configuration/clusters.jade | 63 +- .../main/js/views/configuration/summary.jade | 6 +- .../src/main/js/views/includes/controls.jade | 2 +- 105 files changed, 5476 insertions(+), 2105 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/.gitignore ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/.gitignore b/modules/control-center-web/src/main/js/.gitignore index d0e9143..05d5693 100644 --- a/modules/control-center-web/src/main/js/.gitignore +++ b/modules/control-center-web/src/main/js/.gitignore @@ -2,7 +2,7 @@ node_modules jspm_packages *.idea *.log -*.css .npmrc build -app/plugins \ No newline at end of file +app/plugins +public/stylesheets/*.css \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/data/java-classes.json ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/data/java-classes.json b/modules/control-center-web/src/main/js/app/data/java-classes.json new file mode 100644 index 0000000..414b7bc --- /dev/null +++ b/modules/control-center-web/src/main/js/app/data/java-classes.json @@ -0,0 +1,15 @@ +[ + "BigDecimal", + "Boolean", + "Byte", + "Date", + "Double", + "Float", + "Integer", + "Long", + "Short", + "String", + "Time", + "Timestamp", + "UUID" +] http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/data/java-fullname-classes.json ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/data/java-fullname-classes.json b/modules/control-center-web/src/main/js/app/data/java-fullname-classes.json new file mode 100644 index 0000000..f8768a4 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/data/java-fullname-classes.json @@ -0,0 +1,15 @@ +[ + "java.math.BigDecimal", + "java.lang.Boolean", + "java.lang.Byte", + "java.sql.Date", + "java.lang.Double", + "java.lang.Float", + "java.lang.Integer", + "java.lang.Long", + "java.lang.Short", + "java.lang.String", + "java.sql.Time", + "java.sql.Timestamp", + "java.util.UUID" +] http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/data/java-keywords.json ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/data/java-keywords.json b/modules/control-center-web/src/main/js/app/data/java-keywords.json new file mode 100644 index 0000000..a2d5ec2 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/data/java-keywords.json @@ -0,0 +1,55 @@ +[ + "abstract", + "assert", + "boolean", + "break", + "byte", + "case", + "catch", + "char", + "class", + "const", + "continue", + "default", + "do", + "double", + "else", + "enum", + "extends", + "false", + "final", + "finally", + "float", + "for", + "goto", + "if", + "implements", + "import", + "instanceof", + "int", + "interface", + "long", + "native", + "new", + "null", + "package", + "private", + "protected", + "public", + "return", + "short", + "static", + "strictfp", + "super", + "switch", + "synchronized", + "this", + "throw", + "throws", + "transient", + "true", + "try", + "void", + "volatile", + "while" +] http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.directive.js b/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.directive.js new file mode 100644 index 0000000..00e6177 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.directive.js @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import template from './form-field-java-class.jade!'; + +export default ['igniteFormFieldJavaClass', ['IgniteFormGUID', (guid) => { + const link = (scope, el, attrs, [form, label]) => { + const {id, name} = scope; + const field = form[name]; + + scope.form = form; + scope.field = field; + label.for = scope.id = id || guid(); + + scope.$watch('required', (required) => { + label.required = required || false; + }); + }; + + return { + restrict: 'E', + scope: { + id: '@', + name: '@', + required: '=ngRequired', + disabled: '=ngDisabled', + unique: '=igniteUnique', + + ngModel: '=', + ngBlur: '&', + + autofocus: '=igniteFormFieldInputAutofocus' + }, + link, + template, + replace: true, + transclude: true, + require: ['^form', '?^igniteFormField'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade b/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade new file mode 100644 index 0000000..5c7b75d --- /dev/null +++ b/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade @@ -0,0 +1,35 @@ +mixin feedback(error, message) + i.fa.fa-exclamation-triangle.form-control-feedback( + ng-show='!form[name].$pristine && form[name].$error.#{error}' + bs-tooltip + data-title='#{message}' + ) + +div + ignite-form-field-input-text( + data-id='{{ id }}' + data-name='{{ name }}' + data-placeholder='Enter fully qualified class name' + + data-ng-model='ngModel' + data-ng-required='required || false' + data-ng-disabled='disabled || false' + + data-java-keywords='true' + data-java-identifier='true' + data-java-package-specified='true' + data-java-built-in-class='true' + + data-ignite-unique='unique' + data-ignite-form-field-input-autofocus='autofocus || false ' + + on-enter='onEnter()' + data-ng-blur='ngBlur()' + ) + span(ng-transclude) + + +feedback('javaIdentifier', 'Trust manager is invalid!') + +feedback('required', 'Trust manager could not be empty!') + +feedback('javaKeywords', 'Trust manager could not contains reserved java keyword: ""!') + +feedback('javaBuiltInClass', 'Trust manager should not be the Java built-in class!') + +feedback('javaPackageSpecified', 'Trust manager does not have package specified!') http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/directives/ui-ace-pojos/ui-ace-pojos.controller.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/directives/ui-ace-pojos/ui-ace-pojos.controller.js b/modules/control-center-web/src/main/js/app/directives/ui-ace-pojos/ui-ace-pojos.controller.js index 177a673..973beaa 100644 --- a/modules/control-center-web/src/main/js/app/directives/ui-ace-pojos/ui-ace-pojos.controller.js +++ b/modules/control-center-web/src/main/js/app/directives/ui-ace-pojos/ui-ace-pojos.controller.js @@ -50,7 +50,7 @@ export default ['$scope', 'IgniteUiAceOnLoad', 'JavaTypes', function($scope, onL const classes = ctrl.classes = []; _.forEach(ctrl.pojos, (pojo) => { - if (pojo.keyType && !JavaTypes.isBuiltInClass(pojo.keyType)) + if (pojo.keyType && JavaTypes.nonBuiltInClass(pojo.keyType)) classes.push(pojo.keyType); classes.push(pojo.valueType); @@ -64,7 +64,7 @@ export default ['$scope', 'IgniteUiAceOnLoad', 'JavaTypes', function($scope, onL const keyType = ctrl.pojos[0].keyType; - ctrl.class = ctrl.class || (JavaTypes.isBuiltInClass(keyType) ? null : keyType) || ctrl.pojos[0].valueType; + ctrl.class = ctrl.class || (JavaTypes.nonBuiltInClass(keyType) ? keyType : null) || ctrl.pojos[0].valueType; }; // Update pojos data. http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/index.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/index.js b/modules/control-center-web/src/main/js/app/index.js index c9611b7..dd8515e 100644 --- a/modules/control-center-web/src/main/js/app/index.js +++ b/modules/control-center-web/src/main/js/app/index.js @@ -88,6 +88,7 @@ import igniteUiAceJava from './directives/ui-ace-java/ui-ace-java.directive'; import igniteUiAcePom from './directives/ui-ace-pom/ui-ace-pom.directive'; import igniteUiAceDocker from './directives/ui-ace-docker/ui-ace-docker.directive'; import igniteUiAcePojos from './directives/ui-ace-pojos/ui-ace-pojos.directive'; +import igniteFormFieldJavaClass from './directives/form-field-java-class/form-field-java-class.directive'; // Services. import IgniteUiAceOnLoad from './services/UiAceOnLoad/service'; @@ -131,6 +132,7 @@ angular .directive(...igniteUiAcePom) .directive(...igniteUiAceDocker) .directive(...igniteUiAcePojos) +.directive(...igniteFormFieldJavaClass) // Services. .service(...IgniteUiAceOnLoad) // Filters. http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/down.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/down.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/field/down.directive.js new file mode 100644 index 0000000..0f21af2 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/down.directive.js @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +const template = ``; + +export default ['igniteFormFieldDown', ['$tooltip', ($tooltip) => { + const link = (scope, $element) => { + $tooltip($element, { title: 'Move item down' }); + + scope.down = () => { + const i = scope.models.indexOf(scope.model); + scope.models.splice(i, 1); + scope.models.splice(i + 1, 0, scope.model); + }; + }; + + return { + restrict: 'E', + scope: { + model: '=ngModel', + models: '=models' + }, + template, + link, + replace: true, + transclude: true, + require: '^form' + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/dropdown.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/dropdown.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/field/dropdown.directive.js index 8bf636c..919da94 100644 --- a/modules/control-center-web/src/main/js/app/modules/Form/field/dropdown.directive.js +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/dropdown.directive.js @@ -18,10 +18,25 @@ import template from './dropdown.jade!'; export default ['igniteFormFieldDropdown', ['IgniteFormGUID', (guid) => { - const link = (scope) => { - const {id} = scope; + const controller = () => {}; + + const link = (scope, $element, attrs, [form]) => { + const {id, name} = scope; scope.id = id || guid(); + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + + const setAsDefault = () => { + if (!form.$pristine) return; + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + }; + + scope.$watch(() => form.$pristine, setAsDefault); + scope.$watch('value', setAsDefault); }; return { @@ -29,11 +44,19 @@ export default ['igniteFormFieldDropdown', ['IgniteFormGUID', (guid) => { scope: { id: '@', name: '@', + value: '=ngModel' + }, + bindToController: { + value: '=ngModel', + placeholder: '@', options: '=', - ngModel: '=' + ngDisabled: '=', + multiple: '=' }, link, template, + controller, + controllerAs: 'dropdown', replace: true, transclude: true, require: ['^form', '?^igniteFormField'] http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/dropdown.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/dropdown.jade b/modules/control-center-web/src/main/js/app/modules/Form/field/dropdown.jade index a2cbafe..ba461d0 100644 --- a/modules/control-center-web/src/main/js/app/modules/Form/field/dropdown.jade +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/dropdown.jade @@ -16,16 +16,36 @@ .input-tip button.select-toggle.form-control( + ng-if='dropdown.multiple' id='{{ id }}' name='{{ name }}' - data-placeholder='{{ placeholder }}' + data-placeholder='{{ dropdown.placeholder }}' bs-select - bs-options='item.value as item.label for item in options' + bs-options='item.value as item.label for item in dropdown.options' + data-multiple="1" - ng-attr-data-container='' - ng-model='ngModel' - ng-class='{ placeholder: ngModel === undefined || ngModel === null}' + ng-model='dropdown.value' + ng-class='{ placeholder: value === undefined || value === null || !value.length }' + ng-disabled='dropdown.ngDisabled' + + tabindex='0' + ) + + button.select-toggle.form-control( + ng-if='!dropdown.multiple' + id='{{ id }}' + name='{{ name }}' + data-placeholder='{{ dropdown.placeholder }}' + + bs-select + bs-options='item.value as item.label for item in dropdown.options' + + ng-model='dropdown.value' + ng-class='{ placeholder: value === undefined || value === null || !value.length }' + ng-disabled='dropdown.ngDisabled' + + tabindex='0' ) span(ng-transclude='') http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/field.css ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/field.css b/modules/control-center-web/src/main/js/app/modules/Form/field/field.css new file mode 100644 index 0000000..66ceb90 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/field.css @@ -0,0 +1,6 @@ +.indexField { + float: left; + line-height: 28px; + margin-right: 5px; + color: #ec1c24; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/field.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/field.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/field/field.directive.js index bacacec..e02bebe 100644 --- a/modules/control-center-web/src/main/js/app/modules/Form/field/field.directive.js +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/field.directive.js @@ -16,16 +16,22 @@ */ import template from './field.jade!'; +import './field.css!'; export default ['igniteFormField', [() => { - const controller = () => {}; + const controller = [function() { + const ctrl = this; + + ctrl.type = ctrl.type || 'external'; + }]; return { restrict: 'E', scope: {}, bindToController: { for: '@', - label: '@' + label: '@', + type: '@' }, template, controller, http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/field.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/field.jade b/modules/control-center-web/src/main/js/app/modules/Form/field/field.jade index b529d21..6d7c04a 100644 --- a/modules/control-center-web/src/main/js/app/modules/Form/field/field.jade +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/field.jade @@ -14,6 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. -div.col-xs-8.col-sm-8.col-md-6 - label.col-xs-6.col-sm-6.col-md-6(for='{{::field.for}}') {{::field.label}}: - div.col-xs-6.col-sm-6.col-md-6(ng-transclude='') +div + div(ng-if='field.type == "external"') + label.col-xs-4.col-sm-4.col-md-4( + for='{{::field.for}}' + class='{{ field.required ? "required" : "" }}' + ) + span(ng-if='field.label') {{::field.label}}: + .col-xs-8.col-sm-8.col-md-8(ng-transclude='') + div(ng-if='field.type == "internal"') + label.col-xs-12.col-sm-12.col-md-12(ng-transclude) http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/input/autofocus.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/input/autofocus.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/field/input/autofocus.directive.js new file mode 100644 index 0000000..eeccc3f --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/input/autofocus.directive.js @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default ['igniteFormFieldInputAutofocus', [() => { + const link = (scope, el, attrs) => { + if (typeof attrs.igniteFormFieldInputAutofocus === 'undefined' || !attrs.igniteFormFieldInputAutofocus) + return; + + el.focus(); + }; + + return { + restrict: 'A', + link + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/input/checkbox.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/input/checkbox.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/field/input/checkbox.directive.js new file mode 100644 index 0000000..d259718 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/input/checkbox.directive.js @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import template from './checkbox.jade!'; + +export default ['igniteFormFieldInputCheckbox', ['IgniteFormGUID', (guid) => { + const link = (scope, el, attrs, [form, label]) => { + const {id, name} = scope; + const field = form[name]; + + scope.field = field; + label.for = scope.id = id || guid(); + + label.type = 'internal'; + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + + const setAsDefault = () => { + if (!form.$pristine) return; + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + }; + + scope.$watch(() => form.$pristine, setAsDefault); + scope.$watch('value', setAsDefault); + }; + + return { + restrict: 'E', + scope: { + id: '@', + name: '@', + required: '=ngRequired', + disabled: '=ngDisabled', + + value: '=ngModel' + }, + link, + template, + replace: true, + transclude: true, + require: ['^form', '?^igniteFormField'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/input/checkbox.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/input/checkbox.jade b/modules/control-center-web/src/main/js/app/modules/Form/field/input/checkbox.jade new file mode 100644 index 0000000..c3cd283 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/input/checkbox.jade @@ -0,0 +1,28 @@ +//- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +.input-tip + input( + id='{{ id }}' + name='{{ name }}' + type='checkbox' + + data-ng-model='value' + data-ng-required='required || false' + data-ng-disabled='disabled || false' + ) + + span(ng-transclude='') http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/input/datalist.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/input/datalist.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/field/input/datalist.directive.js new file mode 100644 index 0000000..9627965 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/input/datalist.directive.js @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import template from './datalist.jade!'; + +export default ['igniteFormFieldInputDatalist', ['IgniteFormGUID', (guid) => { + const link = (scope, $element, attrs, [form]) => { + const {id, name} = scope; + + scope.id = id || guid(); + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + + const setAsDefault = () => { + if (!form.$pristine) return; + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + }; + + scope.$watch(() => form.$pristine, setAsDefault); + scope.$watch('value', setAsDefault); + }; + + return { + restrict: 'E', + scope: { + id: '@', + name: '@', + placeholder: '@', + disabled: '=ngDisabled', + + options: '=', + value: '=ngModel' + }, + link, + template, + replace: true, + transclude: true, + require: ['^form', '?^igniteFormField'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/input/datalist.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/input/datalist.jade b/modules/control-center-web/src/main/js/app/modules/Form/field/input/datalist.jade new file mode 100644 index 0000000..1002d03 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/input/datalist.jade @@ -0,0 +1,33 @@ +//- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +.input-tip + input.form-control( + id='{{ id }}' + name='{{ name }}' + placeholder='{{ placeholder }}' + data-min-length='1' + + bs-typeahead + bs-options='item for item in options' + retain-selection + container='body' + + data-ng-model='value' + data-ng-disabled='disabled || false' + ) + + span(ng-transclude='') http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/input/number.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/input/number.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/field/input/number.directive.js index f06e189..b88425f 100644 --- a/modules/control-center-web/src/main/js/app/modules/Form/field/input/number.directive.js +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/input/number.directive.js @@ -24,6 +24,19 @@ export default ['igniteFormFieldInputNumber', ['IgniteFormGUID', (guid) => { scope.field = field; label.for = scope.id = id || guid(); + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + + const setAsDefault = () => { + if (!form.$pristine) return; + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + }; + + scope.$watch(() => form.$pristine, setAsDefault); + scope.$watch('value', setAsDefault); }; return { @@ -32,7 +45,12 @@ export default ['igniteFormFieldInputNumber', ['IgniteFormGUID', (guid) => { id: '@', name: '@', placeholder: '@', - ngModel: '=' + required: '=ngRequired', + disabled: '=ngDisabled', + + min: '@', + max: '@', + value: '=ngModel' }, link, template, http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/input/number.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/input/number.jade b/modules/control-center-web/src/main/js/app/modules/Form/field/input/number.jade index 973d4ae..2738309 100644 --- a/modules/control-center-web/src/main/js/app/modules/Form/field/input/number.jade +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/input/number.jade @@ -17,12 +17,15 @@ .input-tip input.form-control( id='{{ id }}' - name='{{ name }}' - placeholder='{{ placeholder }}' - type='number' - min='0' - max='Number.MAX_VALUE' - ng-model='ngModel' + name='{{ name }}' + placeholder='{{ placeholder }}' + type='number' + min='{{ min || 0 }}' + max='{{ max || Number.MAX_VALUE }}' + + data-ng-model='value' + data-ng-required='required || false' + data-ng-disabled='disabled || false' ) i.fa.fa-exclamation-triangle.form-control-feedback( http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.css ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.css b/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.css new file mode 100644 index 0000000..9efdb2c --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.css @@ -0,0 +1,24 @@ +label .input-tip { + position: initial; +} + +.input-tip .fa-floppy-o { + position: absolute; + top: 0; + right: 0; + z-index: 2; + + width: 34px; + height: 34px; + + text-align: center; + + display: inline-block; + line-height: 28px; + pointer-events: initial; +} + +.input-tip .form-control-feedback { + height: auto; +} + http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.directive.js new file mode 100644 index 0000000..65c744d --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.directive.js @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import template from './text.jade!'; +import './text.css!'; + +export default ['igniteFormFieldInputText', ['IgniteFormGUID', (guid) => { + const link = (scope, el, attrs, [form, label]) => { + const {id, name} = scope; + const field = form[name]; + + scope.form = form; + scope.field = field; + label.for = scope.id = id || guid(); + + scope.$watch('required', (required) => { + label.required = required || false; + }); + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + + const setAsDefault = () => { + if (!form.$pristine) return; + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + }; + + scope.$watch(() => form.$pristine, setAsDefault); + scope.$watch('value', setAsDefault); + }; + + return { + restrict: 'E', + scope: { + id: '@', + name: '@', + placeholder: '@', + unique: '=igniteUnique', + required: '=ngRequired', + disabled: '=ngDisabled', + + value: '=ngModel', + ngBlur: '&', + + javaKeywords: '=', + javaIdentifier: '=', + javaPackageSpecified: '=', + javaBuiltInClass: '=', + javaPackageName: '=', + + autofocus: '=igniteFormFieldInputAutofocus' + }, + link, + template, + replace: true, + transclude: true, + require: ['^form', '?^igniteFormField'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.jade b/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.jade new file mode 100644 index 0000000..5ce3c51 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/input/text.jade @@ -0,0 +1,39 @@ +//- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +.input-tip + input.form-control( + id='{{ id }}' + name='{{ name }}' + placeholder='{{ placeholder }}' + type='text' + + data-ng-model='value' + data-ng-required='required || false' + data-ng-disabled='disabled || false' + data-ng-blur='ngBlur()' + + data-java-keywords='{{ javaKeywords }}' + data-java-identifier='{{ javaIdentifier }}' + data-java-package-specified='{{ javaPackageSpecified }}' + data-java-built-in-class='{{ javaBuiltInClass }}' + data-java-package-name='{{ javaPackageName }}' + + data-ignite-unique='unique' + data-ignite-form-field-input-autofocus='autofocus || false' + ) + + span(ng-transclude='') http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/label.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/label.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/field/label.directive.js new file mode 100644 index 0000000..f5f1c59 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/label.directive.js @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default ['igniteFormFieldLabel', [() => { + return { + restrict: 'E', + compile() { + return { + post($scope, $element, $attrs, $ctrl, $transclude) { + $transclude($scope, function(clone) { + const $label = $element.parent().parent().find('label'); + + $label.append(clone); + }); + } + }; + }, + replace: true, + transclude: true, + require: '^form' + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/tooltip.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/tooltip.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/field/tooltip.directive.js new file mode 100644 index 0000000..78aa8fd --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/tooltip.directive.js @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const template = ``; + +export default ['igniteFormFieldTooltip', ['$tooltip', ($tooltip) => { + const link = ($scope, $element, $attrs, $ctrls, $transclude) => { + const content = Array.prototype.slice.apply($transclude($scope)) + .reduce((html, el) => html += el.outerHTML, ''); + + $tooltip($element, { title: content }); + + // TODO cleanup css styles. + if ($element.hasClass('tipLabel')) + $element.removeClass('tipField'); + + if ($element.parent('label').length) + $element.addClass('tipLabel').removeClass('tipField'); + }; + + return { + restrict: 'E', + scope: {}, + template, + link, + replace: true, + transclude: true, + require: '^form' + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/field/up.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/field/up.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/field/up.directive.js new file mode 100644 index 0000000..d591eac --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/field/up.directive.js @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +const template = ``; + +export default ['igniteFormFieldUp', ['$tooltip', ($tooltip) => { + const link = (scope, $element) => { + $tooltip($element, { title: 'Move item up' }); + + scope.up = () => { + const idx = scope.models.indexOf(scope.model); + + scope.models.splice(idx, 1); + scope.models.splice(idx - 1, 0, scope.model); + }; + }; + + return { + restrict: 'E', + scope: { + model: '=ngModel', + models: '=models' + }, + template, + link, + replace: true, + transclude: true, + require: '^form' + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/group/add.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/group/add.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/group/add.directive.js new file mode 100644 index 0000000..6d79026 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/group/add.directive.js @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const template = ``; + +export default ['igniteFormGroupAdd', ['$tooltip', ($tooltip) => { + const link = ($scope, $element, $attrs, $ctrls, $transclude) => { + const content = Array.prototype.slice + .apply($transclude($scope)) + .reduce((html, el) => html += el.outerHTML, ''); + + $tooltip($element, { title: content }); + + $element.closest('.group').find('.group-legend').append($element); + }; + + return { + restrict: 'E', + scope: {}, + template, + link, + replace: true, + transclude: true, + require: ['^form', '^igniteFormGroup'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/group/group.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/group/group.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/group/group.directive.js new file mode 100644 index 0000000..56b6c94 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/group/group.directive.js @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import template from './group.jade!'; + +export default ['igniteFormGroup', [() => { + const controller = [function() { }]; + + const link = (scope, el, attrs, [form]) => { + const {name} = scope; + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + + const setAsDefault = () => { + if (!form.$pristine) return; + + form.$defaults = form.$defaults || {}; + form.$defaults[name] = _.cloneDeep(scope.value); + }; + + scope.$watch(() => form.$pristine, setAsDefault); + scope.$watch('value', setAsDefault); + }; + + return { + restrict: 'E', + scope: { + name: '@', + value: '=ngModel' + }, + bindToController: { + label: '@' + }, + link, + template, + controller, + controllerAs: 'group', + replace: true, + transclude: true, + require: ['^form', '?^igniteFormField'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/group/group.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/group/group.jade b/modules/control-center-web/src/main/js/app/modules/Form/group/group.jade new file mode 100644 index 0000000..ba3a8f2 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/group/group.jade @@ -0,0 +1,21 @@ +//- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +.group-section + .group + .group-legend + label {{::group.label}} + div(ng-transclude='') http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/group/table.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/group/table.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/group/table.directive.js new file mode 100644 index 0000000..520f8c2 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/group/table.directive.js @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import template from './table.jade!'; + +export default ['igniteFormGroupTable', [() => { + return { + restrict: 'E', + scope: {}, + template, + replace: true, + transclude: true, + require: ['^form', '^igniteFormGroup'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/group/table.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/group/table.jade b/modules/control-center-web/src/main/js/app/modules/Form/group/table.jade new file mode 100644 index 0000000..6f9486d --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/group/table.jade @@ -0,0 +1,17 @@ +//- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +div \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/group/tooltip.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/group/tooltip.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/group/tooltip.directive.js new file mode 100644 index 0000000..5af8fb1 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/group/tooltip.directive.js @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const template = ``; + +export default ['igniteFormGroupTooltip', ['$tooltip', ($tooltip) => { + const link = ($scope, $element, $attrs, $ctrls, $transclude) => { + const content = Array.prototype.slice + .apply($transclude($scope)) + .reduce((html, el) => html += el.outerHTML, ''); + + $tooltip($element, { title: content }); + + $element.closest('.group').find('.group-legend').append($element); + }; + + return { + restrict: 'E', + scope: {}, + template, + link, + replace: true, + transclude: true, + require: ['^form', '^igniteFormGroup'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/index.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/index.js b/modules/control-center-web/src/main/js/app/modules/Form/index.js index eb6dcbf..2650e48 100644 --- a/modules/control-center-web/src/main/js/app/modules/Form/index.js +++ b/modules/control-center-web/src/main/js/app/modules/Form/index.js @@ -16,17 +16,73 @@ */ import angular from 'angular'; + +// Panel. +import igniteFormPanel from './panel/panel.directive'; +import igniteFormPanelChevron from './panel/chevron.directive'; +import igniteFormRevert from './panel/revert.directive'; + +// Field. import igniteFormField from './field/field.directive'; +import igniteFormFieldLabel from './field/label.directive'; +import igniteFormFieldTooltip from './field/tooltip.directive'; import igniteFormFieldDropdown from './field/dropdown.directive'; import igniteFormFieldInputNumber from './field/input/number.directive'; +import igniteFormFieldInputText from './field/input/text.directive'; +import igniteFormFieldInputCheckbox from './field/input/checkbox.directive'; +import igniteFormFieldInputDatalist from './field/input/datalist.directive'; + +// Group. +import igniteFormGroup from './group/group.directive'; +import igniteFormGroupAdd from './group/add.directive'; +import igniteFormGroupTooltip from './group/tooltip.directive'; + +// Validators. +import javaKeywords from './validator/java-keywords.directive'; +import javaPackageSpecified from './validator/java-package-specified.directive'; +import javaBuiltInClass from './validator/java-built-in-class.directive'; +import javaIdentifier from './validator/java-identifier.directive'; +import javaPackageName from './validator/java-package-name.directive'; +import unique from './validator/unique.directive'; + +// Helpers. +import igniteFormFieldInputAutofocus from './field/input/autofocus.directive'; +import igniteFormFieldUp from './field/up.directive'; +import igniteFormFieldDown from './field/down.directive'; angular .module('ignite-console.Form', [ ]) +// Panel. +.directive(...igniteFormPanel) +.directive(...igniteFormPanelChevron) +.directive(...igniteFormRevert) +// Field. .directive(...igniteFormField) +.directive(...igniteFormFieldLabel) +.directive(...igniteFormFieldTooltip) .directive(...igniteFormFieldDropdown) .directive(...igniteFormFieldInputNumber) +.directive(...igniteFormFieldInputText) +.directive(...igniteFormFieldInputCheckbox) +.directive(...igniteFormFieldInputDatalist) +// Group. +.directive(...igniteFormGroup) +.directive(...igniteFormGroupAdd) +.directive(...igniteFormGroupTooltip) +// Validators. +.directive(...javaKeywords) +.directive(...javaPackageSpecified) +.directive(...javaBuiltInClass) +.directive(...javaIdentifier) +.directive(...javaPackageName) +.directive(...unique) +// Helpers. +.directive(...igniteFormFieldInputAutofocus) +.directive(...igniteFormFieldUp) +.directive(...igniteFormFieldDown) +// Generator of globally unique identifier. .factory('IgniteFormGUID', [() => { let guid = 0; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/panel/chevron.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/panel/chevron.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/panel/chevron.directive.js new file mode 100644 index 0000000..9f7e1d0 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/panel/chevron.directive.js @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const template = ``; + +export default ['igniteFormPanelChevron', [() => { + const controller = [() => {}]; + + const link = ($scope, $element, $attrs, [bsCollapseCtrl]) => { + const $target = $element.parent().parent().find('.panel-collapse'); + + bsCollapseCtrl.$viewChangeListeners.push(function() { + const index = bsCollapseCtrl.$targets.reduce((acc, el, i) => { + if (el[0] === $target[0]) + acc.push(i); + + return acc; + }, [])[0]; + + $scope.isOpen = false; + + const active = bsCollapseCtrl.$activeIndexes(); + + if ((active instanceof Array) && active.indexOf(index) !== -1 || active === index) + $scope.isOpen = true; + }); + }; + + return { + restrict: 'E', + scope: {}, + link, + template, + controller, + replace: true, + transclude: true, + require: ['^bsCollapse'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/panel/panel.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/panel/panel.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/panel/panel.directive.js new file mode 100644 index 0000000..b8e7c25 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/panel/panel.directive.js @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default ['form', [() => { + const link = (scope, $element, $attrs, [form]) => { + const $form = $element.parent().closest('form'); + + scope.$watch(() => { + return $form.hasClass('ng-pristine'); + }, (value) => { + if (!value) + return; + + form.$setPristine(); + }); + }; + + return { + restrict: 'E', + link, + require: ['^form'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/panel/revert.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/panel/revert.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/panel/revert.directive.js new file mode 100644 index 0000000..874b466 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/panel/revert.directive.js @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const template = ``; + +export default ['igniteFormRevert', ['$tooltip', ($tooltip) => { + const link = (scope, $element, $attrs, [form]) => { + $tooltip($element, { title: 'Undo unsaved changes' }); + + scope.form = form; + + scope.revert = (e) => { + e.stopPropagation(); + + for (const name in form.$defaults) { + if ({}.hasOwnProperty.call(form.$defaults, name) && form[name]) { + form[name].$setViewValue(form.$defaults[name]); + form[name].$setPristine(); + form[name].$render(); + } + } + + form.$setPristine(); + }; + }; + + return { + restrict: 'E', + scope: { + model: '=ngModel', + models: '=models' + }, + template, + link, + replace: true, + require: ['^form'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/validator/java-built-in-class.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/validator/java-built-in-class.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/validator/java-built-in-class.directive.js new file mode 100644 index 0000000..caa268d --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/validator/java-built-in-class.directive.js @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default ['javaBuiltInClass', ['JavaTypes', (JavaTypes) => { + const link = (scope, el, attrs, [ngModel]) => { + if (typeof attrs.javaBuiltInClass === 'undefined' || !attrs.javaBuiltInClass) + return; + + ngModel.$validators.javaBuiltInClass = JavaTypes.nonBuiltInClass; + }; + + return { + restrict: 'A', + link, + require: ['ngModel'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/validator/java-identifier.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/validator/java-identifier.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/validator/java-identifier.directive.js new file mode 100644 index 0000000..b52115a --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/validator/java-identifier.directive.js @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default ['javaIdentifier', ['JavaTypes', (JavaTypes) => { + const link = (scope, el, attrs, [ngModel]) => { + if (typeof attrs.validIdentifier === 'undefined' || !attrs.validIdentifier) + return; + + ngModel.$validators.javaIdentifier = JavaTypes.validIdentifier; + }; + + return { + restrict: 'A', + link, + require: ['ngModel'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/validator/java-keywords.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/validator/java-keywords.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/validator/java-keywords.directive.js new file mode 100644 index 0000000..9c91262 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/validator/java-keywords.directive.js @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default ['javaKeywords', ['JavaTypes', (JavaTypes) => { + const link = (scope, el, attrs, [ngModel]) => { + if (typeof attrs.javaKeywords === 'undefined' || !attrs.javaKeywords) + return; + + ngModel.$validators.javaKeywords = JavaTypes.nonKeywords; + }; + + return { + restrict: 'A', + link, + require: ['ngModel'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/validator/java-package-name.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/validator/java-package-name.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/validator/java-package-name.directive.js new file mode 100644 index 0000000..173e118 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/validator/java-package-name.directive.js @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default ['javaPackageName', ['JavaTypes', (JavaTypes) => { + const link = (scope, el, attrs, [ngModel]) => { + if (typeof attrs.javaPackageName === 'undefined' || !attrs.javaPackageName) + return; + + ngModel.$validators.javaPackageName = JavaTypes.validPackage; + }; + + return { + restrict: 'A', + link, + require: ['ngModel'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/validator/java-package-specified.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/validator/java-package-specified.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/validator/java-package-specified.directive.js new file mode 100644 index 0000000..9ba43f3 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/validator/java-package-specified.directive.js @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default ['javaPackageSpecified', [() => { + const link = (scope, el, attrs, [ngModel]) => { + if (typeof attrs.javaPackageSpecified === 'undefined' || !attrs.javaPackageSpecified) + return; + + ngModel.$validators.javaPackageSpecified = (value) => { + return !value || !(value.split('.').length < 2); + }; + }; + + return { + restrict: 'A', + link, + require: ['ngModel'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/Form/validator/unique.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/Form/validator/unique.directive.js b/modules/control-center-web/src/main/js/app/modules/Form/validator/unique.directive.js new file mode 100644 index 0000000..1ddbb79 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/Form/validator/unique.directive.js @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default ['igniteUnique', ['$parse', ($parse) => { + const link = (scope, el, attrs, [ngModel]) => { + if (typeof attrs.igniteUnique === 'undefined' || !attrs.igniteUnique) + return; + + ngModel.$validators.igniteUnique = (value) => { + const arr = $parse(attrs.igniteUnique)(scope); + + // Return true in case if array not exist, array empty, or value is unique. + return !arr || !arr.length || !~arr.indexOf(value); + }; + }; + + return { + restrict: 'A', + link, + require: ['ngModel'] + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/JavaTypes/index.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/JavaTypes/index.js b/modules/control-center-web/src/main/js/app/modules/JavaTypes/index.js index 5c2de9c..0319ae2 100644 --- a/modules/control-center-web/src/main/js/app/modules/JavaTypes/index.js +++ b/modules/control-center-web/src/main/js/app/modules/JavaTypes/index.js @@ -17,34 +17,50 @@ import angular from 'angular'; -angular - .module('ignite-console.JavaTypes', []) - .provider('JavaTypes', function() { - // Java built-in short class names. - const _classes = [ - 'BigDecimal', 'Boolean', 'Byte', 'Date', 'Double', 'Float', 'Integer', 'Long', 'Short', 'String', 'Time', 'Timestamp', 'UUID' - ]; +// Java built-in short class names. +import JAVA_CLASSES from 'app/data/java-classes.json!'; - // TODO use later const _types = [ - // 'BigDecimal', 'boolean', 'Boolean', 'byte', 'Byte', 'Date', 'double', 'Double', 'float', 'Float', - // 'int', 'Integer', 'long', 'Long', 'short', 'Short', 'String', 'Time', 'Timestamp', 'UUID' - // ]; +// Java built-in full class names. +import JAVA_FULLNAME_CLASSES from 'app/data/java-fullname-classes.json!'; - // Java built-in full class names. - const _fullNameClasses = [ - 'java.math.BigDecimal', 'java.lang.Boolean', 'java.lang.Byte', 'java.sql.Date', 'java.lang.Double', - 'java.lang.Float', 'java.lang.Integer', 'java.lang.Long', 'java.lang.Short', 'java.lang.String', - 'java.sql.Time', 'java.sql.Timestamp', 'java.util.UUID' - ]; +import JAVA_KEYWORDS from 'app/data/java-keywords.json!'; +angular + .module('ignite-console.JavaTypes', []) + .provider('JavaTypes', function() { this.$get = [function() { return { /** * @param cls Class name to check. - * @returns 'true' if given class name is a Java built-in type. + * @returns boolean 'true' if given class name non a Java built-in type. + */ + nonBuiltInClass(cls) { + return !(_.contains(JAVA_CLASSES, cls) || _.contains(JAVA_FULLNAME_CLASSES, cls)); + }, + /** + * @param value text to check. + * @returns boolean 'true' if given text is valid Java identifier. + */ + validIdentifier(value) { + const regexp = /^(([a-zA-Z_$][a-zA-Z0-9_$]*)\.)*([a-zA-Z_$][a-zA-Z0-9_$]*)$/igm; + + return value === '' || regexp.test(value); + }, + /** + * @param value text to check. + * @returns boolean 'true' if given text is valid Java package. + */ + validPackage(value) { + const regexp = /^(([a-zA-Z_$][a-zA-Z0-9_$]*)\.)*([a-zA-Z_$][a-zA-Z0-9_$]*(\.[*]|[*])?)$/igm; + + return value === '' || regexp.test(value); + }, + /** + * @param value text to check. + * @returns boolean 'true' if given text non Java keyword. */ - isBuiltInClass(cls) { - return _.contains(_classes, cls) || _.contains(_fullNameClasses, cls); + nonKeywords(value) { + return !JAVA_KEYWORDS.contains(value); } }; }]; http://git-wip-us.apache.org/repos/asf/ignite/blob/b9e62281/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/atomic.directive.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/atomic.directive.js b/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/atomic.directive.js new file mode 100644 index 0000000..062a527 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/states/configuration/clusters/atomic.directive.js @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import template from './atomic.jade!'; + +export default ['igniteConfigurationClustersAtomic', [() => { + return { + scope: true, + restrict: 'E', + template, + replace: true + }; +}]];