http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/controllers/domains-controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/controllers/domains-controller.js b/modules/web-console/src/main/js/controllers/domains-controller.js index 467dc98..cfb539d 100644 --- a/modules/web-console/src/main/js/controllers/domains-controller.js +++ b/modules/web-console/src/main/js/controllers/domains-controller.js @@ -16,12 +16,10 @@ */ // Controller for Domain model screen. -import consoleModule from 'controllers/common-module'; - -consoleModule.controller('domainsController', [ - '$rootScope', '$scope', '$http', '$state', '$filter', '$timeout', '$modal', '$common', '$focus', '$confirm', '$confirmBatch', '$clone', '$loading', '$cleanup', '$unsavedChangesGuard', 'IgniteAgentMonitor', '$table', - function($root, $scope, $http, $state, $filter, $timeout, $modal, $common, $focus, $confirm, $confirmBatch, $clone, $loading, $cleanup, $unsavedChangesGuard, IgniteAgentMonitor, $table) { - $unsavedChangesGuard.install($scope); +export default ['domainsController', [ + '$rootScope', '$scope', '$http', '$state', '$filter', '$timeout', '$modal', 'IgniteLegacyUtils', 'IgniteMessages', 'IgniteFocus', 'IgniteConfirm', 'IgniteConfirmBatch', 'IgniteClone', 'IgniteLoading', 'IgniteModelNormalizer', 'IgniteUnsavedChangesGuard', 'IgniteAgentMonitor', 'IgniteLegacyTable', + function($root, $scope, $http, $state, $filter, $timeout, $modal, LegacyUtils, Messages, Focus, Confirm, ConfirmBatch, Clone, Loading, ModelNormalizer, UnsavedChangesGuard, IgniteAgentMonitor, LegacyTable) { + UnsavedChangesGuard.install($scope); const emptyDomain = {empty: true}; @@ -32,7 +30,7 @@ consoleModule.controller('domainsController', [ // We need to initialize backupItem with empty object in order to properly used from angular directives. $scope.backupItem = emptyDomain; - $scope.ui = $common.formUI(); + $scope.ui = LegacyUtils.formUI(); $scope.ui.activePanels = [0, 1]; $scope.ui.topPanels = [0, 1, 2]; @@ -68,14 +66,14 @@ consoleModule.controller('domainsController', [ return !item.empty && (!item._id || _.find($scope.displayedRows, {_id: item._id})); }; - $scope.getModel = $common.getModel; - $scope.javaBuiltInClasses = $common.javaBuiltInClasses; - $scope.compactJavaName = $common.compactJavaName; - $scope.widthIsSufficient = $common.widthIsSufficient; - $scope.saveBtnTipText = $common.saveBtnTipText; + $scope.getModel = LegacyUtils.getModel; + $scope.javaBuiltInClasses = LegacyUtils.javaBuiltInClasses; + $scope.compactJavaName = LegacyUtils.compactJavaName; + $scope.widthIsSufficient = LegacyUtils.widthIsSufficient; + $scope.saveBtnTipText = LegacyUtils.saveBtnTipText; $scope.tableSave = function(field, index, stopEdit) { - if ($table.tableEditing({model: 'table-index-fields'}, $table.tableEditedRowIndex())) { + if (LegacyTable.tableEditing({model: 'table-index-fields'}, LegacyTable.tableEditedRowIndex())) { if ($scope.tableIndexItemSaveVisible(field, index)) return $scope.tableIndexItemSave(field, field.indexIdx, index, stopEdit); } @@ -83,8 +81,8 @@ consoleModule.controller('domainsController', [ switch (field.type) { case 'fields': case 'aliases': - if ($table.tablePairSaveVisible(field, index)) - return $table.tablePairSave($scope.tablePairValid, $scope.backupItem, field, index, stopEdit); + if (LegacyTable.tablePairSaveVisible(field, index)) + return LegacyTable.tablePairSave($scope.tablePairValid, $scope.backupItem, field, index, stopEdit); break; @@ -108,37 +106,37 @@ consoleModule.controller('domainsController', [ }; $scope.tableReset = (trySave) => { - const field = $table.tableField(); + const field = LegacyTable.tableField(); - if (trySave && $common.isDefined(field) && !$scope.tableSave(field, $table.tableEditedRowIndex(), true)) + if (trySave && LegacyUtils.isDefined(field) && !$scope.tableSave(field, LegacyTable.tableEditedRowIndex(), true)) return false; - $table.tableReset(); + LegacyTable.tableReset(); return true; }; $scope.tableNewItem = function(field) { if ($scope.tableReset(true)) - $table.tableNewItem(field); + LegacyTable.tableNewItem(field); }; - $scope.tableNewItemActive = $table.tableNewItemActive; + $scope.tableNewItemActive = LegacyTable.tableNewItemActive; $scope.tableStartEdit = function(item, field, index) { if ($scope.tableReset(true)) - $table.tableStartEdit(item, field, index, $scope.tableSave); + LegacyTable.tableStartEdit(item, field, index, $scope.tableSave); }; - $scope.tableEditing = $table.tableEditing; + $scope.tableEditing = LegacyTable.tableEditing; $scope.tableRemove = function(item, field, index) { if ($scope.tableReset(true)) - $table.tableRemove(item, field, index); + LegacyTable.tableRemove(item, field, index); }; - $scope.tablePairSave = $table.tablePairSave; - $scope.tablePairSaveVisible = $table.tablePairSaveVisible; + $scope.tablePairSave = LegacyTable.tablePairSave; + $scope.tablePairSaveVisible = LegacyTable.tablePairSaveVisible; $scope.queryFieldsTbl = { type: 'fields', @@ -160,7 +158,7 @@ consoleModule.controller('domainsController', [ save: $scope.tableSave }; - $scope.queryMetadataVariants = $common.mkOptions(['Annotations', 'Configuration']); + $scope.queryMetadataVariants = LegacyUtils.mkOptions(['Annotations', 'Configuration']); const INFO_CONNECT_TO_DB = 'Configure connection to database'; const INFO_SELECT_SCHEMAS = 'Select schemas to load tables from'; @@ -175,11 +173,11 @@ consoleModule.controller('domainsController', [ 'It may be a result of import tables from database without primary keys<br/>' + 'Key field for such key types should be configured manually'; - $scope.hidePopover = $common.hidePopover; + $scope.hidePopover = LegacyUtils.hidePopover; - const showPopoverMessage = $common.showPopoverMessage; + const showPopoverMessage = LegacyUtils.showPopoverMessage; - $scope.indexType = $common.mkOptions(['SORTED', 'FULLTEXT', 'GEOSPATIAL']); + $scope.indexType = LegacyUtils.mkOptions(['SORTED', 'FULLTEXT', 'GEOSPATIAL']); const _dbPresets = [ { @@ -269,8 +267,8 @@ consoleModule.controller('domainsController', [ localStorage.dbPresets = JSON.stringify(_dbPresets); } - catch (errMsg) { - $common.showError(errMsg); + catch (err) { + Messages.showError(err); } } @@ -304,9 +302,9 @@ consoleModule.controller('domainsController', [ $scope.ui.showValid = true; - $scope.supportedJdbcTypes = $common.mkOptions($common.SUPPORTED_JDBC_TYPES); + $scope.supportedJdbcTypes = LegacyUtils.mkOptions(LegacyUtils.SUPPORTED_JDBC_TYPES); - $scope.supportedJavaTypes = $common.mkOptions($common.javaBuiltInTypes); + $scope.supportedJavaTypes = LegacyUtils.mkOptions(LegacyUtils.javaBuiltInTypes); $scope.sortDirections = [ {value: true, label: 'ASC'}, @@ -319,7 +317,7 @@ consoleModule.controller('domainsController', [ const item = $scope.backupItem; if (item && item.keyType) - return $common.isJavaBuiltInClass(item.keyType); + return LegacyUtils.isJavaBuiltInClass(item.keyType); return false; }; @@ -331,7 +329,7 @@ consoleModule.controller('domainsController', [ }; $scope.selectSchema = function() { - if ($common.isDefined($scope.importDomain) && $common.isDefined($scope.importDomain.displayedSchemas)) + if (LegacyUtils.isDefined($scope.importDomain) && LegacyUtils.isDefined($scope.importDomain.displayedSchemas)) $scope.importDomain.allSchemasSelected = $scope.importDomain.displayedSchemas.length > 0 && _.every($scope.importDomain.displayedSchemas, 'use', true); }; @@ -344,7 +342,7 @@ consoleModule.controller('domainsController', [ }; $scope.selectTable = function() { - if ($common.isDefined($scope.importDomain) && $common.isDefined($scope.importDomain.displayedTables)) + if (LegacyUtils.isDefined($scope.importDomain) && LegacyUtils.isDefined($scope.importDomain.displayedTables)) $scope.importDomain.allTablesSelected = $scope.importDomain.displayedTables.length > 0 && _.every($scope.importDomain.displayedTables, 'use', true); }; @@ -378,9 +376,9 @@ consoleModule.controller('domainsController', [ * Show import domain models modal. */ $scope.showImportDomainModal = function() { - $table.tableReset(); + LegacyTable.tableReset(); - $common.confirmUnsavedChanges($scope.ui.inputForm.$dirty, function() { + LegacyUtils.confirmUnsavedChanges($scope.ui.inputForm.$dirty, function() { if ($scope.ui.inputForm.$dirty) $scope.backupItem = $scope.selectedItem ? angular.copy($scope.selectedItem) : prepareNewItem(); @@ -412,7 +410,7 @@ consoleModule.controller('domainsController', [ } // Get available JDBC drivers via agent. - $loading.start('importDomainFromDb'); + Loading.start('importDomainFromDb'); $scope.jdbcDriverJars = []; $scope.ui.selectedJdbcDriverJar = {}; @@ -436,12 +434,12 @@ consoleModule.controller('domainsController', [ $scope.ui.selectedJdbcDriverJar = $scope.jdbcDriverJars[0].value; - $common.confirmUnsavedChanges($scope.ui.inputForm.$dirty, function() { + LegacyUtils.confirmUnsavedChanges($scope.ui.inputForm.$dirty, function() { importDomainModal.$promise.then(() => { $scope.importDomain.action = 'connect'; $scope.importDomain.tables = []; - $focus('jdbcUrl'); + Focus.move('jdbcUrl'); }); }); } @@ -453,7 +451,7 @@ consoleModule.controller('domainsController', [ .finally(function() { $scope.importDomain.info = INFO_CONNECT_TO_DB; - $loading.finish('importDomainFromDb'); + Loading.finish('importDomainFromDb'); }); }); }); @@ -466,7 +464,7 @@ consoleModule.controller('domainsController', [ IgniteAgentMonitor.awaitAgent() .then(function() { $scope.importDomain.loadingOptions = LOADING_SCHEMAS; - $loading.start('importDomainFromDb'); + Loading.start('importDomainFromDb'); if ($root.IgniteDemoMode) return IgniteAgentMonitor.schemas($scope.demoConnection); @@ -489,12 +487,8 @@ consoleModule.controller('domainsController', [ $scope.importDomain.info = INFO_SELECT_SCHEMAS; }) - .catch(function(errMsg) { - $common.showError(errMsg); - }) - .finally(function() { - $loading.finish('importDomainFromDb'); - }); + .catch(Messages.showError) + .finally(() => Loading.finish('importDomainFromDb')); } const DFLT_PARTITIONED_CACHE = { @@ -594,7 +588,7 @@ consoleModule.controller('domainsController', [ IgniteAgentMonitor.awaitAgent() .then(function() { $scope.importDomain.loadingOptions = LOADING_TABLES; - $loading.start('importDomainFromDb'); + Loading.start('importDomainFromDb'); $scope.importDomain.allTablesSelected = false; @@ -621,7 +615,7 @@ consoleModule.controller('domainsController', [ tbl.cacheOrTemplate = DFLT_PARTITIONED_CACHE.value; tbl.label = tbl.schema + '.' + tbl.tbl; tbl.edit = false; - tbl.use = $common.isDefined(_.find(tbl.cols, function(col) { + tbl.use = LegacyUtils.isDefined(_.find(tbl.cols, function(col) { return col.key; })); }); @@ -630,12 +624,8 @@ consoleModule.controller('domainsController', [ $scope.importDomain.tables = tables; $scope.importDomain.info = INFO_SELECT_TABLES; }) - .catch(function(errMsg) { - $common.showError(errMsg); - }) - .finally(function() { - $loading.finish('importDomainFromDb'); - }); + .catch(Messages.showError) + .finally(() => Loading.finish('importDomainFromDb')); } $scope.applyDefaults = function() { @@ -678,13 +668,13 @@ consoleModule.controller('domainsController', [ $scope.importDomain.button = 'Save'; $scope.importDomain.info = INFO_SELECT_OPTIONS; - $focus('domainPackageName'); + Focus.move('domainPackageName'); } function _saveBatch(batch) { if (batch && batch.length > 0) { $scope.importDomain.loadingOptions = SAVING_DOMAINS; - $loading.start('importDomainFromDb'); + Loading.start('importDomainFromDb'); $http.post('/api/v1/configuration/domains/save/batch', batch) .success(function(savedBatch) { @@ -717,17 +707,15 @@ consoleModule.controller('domainsController', [ $scope.selectItem(lastItem); - $common.showInfo('Domain models imported from database.'); + Messages.showInfo('Domain models imported from database.'); $scope.ui.activePanels = [0, 1, 2]; $scope.ui.showValid = true; }) - .error(function(errMsg) { - $common.showError(errMsg); - }) - .finally(function() { - $loading.finish('importDomainFromDb'); + .error(Messages.showError) + .finally(() => { + Loading.finish('importDomainFromDb'); importDomainModal.hide(); }); @@ -737,10 +725,10 @@ consoleModule.controller('domainsController', [ } function _saveDomainModel() { - if ($common.isEmptyString($scope.ui.packageName)) - return $common.showPopoverMessage(null, null, 'domainPackageName', 'Package could not be empty'); + if (LegacyUtils.isEmptyString($scope.ui.packageName)) + return LegacyUtils.showPopoverMessage(null, null, 'domainPackageName', 'Package could not be empty'); - if (!$common.isValidJavaClass('Package', $scope.ui.packageName, false, 'domainPackageName', true)) + if (!LegacyUtils.isValidJavaClass('Package', $scope.ui.packageName, false, 'domainPackageName', true)) return false; const batch = []; @@ -787,7 +775,7 @@ consoleModule.controller('domainsController', [ _.forEach(table.cols, function(col) { const colName = col.name; - const jdbcType = $common.findJdbcType(col.type); + const jdbcType = LegacyUtils.findJdbcType(col.type); const nullable = col.nullable; qryFields.push(queryField(colName, jdbcType)); @@ -835,7 +823,7 @@ consoleModule.controller('domainsController', [ caches: [] }; - if ($common.isDefined(domainFound)) { + if (LegacyUtils.isDefined(domainFound)) { newDomain._id = domainFound._id; newDomain.caches = domainFound.caches; newDomain.confirm = true; @@ -894,7 +882,11 @@ consoleModule.controller('domainsController', [ if (!newCache.cacheStoreFactory || newCache.cacheStoreFactory.kind !== 'CacheJdbcPojoStoreFactory') { const dialect = $scope.importDomain.demo ? 'H2' : $scope.selectedPreset.db; - newCache.cacheStoreFactory = {kind: 'CacheJdbcPojoStoreFactory', CacheJdbcPojoStoreFactory: {dataSourceBean: 'ds' + dialect, dialect}}; + newCache.cacheStoreFactory = { + kind: 'CacheJdbcPojoStoreFactory', + CacheJdbcPojoStoreFactory: {dataSourceBean: 'ds' + dialect, dialect}, + CacheJdbcBlobStoreFactory: { connectVia: 'DataSource' } + }; } if (!newCache.readThrough && !newCache.writeThrough) { @@ -910,7 +902,7 @@ consoleModule.controller('domainsController', [ if (!_.includes(checkedCaches, cacheId)) { const cache = _.find($scope.caches, {value: cacheId}).cache; - const change = $common.autoCacheStoreConfiguration(cache, [newDomain]); + const change = LegacyUtils.autoCacheStoreConfiguration(cache, [newDomain]); if (change) newDomain.cacheStoreChanges = [{cacheId, change}]; @@ -941,9 +933,9 @@ consoleModule.controller('domainsController', [ function checkOverwrite() { if (itemsToConfirm.length > 0) { - $confirmBatch.confirm(overwriteMessage, itemsToConfirm) + ConfirmBatch.confirm(overwriteMessage, itemsToConfirm) .then(() => _saveBatch(_.filter(batch, (item) => !item.skip))) - .catch(() => $common.showError('Importing of domain models interrupted by user.')); + .catch(() => Messages.showError('Importing of domain models interrupted by user.')); } else _saveBatch(batch); @@ -952,7 +944,7 @@ consoleModule.controller('domainsController', [ if (containKey) checkOverwrite(); else { - $confirm.confirm('Some tables have no primary key.<br/>' + + Confirm.confirm('Some tables have no primary key.<br/>' + 'You will need to configure key type and key fields for such tables after import complete.') .then(() => checkOverwrite()); } @@ -1067,7 +1059,7 @@ consoleModule.controller('domainsController', [ $scope.importCommon = {}; // When landing on the page, get domain models and show them. - $loading.start('loadingDomainModelsScreen'); + Loading.start('loadingDomainModelsScreen'); $http.post('/api/v1/configuration/domains/list') .success(function(data) { @@ -1120,26 +1112,25 @@ consoleModule.controller('domainsController', [ } $scope.$watch('ui.inputForm.$valid', function(valid) { - if (valid && _.isEqual(__original_value, $cleanup($scope.backupItem))) + if (valid && ModelNormalizer.isEqual(__original_value, $scope.backupItem)) $scope.ui.inputForm.$dirty = false; }); $scope.$watch('backupItem', function(val) { const form = $scope.ui.inputForm; - if (form.$pristine || (form.$valid && _.isEqual(__original_value, $cleanup(val)))) + if (form.$pristine || (form.$valid && ModelNormalizer.isEqual(__original_value, val))) form.$setPristine(); else form.$setDirty(); }, true); }) - .catch(function(errMsg) { - $common.showError(errMsg); - }) - .finally(function() { + .catch(Messages.showError) + .finally(() => { $scope.ui.ready = true; $scope.ui.inputForm.$setPristine(); - $loading.finish('loadingDomainModelsScreen'); + + Loading.finish('loadingDomainModelsScreen'); }); const clearFormDefaults = (ngFormCtrl) => { @@ -1155,7 +1146,7 @@ consoleModule.controller('domainsController', [ function selectItem() { clearFormDefaults($scope.ui.inputForm); - $table.tableReset(); + LegacyTable.tableReset(); $scope.selectedItem = item; @@ -1178,27 +1169,27 @@ consoleModule.controller('domainsController', [ $scope.backupItem = angular.merge({}, blank, $scope.backupItem); - __original_value = $cleanup($scope.backupItem); + __original_value = ModelNormalizer.normalize($scope.backupItem); - if ($common.isDefined($scope.backupItem) && !$common.isDefined($scope.backupItem.queryMetadata)) + if (LegacyUtils.isDefined($scope.backupItem) && !LegacyUtils.isDefined($scope.backupItem.queryMetadata)) $scope.backupItem.queryMetadata = 'Configuration'; - if ($common.isDefined($scope.selectedItem) && !$common.isDefined($scope.selectedItem.queryMetadata)) + if (LegacyUtils.isDefined($scope.selectedItem) && !LegacyUtils.isDefined($scope.selectedItem.queryMetadata)) $scope.selectedItem.queryMetadata = 'Configuration'; - if ($common.getQueryVariable('new')) + if (LegacyUtils.getQueryVariable('new')) $state.go('base.configuration.domains'); } - $common.confirmUnsavedChanges($scope.ui.inputForm.$dirty, selectItem); + LegacyUtils.confirmUnsavedChanges($scope.ui.inputForm.$dirty, selectItem); }; // Add new domain model. $scope.createItem = function(cacheId) { if ($scope.tableReset(true)) { $timeout(() => { - $common.ensureActivePanel($scope.ui, 'query'); - $common.ensureActivePanel($scope.ui, 'general', 'keyType'); + LegacyUtils.ensureActivePanel($scope.ui, 'query'); + LegacyUtils.ensureActivePanel($scope.ui, 'general', 'keyType'); }); $scope.selectItem(null, prepareNewItem(cacheId)); @@ -1206,7 +1197,7 @@ consoleModule.controller('domainsController', [ }; function checkQueryConfiguration(item) { - if (item.queryMetadata === 'Configuration' && $common.domainForQueryConfigured(item)) { + if (item.queryMetadata === 'Configuration' && LegacyUtils.domainForQueryConfigured(item)) { if (_.isEmpty(item.fields)) return showPopoverMessage($scope.ui, 'query', 'queryFields', 'Query fields should not be empty'); @@ -1225,17 +1216,17 @@ consoleModule.controller('domainsController', [ } function checkStoreConfiguration(item) { - if ($common.domainForStoreConfigured(item)) { - if ($common.isEmptyString(item.databaseSchema)) + if (LegacyUtils.domainForStoreConfigured(item)) { + if (LegacyUtils.isEmptyString(item.databaseSchema)) return showPopoverMessage($scope.ui, 'store', 'databaseSchema', 'Database schema should not be empty'); - if ($common.isEmptyString(item.databaseTable)) + if (LegacyUtils.isEmptyString(item.databaseTable)) return showPopoverMessage($scope.ui, 'store', 'databaseTable', 'Database table should not be empty'); if (_.isEmpty(item.keyFields)) return showPopoverMessage($scope.ui, 'store', 'keyFields', 'Key fields are not specified'); - if ($common.isJavaBuiltInClass(item.keyType) && item.keyFields.length !== 1) + if (LegacyUtils.isJavaBuiltInClass(item.keyType) && item.keyFields.length !== 1) return showPopoverMessage($scope.ui, 'store', 'keyFields', 'Only one field should be specified in case when key type is a Java built-in type'); if (_.isEmpty(item.valueFields)) @@ -1247,7 +1238,7 @@ consoleModule.controller('domainsController', [ // Check domain model logical consistency. function validate(item) { - if (!$common.checkFieldValidators($scope.ui)) + if (!LegacyUtils.checkFieldValidators($scope.ui)) return false; if (!checkQueryConfiguration(item)) @@ -1256,7 +1247,7 @@ consoleModule.controller('domainsController', [ if (!checkStoreConfiguration(item)) return false; - if (!$common.domainForStoreConfigured(item) && !$common.domainForQueryConfigured(item) && item.queryMetadata === 'Configuration') + if (!LegacyUtils.domainForStoreConfigured(item) && !LegacyUtils.domainForQueryConfigured(item) && item.queryMetadata === 'Configuration') return showPopoverMessage($scope.ui, 'query', 'query-title', 'SQL query domain model should be configured'); return true; @@ -1272,8 +1263,8 @@ consoleModule.controller('domainsController', [ // Save domain models into database. function save(item) { - const qry = $common.domainForQueryConfigured(item); - const str = $common.domainForStoreConfigured(item); + const qry = LegacyUtils.domainForQueryConfigured(item); + const str = LegacyUtils.domainForStoreConfigured(item); item.kind = 'query'; @@ -1306,13 +1297,11 @@ consoleModule.controller('domainsController', [ $scope.selectItem(savedMeta); - $common.showInfo('Domain model "' + item.valueType + '" saved.'); + Messages.showInfo('Domain model "' + item.valueType + '" saved.'); _checkShowValidPresentation(); }) - .error(function(errMsg) { - $common.showError(errMsg); - }); + .error(Messages.showError); } // Save domain model. @@ -1325,7 +1314,7 @@ consoleModule.controller('domainsController', [ _.forEach(item.caches, function(cacheId) { const cache = _.find($scope.caches, {value: cacheId}).cache; - const change = $common.autoCacheStoreConfiguration(cache, [item]); + const change = LegacyUtils.autoCacheStoreConfiguration(cache, [item]); if (change) item.cacheStoreChanges.push({cacheId, change}); @@ -1343,13 +1332,13 @@ consoleModule.controller('domainsController', [ } function _newNameIsValidJavaClass(newName) { - return $common.isValidJavaClass('New name for value type', newName, false, 'copy-new-name'); + return LegacyUtils.isValidJavaClass('New name for value type', newName, false, 'copy-new-name'); } // Save domain model with new name. $scope.cloneItem = function() { if ($scope.tableReset(true) && validate($scope.backupItem)) { - $clone.confirm($scope.backupItem.valueType, _domainNames(), _newNameIsValidJavaClass).then(function(newName) { + Clone.confirm($scope.backupItem.valueType, _domainNames(), _newNameIsValidJavaClass).then(function(newName) { const item = angular.copy($scope.backupItem); delete item._id; @@ -1362,17 +1351,17 @@ consoleModule.controller('domainsController', [ // Remove domain model from db. $scope.removeItem = function() { - $table.tableReset(); + LegacyTable.tableReset(); const selectedItem = $scope.selectedItem; - $confirm.confirm('Are you sure you want to remove domain model: "' + selectedItem.valueType + '"?') + Confirm.confirm('Are you sure you want to remove domain model: "' + selectedItem.valueType + '"?') .then(function() { const _id = selectedItem._id; $http.post('/api/v1/configuration/domains/remove', {_id}) .success(function() { - $common.showInfo('Domain model has been removed: ' + selectedItem.valueType); + Messages.showInfo('Domain model has been removed: ' + selectedItem.valueType); const domains = $scope.domains; @@ -1395,21 +1384,19 @@ consoleModule.controller('domainsController', [ _checkShowValidPresentation(); }) - .error(function(errMsg) { - $common.showError(errMsg); - }); + .error(Messages.showError); }); }; // Remove all domain models from db. $scope.removeAllItems = function() { - $table.tableReset(); + LegacyTable.tableReset(); - $confirm.confirm('Are you sure you want to remove all domain models?') + Confirm.confirm('Are you sure you want to remove all domain models?') .then(function() { $http.post('/api/v1/configuration/domains/remove/all') .success(function() { - $common.showInfo('All domain models have been removed'); + Messages.showInfo('All domain models have been removed'); $scope.domains = []; @@ -1419,9 +1406,7 @@ consoleModule.controller('domainsController', [ $scope.backupItem = emptyDomain; $scope.ui.showValid = true; }) - .error(function(errMsg) { - $common.showError(errMsg); - }); + .error(Messages.showError); }); }; @@ -1432,7 +1417,7 @@ consoleModule.controller('domainsController', [ let idx = -1; - if ($common.isDefined($scope.selectedItem)) { + if (LegacyUtils.isDefined($scope.selectedItem)) { idx = _.findIndex(validFilter($scope.domains, $scope.ui.showValid, true), function(domain) { return domain._id === $scope.selectedItem._id; }); @@ -1458,23 +1443,23 @@ consoleModule.controller('domainsController', [ $scope.tablePairValid = function(item, field, index) { const pairField = pairFields[field.model]; - const pairValue = $table.tablePairValue(field, index); + const pairValue = LegacyTable.tablePairValue(field, index); if (pairField) { const model = item[field.model]; - if ($common.isDefined(model)) { + if (LegacyUtils.isDefined(model)) { const idx = _.findIndex(model, function(pair) { return pair[pairField.searchCol] === pairValue[pairField.valueCol]; }); // Found duplicate by key. if (idx >= 0 && idx !== index) - return showPopoverMessage($scope.ui, 'query', $table.tableFieldId(index, pairField.idPrefix + pairField.id), 'Field with such ' + pairField.dupObjName + ' already exists!'); + return showPopoverMessage($scope.ui, 'query', LegacyTable.tableFieldId(index, pairField.idPrefix + pairField.id), 'Field with such ' + pairField.dupObjName + ' already exists!'); } - if (pairField.classValidation && !$common.isValidJavaClass(pairField.msg, pairValue.value, true, $table.tableFieldId(index, 'Value' + pairField.id), false, $scope.ui, 'query')) - return $table.tableFocusInvalidField(index, 'Value' + pairField.id); + if (pairField.classValidation && !LegacyUtils.isValidJavaClass(pairField.msg, pairValue.value, true, LegacyTable.tableFieldId(index, 'Value' + pairField.id), false, $scope.ui, 'query')) + return LegacyTable.tableFocusInvalidField(index, 'Value' + pairField.id); } return true; @@ -1497,10 +1482,10 @@ consoleModule.controller('domainsController', [ $scope.tableDbFieldSaveVisible = function(field, index) { const dbFieldValue = tableDbFieldValue(field, index); - return $common.isDefined(dbFieldValue.databaseFieldType) && - $common.isDefined(dbFieldValue.javaFieldType) && - !$common.isEmptyString(dbFieldValue.databaseFieldName) && - !$common.isEmptyString(dbFieldValue.javaFieldName); + return LegacyUtils.isDefined(dbFieldValue.databaseFieldType) && + LegacyUtils.isDefined(dbFieldValue.javaFieldType) && + !LegacyUtils.isEmptyString(dbFieldValue.databaseFieldName) && + !LegacyUtils.isEmptyString(dbFieldValue.javaFieldName); }; const dbFieldTables = { @@ -1518,17 +1503,17 @@ consoleModule.controller('domainsController', [ let model = item[field.model]; - if (!$common.isValidJavaIdentifier(dbFieldTable.msg + ' java name', dbFieldValue.javaFieldName, $table.tableFieldId(index, 'JavaFieldName' + dbFieldTable.id))) + if (!LegacyUtils.isValidJavaIdentifier(dbFieldTable.msg + ' java name', dbFieldValue.javaFieldName, LegacyTable.tableFieldId(index, 'JavaFieldName' + dbFieldTable.id))) return false; - if ($common.isDefined(model)) { + if (LegacyUtils.isDefined(model)) { let idx = _.findIndex(model, function(dbMeta) { return dbMeta.databaseFieldName === dbFieldValue.databaseFieldName; }); // Found duplicate. if (idx >= 0 && index !== idx) - return showPopoverMessage($scope.ui, 'store', $table.tableFieldId(index, 'DatabaseFieldName' + dbFieldTable.id), 'Field with such database name already exists!'); + return showPopoverMessage($scope.ui, 'store', LegacyTable.tableFieldId(index, 'DatabaseFieldName' + dbFieldTable.id), 'Field with such database name already exists!'); idx = _.findIndex(model, function(dbMeta) { return dbMeta.javaFieldName === dbFieldValue.javaFieldName; @@ -1536,7 +1521,7 @@ consoleModule.controller('domainsController', [ // Found duplicate. if (idx >= 0 && index !== idx) - return showPopoverMessage($scope.ui, 'store', $table.tableFieldId(index, 'JavaFieldName' + dbFieldTable.id), 'Field with such java name already exists!'); + return showPopoverMessage($scope.ui, 'store', LegacyTable.tableFieldId(index, 'JavaFieldName' + dbFieldTable.id), 'Field with such java name already exists!'); if (index < 0) model.push(dbFieldValue); @@ -1557,11 +1542,11 @@ consoleModule.controller('domainsController', [ if (!stopEdit) { if (index < 0) - $table.tableNewItem(field); + LegacyTable.tableNewItem(field); else if (index < model.length - 1) - $table.tableStartEdit(item, field, index + 1); + LegacyTable.tableStartEdit(item, field, index + 1); else - $table.tableNewItem(field); + LegacyTable.tableNewItem(field); } return true; @@ -1579,7 +1564,7 @@ consoleModule.controller('domainsController', [ } $scope.tableIndexSaveVisible = function(field, index) { - return !$common.isEmptyString(tableIndexName(field, index)) && $common.isDefined(tableIndexType(field, index)); + return !LegacyUtils.isEmptyString(tableIndexName(field, index)) && LegacyUtils.isDefined(tableIndexType(field, index)); }; $scope.tableIndexSave = function(field, curIdx, stopEdit) { @@ -1590,17 +1575,17 @@ consoleModule.controller('domainsController', [ const indexes = item.indexes; - if ($common.isDefined(indexes)) { + if (LegacyUtils.isDefined(indexes)) { const idx = _.findIndex(indexes, function(index) { return index.name === indexName; }); // Found duplicate. if (idx >= 0 && idx !== curIdx) - return showPopoverMessage($scope.ui, 'query', $table.tableFieldId(curIdx, 'IndexName'), 'Index with such name already exists!'); + return showPopoverMessage($scope.ui, 'query', LegacyTable.tableFieldId(curIdx, 'IndexName'), 'Index with such name already exists!'); } - $table.tableReset(); + LegacyTable.tableReset(); if (curIdx < 0) { const newIndex = {name: indexName, indexType}; @@ -1635,8 +1620,8 @@ consoleModule.controller('domainsController', [ if ($scope.tableReset(true)) { const index = $scope.backupItem.indexes[indexIdx]; - $table.tableState(field, -1, 'table-index-fields'); - $table.tableFocusInvalidField(-1, 'FieldName' + (index.indexType === 'SORTED' ? 'S' : '') + indexIdx); + LegacyTable.tableState(field, -1, 'table-index-fields'); + LegacyTable.tableFocusInvalidField(-1, 'FieldName' + (index.indexType === 'SORTED' ? 'S' : '') + indexIdx); field.newFieldName = null; field.newDirection = true; @@ -1651,7 +1636,7 @@ consoleModule.controller('domainsController', [ const index = indexes[itemIndex]; if (index) - return $table.tableNewItemActive({model: 'table-index-fields'}) && field.indexIdx === itemIndex; + return LegacyTable.tableNewItemActive({model: 'table-index-fields'}) && field.indexIdx === itemIndex; } return false; @@ -1664,7 +1649,7 @@ consoleModule.controller('domainsController', [ const index = indexes[itemIndex]; if (index) - return $table.tableEditing({model: 'table-index-fields'}, curIdx) && field.indexIdx === itemIndex; + return LegacyTable.tableEditing({model: 'table-index-fields'}, curIdx) && field.indexIdx === itemIndex; } return false; @@ -1684,7 +1669,7 @@ consoleModule.controller('domainsController', [ if ($scope.tableReset(true)) { const index = $scope.backupItem.indexes[indexIdx]; - $table.tableState(field, curIdx, 'table-index-fields'); + LegacyTable.tableState(field, curIdx, 'table-index-fields'); const indexItem = index.fields[curIdx]; @@ -1692,12 +1677,12 @@ consoleModule.controller('domainsController', [ field.curDirection = indexItem.direction; field.indexIdx = indexIdx; - $focus('curFieldName' + (index.indexType === 'SORTED' ? 'S' : '') + field.indexIdx + '-' + curIdx); + Focus.move('curFieldName' + (index.indexType === 'SORTED' ? 'S' : '') + field.indexIdx + '-' + curIdx); } }; $scope.tableIndexItemSaveVisible = function(field, index) { - return !$common.isEmptyString(tableIndexItemValue(field, index).name); + return !LegacyUtils.isEmptyString(tableIndexItemValue(field, index).name); }; $scope.tableIndexItemSave = function(field, indexIdx, curIdx, stopEdit) { @@ -1707,15 +1692,15 @@ consoleModule.controller('domainsController', [ const fields = index.fields; - if ($common.isDefined(fields)) { + if (LegacyUtils.isDefined(fields)) { const idx = _.findIndex(fields, (fld) => fld.name === indexItemValue.name); // Found duplicate. if (idx >= 0 && idx !== curIdx) - return showPopoverMessage($scope.ui, 'query', $table.tableFieldId(curIdx, 'FieldName' + (index.indexType === 'SORTED' ? 'S' : '') + indexIdx + (curIdx >= 0 ? '-' : '')), 'Field with such name already exists in index!'); + return showPopoverMessage($scope.ui, 'query', LegacyTable.tableFieldId(curIdx, 'FieldName' + (index.indexType === 'SORTED' ? 'S' : '') + indexIdx + (curIdx >= 0 ? '-' : '')), 'Field with such name already exists in index!'); } - $table.tableReset(); + LegacyTable.tableReset(); field.indexIdx = -1; @@ -1743,19 +1728,19 @@ consoleModule.controller('domainsController', [ }; $scope.tableRemoveIndexItem = function(index, curIdx) { - $table.tableReset(); + LegacyTable.tableReset(); index.fields.splice(curIdx, 1); }; $scope.resetAll = function() { - $table.tableReset(); + LegacyTable.tableReset(); - $confirm.confirm('Are you sure you want to undo all changes for current domain model?') + Confirm.confirm('Are you sure you want to undo all changes for current domain model?') .then(function() { $scope.backupItem = $scope.selectedItem ? angular.copy($scope.selectedItem) : prepareNewItem(); $scope.ui.inputForm.$setPristine(); }); }; - }] -); + } +]];
http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/controllers/igfs-controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/controllers/igfs-controller.js b/modules/web-console/src/main/js/controllers/igfs-controller.js index c37d08f..5f5f0bb 100644 --- a/modules/web-console/src/main/js/controllers/igfs-controller.js +++ b/modules/web-console/src/main/js/controllers/igfs-controller.js @@ -16,12 +16,10 @@ */ // Controller for IGFS screen. -import consoleModule from 'controllers/common-module'; - -consoleModule.controller('igfsController', [ - '$scope', '$http', '$state', '$filter', '$timeout', '$common', '$confirm', '$clone', '$loading', '$cleanup', '$unsavedChangesGuard', '$table', - function($scope, $http, $state, $filter, $timeout, $common, $confirm, $clone, $loading, $cleanup, $unsavedChangesGuard, $table) { - $unsavedChangesGuard.install($scope); +export default ['igfsController', [ + '$scope', '$http', '$state', '$filter', '$timeout', 'IgniteLegacyUtils', 'IgniteMessages', 'IgniteConfirm', 'IgniteClone', 'IgniteLoading', 'IgniteModelNormalizer', 'IgniteUnsavedChangesGuard', 'IgniteLegacyTable', + function($scope, $http, $state, $filter, $timeout, LegacyUtils, Messages, Confirm, Clone, Loading, ModelNormalizer, UnsavedChangesGuard, LegacyTable) { + UnsavedChangesGuard.install($scope); const emptyIgfs = {empty: true}; @@ -35,69 +33,68 @@ consoleModule.controller('igfsController', [ // We need to initialize backupItem with empty object in order to properly used from angular directives. $scope.backupItem = emptyIgfs; - $scope.ui = $common.formUI(); + $scope.ui = LegacyUtils.formUI(); $scope.ui.activePanels = [0]; $scope.ui.topPanels = [0]; - $scope.compactJavaName = $common.compactJavaName; - $scope.widthIsSufficient = $common.widthIsSufficient; - $scope.saveBtnTipText = $common.saveBtnTipText; + $scope.compactJavaName = LegacyUtils.compactJavaName; + $scope.widthIsSufficient = LegacyUtils.widthIsSufficient; + $scope.saveBtnTipText = LegacyUtils.saveBtnTipText; - const showPopoverMessage = $common.showPopoverMessage; + const showPopoverMessage = LegacyUtils.showPopoverMessage; - // TODO LEGACY start $scope.tableSave = function(field, index, stopEdit) { - if (field.type === 'pathModes' && $table.tablePairSaveVisible(field, index)) - return $table.tablePairSave($scope.tablePairValid, $scope.backupItem, field, index, stopEdit); + if (field.type === 'pathModes' && LegacyTable.tablePairSaveVisible(field, index)) + return LegacyTable.tablePairSave($scope.tablePairValid, $scope.backupItem, field, index, stopEdit); return true; }; $scope.tableReset = (trySave) => { - const field = $table.tableField(); + const field = LegacyTable.tableField(); - if (trySave && $common.isDefined(field) && !$scope.tableSave(field, $table.tableEditedRowIndex(), true)) + if (trySave && LegacyUtils.isDefined(field) && !$scope.tableSave(field, LegacyTable.tableEditedRowIndex(), true)) return false; - $table.tableReset(); + LegacyTable.tableReset(); return true; }; $scope.tableNewItem = function(field) { if ($scope.tableReset(true)) - $table.tableNewItem(field); + LegacyTable.tableNewItem(field); }; - $scope.tableNewItemActive = $table.tableNewItemActive; + $scope.tableNewItemActive = LegacyTable.tableNewItemActive; $scope.tableStartEdit = function(item, field, index) { if ($scope.tableReset(true)) - $table.tableStartEdit(item, field, index, $scope.tableSave); + LegacyTable.tableStartEdit(item, field, index, $scope.tableSave); }; - $scope.tableEditing = $table.tableEditing; - $scope.tablePairSave = $table.tablePairSave; - $scope.tablePairSaveVisible = $table.tablePairSaveVisible; + $scope.tableEditing = LegacyTable.tableEditing; + $scope.tablePairSave = LegacyTable.tablePairSave; + $scope.tablePairSaveVisible = LegacyTable.tablePairSaveVisible; $scope.tableRemove = function(item, field, index) { if ($scope.tableReset(true)) - $table.tableRemove(item, field, index); + LegacyTable.tableRemove(item, field, index); }; $scope.tablePairValid = function(item, field, index) { - const pairValue = $table.tablePairValue(field, index); + const pairValue = LegacyTable.tablePairValue(field, index); const model = item[field.model]; - if ($common.isDefined(model)) { + if (LegacyUtils.isDefined(model)) { const idx = _.findIndex(model, function(pair) { return pair.path === pairValue.key; }); // Found duplicate. if (idx >= 0 && idx !== index) - return showPopoverMessage($scope.ui, 'misc', $table.tableFieldId(index, 'KeyPathMode'), 'Such path already exists!'); + return showPopoverMessage($scope.ui, 'misc', LegacyTable.tableFieldId(index, 'KeyPathMode'), 'Such path already exists!'); } return true; @@ -113,8 +110,7 @@ consoleModule.controller('igfsController', [ save: $scope.tableSave }; - $scope.igfsModes = $common.mkOptions(['PRIMARY', 'PROXY', 'DUAL_SYNC', 'DUAL_ASYNC']); - // TODO LEGACY start - end + $scope.igfsModes = LegacyUtils.mkOptions(['PRIMARY', 'PROXY', 'DUAL_SYNC', 'DUAL_ASYNC']); $scope.contentVisible = function() { const item = $scope.backupItem; @@ -125,7 +121,7 @@ consoleModule.controller('igfsController', [ $scope.toggleExpanded = function() { $scope.ui.expanded = !$scope.ui.expanded; - $common.hidePopover(); + LegacyUtils.hidePopover(); }; $scope.igfss = []; @@ -136,7 +132,7 @@ consoleModule.controller('igfsController', [ $scope.selectItem($scope.igfss[0]); } - $loading.start('loadingIgfsScreen'); + Loading.start('loadingIgfsScreen'); // When landing on the page, get IGFSs and show them. $http.post('/api/v1/configuration/igfs/list') @@ -184,31 +180,29 @@ consoleModule.controller('igfsController', [ } $scope.$watch('ui.inputForm.$valid', function(valid) { - if (valid && _.isEqual(__original_value, $cleanup($scope.backupItem))) + if (valid && ModelNormalizer.isEqual(__original_value, $scope.backupItem)) $scope.ui.inputForm.$dirty = false; }); $scope.$watch('backupItem', function(val) { const form = $scope.ui.inputForm; - if (form.$pristine || (form.$valid && _.isEqual(__original_value, $cleanup(val)))) + if (form.$pristine || (form.$valid && ModelNormalizer.isEqual(__original_value, val))) form.$setPristine(); else form.$setDirty(); }, true); }) - .catch(function(errMsg) { - $common.showError(errMsg); - }) + .catch(Messages.showError) .finally(function() { $scope.ui.ready = true; $scope.ui.inputForm.$setPristine(); - $loading.finish('loadingIgfsScreen'); + Loading.finish('loadingIgfsScreen'); }); $scope.selectItem = function(item, backup) { function selectItem() { - $table.tableReset(); // TODO LEGACY + LegacyTable.tableReset(); $scope.selectedItem = item; @@ -231,13 +225,13 @@ consoleModule.controller('igfsController', [ $scope.backupItem = angular.merge({}, blank, $scope.backupItem); - __original_value = $cleanup($scope.backupItem); + __original_value = ModelNormalizer.normalize($scope.backupItem); - if ($common.getQueryVariable('new')) + if (LegacyUtils.getQueryVariable('new')) $state.go('base.configuration.igfs'); } - $common.confirmUnsavedChanges($scope.backupItem && $scope.ui.inputForm.$dirty, selectItem); + LegacyUtils.confirmUnsavedChanges($scope.backupItem && $scope.ui.inputForm.$dirty, selectItem); }; $scope.linkId = () => $scope.backupItem._id ? $scope.backupItem._id : 'create'; @@ -256,8 +250,8 @@ consoleModule.controller('igfsController', [ // Add new IGFS. $scope.createItem = function(linkId) { - if ($scope.tableReset(true)) { // TODO LEGACY - $timeout(() => $common.ensureActivePanel($scope.ui, 'general', 'igfsName')); + if ($scope.tableReset(true)) { + $timeout(() => LegacyUtils.ensureActivePanel($scope.ui, 'general', 'igfsName')); $scope.selectItem(null, prepareNewItem(linkId)); } @@ -265,12 +259,12 @@ consoleModule.controller('igfsController', [ // Check IGFS logical consistency. function validate(item) { - $common.hidePopover(); + LegacyUtils.hidePopover(); - if ($common.isEmptyString(item.name)) + if (LegacyUtils.isEmptyString(item.name)) return showPopoverMessage($scope.ui, 'general', 'igfsName', 'IGFS name should not be empty!'); - if (!$common.checkFieldValidators($scope.ui)) + if (!LegacyUtils.checkFieldValidators($scope.ui)) return false; if (!item.secondaryFileSystemEnabled && (item.defaultMode === 'PROXY')) @@ -305,16 +299,14 @@ consoleModule.controller('igfsController', [ $scope.selectItem(item); - $common.showInfo('IGFS "' + item.name + '" saved.'); + Messages.showInfo('IGFS "' + item.name + '" saved.'); }) - .error(function(errMsg) { - $common.showError(errMsg); - }); + .error(Messages.showError); } // Save IGFS. $scope.saveItem = function() { - if ($scope.tableReset(true)) { // TODO LEGACY + if ($scope.tableReset(true)) { const item = $scope.backupItem; if (validate(item)) @@ -330,8 +322,8 @@ consoleModule.controller('igfsController', [ // Clone IGFS with new name. $scope.cloneItem = function() { - if ($scope.tableReset(true) && validate($scope.backupItem)) { // TODO LEGACY - $clone.confirm($scope.backupItem.name, _igfsNames()).then(function(newName) { + if ($scope.tableReset(true) && validate($scope.backupItem)) { + Clone.confirm($scope.backupItem.name, _igfsNames()).then(function(newName) { const item = angular.copy($scope.backupItem); delete item._id; @@ -345,17 +337,17 @@ consoleModule.controller('igfsController', [ // Remove IGFS from db. $scope.removeItem = function() { - $table.tableReset(); // TODO LEGACY + LegacyTable.tableReset(); const selectedItem = $scope.selectedItem; - $confirm.confirm('Are you sure you want to remove IGFS: "' + selectedItem.name + '"?') + Confirm.confirm('Are you sure you want to remove IGFS: "' + selectedItem.name + '"?') .then(function() { const _id = selectedItem._id; $http.post('/api/v1/configuration/igfs/remove', {_id}) .success(function() { - $common.showInfo('IGFS has been removed: ' + selectedItem.name); + Messages.showInfo('IGFS has been removed: ' + selectedItem.name); const igfss = $scope.igfss; @@ -374,40 +366,36 @@ consoleModule.controller('igfsController', [ } } }) - .error(function(errMsg) { - $common.showError(errMsg); - }); + .error(Messages.showError); }); }; // Remove all IGFS from db. $scope.removeAllItems = function() { - $table.tableReset(); // TODO LEGACY + LegacyTable.tableReset(); - $confirm.confirm('Are you sure you want to remove all IGFS?') + Confirm.confirm('Are you sure you want to remove all IGFS?') .then(function() { $http.post('/api/v1/configuration/igfs/remove/all') .success(function() { - $common.showInfo('All IGFS have been removed'); + Messages.showInfo('All IGFS have been removed'); $scope.igfss = []; $scope.backupItem = emptyIgfs; $scope.ui.inputForm.$setPristine(); }) - .error(function(errMsg) { - $common.showError(errMsg); - }); + .error(Messages.showError); }); }; $scope.resetAll = function() { - $table.tableReset(); // TODO LEGACY + LegacyTable.tableReset(); - $confirm.confirm('Are you sure you want to undo all changes for current IGFS?') + Confirm.confirm('Are you sure you want to undo all changes for current IGFS?') .then(function() { $scope.backupItem = $scope.selectedItem ? angular.copy($scope.selectedItem) : prepareNewItem(); $scope.ui.inputForm.$setPristine(); }); }; - }] -); + } +]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/controllers/profile-controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/controllers/profile-controller.js b/modules/web-console/src/main/js/controllers/profile-controller.js index 39457af..6b8f541 100644 --- a/modules/web-console/src/main/js/controllers/profile-controller.js +++ b/modules/web-console/src/main/js/controllers/profile-controller.js @@ -16,18 +16,16 @@ */ // Controller for Profile screen. -import consoleModule from 'controllers/common-module'; - -consoleModule.controller('profileController', [ - '$rootScope', '$scope', '$http', '$common', '$focus', '$confirm', 'IgniteCountries', 'User', - function($root, $scope, $http, $common, $focus, $confirm, Countries, User) { +export default ['profileController', [ + '$rootScope', '$scope', '$http', 'IgniteLegacyUtils', 'IgniteMessages', 'IgniteFocus', 'IgniteConfirm', 'IgniteCountries', 'User', + function($root, $scope, $http, LegacyUtils, Messages, Focus, Confirm, Countries, User) { $scope.user = angular.copy($root.user); $scope.countries = Countries.getAll(); $scope.generateToken = () => { - $confirm.confirm('Are you sure you want to change security token?') - .then(() => $scope.user.token = $common.randomString(20)); + Confirm.confirm('Are you sure you want to change security token?') + .then(() => $scope.user.token = LegacyUtils.randomString(20)); }; const _passwordValid = () => { @@ -53,9 +51,10 @@ consoleModule.controller('profileController', [ $scope.togglePassword = () => { $scope.expandedPassword = !$scope.expandedPassword; - if (!$scope.expandedPassword) { + if ($scope.expandedPassword) + Focus.move('profile_password'); + else { delete $scope.user.password; - delete $scope.user.confirm; } }; @@ -82,11 +81,11 @@ consoleModule.controller('profileController', [ if ($scope.expandedToken) $scope.toggleToken(); - $common.showInfo('Profile saved.'); + Messages.showInfo('Profile saved.'); - $focus('profile-username'); + Focus.move('profile-username'); }) - .catch((err) => $common.showError('Failed to save profile: ' + $common.errorMessage(err))); + .catch(({data}) => Messages.showError(Messages.errorMessage('Failed to save profile: ', data))); }; - }] -); + } +]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/controllers/sql-controller.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/controllers/sql-controller.js b/modules/web-console/src/main/js/controllers/sql-controller.js index a8058ff..7a851c3 100644 --- a/modules/web-console/src/main/js/controllers/sql-controller.js +++ b/modules/web-console/src/main/js/controllers/sql-controller.js @@ -16,11 +16,9 @@ */ // Controller for SQL notebook screen. -import consoleModule from 'controllers/common-module'; - -consoleModule.controller('sqlController', [ - '$rootScope', '$scope', '$http', '$q', '$timeout', '$interval', '$animate', '$location', '$anchorScroll', '$state', '$modal', '$popover', '$loading', '$common', '$confirm', 'IgniteAgentMonitor', 'IgniteChartColors', 'QueryNotebooks', 'uiGridConstants', 'uiGridExporterConstants', - function($root, $scope, $http, $q, $timeout, $interval, $animate, $location, $anchorScroll, $state, $modal, $popover, $loading, $common, $confirm, agentMonitor, IgniteChartColors, QueryNotebooks, uiGridConstants, uiGridExporterConstants) { +export default ['sqlController', [ + '$rootScope', '$scope', '$http', '$q', '$timeout', '$interval', '$animate', '$location', '$anchorScroll', '$state', '$modal', '$popover', 'IgniteLoading', 'IgniteLegacyUtils', 'IgniteMessages', 'IgniteConfirm', 'IgniteAgentMonitor', 'IgniteChartColors', 'QueryNotebooks', 'uiGridConstants', 'uiGridExporterConstants', + function($root, $scope, $http, $q, $timeout, $interval, $animate, $location, $anchorScroll, $state, $modal, $popover, Loading, LegacyUtils, Messages, Confirm, agentMonitor, IgniteChartColors, QueryNotebooks, uiGridConstants, uiGridExporterConstants) { let stopTopology = null; const _tryStopRefresh = function(paragraph) { @@ -48,7 +46,7 @@ consoleModule.controller('sqlController', [ $scope.aggregateFxs = ['FIRST', 'LAST', 'MIN', 'MAX', 'SUM', 'AVG', 'COUNT']; - $scope.modes = $common.mkOptions(['PARTITIONED', 'REPLICATED', 'LOCAL']); + $scope.modes = LegacyUtils.mkOptions(['PARTITIONED', 'REPLICATED', 'LOCAL']); $scope.loadingText = $root.IgniteDemoMode ? 'Demo grid is starting. Please wait...' : 'Loading notebook screen...'; @@ -79,10 +77,6 @@ consoleModule.controller('sqlController', [ $scope.maskCacheName = (cacheName) => _.isEmpty(cacheName) ? '<default>' : cacheName; - const _handleException = function(err) { - $common.showError(err); - }; - // Time line X axis descriptor. const TIME_LINE = {value: -1, type: 'java.sql.Date', label: 'TIME_LINE'}; @@ -690,7 +684,8 @@ consoleModule.controller('sqlController', [ displayName: col.fieldName, headerTooltip: _fullColName(col), field: col.field, - minWidth: 50 + minWidth: 50, + cellClass: 'cell-left' }; }); @@ -772,7 +767,7 @@ consoleModule.controller('sqlController', [ }); const _startTopologyRefresh = () => { - $loading.start('sqlLoading'); + Loading.start('sqlLoading'); agentMonitor.awaitAgent() .then(_updateTopology) @@ -780,7 +775,7 @@ consoleModule.controller('sqlController', [ if ($root.IgniteDemoMode) _.forEach($scope.notebook.paragraphs, $scope.execute); - $loading.finish('sqlLoading'); + Loading.finish('sqlLoading'); stopTopology = $interval(_updateTopology, 5000, 0, false); }); @@ -826,7 +821,7 @@ consoleModule.controller('sqlController', [ .catch(() => { $scope.notebookLoadFailed = true; - $loading.finish('sqlLoading'); + Loading.finish('sqlLoading'); }); $scope.renameNotebook = function(name) { @@ -855,7 +850,7 @@ consoleModule.controller('sqlController', [ .catch((err) => { $scope.notebook.name = prevName; - _handleException(err); + Messages.showError(err); }); } else @@ -863,7 +858,7 @@ consoleModule.controller('sqlController', [ }; $scope.removeNotebook = function() { - $confirm.confirm('Are you sure you want to remove: "' + $scope.notebook.name + '"?') + Confirm.confirm('Are you sure you want to remove: "' + $scope.notebook.name + '"?') .then(function() { return QueryNotebooks.remove($scope.notebook); }) @@ -873,7 +868,7 @@ consoleModule.controller('sqlController', [ else $state.go('base.configuration.clusters'); }) - .catch(_handleException); + .catch(Messages.showError); }; $scope.renameParagraph = function(paragraph, newName) { @@ -886,8 +881,8 @@ consoleModule.controller('sqlController', [ $scope.rebuildScrollParagraphs(); QueryNotebooks.save($scope.notebook) - .then(function() { paragraph.edit = false; }) - .catch(_handleException); + .then(() => paragraph.edit = false) + .catch(Messages.showError); } else paragraph.edit = false; @@ -934,7 +929,7 @@ consoleModule.controller('sqlController', [ if (!_.isEmpty(paragraph.charts)) { const chart = paragraph.charts[0].api.getScope().chart; - if (!$common.isDefined(paragraph.chartsOptions)) + if (!LegacyUtils.isDefined(paragraph.chartsOptions)) paragraph.chartsOptions = {barChart: {stacked: true}, areaChart: {style: 'stack'}}; switch (paragraph.result) { @@ -972,7 +967,7 @@ consoleModule.controller('sqlController', [ }; $scope.removeParagraph = function(paragraph) { - $confirm.confirm('Are you sure you want to remove: "' + paragraph.name + '"?') + Confirm.confirm('Are you sure you want to remove: "' + paragraph.name + '"?') .then(function() { $scope.stopRefresh(paragraph); @@ -992,7 +987,7 @@ consoleModule.controller('sqlController', [ $scope.rebuildScrollParagraphs(); QueryNotebooks.save($scope.notebook) - .catch(_handleException); + .catch(Messages.showError); }); }; @@ -1013,7 +1008,7 @@ consoleModule.controller('sqlController', [ }; const _notObjectType = function(cls) { - return $common.isJavaBuiltInClass(cls); + return LegacyUtils.isJavaBuiltInClass(cls); }; function _retainColumns(allCols, curCols, acceptableType, xAxis, unwantedCols) { @@ -1060,7 +1055,7 @@ consoleModule.controller('sqlController', [ _.forEach(colsByTypes, function(colsByType, typeName) { _.forEach(colsByType, function(col, ix) { - col.fieldName = (needType && !$common.isEmptyString(typeName) ? typeName + '.' : '') + fieldName + (ix > 0 ? ix : ''); + col.fieldName = (needType && !LegacyUtils.isEmptyString(typeName) ? typeName + '.' : '') + fieldName + (ix > 0 ? ix : ''); }); }); }); @@ -1131,10 +1126,10 @@ consoleModule.controller('sqlController', [ paragraph.chartColumns = []; - if (!$common.isDefined(paragraph.chartKeyCols)) + if (!LegacyUtils.isDefined(paragraph.chartKeyCols)) paragraph.chartKeyCols = []; - if (!$common.isDefined(paragraph.chartValCols)) + if (!LegacyUtils.isDefined(paragraph.chartValCols)) paragraph.chartValCols = []; if (res.fieldsMetadata.length <= 2) { @@ -1247,7 +1242,7 @@ consoleModule.controller('sqlController', [ $scope.execute = function(paragraph) { QueryNotebooks.save($scope.notebook) - .catch(_handleException); + .catch(Messages.showError); paragraph.prevQuery = paragraph.queryArgs ? paragraph.queryArgs.query : paragraph.query; @@ -1279,7 +1274,7 @@ consoleModule.controller('sqlController', [ }; $scope.queryExecuted = function(paragraph) { - return $common.isDefined(paragraph.queryArgs); + return LegacyUtils.isDefined(paragraph.queryArgs); }; const _cancelRefresh = function(paragraph) { @@ -1296,7 +1291,7 @@ consoleModule.controller('sqlController', [ $scope.explain = function(paragraph) { QueryNotebooks.save($scope.notebook) - .catch(_handleException); + .catch(Messages.showError); _cancelRefresh(paragraph); @@ -1323,7 +1318,7 @@ consoleModule.controller('sqlController', [ $scope.scan = function(paragraph) { QueryNotebooks.save($scope.notebook) - .catch(_handleException); + .catch(Messages.showError); _cancelRefresh(paragraph); @@ -1440,7 +1435,7 @@ consoleModule.controller('sqlController', [ csvContent += cols.join(';') + '\n'; }); - $common.download('application/octet-stream;charset=utf-8', fileName, escape(csvContent)); + LegacyUtils.download('application/octet-stream;charset=utf-8', fileName, escape(csvContent)); }; $scope.exportCsv = function(paragraph) { @@ -1458,7 +1453,7 @@ consoleModule.controller('sqlController', [ agentMonitor.queryGetAll(args.cacheName, args.query) .then((res) => _export(paragraph.name + '-all.csv', paragraph.columnFilter, res.fieldsMetadata, res.items)) - .catch((err) => $common.showError(err)) + .catch(Messages.showError) .finally(() => paragraph.ace.focus()); }; @@ -1467,9 +1462,7 @@ consoleModule.controller('sqlController', [ // .success(function(item) { // _export(paragraph.name + '-all.csv', item.meta, item.rows); // }) - // .error(function(errMsg) { - // $common.showError(errMsg); - // }); + // .error(Messages.showError); // }; $scope.rateAsString = function(paragraph) { @@ -1544,7 +1537,7 @@ consoleModule.controller('sqlController', [ }; $scope.importMetadata = function() { - $loading.start('loadingCacheMetadata'); + Loading.start('loadingCacheMetadata'); $scope.metadata = []; @@ -1566,12 +1559,12 @@ consoleModule.controller('sqlController', [ return cache; }), 'name'); }) - .catch(_handleException) - .finally(() => $loading.finish('loadingCacheMetadata')); + .catch(Messages.showError) + .finally(() => Loading.finish('loadingCacheMetadata')); }; $scope.showResultQuery = function(paragraph) { - if ($common.isDefined(paragraph)) { + if (LegacyUtils.isDefined(paragraph)) { const scope = $scope.$new(); if (_.isNil(paragraph.queryArgs.query)) { @@ -1591,5 +1584,5 @@ consoleModule.controller('sqlController', [ $modal({scope, template: '/templates/message.html', placement: 'center', show: true}); } }; - }] -); + } +]]; http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/generator/generator-java.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/generator/generator-java.js b/modules/web-console/src/main/js/generator/generator-java.js index 2b6ac2f..d9425e0 100644 --- a/modules/web-console/src/main/js/generator/generator-java.js +++ b/modules/web-console/src/main/js/generator/generator-java.js @@ -1319,10 +1319,9 @@ $generatorJava.cacheGeneral = function(cache, varName, res) { $generatorJava.enumProperty(res, varName, cache, 'cacheMode', 'org.apache.ignite.cache.CacheMode'); $generatorJava.enumProperty(res, varName, cache, 'atomicityMode', 'org.apache.ignite.cache.CacheAtomicityMode'); - if (cache.cacheMode === 'PARTITIONED') - $generatorJava.property(res, varName, cache, 'backups'); + if (cache.cacheMode === 'PARTITIONED' && $generatorJava.property(res, varName, cache, 'backups')) + $generatorJava.property(res, varName, cache, 'readFromBackup'); - $generatorJava.property(res, varName, cache, 'readFromBackup'); $generatorJava.property(res, varName, cache, 'copyOnRead'); if (cache.cacheMode === 'PARTITIONED' && cache.atomicityMode === 'TRANSACTIONAL') @@ -1806,6 +1805,8 @@ $generatorJava.domainModelQueryIndexes = function(res, domain) { $generatorJava.property(res, 'index', index, 'name'); $generatorJava.enumProperty(res, 'index', index, 'indexType', 'org.apache.ignite.cache.QueryIndexType'); + res.needEmptyLine = true; + if (fields && fields.length > 0) { $generatorJava.declareVariable(res, 'indFlds', 'java.util.LinkedHashMap', 'java.util.LinkedHashMap', 'String', 'Boolean'); http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/generator/generator-xml.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/generator/generator-xml.js b/modules/web-console/src/main/js/generator/generator-xml.js index 4528f36..efc8df8 100644 --- a/modules/web-console/src/main/js/generator/generator-xml.js +++ b/modules/web-console/src/main/js/generator/generator-xml.js @@ -1062,10 +1062,9 @@ $generatorXml.cacheGeneral = function(cache, res) { $generatorXml.property(res, cache, 'cacheMode'); $generatorXml.property(res, cache, 'atomicityMode'); - if (cache.cacheMode === 'PARTITIONED') - $generatorXml.property(res, cache, 'backups'); + if (cache.cacheMode === 'PARTITIONED' && $generatorXml.property(res, cache, 'backups')) + $generatorXml.property(res, cache, 'readFromBackup'); - $generatorXml.property(res, cache, 'readFromBackup'); $generatorXml.property(res, cache, 'copyOnRead'); if (cache.cacheMode === 'PARTITIONED' && cache.atomicityMode === 'TRANSACTIONAL') http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/gulpfile.babel.js/paths.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/gulpfile.babel.js/paths.js b/modules/web-console/src/main/js/gulpfile.babel.js/paths.js index b865fcf..cca3643 100644 --- a/modules/web-console/src/main/js/gulpfile.babel.js/paths.js +++ b/modules/web-console/src/main/js/gulpfile.babel.js/paths.js @@ -17,85 +17,54 @@ import path from 'path'; -const srcDir = './app'; -const destDir = './build'; +const rootDir = path.resolve('./'); +const srcDir = path.resolve('app'); +const destDir = path.resolve('build'); const igniteModulesDir = process.env.IGNITE_MODULES ? path.normalize(process.env.IGNITE_MODULES) : './ignite_modules'; -const igniteModulesTemp = './ignite_modules_temp'; - -const sassPaths = [ - './public/stylesheets/*.scss' -]; +const igniteModulesTemp = path.resolve('ignite_modules_temp'); const jadePaths = [ - '!./views/error.jade', './views/*.jade', './views/**/*.jade' ]; -const jadeModulePaths = [ - igniteModulesDir + '/**/view/**/*.jade' -]; - const resourcePaths = [ - './controllers/**/*.json', './public/**/*.png', './public/*.ico' ]; -const resourceModulePaths = [ - igniteModulesDir + '/**/controllers/models/*.json', - igniteModulesDir + '/**/images/*.png' -]; - -const jsPaths = [ - './{app,controllers,generator}/*.js', - './{app,controllers,generator}/**/*.js' -]; - -const jsModulePaths = [ - igniteModulesTemp + '/index.js', - igniteModulesTemp + '/**/main.js', - igniteModulesTemp + '/**/module.js', - igniteModulesTemp + '/**/app/modules/*.js', - igniteModulesTemp + '/**/app/modules/**/*.js', - igniteModulesTemp + '/**/app/modules/**/*.jade' +const jadeModulePaths = [ + igniteModulesDir + '/**/view/**/*.jade' ]; -const appPaths = [ - './app/**/*.Ñss', - './app/**/*.jade', - './app/data/*.json' -].concat(jsPaths); - const appModulePaths = [ igniteModulesDir + '/index.js', igniteModulesDir + '/**/main.js', igniteModulesDir + '/**/module.js', - igniteModulesDir + '/**/app/**/*.css', - igniteModulesDir + '/**/app/data/*.json', igniteModulesDir + '/**/app/modules/*.js', igniteModulesDir + '/**/app/modules/**/*.js', - igniteModulesDir + '/**/app/modules/**/*.jade' + igniteModulesDir + '/**/app/modules/**/*.jade', + igniteModulesDir + '/**/app/**/*.css', + igniteModulesDir + '/**/app/data/*.json' +]; + +const resourceModulePaths = [ + igniteModulesDir + '/**/images/*.png', + igniteModulesDir + '/*.ico' ]; export { + rootDir, srcDir, destDir, igniteModulesDir, igniteModulesTemp, - sassPaths, - jadePaths, - jadeModulePaths, - resourcePaths, - resourceModulePaths, - jsPaths, - jsModulePaths, - - appPaths, + jadeModulePaths, + resourceModulePaths, appModulePaths }; http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/gulpfile.babel.js/tasks/build.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/gulpfile.babel.js/tasks/build.js b/modules/web-console/src/main/js/gulpfile.babel.js/tasks/build.js index 69cd6cd..7d7401b 100644 --- a/modules/web-console/src/main/js/gulpfile.babel.js/tasks/build.js +++ b/modules/web-console/src/main/js/gulpfile.babel.js/tasks/build.js @@ -18,4 +18,4 @@ import gulp from 'gulp'; import sequence from 'gulp-sequence'; -gulp.task('build', (cb) => sequence(['clean', 'clean:ignite-modules-temp'], 'ignite:modules', ['copy', 'jade', 'sass'], 'bundle', cb)); +gulp.task('build', (cb) => sequence(['clean', 'clean:ignite-modules-temp'], 'ignite:modules', ['copy:resource', 'jade'], 'bundle', cb)); http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/gulpfile.babel.js/tasks/bundle.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/gulpfile.babel.js/tasks/bundle.js b/modules/web-console/src/main/js/gulpfile.babel.js/tasks/bundle.js index 38ed8d8..d3e8dca 100644 --- a/modules/web-console/src/main/js/gulpfile.babel.js/tasks/bundle.js +++ b/modules/web-console/src/main/js/gulpfile.babel.js/tasks/bundle.js @@ -16,61 +16,17 @@ */ import gulp from 'gulp'; -import jspm from 'jspm'; -import util from 'gulp-util'; -import sequence from 'gulp-sequence'; -import htmlReplace from 'gulp-html-replace'; - -import { srcDir, destDir, igniteModulesTemp } from '../paths'; - -const options = { - minify: true -}; - -if (util.env.debug) - delete options.minify; - -if (util.env.debug || util.env.sourcemaps) - options.sourceMaps = true; - -gulp.task('bundle', ['eslint', 'bundle:ignite']); - -// Package all external dependencies and ignite-console. -gulp.task('bundle:ignite', (cb) => { - if (util.env.debug) - return sequence('bundle:ignite:vendors', 'bundle:ignite:app', cb); - - return sequence('bundle:ignite:app-min', 'bundle:ignite:app-min:replace', cb); -}); - -gulp.task('bundle:ignite:vendors', () => { - const exclude = [ - `${srcDir}/**/*`, - `${srcDir}/**/*!jade`, - './controllers/**/*.js', - './generator/**/*.js', - './public/**/*!css', - `${igniteModulesTemp}/**/*`, - `${igniteModulesTemp}/**/*!jade`, - `${igniteModulesTemp}/**/*!css` - ].map((item) => `[${item}]`).join(' - '); - - return jspm.bundle(`${srcDir}/index - ${exclude}`, `${destDir}/vendors.js`, options); +import webpack from 'webpack'; +import webpackConfig from '../webpack'; +import WebpackDevServer from 'webpack-dev-server'; + +gulp.task('bundle', (cb) => { + if (process.env.NODE_ENV === 'development') { + // Important! Call webpack and WebpackDevServer must be inline. + new WebpackDevServer(webpack(webpackConfig), webpackConfig.devServer) + .listen(webpackConfig.devServer.port, 'localhost', cb); + } + else + webpack(webpackConfig, cb); }); -gulp.task('bundle:ignite:app', () => - jspm.bundle(`${srcDir}/index - ${destDir}/vendors`, `${destDir}/app.js`, options) -); - -gulp.task('bundle:ignite:app-min', () => - jspm.bundleSFX(`${srcDir}/index`, `${destDir}/app.min.js`, options) -); - -gulp.task('bundle:ignite:app-min:replace', () => - gulp.src('./build/index.html') - .pipe(htmlReplace({ - css: 'app.min.css', - js: 'app.min.js' - })) - .pipe(gulp.dest('./build')) -); http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/gulpfile.babel.js/tasks/clean.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/gulpfile.babel.js/tasks/clean.js b/modules/web-console/src/main/js/gulpfile.babel.js/tasks/clean.js index 4c821e8..c9104b2 100644 --- a/modules/web-console/src/main/js/gulpfile.babel.js/tasks/clean.js +++ b/modules/web-console/src/main/js/gulpfile.babel.js/tasks/clean.js @@ -16,16 +16,13 @@ */ import gulp from 'gulp'; -import ignore from 'gulp-ignore'; import clean from 'gulp-rimraf'; import { destDir, igniteModulesTemp } from '../paths'; // Clean build folder, remove files. gulp.task('clean', () => - gulp.src(`${ destDir }/*`, {read: false}) - .pipe(ignore('jspm_packages')) - .pipe(ignore('system.config.js')) + gulp.src(`${destDir}/*`, {read: false}) .pipe(clean({ force: true })) ); http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/gulpfile.babel.js/tasks/connect.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/gulpfile.babel.js/tasks/connect.js b/modules/web-console/src/main/js/gulpfile.babel.js/tasks/connect.js deleted file mode 100644 index 4bffe50..0000000 --- a/modules/web-console/src/main/js/gulpfile.babel.js/tasks/connect.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 gulp from 'gulp'; -import connect from 'gulp-connect'; -import proxy from 'http-proxy-middleware'; - -import { destDir } from '../paths'; - -// Task run static server to local development. -gulp.task('connect', () => { - connect.server({ - port: 8090, - root: [destDir], - middleware() { - return [ - proxy('/socket.io', { - target: 'http://localhost:3000', - changeOrigin: true, - ws: true - }), - proxy('/api/v1/', { - target: 'http://localhost:3000', - changeOrigin: true, - pathRewrite: { - '^/api/v1/': '/' // remove path - } - }) - ]; - }, - fallback: `${destDir}/index.html` - }); -}); http://git-wip-us.apache.org/repos/asf/ignite/blob/c38b3ba2/modules/web-console/src/main/js/gulpfile.babel.js/tasks/copy.js ---------------------------------------------------------------------- diff --git a/modules/web-console/src/main/js/gulpfile.babel.js/tasks/copy.js b/modules/web-console/src/main/js/gulpfile.babel.js/tasks/copy.js index c97f11a..59373a8 100644 --- a/modules/web-console/src/main/js/gulpfile.babel.js/tasks/copy.js +++ b/modules/web-console/src/main/js/gulpfile.babel.js/tasks/copy.js @@ -16,42 +16,18 @@ */ import gulp from 'gulp'; -import util from 'gulp-util'; -import cache from 'gulp-cached'; import sequence from 'gulp-sequence'; -import { destDir, jsPaths, jsModulePaths, resourcePaths, resourceModulePaths, igniteModulesTemp } from '../paths'; +import { destDir, resourcePaths, resourceModulePaths } from '../paths'; -gulp.task('copy', (cb) => { - const tasks = ['copy:resource', 'copy:ignite_modules:resource']; +gulp.task('copy:resource', (cb) => sequence('copy:resource:app', 'copy:resource:ignite_modules', cb)); - if (util.env.debug || util.env.sourcemaps) { - tasks.push('copy:js'); - - tasks.push('copy:ignite_modules:js'); - } - - return sequence(tasks, cb); -}); - -gulp.task('copy:js', () => - gulp.src(jsPaths, {base: './'}) - .pipe(cache('copy:js')) - .pipe(gulp.dest(destDir)) -); - -gulp.task('copy:ignite_modules:js', () => - gulp.src(jsModulePaths) - .pipe(cache('copy:ignite_modules:js')) - .pipe(gulp.dest(`${destDir}/${igniteModulesTemp}`)) -); - -gulp.task('copy:resource', () => +gulp.task('copy:resource:app', () => gulp.src(resourcePaths) .pipe(gulp.dest(destDir)) ); -gulp.task('copy:ignite_modules:resource', () => +gulp.task('copy:resource:ignite_modules', () => gulp.src(resourceModulePaths) .pipe(gulp.dest(`${destDir}/ignite_modules`)) );