IGNITE-3375 Refactored legacy common-module to small parts.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/00d8c0af Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/00d8c0af Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/00d8c0af Branch: refs/heads/ignite-3262 Commit: 00d8c0af4372abbb2d3baee2041cf33e06e63095 Parents: dbc3964 Author: Alexey Kuznetsov <[email protected]> Authored: Thu Jun 30 11:34:28 2016 +0700 Committer: Alexey Kuznetsov <[email protected]> Committed: Thu Jun 30 11:34:28 2016 +0700 ---------------------------------------------------------------------- .../web-console/src/main/js/app/app.config.js | 86 + modules/web-console/src/main/js/app/app.js | 167 +- .../main/js/app/controllers/auth.controller.js | 30 + .../js/app/controllers/notebooks.controller.js | 69 + .../controllers/reset-password.controller.js | 51 + .../js/app/directives/auto-focus.directive.js | 26 + .../directives/copy-to-clipboard.directive.js | 29 + .../main/js/app/directives/match.directive.js | 27 + .../app/directives/on-click-focus.directive.js | 26 + .../directives/on-enter-focus-move.directive.js | 29 + .../js/app/directives/on-enter.directive.js | 32 + .../js/app/directives/on-escape.directive.js | 32 + .../directives/retain-selection.directive.js | 66 + .../js/app/filters/domainsValidation.filter.js | 33 + .../src/main/js/app/helpers/jade/mixins.jade | 26 +- .../src/main/js/app/modules/Demo/Demo.module.js | 13 +- .../main/js/app/modules/agent/agent.module.js | 10 +- .../modules/form/field/dropdown.directive.js | 5 +- .../js/app/modules/form/field/dropdown.jade | 4 +- .../form/field/input/checkbox.directive.js | 5 +- .../form/field/input/datalist.directive.js | 5 +- .../app/modules/form/field/input/datalist.jade | 2 +- .../form/field/input/number.directive.js | 5 +- .../modules/form/field/input/text.directive.js | 5 +- .../app/modules/form/panel/revert.directive.js | 4 +- .../states/configuration/caches/store.jade | 4 +- .../states/configuration/domains/query.jade | 14 +- .../states/configuration/domains/store.jade | 8 +- .../modules/states/configuration/igfs/misc.jade | 4 +- .../configuration/summary/summary.controller.js | 6 +- .../main/js/app/modules/user/Auth.service.js | 10 +- .../src/main/js/app/services/Clone.service.js | 64 + .../js/app/services/ConfirmBatch.service.js | 85 + .../js/app/services/CopyToClipboard.service.js | 50 + .../src/main/js/app/services/Focus.service.js | 33 + .../main/js/app/services/LegacyTable.service.js | 205 +++ .../main/js/app/services/LegacyUtils.service.js | 941 ++++++++++ .../main/js/app/services/Messages.service.js | 51 + .../app/services/UnsavedChangesGuard.service.js | 38 + .../src/main/js/app/services/confirm.service.js | 2 +- .../src/main/js/controllers/admin-controller.js | 33 +- .../main/js/controllers/caches-controller.js | 84 +- .../main/js/controllers/clusters-controller.js | 132 +- .../src/main/js/controllers/common-module.js | 1741 ------------------ .../main/js/controllers/domains-controller.js | 267 ++- .../src/main/js/controllers/igfs-controller.js | 116 +- .../main/js/controllers/profile-controller.js | 24 +- .../src/main/js/controllers/sql-controller.js | 62 +- .../js/views/configuration/domains-import.jade | 2 +- .../web-console/src/main/js/views/reset.jade | 4 +- .../src/main/js/views/settings/profile.jade | 16 +- .../web-console/src/main/js/views/signin.jade | 28 +- .../src/main/js/views/sql/notebook-new.jade | 2 +- .../src/main/js/views/sql/paragraph-rate.jade | 2 +- .../web-console/src/main/js/views/sql/sql.jade | 6 +- .../main/js/views/templates/agent-download.jade | 2 +- .../src/main/js/views/templates/clone.jade | 2 +- 57 files changed, 2545 insertions(+), 2280 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/app.config.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/app.config.js b/modules/web-console/src/main/js/app/app.config.js new file mode 100644 index 0000000..25c24b0 --- /dev/null +++ b/modules/web-console/src/main/js/app/app.config.js @@ -0,0 +1,86 @@ +/* + * 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 alertTemplateUrl from '../views/templates/alert.jade'; + +const igniteConsoleCfg = angular.module('ignite-console.config', ['ngAnimate', 'mgcrea.ngStrap']); + +// Configure AngularJS animation: do not animate fa-spin. +igniteConsoleCfg.config(['$animateProvider', ($animateProvider) => { + $animateProvider.classNameFilter(/^((?!(fa-spin)).)*$/); +}]); + +// AngularStrap modal popup configuration. +igniteConsoleCfg.config(['$modalProvider', ($modalProvider) => { + angular.extend($modalProvider.defaults, { + animation: 'am-fade-and-scale', + html: true + }); +}]); + +// AngularStrap popover configuration. +igniteConsoleCfg.config(['$popoverProvider', ($popoverProvider) => { + angular.extend($popoverProvider.defaults, { + trigger: 'manual', + placement: 'right', + container: 'body', + templateUrl: '/templates/validation-error.html' + }); +}]); + +// AngularStrap tooltips configuration. +igniteConsoleCfg.config(['$tooltipProvider', ($tooltipProvider) => { + angular.extend($tooltipProvider.defaults, { + container: 'body', + delay: 150, + placement: 'right', + html: 'true', + trigger: 'click hover' + }); +}]); + +// AngularStrap select (combobox) configuration. +igniteConsoleCfg.config(['$selectProvider', ($selectProvider) => { + angular.extend($selectProvider.defaults, { + container: 'body', + maxLength: '5', + allText: 'Select All', + noneText: 'Clear All', + templateUrl: '/templates/select.html', + iconCheckmark: 'fa fa-check', + caretHtml: '' + }); +}]); + +// AngularStrap alerts configuration. +igniteConsoleCfg.config(['$alertProvider', ($alertProvider) => { + angular.extend($alertProvider.defaults, { + container: 'body', + placement: 'top-right', + duration: '5', + templateUrl: alertTemplateUrl, + type: 'danger' + }); +}]); + + +// AngularStrap dropdowns () configuration. +igniteConsoleCfg.config(['$dropdownProvider', ($dropdownProvider) => { + angular.extend($dropdownProvider.defaults, { + templateUrl: 'templates/dropdown.html' + }); +}]); http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/app.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/app.js b/modules/web-console/src/main/js/app/app.js index a33e385..ca6b605 100644 --- a/modules/web-console/src/main/js/app/app.js +++ b/modules/web-console/src/main/js/app/app.js @@ -17,10 +17,11 @@ import '../public/stylesheets/style.scss'; +import './app.config'; + import './decorator/select'; import './decorator/tooltip'; -import './services/JavaTypes.service.js'; import './modules/form/form.module'; import './modules/agent/agent.module.js'; import './modules/query-notebooks/query-notebooks.module'; @@ -48,30 +49,47 @@ import './modules/loading/loading.module'; // endignite // Directives. +import igniteAutoFocus from './directives/auto-focus.directive.js'; +import igniteBsAffixUpdate from './directives/bs-affix-update.directive'; +import igniteCentered from './directives/centered/centered.directive.js'; +import igniteCopyToClipboard from './directives/copy-to-clipboard.directive.js'; import igniteHideOnStateChange from './directives/hide-on-state-change/hide-on-state-change.directive'; import igniteInformation from './directives/information/information.directive'; -import igniteUiAceTabs from './directives/ui-ace-tabs.directive'; -import igniteUiAceXml from './directives/ui-ace-xml/ui-ace-xml.directive'; -import igniteUiAceJava from './directives/ui-ace-java/ui-ace-java.directive'; -import igniteUiAcePom from './directives/ui-ace-pom/ui-ace-pom.directive'; +import igniteMatch from './directives/match.directive.js'; +import igniteOnClickFocus from './directives/on-click-focus.directive.js'; +import igniteOnEnter from './directives/on-enter.directive.js'; +import igniteOnEnterFocusMove from './directives/on-enter-focus-move.directive.js'; +import igniteOnEscape from './directives/on-escape.directive.js'; +import igniteRetainSelection from './directives/retain-selection.directive.js'; import igniteUiAceDocker from './directives/ui-ace-docker/ui-ace-docker.directive'; +import igniteUiAceJava from './directives/ui-ace-java/ui-ace-java.directive'; import igniteUiAcePojos from './directives/ui-ace-pojos/ui-ace-pojos.directive'; -import igniteBsAffixUpdate from './directives/bs-affix-update.directive'; -import igniteCentered from './directives/centered/centered.directive.js'; +import igniteUiAcePom from './directives/ui-ace-pom/ui-ace-pom.directive'; +import igniteUiAceTabs from './directives/ui-ace-tabs.directive'; +import igniteUiAceXml from './directives/ui-ace-xml/ui-ace-xml.directive'; // Services. -import cleanup from './services/cleanup.service'; -import confirm from './services/confirm.service'; -import IgniteInetAddress from './services/InetAddress.service'; -import IgniteCountries from './services/Countries.service'; -import IgniteChartColors from './services/ChartColors.service'; +import ChartColors from './services/ChartColors.service'; +import Cleanup from './services/cleanup.service'; +import Clone from './services/Clone.service.js'; +import Confirm from './services/confirm.service'; +import ConfirmBatch from './services/ConfirmBatch.service.js'; +import CopyToClipboard from './services/CopyToClipboard.service'; +import Countries from './services/Countries.service'; +import Focus from './services/Focus.service'; +import InetAddress from './services/InetAddress.service'; import JavaTypes from './services/JavaTypes.service'; +import Messages from './services/Messages.service'; +import LegacyTable from './services/LegacyTable.service'; +import LegacyUtils from './services/LegacyUtils.service'; +import UnsavedChangesGuard from './services/UnsavedChangesGuard.service'; // Providers. // Filters. -import hasPojo from './filters/hasPojo.filter'; import byName from './filters/byName.filter'; +import domainsValidation from './filters/domainsValidation.filter'; +import hasPojo from './filters/hasPojo.filter'; // Generators import $generatorCommon from 'generator/generator-common'; @@ -88,17 +106,17 @@ window.$generatorProperties = $generatorProperties; window.$generatorReadme = $generatorReadme; window.$generatorXml = $generatorXml; -// Add legacy logic; -import consoleModule from 'controllers/common-module'; -window.consoleModule = consoleModule; - -import 'controllers/admin-controller'; -import 'controllers/caches-controller'; -import 'controllers/clusters-controller'; -import 'controllers/domains-controller'; -import 'controllers/igfs-controller'; -import 'controllers/profile-controller'; -import 'controllers/sql-controller'; +// Controllers +import admin from 'controllers/admin-controller'; +import caches from 'controllers/caches-controller'; +import clusters from 'controllers/clusters-controller'; +import domains from 'controllers/domains-controller'; +import igfs from 'controllers/igfs-controller'; +import profile from 'controllers/profile-controller'; +import sql from 'controllers/sql-controller'; +import auth from './controllers/auth.controller'; +import notebooks from './controllers/notebooks.controller'; +import resetPassword from './controllers/reset-password.controller'; // Inject external modules. import 'ignite_modules_temp/index'; @@ -107,13 +125,25 @@ import baseTemplate from '../views/base.jade'; angular .module('ignite-console', [ - 'ngRetina', - 'btford.socket-io', + // Optional AngularJS modules. 'ngAnimate', 'ngSanitize', + // Third party libs. + 'ngRetina', + 'btford.socket-io', 'mgcrea.ngStrap', 'ui.router', 'gridster', + 'dndLists', + 'nvd3', + 'smart-table', + 'treeControl', + 'ui.grid', + 'ui.grid.saveState', + 'ui.grid.selection', + 'ui.grid.resizeColumns', + 'ui.grid.autoResize', + 'ui.grid.exporter', // Base modules. 'ignite-console.ace', 'ignite-console.Form', @@ -138,32 +168,59 @@ angular 'ignite-console.getting-started', 'ignite-console.version', 'ignite-console.loading', - // Ignite legacy module. - 'ignite-console.legacy', + // Ignite configuration module. + 'ignite-console.config', // Ignite modules. 'ignite-console.modules' ]) // Directives. +.directive(...igniteAutoFocus) +.directive(...igniteBsAffixUpdate) +.directive(...igniteCentered) +.directive(...igniteCopyToClipboard) .directive(...igniteHideOnStateChange) .directive(...igniteInformation) -.directive(...igniteUiAceTabs) -.directive(...igniteUiAceXml) -.directive(...igniteUiAceJava) -.directive(...igniteUiAcePom) +.directive(...igniteMatch) +.directive(...igniteOnClickFocus) +.directive(...igniteOnEnter) +.directive(...igniteOnEnterFocusMove) +.directive(...igniteOnEscape) +.directive(...igniteRetainSelection) .directive(...igniteUiAceDocker) +.directive(...igniteUiAceJava) .directive(...igniteUiAcePojos) -.directive(...igniteBsAffixUpdate) -.directive(...igniteCentered) +.directive(...igniteUiAcePom) +.directive(...igniteUiAceTabs) +.directive(...igniteUiAceXml) // Services. -.service(...cleanup) -.service(...confirm) -.service(...IgniteInetAddress) -.service(...IgniteCountries) -.service(...IgniteChartColors) +.service(...ChartColors) +.service(...Cleanup) +.service(...Clone) +.service(...Confirm) +.service(...ConfirmBatch) +.service(...CopyToClipboard) +.service(...Countries) +.service(...Focus) +.service(...InetAddress) .service(...JavaTypes) -// Providers. +.service(...Messages) +.service(...LegacyTable) +.service(...LegacyUtils) +.service(...UnsavedChangesGuard) +// Controllers. +.controller(...admin) +.controller(...auth) +.controller(...notebooks) +.controller(...resetPassword) +.controller(...caches) +.controller(...clusters) +.controller(...domains) +.controller(...igfs) +.controller(...profile) +.controller(...sql) // Filters. .filter(...hasPojo) +.filter(...domainsValidation) .filter(...byName) .config(['$stateProvider', '$locationProvider', '$urlRouterProvider', ($stateProvider, $locationProvider, $urlRouterProvider) => { // Set up the states. @@ -183,17 +240,13 @@ angular $locationProvider.html5Mode(true); }]) -.config(['$animateProvider', ($animateProvider) => { - $animateProvider.classNameFilter(/^((?!(fa-spin)).)*$/); -}]) -.run(['$rootScope', ($root) => { +.run(['$rootScope', '$state', 'MetaTags', 'gettingStarted', ($root, $state, $meta, gettingStarted) => { $root._ = _; -}]) -.run(['$rootScope', '$state', 'MetaTags', 'Auth', 'User', 'IgniteAgentMonitor', ($root, $state, $meta, Auth, User, agentMonitor) => { $root.$state = $state; - $root.$meta = $meta; - + $root.gettingStarted = gettingStarted; +}]) +.run(['$rootScope', 'Auth', 'User', 'IgniteAgentMonitor', ($root, Auth, User, agentMonitor) => { if (Auth.authorized) { User.read() .then((user) => $root.$broadcast('user', user)) @@ -204,4 +257,20 @@ angular $root.$on('$stateChangeStart', () => { _.forEach(angular.element('.modal'), (m) => angular.element(m).scope().$hide()); }); -}]); +}]) +.run(['$rootScope', '$http', '$state', 'IgniteMessages', 'User', + ($root, $http, $state, Messages, User) => { // eslint-disable-line no-shadow + $root.revertIdentity = () => { + $http + .get('/api/v1/admin/revert/identity') + .then(User.read) + .then((user) => { + $root.$broadcast('user', user); + + $state.go('settings.admin'); + }) + .catch(Messages.showError); + }; + } +]); + http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/controllers/auth.controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/controllers/auth.controller.js b/modules/web-console/src/main/js/app/controllers/auth.controller.js new file mode 100644 index 0000000..21ffeb8 --- /dev/null +++ b/modules/web-console/src/main/js/app/controllers/auth.controller.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. + */ + +// Sign in controller. +// TODO IGNITE-1936 Refactor this controller. +export default ['auth', [ + '$scope', 'IgniteFocus', 'IgniteCountries', 'Auth', + ($scope, Focus, Countries, Auth) => { + $scope.auth = Auth.auth; + $scope.forgotPassword = Auth.forgotPassword; + $scope.action = 'signin'; + $scope.countries = Countries.getAll(); + + Focus.move('user_email'); + } +]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/controllers/notebooks.controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/controllers/notebooks.controller.js b/modules/web-console/src/main/js/app/controllers/notebooks.controller.js new file mode 100644 index 0000000..0440c46 --- /dev/null +++ b/modules/web-console/src/main/js/app/controllers/notebooks.controller.js @@ -0,0 +1,69 @@ +/* + * 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. + */ + +// Controller that load notebooks in navigation bar . +export default ['notebooks', [ + '$rootScope', '$scope', '$modal', '$state', '$http', 'IgniteMessages', + ($root, $scope, $modal, $state, $http, Messages) => { + $root.notebooks = []; + + // Pre-fetch modal dialogs. + const _notebookNewModal = $modal({scope: $scope, templateUrl: '/sql/notebook-new.html', show: false}); + + $root.rebuildDropdown = function() { + $scope.notebookDropdown = [ + {text: 'Create new notebook', click: 'inputNotebookName()'}, + {divider: true} + ]; + + _.forEach($root.notebooks, (notebook) => $scope.notebookDropdown.push({ + text: notebook.name, + sref: 'base.sql.notebook({noteId:"' + notebook._id + '"})' + })); + }; + + $root.reloadNotebooks = function() { + // When landing on the page, get clusters and show them. + $http.post('/api/v1/notebooks/list') + .success((data) => { + $root.notebooks = data; + + $root.rebuildDropdown(); + }) + .error(Messages.showError); + }; + + $root.inputNotebookName = () => { + _notebookNewModal.$promise.then(_notebookNewModal.show); + }; + + $root.createNewNotebook = (name) => { + $http.post('/api/v1/notebooks/new', {name}) + .success((noteId) => { + _notebookNewModal.hide(); + + $root.reloadNotebooks(); + + $state.go('base.sql.notebook', {noteId}); + }) + .error(Messages.showError); + }; + + $root.reloadNotebooks(); + + } +]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/controllers/reset-password.controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/controllers/reset-password.controller.js b/modules/web-console/src/main/js/app/controllers/reset-password.controller.js new file mode 100644 index 0000000..f3cee81 --- /dev/null +++ b/modules/web-console/src/main/js/app/controllers/reset-password.controller.js @@ -0,0 +1,51 @@ +/* + * 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. + */ + +// Controller for password reset. +export default ['resetPassword', [ + '$scope', '$modal', '$http', '$state', 'IgniteMessages', 'IgniteFocus', + ($scope, $modal, $http, $state, Messages, Focus) => { + if ($state.params.token) { + $http.post('/api/v1/password/validate/token', {token: $state.params.token}) + .success((res) => { + $scope.email = res.email; + $scope.token = res.token; + $scope.error = res.error; + + if ($scope.token && !$scope.error) + Focus.move('user_password'); + }); + } + + // Try to reset user password for provided token. + $scope.resetPassword = (reset_info) => { + $http.post('/api/v1/password/reset', reset_info) + .success(() => { + Messages.showInfo('Password successfully changed'); + + $state.go('base.configuration.clusters'); + }) + .error((err, state) => { + Messages.showError(err); + + if (state === 503) + $state.go('base.configuration.clusters'); + }); + }; + + } +]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/directives/auto-focus.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/directives/auto-focus.directive.js b/modules/web-console/src/main/js/app/directives/auto-focus.directive.js new file mode 100644 index 0000000..326fe1f --- /dev/null +++ b/modules/web-console/src/main/js/app/directives/auto-focus.directive.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. + */ + +// Directive to auto-focus specified element. +export default ['igniteAutoFocus', ['$timeout', ($timeout) => { + return { + restrict: 'AC', + link(scope, element) { + $timeout(() => element[0].focus()); + } + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/directives/copy-to-clipboard.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/directives/copy-to-clipboard.directive.js b/modules/web-console/src/main/js/app/directives/copy-to-clipboard.directive.js new file mode 100644 index 0000000..ee2110e --- /dev/null +++ b/modules/web-console/src/main/js/app/directives/copy-to-clipboard.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. + */ + +// Directive for copy to clipboard. +export default ['igniteCopyToClipboard', ['IgniteCopyToClipboard', (CopyToClipboard) => { + return { + restrict: 'A', + link(scope, element, attrs) { + element.bind('click', () => CopyToClipboard.copy(attrs.igniteCopyToClipboard)); + + if (!document.queryCommandSupported('copy')) + element.hide(); + } + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/directives/match.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/directives/match.directive.js b/modules/web-console/src/main/js/app/directives/match.directive.js new file mode 100644 index 0000000..f222f22 --- /dev/null +++ b/modules/web-console/src/main/js/app/directives/match.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. + */ + +// Directive to enable validation to match specified value. +export default ['igniteMatch', ['$parse', ($parse) => { + return { + require: 'ngModel', + link(scope, elem, attrs, ctrl) { + scope.$watch(() => $parse(attrs.match)(scope) === ctrl.$modelValue, + (currentValue) => ctrl.$setValidity('mismatch', currentValue)); + } + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/directives/on-click-focus.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/directives/on-click-focus.directive.js b/modules/web-console/src/main/js/app/directives/on-click-focus.directive.js new file mode 100644 index 0000000..5c9ee88 --- /dev/null +++ b/modules/web-console/src/main/js/app/directives/on-click-focus.directive.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. + */ + +// Directive to describe element that should be focused on click. +export default ['igniteOnClickFocus', ['IgniteFocus', (Focus) => { + return function(scope, elem, attrs) { + elem.on('click', () => Focus.move(attrs.igniteOnClickFocus)); + + // Removes bound events in the element itself when the scope is destroyed + scope.$on('$destroy', () => elem.off('click')); + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/directives/on-enter-focus-move.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/directives/on-enter-focus-move.directive.js b/modules/web-console/src/main/js/app/directives/on-enter-focus-move.directive.js new file mode 100644 index 0000000..2dd2884 --- /dev/null +++ b/modules/web-console/src/main/js/app/directives/on-enter-focus-move.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. + */ + +// Directive to move focus to specified element on ENTER key. +export default ['igniteOnEnterFocusMove', ['IgniteFocus', (Focus) => { + return function(scope, elem, attrs) { + elem.on('keydown keypress', (event) => { + if (event.which === 13) { + event.preventDefault(); + + Focus.move(attrs.igniteOnEnterFocusMove); + } + }); + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/directives/on-enter.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/directives/on-enter.directive.js b/modules/web-console/src/main/js/app/directives/on-enter.directive.js new file mode 100644 index 0000000..459220e --- /dev/null +++ b/modules/web-console/src/main/js/app/directives/on-enter.directive.js @@ -0,0 +1,32 @@ +/* + * 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. + */ + +// Directive to bind ENTER key press with some user action. +export default ['igniteOnEnter', ['$timeout', ($timeout) => { + return function(scope, elem, attrs) { + elem.on('keydown keypress', (event) => { + if (event.which === 13) { + scope.$apply(() => $timeout(() => scope.$eval(attrs.igniteOnEnter))); + + event.preventDefault(); + } + }); + + // Removes bound events in the element itself when the scope is destroyed. + scope.$on('$destroy', () => elem.off('keydown keypress')); + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/directives/on-escape.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/directives/on-escape.directive.js b/modules/web-console/src/main/js/app/directives/on-escape.directive.js new file mode 100644 index 0000000..aa1accd --- /dev/null +++ b/modules/web-console/src/main/js/app/directives/on-escape.directive.js @@ -0,0 +1,32 @@ +/* + * 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. + */ + +// Directive to bind ESC key press with some user action. +export default ['igniteOnEscape', ['$timeout', ($timeout) => { + return function(scope, elem, attrs) { + elem.on('keydown keypress', (event) => { + if (event.which === 27) { + scope.$apply(() => $timeout(() => scope.$eval(attrs.igniteOnEscape))); + + event.preventDefault(); + } + }); + + // Removes bound events in the element itself when the scope is destroyed. + scope.$on('$destroy', () => elem.off('keydown keypress')); + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/directives/retain-selection.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/directives/retain-selection.directive.js b/modules/web-console/src/main/js/app/directives/retain-selection.directive.js new file mode 100644 index 0000000..a4c2023 --- /dev/null +++ b/modules/web-console/src/main/js/app/directives/retain-selection.directive.js @@ -0,0 +1,66 @@ +/* + * 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. + */ + +// Directive to retain selection. To fix angular-strap typeahead bug with setting cursor to the end of text. +export default ['igniteRetainSelection', ['$timeout', ($timeout) => { + let promise; + + return function(scope, elem) { + elem.on('keydown', (evt) => { + const key = evt.which; + const ctrlDown = evt.ctrlKey || evt.metaKey; + const input = this; + + let start = input.selectionStart; + + if (promise) + $timeout.cancel(promise); + + promise = $timeout(() => { + let setCursor = false; + + // Handle Backspace[8]. + if (key === 8 && start > 0) { + start -= 1; + + setCursor = true; + } + // Handle Del[46]. + else if (key === 46) + setCursor = true; + // Handle: Caps Lock[20], Tab[9], Shift[16], Ctrl[17], Alt[18], Esc[27], Enter[13], Arrows[37..40], Home[36], End[35], Ins[45], PgUp[33], PgDown[34], F1..F12[111..124], Num Lock[], Scroll Lock[145]. + else if (!(key === 8 || key === 9 || key === 13 || (key > 15 && key < 20) || key === 27 || + (key > 32 && key < 41) || key === 45 || (key > 111 && key < 124) || key === 144 || key === 145)) { + // Handle: Ctrl + [A[65], C[67], V[86]]. + if (!(ctrlDown && (key === 65 || key === 67 || key === 86))) { + start += 1; + + setCursor = true; + } + } + + if (setCursor) + input.setSelectionRange(start, start); + + promise = null; + }); + }); + + // Removes bound events in the element itself when the scope is destroyed + scope.$on('$destroy', () => elem.off('keydown')); + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/filters/domainsValidation.filter.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/filters/domainsValidation.filter.js b/modules/web-console/src/main/js/app/filters/domainsValidation.filter.js new file mode 100644 index 0000000..1a38392 --- /dev/null +++ b/modules/web-console/src/main/js/app/filters/domainsValidation.filter.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. + */ + +// Filter domain models with key fields configuration. +export default ['domainsValidation', ['IgniteLegacyUtils', (LegacyUtils) => (domains, valid, invalid) => { + if (valid && invalid) + return domains; + + const out = []; + + _.forEach(domains, function(domain) { + const _valid = !LegacyUtils.domainForStoreConfigured(domain) || LegacyUtils.isJavaBuiltInClass(domain.keyType) || !_.isEmpty(domain.keyFields); + + if (valid && _valid || invalid && !_valid) + out.push(domain); + }); + + return out; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/helpers/jade/mixins.jade ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/helpers/jade/mixins.jade b/modules/web-console/src/main/js/app/helpers/jade/mixins.jade index 2b8b282..08ebe87 100644 --- a/modules/web-console/src/main/js/app/helpers/jade/mixins.jade +++ b/modules/web-console/src/main/js/app/helpers/jade/mixins.jade @@ -42,7 +42,7 @@ mixin main-table(title, rows, focusId, click, rowTemplate, searchField) tbody tr(ng-repeat='row in displayedRows track by row._id' ignite-bs-affix-update) td - a(ng-class='{active: row._id == selectedItem._id}' on-click-focus=focusId ng-click=click) #{rowTemplate} + a(ng-class='{active: row._id == selectedItem._id}' ignite-on-click-focus=focusId ng-click=click) #{rowTemplate} label.placeholder(ng-show='displayedRows.length == 0') No #{title} found //- Mixin with save, remove, clone and undo buttons. @@ -359,8 +359,8 @@ mixin table-text-field(field, items, valid, save, placeholder, newItem) data-placeholder=placeholder data-ignite-unique=items data-ignite-form-field-input-autofocus='true' - on-enter=onEnter - on-escape=onEscape + ignite-on-enter=onEnter + ignite-on-escape=onEscape ng-blur=onBlur ) block @@ -389,8 +389,8 @@ mixin table-java-class-field(lbl, field, items, valid, save, newItem) data-placeholder='Enter fully qualified class name' - on-enter=onEnter - on-escape=onEscape + ignite-on-enter=onEnter + ignite-on-escape=onEscape ng-blur=onBlur ) +error-feedback('form[ngModelName].$error.javaBuiltInClass', 'javaBuiltInClass', lbl + ' should not be the Java built-in class!') @@ -419,8 +419,8 @@ mixin table-java-package-field(field, items, valid, save, newItem) data-java-package-name='true' data-ignite-unique=items data-ignite-form-field-input-autofocus='true' - on-enter=onEnter - on-escape=onEscape + ignite-on-enter=onEnter + ignite-on-escape=onEscape ng-blur=onBlur ) block @@ -445,8 +445,8 @@ mixin table-address-field(field, items, valid, save, newItem, portRange) data-ipaddress-with-port-range=portRange ? 'true' : null data-ignite-unique=items data-ignite-form-field-input-autofocus='true' - on-enter=onEnter - on-escape=onEscape + ignite-on-enter=onEnter + ignite-on-escape=onEscape ng-blur=onBlur ) block @@ -571,9 +571,9 @@ mixin table-pair-edit(tbl, prefix, keyPlaceholder, valPlaceholder, keyJavaBuiltI .fieldSep !{divider} .input-tip if keyJavaBuiltInTypes - input.form-control(id=keyFocusId enter-focus-next=valFocusId type='text' ng-model=keyModel placeholder=keyPlaceholder bs-typeahead container='body' retain-selection data-min-length='1' bs-options='javaClass for javaClass in javaBuiltInClasses' on-escape='tableReset()') + input.form-control(id=keyFocusId ignite-on-enter-focus-move=valFocusId type='text' ng-model=keyModel placeholder=keyPlaceholder bs-typeahead container='body' ignite-retain-selection data-min-length='1' bs-options='javaClass for javaClass in javaBuiltInClasses' ignite-on-escape='tableReset()') else - input.form-control(id=keyFocusId enter-focus-next=valFocusId type='text' ng-model=keyModel placeholder=keyPlaceholder on-escape='tableReset()') + input.form-control(id=keyFocusId ignite-on-enter-focus-move=valFocusId type='text' ng-model=keyModel placeholder=keyPlaceholder ignite-on-escape='tableReset()') .col-xs-6.col-sm-6.col-md-6 -var arg = keyModel + ', ' + valModel -var btnVisible = 'tablePairSaveVisible(' + tbl + ', ' + index + ')' @@ -583,6 +583,6 @@ mixin table-pair-edit(tbl, prefix, keyPlaceholder, valPlaceholder, keyJavaBuiltI +btn-save(btnVisible, btnSave) .input-tip if valueJavaBuiltInTypes - input.form-control(id=valFocusId type='text' ng-model=valModel placeholder=valPlaceholder bs-typeahead container='body' retain-selection data-min-length='1' bs-options='javaClass for javaClass in javaBuiltInClasses' on-enter=btnVisibleAndSave on-escape='tableReset()') + input.form-control(id=valFocusId type='text' ng-model=valModel placeholder=valPlaceholder bs-typeahead container='body' ignite-retain-selection data-min-length='1' bs-options='javaClass for javaClass in javaBuiltInClasses' ignite-on-enter=btnVisibleAndSave ignite-on-escape='tableReset()') else - input.form-control(id=valFocusId type='text' ng-model=valModel placeholder=valPlaceholder on-enter=btnVisibleAndSave on-escape='tableReset()') + input.form-control(id=valFocusId type='text' ng-model=valModel placeholder=valPlaceholder ignite-on-enter=btnVisibleAndSave ignite-on-escape='tableReset()') http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/Demo/Demo.module.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/Demo/Demo.module.js b/modules/web-console/src/main/js/app/modules/Demo/Demo.module.js index 7680408..68aca9d 100644 --- a/modules/web-console/src/main/js/app/modules/Demo/Demo.module.js +++ b/modules/web-console/src/main/js/app/modules/Demo/Demo.module.js @@ -39,17 +39,16 @@ angular }) .state('demo.reset', { url: '/demo/reset', - controller: ['$state', '$http', '$common', ($state, $http, $common) => { + controller: ['$state', '$http', 'IgniteMessages', ($state, $http, Messages) => { $http.post('/api/v1/demo/reset') .then(() => $state.go('base.configuration.clusters')) - .catch((errMsg) => { + .catch((err) => { $state.go('base.configuration.clusters'); - $common.showError(errMsg); + Messages.showError(err); }); }], - metaTags: { - } + metaTags: {} }); }]) .provider('Demo', ['$stateProvider', '$httpProvider', 'igniteSocketFactoryProvider', function($state, $http, socketFactory) { @@ -82,14 +81,14 @@ angular } }; }]) -.controller('demoController', ['$scope', '$state', '$window', '$confirm', ($scope, $state, $window, $confirm) => { +.controller('demoController', ['$scope', '$state', '$window', 'IgniteConfirm', ($scope, $state, $window, Confirm) => { const _openTab = (stateName) => $window.open($state.href(stateName), '_blank'); $scope.startDemo = () => { if (!$scope.user.demoCreated) return _openTab('demo.reset'); - $confirm.confirm('Would you like to continue with previous demo session?', true, false) + Confirm.confirm('Would you like to continue with previous demo session?', true, false) .then((resume) => { if (resume) return _openTab('demo.resume'); http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/agent/agent.module.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/agent/agent.module.js b/modules/web-console/src/main/js/app/modules/agent/agent.module.js index 4e3f7ef..ca95166 100644 --- a/modules/web-console/src/main/js/app/modules/agent/agent.module.js +++ b/modules/web-console/src/main/js/app/modules/agent/agent.module.js @@ -19,7 +19,7 @@ import angular from 'angular'; import io from 'socket.io-client'; // eslint-disable-line no-unused-vars class IgniteAgentMonitor { - constructor(socketFactory, $root, $q, $state, $modal, $common) { + constructor(socketFactory, $root, $q, $state, $modal, Messages) { this._scope = $root.$new(); $root.$watch('user', () => { @@ -45,7 +45,7 @@ class IgniteAgentMonitor { * Special dialog hide function. */ this._downloadAgentModal.hide = () => { - $common.hideAlert(); + Messages.hideAlert(); _modalHide(); }; @@ -87,7 +87,7 @@ class IgniteAgentMonitor { this._$q = $q; - this._$common = $common; + this.Messages = Messages; } /** @@ -234,7 +234,7 @@ class IgniteAgentMonitor { if (this._scope.showModal) { this._downloadAgentModal.$promise.then(this._downloadAgentModal.show); - this._$common.showError(err); + this.Messages.showError(err); } } @@ -314,7 +314,7 @@ class IgniteAgentMonitor { } } -IgniteAgentMonitor.$inject = ['igniteSocketFactory', '$rootScope', '$q', '$state', '$modal', '$common']; +IgniteAgentMonitor.$inject = ['igniteSocketFactory', '$rootScope', '$q', '$state', '$modal', 'IgniteMessages']; angular .module('ignite-console.agent', [ http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/form/field/dropdown.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/form/field/dropdown.directive.js b/modules/web-console/src/main/js/app/modules/form/field/dropdown.directive.js index a4c6abb..23c900a 100644 --- a/modules/web-console/src/main/js/app/modules/form/field/dropdown.directive.js +++ b/modules/web-console/src/main/js/app/modules/form/field/dropdown.directive.js @@ -17,7 +17,7 @@ import templateUrl from './dropdown.jade'; -export default ['igniteFormFieldDropdown', ['IgniteFormGUID', '$table', (guid, $table) => { +export default ['igniteFormFieldDropdown', ['IgniteFormGUID', 'IgniteLegacyTable', (guid, LegacyTable) => { const controller = () => {}; const link = (scope, $element, attrs, [form, label]) => { @@ -48,9 +48,8 @@ export default ['igniteFormFieldDropdown', ['IgniteFormGUID', '$table', (guid, $ scope.$watch(() => form.$pristine, setAsDefault); scope.$watch('value', setAsDefault); - // TODO LEGACY scope.tableReset = () => { - $table.tableSaveAndReset(); + LegacyTable.tableSaveAndReset(); }; }; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/form/field/dropdown.jade ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/form/field/dropdown.jade b/modules/web-console/src/main/js/app/modules/form/field/dropdown.jade index 48b55d9..5b7cdf6 100644 --- a/modules/web-console/src/main/js/app/modules/form/field/dropdown.jade +++ b/modules/web-console/src/main/js/app/modules/form/field/dropdown.jade @@ -30,7 +30,7 @@ data-ng-required='required || false' - on-enter='{{ onEnter }}' + ignite-on-enter='{{ onEnter }}' tabindex='0' @@ -51,7 +51,7 @@ data-ng-required='required || false' - on-enter='{{ onEnter }}' + ignite-on-enter='{{ onEnter }}' tabindex='0' http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/form/field/input/checkbox.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/form/field/input/checkbox.directive.js b/modules/web-console/src/main/js/app/modules/form/field/input/checkbox.directive.js index d03b9ae..3d84b4e 100644 --- a/modules/web-console/src/main/js/app/modules/form/field/input/checkbox.directive.js +++ b/modules/web-console/src/main/js/app/modules/form/field/input/checkbox.directive.js @@ -17,7 +17,7 @@ import templateUrl from './checkbox.jade'; -export default ['igniteFormFieldInputCheckbox', ['IgniteFormGUID', '$table', (guid, $table) => { +export default ['igniteFormFieldInputCheckbox', ['IgniteFormGUID', 'IgniteLegacyTable', (guid, LegacyTable) => { const link = (scope, el, attrs, [form, label]) => { const {id, name} = scope; const field = form[name]; @@ -40,9 +40,8 @@ export default ['igniteFormFieldInputCheckbox', ['IgniteFormGUID', '$table', (gu scope.$watch(() => form.$pristine, setAsDefault); scope.$watch('value', setAsDefault); - // TODO LEGACY scope.tableReset = () => { - $table.tableSaveAndReset(); + LegacyTable.tableSaveAndReset(); }; }; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/form/field/input/datalist.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/form/field/input/datalist.directive.js b/modules/web-console/src/main/js/app/modules/form/field/input/datalist.directive.js index 2fd8aa0..6c43a2a 100644 --- a/modules/web-console/src/main/js/app/modules/form/field/input/datalist.directive.js +++ b/modules/web-console/src/main/js/app/modules/form/field/input/datalist.directive.js @@ -17,7 +17,7 @@ import templateUrl from './datalist.jade'; -export default ['igniteFormFieldInputDatalist', ['IgniteFormGUID', '$table', (guid, $table) => { +export default ['igniteFormFieldInputDatalist', ['IgniteFormGUID', 'IgniteLegacyTable', (guid, LegacyTable) => { const link = (scope, element, attrs, [ngModel, form, label], transclude) => { const {id, ngModelName} = scope; @@ -86,9 +86,8 @@ export default ['igniteFormFieldInputDatalist', ['IgniteFormGUID', '$table', (gu scope.value = ngModel.$modelValue; }; - // TODO LEGACY scope.tableReset = () => { - $table.tableSaveAndReset(); + LegacyTable.tableSaveAndReset(); }; transclude(scope.$parent, function(clone, tscope) { http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/form/field/input/datalist.jade ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/form/field/input/datalist.jade b/modules/web-console/src/main/js/app/modules/form/field/input/datalist.jade index 723b348..7ae1411 100644 --- a/modules/web-console/src/main/js/app/modules/form/field/input/datalist.jade +++ b/modules/web-console/src/main/js/app/modules/form/field/input/datalist.jade @@ -43,7 +43,7 @@ mixin feedback(isCheckPristine, error, errorMessage) bs-options='item for item in options' container='body' data-min-length='1' - retain-selection + ignite-retain-selection ) +feedback(true, 'required', '{{ label.name }} could not be empty!') http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/form/field/input/number.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/form/field/input/number.directive.js b/modules/web-console/src/main/js/app/modules/form/field/input/number.directive.js index 71f95b8..0d21f5b 100644 --- a/modules/web-console/src/main/js/app/modules/form/field/input/number.directive.js +++ b/modules/web-console/src/main/js/app/modules/form/field/input/number.directive.js @@ -17,7 +17,7 @@ import templateUrl from './number.jade'; -export default ['igniteFormFieldInputNumber', ['IgniteFormGUID', '$table', (guid, $table) => { +export default ['igniteFormFieldInputNumber', ['IgniteFormGUID', 'IgniteLegacyTable', (guid, LegacyTable) => { const link = (scope, el, attrs, [form, label]) => { const {id, name} = scope; const field = form[name]; @@ -46,9 +46,8 @@ export default ['igniteFormFieldInputNumber', ['IgniteFormGUID', '$table', (guid scope.$watch(() => form.$pristine, setAsDefault); scope.$watch('value', setAsDefault); - // TODO LEGACY scope.tableReset = () => { - $table.tableSaveAndReset(); + LegacyTable.tableSaveAndReset(); }; }; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/form/field/input/text.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/form/field/input/text.directive.js b/modules/web-console/src/main/js/app/modules/form/field/input/text.directive.js index 735578e..56c02b5 100644 --- a/modules/web-console/src/main/js/app/modules/form/field/input/text.directive.js +++ b/modules/web-console/src/main/js/app/modules/form/field/input/text.directive.js @@ -18,7 +18,7 @@ import templateUrl from './text.jade'; import './text.css'; -export default ['igniteFormFieldInputText', ['IgniteFormGUID', '$table', (guid, $table) => { +export default ['igniteFormFieldInputText', ['IgniteFormGUID', 'IgniteLegacyTable', (guid, LegacyTable) => { const link = (scope, element, attrs, [ngModel, form, label], transclude) => { const {id, ngModelName} = scope; @@ -90,9 +90,8 @@ export default ['igniteFormFieldInputText', ['IgniteFormGUID', '$table', (guid, scope.value = ngModel.$modelValue; }; - // TODO LEGACY scope.tableReset = () => { - $table.tableSaveAndReset(); + LegacyTable.tableSaveAndReset(); }; transclude(scope.$parent, function(clone, tscope) { http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/form/panel/revert.directive.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/form/panel/revert.directive.js b/modules/web-console/src/main/js/app/modules/form/panel/revert.directive.js index 2bf4c8c..d60efb8 100644 --- a/modules/web-console/src/main/js/app/modules/form/panel/revert.directive.js +++ b/modules/web-console/src/main/js/app/modules/form/panel/revert.directive.js @@ -17,7 +17,7 @@ const template = '<i ng-show="form.$dirty" class="fa fa-undo pull-right" ng-click="revert($event)"></i>'; -export default ['igniteFormRevert', ['$tooltip', '$table', ($tooltip, $table) => { +export default ['igniteFormRevert', ['$tooltip', 'IgniteLegacyTable', ($tooltip, LegacyTable) => { const link = (scope, $element, $attrs, [form]) => { $tooltip($element, { title: 'Undo unsaved changes' }); @@ -26,7 +26,7 @@ export default ['igniteFormRevert', ['$tooltip', '$table', ($tooltip, $table) => scope.revert = (e) => { e.stopPropagation(); - $table.tableReset(); + LegacyTable.tableReset(); _.forOwn(form.$defaults, (value, name) => { const field = form[name]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/states/configuration/caches/store.jade ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/states/configuration/caches/store.jade b/modules/web-console/src/main/js/app/modules/states/configuration/caches/store.jade index cb26d03..6361e28 100644 --- a/modules/web-console/src/main/js/app/modules/states/configuration/caches/store.jade +++ b/modules/web-console/src/main/js/app/modules/states/configuration/caches/store.jade @@ -67,8 +67,8 @@ mixin hibernateField(items, field, valid, save, newItem) data-ignite-property-unique=items data-ignite-property-value-specified data-ignite-form-field-input-autofocus='true' - on-enter=onEnter - on-escape=reset + ignite-on-enter=onEnter + ignite-on-escape=reset ng-blur=onBlur ) block http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/states/configuration/domains/query.jade ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/states/configuration/domains/query.jade b/modules/web-console/src/main/js/app/modules/states/configuration/domains/query.jade index f66de92..9ac0d00 100644 --- a/modules/web-console/src/main/js/app/modules/states/configuration/domains/query.jade +++ b/modules/web-console/src/main/js/app/modules/states/configuration/domains/query.jade @@ -39,15 +39,15 @@ mixin table-index-item-edit(prefix, index, sortAvailable, idAddition) .col-xs-8.col-sm-8.col-md-8(ng-show=sortAvailable) label.fieldSep / .input-tip - input.form-control(id='{{::"#{fieldName}S" + #{idAddition}}}' enter-focus-next='{{::"#{direction}S" + #{idAddition}}}' type='text' ng-model=fieldNameModel placeholder='Field name' on-escape='tableReset()') + input.form-control(id='{{::"#{fieldName}S" + #{idAddition}}}' ignite-on-enter-focus-move='{{::"#{direction}S" + #{idAddition}}}' type='text' ng-model=fieldNameModel placeholder='Field name' ignite-on-escape='tableReset()') .col-xs-4.col-sm-4.col-md-4(ng-show=sortAvailable) +btn-save(btnVisible, btnSave) .input-tip - button.select-toggle.form-control(id='{{::"#{direction}S" + #{idAddition}}}' ng-model=directionModel bs-select bs-options='item.value as item.label for item in {{sortDirections}}' on-enter=btnVisibleAndSave on-escape='tableReset()' tabindex='0') + button.select-toggle.form-control(id='{{::"#{direction}S" + #{idAddition}}}' ng-model=directionModel bs-select bs-options='item.value as item.label for item in {{sortDirections}}' ignite-on-enter=btnVisibleAndSave ignite-on-escape='tableReset()' tabindex='0') .col-xs-12(ng-show='!(#{sortAvailable})') +btn-save(btnVisible, btnSave) .input-tip - input.form-control(id='{{::"#{fieldName}" + #{idAddition}}}' type='text' ng-model=fieldNameModel placeholder='Field name' on-enter=btnVisibleAndSave on-escape='tableReset()') + input.form-control(id='{{::"#{fieldName}" + #{idAddition}}}' type='text' ng-model=fieldNameModel placeholder='Field name' ignite-on-enter=btnVisibleAndSave ignite-on-escape='tableReset()') form.panel.panel-default(name='query' novalidate) .panel-heading(bs-collapse-toggle) @@ -134,11 +134,11 @@ form.panel.panel-default(name='query' novalidate) .col-sm-7 label.fieldSep / .input-tip - input.form-control(id='curIndexName{{$index}}' type='text' enter-focus-next='curIndexType{{$index}}' ng-model='indexesTbl.curIndexName' placeholder='Index name' on-enter=btnVisibleAndSave on-escape='tableReset()') + input.form-control(id='curIndexName{{$index}}' type='text' ignite-on-enter-focus-move='curIndexType{{$index}}' ng-model='indexesTbl.curIndexName' placeholder='Index name' ignite-on-enter=btnVisibleAndSave ignite-on-escape='tableReset()') .col-sm-5 +btn-save('tableIndexSaveVisible(indexesTbl, $index)', 'tableIndexSave(indexesTbl, $index)') .input-tip - button.select-toggle.form-control(id='curIndexType{{$index}}' bs-select ng-model='indexesTbl.curIndexType' data-placeholder='Select index type' bs-options='item.value as item.label for item in indexType' tabindex='0' on-enter=btnVisibleAndSave on-escape='tableReset()') + button.select-toggle.form-control(id='curIndexType{{$index}}' bs-select ng-model='indexesTbl.curIndexType' data-placeholder='Select index type' bs-options='item.value as item.label for item in indexType' tabindex='0' ignite-on-enter=btnVisibleAndSave ignite-on-escape='tableReset()') .margin-left-dflt table.links-edit-sub(st-table='item.fields' ng-init='itemIndex = $index') tbody @@ -160,10 +160,10 @@ form.panel.panel-default(name='query' novalidate) .col-sm-7 .fieldSep / .input-tip - input#newIndexName.form-control(type='text' enter-focus-next='newIndexType' ng-model='indexesTbl.newIndexName' placeholder='Index name' on-enter='tableIndexSaveVisible(indexesTbl, -1) && tableIndexSave(indexesTbl, -1)' on-escape='tableReset()') + input#newIndexName.form-control(type='text' ignite-on-enter-focus-move='newIndexType' ng-model='indexesTbl.newIndexName' placeholder='Index name' ignite-on-enter='tableIndexSaveVisible(indexesTbl, -1) && tableIndexSave(indexesTbl, -1)' ignite-on-escape='tableReset()') .col-sm-5 +btn-save('tableIndexSaveVisible(indexesTbl, -1)', 'tableIndexSave(indexesTbl, -1)') .input-tip - button#newIndexType.select-toggle.form-control(bs-select ng-model='indexesTbl.newIndexType' data-placeholder='Select index type' bs-options='item.value as item.label for item in indexType' tabindex='0' on-enter=btnVisibleAndSave on-escape='tableReset()') + button#newIndexType.select-toggle.form-control(bs-select ng-model='indexesTbl.newIndexType' data-placeholder='Select index type' bs-options='item.value as item.label for item in indexType' tabindex='0' ignite-on-enter=btnVisibleAndSave ignite-on-escape='tableReset()') .col-sm-6 +preview-xml-java(model, 'domainModelQuery') http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/states/configuration/domains/store.jade ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/states/configuration/domains/store.jade b/modules/web-console/src/main/js/app/modules/states/configuration/domains/store.jade index d2a1dc6..8d3c65b 100644 --- a/modules/web-console/src/main/js/app/modules/states/configuration/domains/store.jade +++ b/modules/web-console/src/main/js/app/modules/states/configuration/domains/store.jade @@ -43,15 +43,15 @@ mixin table-db-field-edit(tbl, prefix, focusId, index) .col-xs-3.col-sm-3.col-md-3 .fieldSep / .input-tip - input.form-control(id=databaseNameId enter-focus-next=databaseTypeId type='text' ng-model=databaseNameModel placeholder='DB name' on-enter='#{javaNameModel} = #{javaNameModel} ? #{javaNameModel} : #{databaseNameModel}' on-escape='tableReset()') + input.form-control(id=databaseNameId ignite-on-enter-focus-move=databaseTypeId type='text' ng-model=databaseNameModel placeholder='DB name' ignite-on-enter='#{javaNameModel} = #{javaNameModel} ? #{javaNameModel} : #{databaseNameModel}' ignite-on-escape='tableReset()') .col-xs-3.col-sm-3.col-md-3 .fieldSep / .input-tip - button.select-toggle.form-control(id=databaseTypeId enter-focus-next=javaNameId ng-model=databaseTypeModel data-placeholder='DB type' ng-class='{placeholder: !#{databaseTypeModel}}' bs-select bs-options='item.value as item.label for item in {{supportedJdbcTypes}}' on-escape='tableReset()' tabindex='0') + button.select-toggle.form-control(id=databaseTypeId ignite-on-enter-focus-move=javaNameId ng-model=databaseTypeModel data-placeholder='DB type' ng-class='{placeholder: !#{databaseTypeModel}}' bs-select bs-options='item.value as item.label for item in {{supportedJdbcTypes}}' ignite-on-escape='tableReset()' tabindex='0') .col-xs-3.col-sm-3.col-md-3 .fieldSep / .input-tip - input.form-control(id=javaNameId enter-focus-next=javaTypeId type='text' ng-model=javaNameModel placeholder='Java name' on-escape='tableReset()') + input.form-control(id=javaNameId ignite-on-enter-focus-move=javaTypeId type='text' ng-model=javaNameModel placeholder='Java name' ignite-on-escape='tableReset()') .col-xs-3.col-sm-3.col-md-3 -var btnVisible = 'tableDbFieldSaveVisible(' + tbl + ', ' + index +')' -var btnSave = 'tableDbFieldSave(' + tbl + ', ' + index +')' @@ -59,7 +59,7 @@ mixin table-db-field-edit(tbl, prefix, focusId, index) +btn-save(btnVisible, btnSave) .input-tip - button.select-toggle.form-control(id=javaTypeId ng-model=javaTypeModel data-placeholder='Java type' ng-class='{placeholder: !#{javaTypeModel}}' bs-select bs-options='item.value as item.label for item in {{supportedJavaTypes}}' on-enter=btnVisibleAndSave on-escape='tableReset()' tabindex='0') + button.select-toggle.form-control(id=javaTypeId ng-model=javaTypeModel data-placeholder='Java type' ng-class='{placeholder: !#{javaTypeModel}}' bs-select bs-options='item.value as item.label for item in {{supportedJavaTypes}}' ignite-on-enter=btnVisibleAndSave ignite-on-escape='tableReset()' tabindex='0') form.panel.panel-default(name=form novalidate) .panel-heading(bs-collapse-toggle='' ng-click='ui.loadPanel("#{form}")') http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/states/configuration/igfs/misc.jade ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/states/configuration/igfs/misc.jade b/modules/web-console/src/main/js/app/modules/states/configuration/igfs/misc.jade index fd42805..eebc291 100644 --- a/modules/web-console/src/main/js/app/modules/states/configuration/igfs/misc.jade +++ b/modules/web-console/src/main/js/app/modules/states/configuration/igfs/misc.jade @@ -32,7 +32,7 @@ mixin table-igfs-path-mode-edit(prefix, focusId, index) .col-xs-8.col-sm-8.col-md-8 .fieldSep / .input-tip - input.form-control(id=keyFocusId enter-focus-next=valFocusId type='text' ng-model=keyModel placeholder='Path' on-escape='tableReset()') + input.form-control(id=keyFocusId ignite-on-enter-focus-move=valFocusId type='text' ng-model=keyModel placeholder='Path' ignite-on-escape='tableReset()') .col-xs-4.col-sm-4.col-md-4 -var arg = keyModel + ', ' + valModel -var btnVisible = 'tablePairSaveVisible(tblPathModes, ' + index + ')' @@ -40,7 +40,7 @@ mixin table-igfs-path-mode-edit(prefix, focusId, index) -var btnVisibleAndSave = btnVisible + ' && ' + btnSave +btn-save(btnVisible, btnSave) .input-tip - button.select-toggle.form-control(id=valFocusId bs-select ng-model=valModel data-placeholder='Mode' bs-options='item.value as item.label for item in igfsModes' tabindex='0' on-enter=btnVisibleAndSave on-escape='tableReset()') + button.select-toggle.form-control(id=valFocusId bs-select ng-model=valModel data-placeholder='Mode' bs-options='item.value as item.label for item in igfsModes' tabindex='0' ignite-on-enter=btnVisibleAndSave ignite-on-escape='tableReset()') form.panel.panel-default(name=form novalidate) .panel-heading(bs-collapse-toggle='' ng-click='ui.loadPanel("#{form}")') http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/states/configuration/summary/summary.controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/states/configuration/summary/summary.controller.js b/modules/web-console/src/main/js/app/modules/states/configuration/summary/summary.controller.js index bba1ae0..d9faf6c 100644 --- a/modules/web-console/src/main/js/app/modules/states/configuration/summary/summary.controller.js +++ b/modules/web-console/src/main/js/app/modules/states/configuration/summary/summary.controller.js @@ -20,8 +20,8 @@ import JSZip from 'jszip'; import saver from 'file-saver'; export default [ - '$rootScope', '$scope', '$http', '$common', '$loading', '$filter', 'ConfigurationSummaryResource', 'JavaTypes', 'IgniteVersion', 'GeneratorDocker', 'GeneratorPom', - function($root, $scope, $http, $common, $loading, $filter, Resource, JavaTypes, IgniteVersion, docker, pom) { + '$rootScope', '$scope', '$http', 'IgniteLegacyUtils', '$loading', '$filter', 'ConfigurationSummaryResource', 'JavaTypes', 'IgniteVersion', 'GeneratorDocker', 'GeneratorPom', + function($root, $scope, $http, LegacyUtils, $loading, $filter, Resource, JavaTypes, IgniteVersion, docker, pom) { const ctrl = this; $scope.ui = { ready: false }; @@ -54,7 +54,7 @@ export default [ return !row || !row._id || _.findIndex(rows, (item) => item._id === row._id) >= 0; }; - $scope.widthIsSufficient = $common.widthIsSufficient; + $scope.widthIsSufficient = LegacyUtils.widthIsSufficient; $scope.dialects = {}; $scope.projectStructureOptions = { http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/modules/user/Auth.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/modules/user/Auth.service.js b/modules/web-console/src/main/js/app/modules/user/Auth.service.js index f0aa397..59370d9 100644 --- a/modules/web-console/src/main/js/app/modules/user/Auth.service.js +++ b/modules/web-console/src/main/js/app/modules/user/Auth.service.js @@ -15,8 +15,8 @@ * limitations under the License. */ -export default ['Auth', ['$http', '$rootScope', '$state', '$window', '$common', 'gettingStarted', 'User', 'IgniteAgentMonitor', - ($http, $root, $state, $window, $common, gettingStarted, User, agentMonitor) => { +export default ['Auth', ['$http', '$rootScope', '$state', '$window', 'IgniteLegacyUtils', 'IgniteMessages', 'gettingStarted', 'User', 'IgniteAgentMonitor', + ($http, $root, $state, $window, LegacyUtils, Messages, gettingStarted, User, agentMonitor) => { let _auth = false; try { @@ -44,7 +44,7 @@ export default ['Auth', ['$http', '$rootScope', '$state', '$window', '$common', forgotPassword(userInfo) { return $http.post('/api/v1/password/forgot', userInfo) .success(() => $state.go('password.send')) - .error((err) => $common.showPopoverMessage(null, null, 'forgot_email', $common.errorMessage(err))); + .error((err) => LegacyUtils.showPopoverMessage(null, null, 'forgot_email', Messages.errorMessage(err))); }, auth(action, userInfo) { return $http.post('/api/v1/' + action, userInfo) @@ -61,7 +61,7 @@ export default ['Auth', ['$http', '$rootScope', '$state', '$window', '$common', agentMonitor.init(); }); }) - .error((err) => $common.showPopoverMessage(null, null, action + '_email', $common.errorMessage(err))); + .error((err) => LegacyUtils.showPopoverMessage(null, null, action + '_email', Messages.errorMessage(err))); }, logout() { return $http.post('/api/v1/logout') @@ -70,7 +70,7 @@ export default ['Auth', ['$http', '$rootScope', '$state', '$window', '$common', $window.open($state.href('signin'), '_self'); }) - .catch((err) => $common.showError(err)); + .catch(Messages.showError); } }; }]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/services/Clone.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/services/Clone.service.js b/modules/web-console/src/main/js/app/services/Clone.service.js new file mode 100644 index 0000000..52a4e4e --- /dev/null +++ b/modules/web-console/src/main/js/app/services/Clone.service.js @@ -0,0 +1,64 @@ +/* + * 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. + */ + +// Service for clone objects. +export default ['IgniteClone', ['$rootScope', '$q', '$modal', ($root, $q, $modal) => { + const scope = $root.$new(); + + let _names = []; + let deferred; + let _validator; + + function _nextAvailableName(name) { + let num = 1; + let tmpName = name; + + while (_.includes(_names, tmpName)) { + tmpName = name + '_' + num.toString(); + + num++; + } + + return tmpName; + } + + const cloneModal = $modal({templateUrl: '/templates/clone.html', scope, placement: 'center', show: false}); + + scope.ok = function(newName) { + if (!_validator || _validator(newName)) { + deferred.resolve(_nextAvailableName(newName)); + + cloneModal.hide(); + } + }; + + cloneModal.confirm = function(oldName, names, validator) { + _names = names; + + scope.newName = _nextAvailableName(oldName); + + _validator = validator; + + deferred = $q.defer(); + + cloneModal.$promise.then(cloneModal.show); + + return deferred.promise; + }; + + return cloneModal; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/services/ConfirmBatch.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/services/ConfirmBatch.service.js b/modules/web-console/src/main/js/app/services/ConfirmBatch.service.js new file mode 100644 index 0000000..ced52af --- /dev/null +++ b/modules/web-console/src/main/js/app/services/ConfirmBatch.service.js @@ -0,0 +1,85 @@ +/* + * 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. + */ + +// Service for confirm or skip several steps. +export default ['IgniteConfirmBatch', ['$rootScope', '$q', '$modal', ($root, $q, $modal) => { + const scope = $root.$new(); + + scope.confirmModal = $modal({templateUrl: '/templates/batch-confirm.html', scope, placement: 'center', show: false}); + + function _done(cancel) { + scope.confirmModal.hide(); + + if (cancel) + scope.deferred.reject('cancelled'); + else + scope.deferred.resolve(); + } + + function _nextElement(skip) { + scope.items[scope.curIx++].skip = skip; + + if (scope.curIx < scope.items.length) + scope.content = scope.contentGenerator(scope.items[scope.curIx]); + else + _done(); + } + + scope.cancel = function() { + _done(true); + }; + + scope.skip = function(applyToAll) { + if (applyToAll) { + for (let i = scope.curIx; i < scope.items.length; i++) + scope.items[i].skip = true; + + _done(); + } + else + _nextElement(true); + }; + + scope.overwrite = function(applyToAll) { + if (applyToAll) + _done(); + else + _nextElement(false); + }; + + return { + /** + * Show confirm all dialog. + * + * @param confirmMessageFn Function to generate a confirm message. + * @param itemsToConfirm Array of element to process by confirm. + */ + confirm(confirmMessageFn, itemsToConfirm) { + scope.deferred = $q.defer(); + + scope.contentGenerator = confirmMessageFn; + + scope.items = itemsToConfirm; + scope.curIx = 0; + scope.content = (scope.items && scope.items.length > 0) ? scope.contentGenerator(scope.items[0]) : null; + + scope.confirmModal.$promise.then(scope.confirmModal.show); + + return scope.deferred.promise; + } + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/services/CopyToClipboard.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/services/CopyToClipboard.service.js b/modules/web-console/src/main/js/app/services/CopyToClipboard.service.js new file mode 100644 index 0000000..74c4764 --- /dev/null +++ b/modules/web-console/src/main/js/app/services/CopyToClipboard.service.js @@ -0,0 +1,50 @@ +/* + * 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. + */ + +// Service to copy some value to OS clipboard. +export default ['IgniteCopyToClipboard', ['$window', 'IgniteMessages', ($window, Messages) => { + const body = angular.element($window.document.body); + + const textArea = angular.element('<textarea/>'); + + textArea.css({ + position: 'fixed', + opacity: '0' + }); + + return { + copy(toCopy) { + textArea.val(toCopy); + + body.append(textArea); + + textArea[0].select(); + + try { + if (document.execCommand('copy')) + Messages.showInfo('Value copied to clipboard'); + else + window.prompt('Copy to clipboard: Ctrl+C, Enter', toCopy); // eslint-disable-line no-alert + } + catch (err) { + window.prompt('Copy to clipboard: Ctrl+C, Enter', toCopy); // eslint-disable-line no-alert + } + + textArea.remove(); + } + }; +}]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/00d8c0af/modules/web-console/src/main/js/app/services/Focus.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/app/services/Focus.service.js b/modules/web-console/src/main/js/app/services/Focus.service.js new file mode 100644 index 0000000..a07e181 --- /dev/null +++ b/modules/web-console/src/main/js/app/services/Focus.service.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. + */ + +// Service to transfer focus for specified element. +export default ['IgniteFocus', ['$timeout', ($timeout) => { + return { + move(id) { + // Timeout makes sure that is invoked after any other event has been triggered. + // E.g. click events that need to run before the focus or inputs elements that are + // in a disabled state but are enabled when those events are triggered. + $timeout(() => { + const elem = $('#' + id); + + if (elem.length > 0) + elem[0].focus(); + }, 100); + } + }; +}]];
