You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2018/04/11 12:28:30 UTC
[08/10] ignite git commit: IGNITE-4091 Web Console: Refactored using
of internal Angular API.
IGNITE-4091 Web Console: Refactored using of internal Angular API.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/74d25456
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/74d25456
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/74d25456
Branch: refs/heads/ignite-8201
Commit: 74d254564a44a95db9945652c9b579ed6b431ee9
Parents: 9752466
Author: Alexander Kalinin <ve...@yandex.ru>
Authored: Wed Apr 11 17:09:41 2018 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Wed Apr 11 17:09:41 2018 +0700
----------------------------------------------------------------------
modules/web-console/frontend/app/app.config.js | 14 +++---
.../components/modal-import-models/component.js | 4 +-
.../app/components/page-profile/controller.js | 4 +-
.../frontend/app/modules/ace.module.js | 47 ++++++++++----------
.../services/AngularStrapSelect.decorator.js | 5 ++-
.../services/AngularStrapTooltip.decorator.js | 8 ++--
.../frontend/app/services/FormUtils.service.js | 3 +-
7 files changed, 45 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d25456/modules/web-console/frontend/app/app.config.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/app.config.js b/modules/web-console/frontend/app/app.config.js
index 9d8dc99..e2bc057 100644
--- a/modules/web-console/frontend/app/app.config.js
+++ b/modules/web-console/frontend/app/app.config.js
@@ -43,7 +43,7 @@ igniteConsoleCfg.config(['$animateProvider', ($animateProvider) => {
// AngularStrap modal popup configuration.
igniteConsoleCfg.config(['$modalProvider', ($modalProvider) => {
- angular.extend($modalProvider.defaults, {
+ Object.assign($modalProvider.defaults, {
animation: 'am-fade-and-scale',
placement: 'center',
html: true
@@ -52,7 +52,7 @@ igniteConsoleCfg.config(['$modalProvider', ($modalProvider) => {
// AngularStrap popover configuration.
igniteConsoleCfg.config(['$popoverProvider', ($popoverProvider) => {
- angular.extend($popoverProvider.defaults, {
+ Object.assign($popoverProvider.defaults, {
trigger: 'manual',
placement: 'right',
container: 'body',
@@ -62,7 +62,7 @@ igniteConsoleCfg.config(['$popoverProvider', ($popoverProvider) => {
// AngularStrap tooltips configuration.
igniteConsoleCfg.config(['$tooltipProvider', ($tooltipProvider) => {
- angular.extend($tooltipProvider.defaults, {
+ Object.assign($tooltipProvider.defaults, {
container: 'body',
delay: {show: 150, hide: 150},
placement: 'right',
@@ -73,7 +73,7 @@ igniteConsoleCfg.config(['$tooltipProvider', ($tooltipProvider) => {
// AngularStrap select (combobox) configuration.
igniteConsoleCfg.config(['$selectProvider', ($selectProvider) => {
- angular.extend($selectProvider.defaults, {
+ Object.assign($selectProvider.defaults, {
container: 'body',
maxLength: '5',
allText: 'Select All',
@@ -87,7 +87,7 @@ igniteConsoleCfg.config(['$selectProvider', ($selectProvider) => {
// AngularStrap alerts configuration.
igniteConsoleCfg.config(['$alertProvider', ($alertProvider) => {
- angular.extend($alertProvider.defaults, {
+ Object.assign($alertProvider.defaults, {
container: 'body',
placement: 'top-right',
duration: '5',
@@ -99,7 +99,7 @@ igniteConsoleCfg.config(['$alertProvider', ($alertProvider) => {
// AngularStrap dropdowns () configuration.
igniteConsoleCfg.config(['$dropdownProvider', ($dropdownProvider) => {
- angular.extend($dropdownProvider.defaults, {
+ Object.assign($dropdownProvider.defaults, {
templateUrl: dropdownTemplateUrl,
animation: ''
});
@@ -107,7 +107,7 @@ igniteConsoleCfg.config(['$dropdownProvider', ($dropdownProvider) => {
// AngularStrap dropdowns () configuration.
igniteConsoleCfg.config(['$datepickerProvider', ($datepickerProvider) => {
- angular.extend($datepickerProvider.defaults, {
+ Object.assign($datepickerProvider.defaults, {
autoclose: true,
iconLeft: 'icon-datepicker-left',
iconRight: 'icon-datepicker-right'
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d25456/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js b/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js
index 7f852b0..813c998 100644
--- a/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js
+++ b/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/component.js
@@ -84,7 +84,7 @@ const DFLT_REPLICATED_CACHE = {
const CACHE_TEMPLATES = [DFLT_PARTITIONED_CACHE, DFLT_REPLICATED_CACHE];
export class ModalImportModels {
- /**
+ /**
* Cluster ID to import models into
* @type {string}
*/
@@ -771,7 +771,7 @@ export class ModalImportModels {
// Prepare caches for generation.
if (table.action === IMPORT_DM_NEW_CACHE) {
- const newCache = angular.copy(this.loadedCaches[table.cacheOrTemplate]);
+ const newCache = _.cloneDeep(this.loadedCaches[table.cacheOrTemplate]);
batchAction.newCache = newCache;
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d25456/modules/web-console/frontend/app/components/page-profile/controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/page-profile/controller.js b/modules/web-console/frontend/app/components/page-profile/controller.js
index 05fe118..c67a603 100644
--- a/modules/web-console/frontend/app/components/page-profile/controller.js
+++ b/modules/web-console/frontend/app/components/page-profile/controller.js
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+import _ from 'lodash';
+
export default class PageProfileController {
static $inject = [
'$rootScope', '$scope', '$http', 'IgniteLegacyUtils', 'IgniteMessages', 'IgniteFocus', 'IgniteConfirm', 'IgniteCountries', 'User'
@@ -28,7 +30,7 @@ export default class PageProfileController {
this.ui = {};
this.User.read()
- .then((user) => this.ui.user = angular.copy(user));
+ .then((user) => this.ui.user = _.cloneDeep(user));
this.ui.countries = this.Countries.getAll();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d25456/modules/web-console/frontend/app/modules/ace.module.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/ace.module.js b/modules/web-console/frontend/app/modules/ace.module.js
index a28536a..6a6e70a 100644
--- a/modules/web-console/frontend/app/modules/ace.module.js
+++ b/modules/web-console/frontend/app/modules/ace.module.js
@@ -16,12 +16,13 @@
*/
import angular from 'angular';
+import _ from 'lodash';
angular
.module('ignite-console.ace', [])
.constant('igniteAceConfig', {})
.directive('igniteAce', ['igniteAceConfig', (aceConfig) => {
- if (angular.isUndefined(window.ace))
+ if (_.isUndefined(window.ace))
throw new Error('ignite-ace need ace to work... (o rly?)');
/**
@@ -43,7 +44,7 @@ angular
*/
const setOptions = (acee, session, opts) => {
// Sets the ace worker path, if running from concatenated or minified source.
- if (angular.isDefined(opts.workerPath)) {
+ if (!_.isUndefined(opts.workerPath)) {
const config = window.ace.acequire('ace/config');
config.set('workerPath', opts.workerPath);
@@ -53,26 +54,26 @@ angular
_.forEach(opts.require, (n) => window.ace.acequire(n));
// Boolean options.
- if (angular.isDefined(opts.showGutter))
+ if (!_.isUndefined(opts.showGutter))
acee.renderer.setShowGutter(opts.showGutter);
- if (angular.isDefined(opts.useWrapMode))
+ if (!_.isUndefined(opts.useWrapMode))
session.setUseWrapMode(opts.useWrapMode);
- if (angular.isDefined(opts.showInvisibles))
+ if (!_.isUndefined(opts.showInvisibles))
acee.renderer.setShowInvisibles(opts.showInvisibles);
- if (angular.isDefined(opts.showIndentGuides))
+ if (!_.isUndefined(opts.showIndentGuides))
acee.renderer.setDisplayIndentGuides(opts.showIndentGuides);
- if (angular.isDefined(opts.useSoftTabs))
+ if (!_.isUndefined(opts.useSoftTabs))
session.setUseSoftTabs(opts.useSoftTabs);
- if (angular.isDefined(opts.showPrintMargin))
+ if (!_.isUndefined(opts.showPrintMargin))
acee.setShowPrintMargin(opts.showPrintMargin);
// Commands.
- if (angular.isDefined(opts.disableSearch) && opts.disableSearch) {
+ if (!_.isUndefined(opts.disableSearch) && opts.disableSearch) {
acee.commands.addCommands([{
name: 'unfind',
bindKey: {
@@ -85,21 +86,21 @@ angular
}
// Base options.
- if (angular.isString(opts.theme))
+ if (_.isString(opts.theme))
acee.setTheme('ace/theme/' + opts.theme);
- if (angular.isString(opts.mode))
+ if (_.isString(opts.mode))
session.setMode('ace/mode/' + opts.mode);
- if (angular.isDefined(opts.firstLineNumber)) {
- if (angular.isNumber(opts.firstLineNumber))
+ if (!_.isUndefined(opts.firstLineNumber)) {
+ if (_.isNumber(opts.firstLineNumber))
session.setOption('firstLineNumber', opts.firstLineNumber);
- else if (angular.isFunction(opts.firstLineNumber))
+ else if (_.isFunction(opts.firstLineNumber))
session.setOption('firstLineNumber', opts.firstLineNumber());
}
// Advanced options.
- if (angular.isDefined(opts.advanced)) {
+ if (!_.isUndefined(opts.advanced)) {
for (const key in opts.advanced) {
if (opts.advanced.hasOwnProperty(key)) {
// Create a javascript object with the key and value.
@@ -112,7 +113,7 @@ angular
}
// Advanced options for the renderer.
- if (angular.isDefined(opts.rendererOptions)) {
+ if (!_.isUndefined(opts.rendererOptions)) {
for (const key in opts.rendererOptions) {
if (opts.rendererOptions.hasOwnProperty(key)) {
// Create a javascript object with the key and value.
@@ -126,7 +127,7 @@ angular
// onLoad callbacks.
_.forEach(opts.callbacks, (cb) => {
- if (angular.isFunction(cb))
+ if (_.isFunction(cb))
cb(acee);
});
};
@@ -147,7 +148,7 @@ angular
*
* @type object
*/
- let opts = angular.extend({}, options, scope.$eval(attrs.igniteAce));
+ let opts = Object.assign({}, options, scope.$eval(attrs.igniteAce));
/**
* ACE editor.
@@ -191,9 +192,9 @@ angular
!scope.$$phase && !scope.$root.$$phase)
scope.$eval(() => ngModel.$setViewValue(newValue));
- if (angular.isDefined(callback)) {
+ if (!_.isUndefined(callback)) {
scope.$evalAsync(() => {
- if (angular.isFunction(callback))
+ if (_.isFunction(callback))
callback([e, acee]);
else
throw new Error('ignite-ace use a function as callback');
@@ -210,10 +211,10 @@ angular
form && form.$removeControl(ngModel);
ngModel.$formatters.push((value) => {
- if (angular.isUndefined(value) || value === null)
+ if (_.isUndefined(value) || value === null)
return '';
- if (angular.isObject(value) || angular.isArray(value))
+ if (_.isObject(value) || _.isArray(value))
throw new Error('ignite-ace cannot use an object or an array as a model');
return value;
@@ -229,7 +230,7 @@ angular
if (current === previous)
return;
- opts = angular.extend({}, options, scope.$eval(attrs.igniteAce));
+ opts = Object.assign({}, options, scope.$eval(attrs.igniteAce));
opts.callbacks = [opts.onLoad];
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d25456/modules/web-console/frontend/app/services/AngularStrapSelect.decorator.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/AngularStrapSelect.decorator.js b/modules/web-console/frontend/app/services/AngularStrapSelect.decorator.js
index 39f7ccd..32fa167 100644
--- a/modules/web-console/frontend/app/services/AngularStrapSelect.decorator.js
+++ b/modules/web-console/frontend/app/services/AngularStrapSelect.decorator.js
@@ -16,6 +16,7 @@
*/
import angular from 'angular';
+import _ from 'lodash';
/**
* Special decorator that fix problem in AngularStrap selectAll / deselectAll methods.
@@ -27,12 +28,12 @@ export default angular.module('mgcrea.ngStrap.select')
const delegate = $delegate(element, controller, config);
// Common vars.
- const options = angular.extend({}, $delegate.defaults, config);
+ const options = Object.assign({}, $delegate.defaults, config);
const scope = delegate.$scope;
const valueByIndex = (index) => {
- if (angular.isUndefined(scope.$matches[index]))
+ if (_.isUndefined(scope.$matches[index]))
return null;
return scope.$matches[index].value;
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d25456/modules/web-console/frontend/app/services/AngularStrapTooltip.decorator.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/AngularStrapTooltip.decorator.js b/modules/web-console/frontend/app/services/AngularStrapTooltip.decorator.js
index d01a450..fa59f32 100644
--- a/modules/web-console/frontend/app/services/AngularStrapTooltip.decorator.js
+++ b/modules/web-console/frontend/app/services/AngularStrapTooltip.decorator.js
@@ -16,7 +16,7 @@
*/
import angular from 'angular';
-import flow from 'lodash/flow';
+import _ from 'lodash';
/**
* Decorator that fix problem in AngularStrap $tooltip.
@@ -62,7 +62,7 @@ export default angular
scope.$emit(options.prefixEvent + '.hide.before', $tooltip);
- if (angular.isDefined(options.onBeforeHide) && angular.isFunction(options.onBeforeHide))
+ if (!_.isUndefined(options.onBeforeHide) && _.isFunction(options.onBeforeHide))
options.onBeforeHide($tooltip);
$tooltip.$isShown = scope.$isShown = false;
@@ -82,8 +82,8 @@ export default angular
const $tooltip = $delegate(el, config);
$tooltip.$referenceElement = el;
- $tooltip.destroy = flow($tooltip.destroy, () => $tooltip.$referenceElement = null);
- $tooltip.$applyPlacement = flow($tooltip.$applyPlacement, () => {
+ $tooltip.destroy = _.flow($tooltip.destroy, () => $tooltip.$referenceElement = null);
+ $tooltip.$applyPlacement = _.flow($tooltip.$applyPlacement, () => {
if (!$tooltip.$element)
return;
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d25456/modules/web-console/frontend/app/services/FormUtils.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/FormUtils.service.js b/modules/web-console/frontend/app/services/FormUtils.service.js
index f22d4bc..da1d737 100644
--- a/modules/web-console/frontend/app/services/FormUtils.service.js
+++ b/modules/web-console/frontend/app/services/FormUtils.service.js
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import _ from 'lodash';
export default ['IgniteFormUtils', ['$window', 'IgniteFocus', ($window, Focus) => {
function ensureActivePanel(ui, pnl, focusId) {
@@ -41,7 +42,7 @@ export default ['IgniteFormUtils', ['$window', 'IgniteFocus', ($window, Focus) =
if (!activePanels || activePanels.length < 1)
ui.activePanels = [idx];
else if (!_.includes(activePanels, idx)) {
- const newActivePanels = angular.copy(activePanels);
+ const newActivePanels = _.cloneDeep(activePanels);
newActivePanels.push(idx);