Repository: ignite Updated Branches: refs/heads/master 79be449dc -> f80d3a95d
IGNITE-8095 Web Console: Refactored previews for generated code. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f80d3a95 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f80d3a95 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f80d3a95 Branch: refs/heads/master Commit: f80d3a95d7abcab16138808e3b6f0785308867f1 Parents: 79be449 Author: Vasiliy Sisko <[email protected]> Authored: Mon Apr 2 11:49:10 2018 +0700 Committer: Alexey Kuznetsov <[email protected]> Committed: Mon Apr 2 11:49:10 2018 +0700 ---------------------------------------------------------------------- modules/web-console/frontend/app/app.js | 9 +- .../app/directives/ui-ace-java/index.js | 26 ++++ .../ui-ace-java/ui-ace-java.controller.js | 108 +------------ .../ui-ace-java/ui-ace-java.directive.js | 43 ++---- .../app/directives/ui-ace-spring/index.js | 26 ++++ .../ui-ace-spring/ui-ace-spring.controller.js | 104 +------------ .../ui-ace-spring/ui-ace-spring.directive.js | 46 ++---- .../app/directives/ui-ace.controller.js | 154 +++++++++++++++++++ 8 files changed, 239 insertions(+), 277 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/f80d3a95/modules/web-console/frontend/app/app.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js index d015ba9..d01d9aa 100644 --- a/modules/web-console/frontend/app/app.js +++ b/modules/web-console/frontend/app/app.js @@ -60,8 +60,6 @@ import igniteOnEnterFocusMove from './directives/on-enter-focus-move.directive.j import igniteOnEscape from './directives/on-escape.directive.js'; import igniteOnFocusOut from './directives/on-focus-out.directive.js'; import igniteRestoreInputFocus from './directives/restore-input-focus.directive.js'; -import igniteUiAceJava from './directives/ui-ace-java/ui-ace-java.directive'; -import igniteUiAceSpring from './directives/ui-ace-spring/ui-ace-spring.directive'; import igniteUiAceCSharp from './directives/ui-ace-sharp/ui-ace-sharp.directive'; import igniteUiAcePojos from './directives/ui-ace-pojos/ui-ace-pojos.directive'; import igniteUiAcePom from './directives/ui-ace-pom/ui-ace-pom.directive'; @@ -142,6 +140,9 @@ import pagePasswordReset from './components/page-password-reset'; import igniteServices from './services'; +import uiAceJava from './directives/ui-ace-java'; +import uiAceSpring from './directives/ui-ace-spring'; + // Inject external modules. import IgniteModules from 'IgniteModules/index'; @@ -227,6 +228,8 @@ angular.module('ignite-console', [ pageLanding.name, pagePasswordChanged.name, pagePasswordReset.name, + uiAceJava.name, + uiAceSpring.name, breadcrumbs.name, // Ignite modules. IgniteModules.name @@ -244,8 +247,6 @@ angular.module('ignite-console', [ .directive(...igniteOnEnter) .directive(...igniteOnEnterFocusMove) .directive(...igniteOnEscape) -.directive(...igniteUiAceSpring) -.directive(...igniteUiAceJava) .directive(...igniteUiAceCSharp) .directive(...igniteUiAcePojos) .directive(...igniteUiAcePom) http://git-wip-us.apache.org/repos/asf/ignite/blob/f80d3a95/modules/web-console/frontend/app/directives/ui-ace-java/index.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/directives/ui-ace-java/index.js b/modules/web-console/frontend/app/directives/ui-ace-java/index.js new file mode 100644 index 0000000..2efdf32 --- /dev/null +++ b/modules/web-console/frontend/app/directives/ui-ace-java/index.js @@ -0,0 +1,26 @@ +/* + * 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 angular from 'angular'; + +import UiAceJavaDirective from './ui-ace-java.directive'; + +export default angular.module('ignite-console.ui-ace-java', [ + 'ignite-console.services', + 'ignite-console.configuration' +]) +.directive('igniteUiAceJava', UiAceJavaDirective); http://git-wip-us.apache.org/repos/asf/ignite/blob/f80d3a95/modules/web-console/frontend/app/directives/ui-ace-java/ui-ace-java.controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/directives/ui-ace-java/ui-ace-java.controller.js b/modules/web-console/frontend/app/directives/ui-ace-java/ui-ace-java.controller.js index efd317c..2d636c0 100644 --- a/modules/web-console/frontend/app/directives/ui-ace-java/ui-ace-java.controller.js +++ b/modules/web-console/frontend/app/directives/ui-ace-java/ui-ace-java.controller.js @@ -15,108 +15,8 @@ * limitations under the License. */ -export default ['IgniteVersion', 'JavaTransformer', function(Version, java) { - const ctrl = this; +import IgniteUiAceGeneratorFactory from '../ui-ace.controller'; - this.$onInit = () => { - delete ctrl.data; - - const client = ctrl.client === 'true'; - - const available = Version.available.bind(Version); - - // Setup generator. - switch (ctrl.generator) { - case 'igniteConfiguration': - const clsName = client ? 'ClientConfigurationFactory' : 'ServerConfigurationFactory'; - - ctrl.generate = (cluster) => java.cluster(cluster, Version.currentSbj.getValue(), 'config', clsName, client); - - break; - case 'clusterCaches': - ctrl.generate = (cluster, caches) => { - const clusterCaches = _.reduce(caches, (acc, cache) => { - if (_.includes(cluster.caches, cache.value)) - acc.push(cache.cache); - - return acc; - }, []); - - const cfg = java.generator.clusterGeneral(cluster, available); - - java.generator.clusterCaches(cluster, clusterCaches, null, available, false, cfg); - - return java.toSection(cfg); - }; - - break; - case 'cacheStore': - case 'cacheQuery': - ctrl.generate = (cache, domains) => { - const cacheDomains = _.reduce(domains, (acc, domain) => { - if (_.includes(cache.domains, domain.value)) - acc.push(domain.meta); - - return acc; - }, []); - - return java[ctrl.generator](cache, cacheDomains, available); - }; - - break; - case 'cacheNodeFilter': - ctrl.generate = (cache, igfss) => { - const cacheIgfss = _.reduce(igfss, (acc, igfs) => { - acc.push(igfs.igfs); - - return acc; - }, []); - - return java.cacheNodeFilter(cache, cacheIgfss); - }; - - break; - case 'clusterServiceConfiguration': - ctrl.generate = (cluster, caches) => { - const clusterCaches = _.reduce(caches, (acc, cache) => { - if (_.includes(cluster.caches, cache.value)) - acc.push(cache.cache); - - return acc; - }, []); - - return java.clusterServiceConfiguration(cluster.serviceConfigurations, clusterCaches); - }; - - break; - case 'clusterCheckpoint': - ctrl.generate = (cluster, caches) => { - const clusterCaches = _.reduce(caches, (acc, cache) => { - if (_.includes(cluster.caches, cache.value)) - acc.push(cache.cache); - - return acc; - }, []); - - return java.clusterCheckpoint(cluster, available, clusterCaches); - }; - - break; - case 'igfss': - ctrl.generate = (cluster, igfss) => { - const clusterIgfss = _.reduce(igfss, (acc, igfs) => { - if (_.includes(cluster.igfss, igfs.value)) - acc.push(igfs.igfs); - - return acc; - }, []); - - return java.clusterIgfss(clusterIgfss, available); - }; - - break; - default: - ctrl.generate = (master) => java[ctrl.generator](master, available); - } - }; -}]; +export default class IgniteUiAceJava extends IgniteUiAceGeneratorFactory { + static $inject = ['$scope', '$attrs', 'IgniteVersion', 'JavaTransformer']; +} http://git-wip-us.apache.org/repos/asf/ignite/blob/f80d3a95/modules/web-console/frontend/app/directives/ui-ace-java/ui-ace-java.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/directives/ui-ace-java/ui-ace-java.directive.js b/modules/web-console/frontend/app/directives/ui-ace-java/ui-ace-java.directive.js index 5d1df42..62eb376 100644 --- a/modules/web-console/frontend/app/directives/ui-ace-java/ui-ace-java.directive.js +++ b/modules/web-console/frontend/app/directives/ui-ace-java/ui-ace-java.directive.js @@ -16,36 +16,9 @@ */ import template from './ui-ace-java.pug'; -import controller from './ui-ace-java.controller'; - -export default ['igniteUiAceJava', ['IgniteVersion', (Version) => { - const link = (scope, $el, attrs, [ctrl, igniteUiAceTabs, formCtrl, ngModelCtrl]) => { - if (formCtrl && ngModelCtrl) - formCtrl.$removeControl(ngModelCtrl); - - if (igniteUiAceTabs && igniteUiAceTabs.onLoad) { - scope.onLoad = (editor) => { - igniteUiAceTabs.onLoad(editor); - - scope.$watch('master', () => editor.attractAttention = false); - }; - } - - if (igniteUiAceTabs && igniteUiAceTabs.onChange) - scope.onChange = igniteUiAceTabs.onChange; - - const noDeepWatch = !(typeof attrs.noDeepWatch !== 'undefined'); - - const next = () => { - ctrl.data = _.isNil(scope.master) ? null : ctrl.generate(scope.master, scope.detail).asString(); - }; - - // Setup watchers. - scope.$watch('master', next, noDeepWatch); - - Version.currentSbj.subscribe({next}); - }; +import IgniteUiAceJava from './ui-ace-java.controller'; +export default () => { return { priority: 1, restrict: 'E', @@ -58,10 +31,14 @@ export default ['igniteUiAceJava', ['IgniteVersion', (Version) => { generator: '@', client: '@' }, - link, template, - controller, + controller: IgniteUiAceJava, controllerAs: 'ctrl', - require: ['igniteUiAceJava', '?^igniteUiAceTabs', '?^form', '?ngModel'] + require: { + ctrl: 'igniteUiAceJava', + igniteUiAceTabs: '?^igniteUiAceTabs', + formCtrl: '?^form', + ngModelCtrl: '?ngModel' + } }; -}]]; +}; http://git-wip-us.apache.org/repos/asf/ignite/blob/f80d3a95/modules/web-console/frontend/app/directives/ui-ace-spring/index.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/directives/ui-ace-spring/index.js b/modules/web-console/frontend/app/directives/ui-ace-spring/index.js new file mode 100644 index 0000000..8bb75dc --- /dev/null +++ b/modules/web-console/frontend/app/directives/ui-ace-spring/index.js @@ -0,0 +1,26 @@ +/* + * 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 angular from 'angular'; + +import UiAceSpringDirective from './ui-ace-spring.directive'; + +export default angular.module('ignite-console.ui-ace-spring', [ + 'ignite-console.services', + 'ignite-console.configuration' +]) +.directive('igniteUiAceSpring', UiAceSpringDirective); http://git-wip-us.apache.org/repos/asf/ignite/blob/f80d3a95/modules/web-console/frontend/app/directives/ui-ace-spring/ui-ace-spring.controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/directives/ui-ace-spring/ui-ace-spring.controller.js b/modules/web-console/frontend/app/directives/ui-ace-spring/ui-ace-spring.controller.js index 5df734f..09c351c 100644 --- a/modules/web-console/frontend/app/directives/ui-ace-spring/ui-ace-spring.controller.js +++ b/modules/web-console/frontend/app/directives/ui-ace-spring/ui-ace-spring.controller.js @@ -15,104 +15,8 @@ * limitations under the License. */ -export default ['IgniteVersion', 'SpringTransformer', function(Version, spring) { - const ctrl = this; +import IgniteUiAceGeneratorFactory from '../ui-ace.controller'; - this.$onInit = () => { - delete ctrl.data; - - const available = Version.available.bind(Version); - - // Setup generator. - switch (ctrl.generator) { - case 'igniteConfiguration': - ctrl.generate = (cluster) => spring.cluster(cluster, Version.currentSbj.getValue(), ctrl.client === 'true'); - - break; - case 'clusterCaches': - ctrl.generate = (cluster, caches) => { - const clusterCaches = _.reduce(caches, (acc, cache) => { - if (_.includes(cluster.caches, cache.value)) - acc.push(cache.cache); - - return acc; - }, []); - - const cfg = spring.generator.clusterGeneral(cluster, available); - - spring.generator.clusterCaches(cluster, clusterCaches, null, available, false, cfg); - - return spring.toSection(cfg); - }; - - break; - case 'cacheStore': - case 'cacheQuery': - ctrl.generate = (cache, domains) => { - const cacheDomains = _.reduce(domains, (acc, domain) => { - if (_.includes(cache.domains, domain.value)) - acc.push(domain.meta); - - return acc; - }, []); - - return spring[ctrl.generator](cache, cacheDomains, available); - }; - - break; - case 'cacheNodeFilter': - ctrl.generate = (cache, igfss) => { - const cacheIgfss = _.reduce(igfss, (acc, igfs) => { - acc.push(igfs.igfs); - - return acc; - }, []); - - return spring.cacheNodeFilter(cache, cacheIgfss); - }; - - break; - case 'clusterServiceConfiguration': - ctrl.generate = (cluster, caches) => { - const clusterCaches = _.reduce(caches, (acc, cache) => { - if (_.includes(cluster.caches, cache.value)) - acc.push(cache.cache); - - return acc; - }, []); - - return spring.clusterServiceConfiguration(cluster.serviceConfigurations, clusterCaches); - }; - - break; - case 'clusterCheckpoint': - ctrl.generate = (cluster, caches) => { - const clusterCaches = _.reduce(caches, (acc, cache) => { - if (_.includes(cluster.caches, cache.value)) - acc.push(cache.cache); - - return acc; - }, []); - - return spring.clusterCheckpoint(cluster, available, clusterCaches); - }; - - break; - case 'igfss': - ctrl.generate = (cluster, igfss) => { - const clusterIgfss = _.reduce(igfss, (acc, igfs) => { - if (_.includes(cluster.igfss, igfs.value)) - acc.push(igfs.igfs); - - return acc; - }, []); - - return spring.clusterIgfss(clusterIgfss, available); - }; - - break; - default: - ctrl.generate = (master) => spring[ctrl.generator](master, available); - } - }; -}]; +export default class IgniteUiAceSpring extends IgniteUiAceGeneratorFactory { + static $inject = ['$scope', '$attrs', 'IgniteVersion', 'SpringTransformer']; +} http://git-wip-us.apache.org/repos/asf/ignite/blob/f80d3a95/modules/web-console/frontend/app/directives/ui-ace-spring/ui-ace-spring.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/directives/ui-ace-spring/ui-ace-spring.directive.js b/modules/web-console/frontend/app/directives/ui-ace-spring/ui-ace-spring.directive.js index 953d6cd..8655fd1 100644 --- a/modules/web-console/frontend/app/directives/ui-ace-spring/ui-ace-spring.directive.js +++ b/modules/web-console/frontend/app/directives/ui-ace-spring/ui-ace-spring.directive.js @@ -15,40 +15,10 @@ * limitations under the License. */ -import _ from 'lodash'; - import template from './ui-ace-spring.pug'; -import controller from './ui-ace-spring.controller'; - -export default ['igniteUiAceSpring', ['IgniteVersion', (Version) => { - const link = (scope, $el, attrs, [ctrl, igniteUiAceTabs, formCtrl, ngModelCtrl]) => { - if (formCtrl && ngModelCtrl) - formCtrl.$removeControl(ngModelCtrl); - - if (igniteUiAceTabs && igniteUiAceTabs.onLoad) { - scope.onLoad = (editor) => { - igniteUiAceTabs.onLoad(editor); - - // Disable highlight in model switch. - scope.$watch('master', () => editor.attractAttention = false); - }; - } - - if (igniteUiAceTabs && igniteUiAceTabs.onChange) - scope.onChange = igniteUiAceTabs.onChange; - - const noDeepWatch = !(typeof attrs.noDeepWatch !== 'undefined'); - - const next = () => { - ctrl.data = _.isNil(scope.master) ? null : ctrl.generate(scope.master, scope.detail).asString(); - }; - - // Setup watchers. - scope.$watch('master', next, noDeepWatch); - - Version.currentSbj.subscribe({next}); - }; +import IgniteUiAceSpring from './ui-ace-spring.controller'; +export default () => { return { priority: 1, restrict: 'E', @@ -61,10 +31,14 @@ export default ['igniteUiAceSpring', ['IgniteVersion', (Version) => { generator: '@', client: '@' }, - link, template, - controller, + controller: IgniteUiAceSpring, controllerAs: 'ctrl', - require: ['igniteUiAceSpring', '?^igniteUiAceTabs', '?^form', '?ngModel'] + require: { + ctrl: 'igniteUiAceSpring', + igniteUiAceTabs: '?^igniteUiAceTabs', + formCtrl: '?^form', + ngModelCtrl: '?ngModel' + } }; -}]]; +}; http://git-wip-us.apache.org/repos/asf/ignite/blob/f80d3a95/modules/web-console/frontend/app/directives/ui-ace.controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/directives/ui-ace.controller.js b/modules/web-console/frontend/app/directives/ui-ace.controller.js new file mode 100644 index 0000000..96e9c5e --- /dev/null +++ b/modules/web-console/frontend/app/directives/ui-ace.controller.js @@ -0,0 +1,154 @@ +/* + * 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 class IgniteUiAceGeneratorFactory { + constructor($scope, $attrs, Version, generatorFactory) { + this.scope = $scope; + this.attrs = $attrs; + this.Version = Version; + this.generatorFactory = generatorFactory; + } + + $onInit() { + delete this.data; + + const available = this.Version.available.bind(this.Version); + + // Setup generator. + switch (this.generator) { + case 'igniteConfiguration': + this.generate = (cluster) => this.generatorFactory.cluster(cluster, this.Version.currentSbj.getValue(), this.client === 'true'); + + break; + case 'clusterCaches': + this.generate = (cluster, caches) => { + const clusterCaches = _.reduce(caches, (acc, cache) => { + if (_.includes(cluster.caches, cache.value)) + acc.push(cache.cache); + + return acc; + }, []); + + const cfg = this.generatorFactory.generator.clusterGeneral(cluster, available); + + this.generatorFactory.generator.clusterCaches(cluster, clusterCaches, null, available, false, cfg); + + return this.generatorFactory.toSection(cfg); + }; + + break; + case 'cacheStore': + case 'cacheQuery': + this.generate = (cache, domains) => { + const cacheDomains = _.reduce(domains, (acc, domain) => { + if (_.includes(cache.domains, domain.value)) + acc.push(domain.meta); + + return acc; + }, []); + + return this.generatorFactory[this.generator](cache, cacheDomains, available); + }; + + break; + case 'cacheNodeFilter': + this.generate = (cache, igfss) => { + const cacheIgfss = _.reduce(igfss, (acc, igfs) => { + acc.push(igfs.igfs); + + return acc; + }, []); + + return this.generatorFactory.cacheNodeFilter(cache, cacheIgfss); + }; + + break; + case 'clusterServiceConfiguration': + this.generate = (cluster, caches) => { + const clusterCaches = _.reduce(caches, (acc, cache) => { + if (_.includes(cluster.caches, cache.value)) + acc.push(cache.cache); + + return acc; + }, []); + + return this.generatorFactory.clusterServiceConfiguration(cluster.serviceConfigurations, clusterCaches); + }; + + break; + case 'clusterCheckpoint': + this.generate = (cluster, caches) => { + const clusterCaches = _.reduce(caches, (acc, cache) => { + if (_.includes(cluster.caches, cache.value)) + acc.push(cache.cache); + + return acc; + }, []); + + return this.generatorFactory.clusterCheckpoint(cluster, available, clusterCaches); + }; + + break; + case 'igfss': + this.generate = (cluster, igfss) => { + const clusterIgfss = _.reduce(igfss, (acc, igfs) => { + if (_.includes(cluster.igfss, igfs.value)) + acc.push(igfs.igfs); + + return acc; + }, []); + + return this.generatorFactory.clusterIgfss(clusterIgfss, available); + }; + + break; + default: + this.generate = (master) => this.generatorFactory[this.generator](master, available); + } + } + + $postLink() { + if (this.formCtrl && this.ngModelCtrl) + this.formCtrl.$removeControl(this.ngModelCtrl); + + if (this.igniteUiAceTabs && this.igniteUiAceTabs.onLoad) { + this.scope.onLoad = (editor) => { + this.igniteUiAceTabs.onLoad(editor); + + this.scope.$watch('master', () => editor.attractAttention = false); + }; + } + + if (this.igniteUiAceTabs && this.igniteUiAceTabs.onChange) + this.scope.onChange = this.igniteUiAceTabs.onChange; + + const noDeepWatch = !(typeof this.attrs.noDeepWatch !== 'undefined'); + + const next = () => { + this.ctrl.data = _.isNil(this.scope.master) ? null : this.ctrl.generate(this.scope.master, this.scope.detail).asString(); + }; + + // Setup watchers. + this.scope.$watch('master', next, noDeepWatch); + + this.subscription = this.Version.currentSbj.subscribe({next}); + } + + $onDestroy() { + this.subscription.unsubscribe(); + } +}
