ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [14/17] ignite git commit: IGNITE-7996 Use configuration.state for state registration only.
Date Thu, 12 Apr 2018 04:11:58 GMT
IGNITE-7996 Use configuration.state for state registration only.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2800ef08
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2800ef08
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2800ef08

Branch: refs/heads/master
Commit: 2800ef084fe480224fcb14f12a73ccb24007edb0
Parents: d5e0be0
Author: Ilya Borisov <Klaster1@gmail.com>
Authored: Fri Apr 6 11:20:13 2018 +0700
Committer: Ilya Borisov <Klaster1@gmail.com>
Committed: Fri Apr 6 11:20:13 2018 +0700

----------------------------------------------------------------------
 .../page-configure/configuration.state.js       | 490 +++++++++----------
 1 file changed, 233 insertions(+), 257 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2800ef08/modules/web-console/frontend/app/components/page-configure/configuration.state.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/page-configure/configuration.state.js
b/modules/web-console/frontend/app/components/page-configure/configuration.state.js
index 1a0a598..f8bb4dc 100644
--- a/modules/web-console/frontend/app/components/page-configure/configuration.state.js
+++ b/modules/web-console/frontend/app/components/page-configure/configuration.state.js
@@ -17,20 +17,11 @@
 
 import angular from 'angular';
 
-import {default as ActivitiesData} from 'app/core/activities/Activities.data';
-
-// Common directives.
-import previewPanel from './configuration/preview-panel.directive.js';
-
-// Summary screen.
-import ConfigurationResource from './configuration/Configuration.resource';
-import IgniteSummaryZipper from './configuration/summary/summary-zipper.service';
-
 import base2 from 'views/base2.pug';
-import pageConfigureAdvancedClusterComponent from 'app/components/page-configure-advanced/components/page-configure-advanced-cluster/component';
-import pageConfigureAdvancedModelsComponent from 'app/components/page-configure-advanced/components/page-configure-advanced-models/component';
-import pageConfigureAdvancedCachesComponent from 'app/components/page-configure-advanced/components/page-configure-advanced-caches/component';
-import pageConfigureAdvancedIGFSComponent from 'app/components/page-configure-advanced/components/page-configure-advanced-igfs/component';
+import pageConfigureAdvancedClusterComponent from '../page-configure-advanced/components/page-configure-advanced-cluster/component';
+import pageConfigureAdvancedModelsComponent from '../page-configure-advanced/components/page-configure-advanced-models/component';
+import pageConfigureAdvancedCachesComponent from '../page-configure-advanced/components/page-configure-advanced-caches/component';
+import pageConfigureAdvancedIGFSComponent from '../page-configure-advanced/components/page-configure-advanced-igfs/component';
 
 import get from 'lodash/get';
 import {Observable} from 'rxjs/Observable';
@@ -47,251 +38,236 @@ const shortCachesResolve = ['ConfigSelectors', 'ConfigureState', 'ConfigEffects'
     .toPromise();
 }];
 
-/**
- * @param {ActivitiesData} ActivitiesData
- * @param {uirouter.UIRouter} $uiRouter
- */
-function initConfiguration(ActivitiesData, $uiRouter) {
-    $uiRouter.transitionService.onSuccess({to: 'base.configuration.**'}, (transition) =>
{
-        ActivitiesData.post({group: 'configuration', action: transition.targetState().name()});
+function registerStates($stateProvider) {
+    // Setup the states.
+    $stateProvider
+    .state('base.configuration', {
+        abstract: true,
+        permission: 'configuration',
+        url: '/configuration',
+        onEnter: ['ConfigureState', (ConfigureState) => ConfigureState.dispatchAction({type:
'PRELOAD_STATE', state: {}})],
+        views: {
+            '@': {
+                template: base2
+            }
+        },
+        resolve: {
+            _shortClusters: ['ConfigEffects', ({etp}) => {
+                return etp('LOAD_USER_CLUSTERS');
+            }]
+        },
+        resolvePolicy: {
+            async: 'NOWAIT'
+        }
+    })
+    .state('base.configuration.overview', {
+        url: '/overview',
+        component: 'pageConfigureOverview',
+        permission: 'configuration',
+        tfMetaTags: {
+            title: 'Configuration'
+        }
+    })
+    .state('base.configuration.edit', {
+        url: `/{clusterID:${idRegex}}`,
+        permission: 'configuration',
+        component: 'pageConfigure',
+        resolve: {
+            _cluster: ['ConfigEffects', '$transition$', ({etp}, $transition$) => {
+                return $transition$.injector().getAsync('_shortClusters').then(() => {
+                    return etp('LOAD_AND_EDIT_CLUSTER', {clusterID: $transition$.params().clusterID});
+                });
+            }]
+        },
+        data: {
+            errorState: 'base.configuration.overview'
+        },
+        redirectTo: ($transition$) => {
+            const [ConfigureState, ConfigSelectors] = ['ConfigureState', 'ConfigSelectors'].map((t)
=> $transition$.injector().get(t));
+            const waitFor = ['_cluster', '_shortClusters'].map((t) => $transition$.injector().getAsync(t));
+            return Observable.fromPromise(Promise.all(waitFor)).switchMap(() => {
+                return Observable.combineLatest(
+                    ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1),
+                    ConfigureState.state$.let(ConfigSelectors.selectShortClusters()).take(1)
+                );
+            })
+            .map(([cluster = {caches: []}, clusters]) => {
+                return (clusters.value.size > 10 || cluster.caches.length > 5)
+                    ? 'base.configuration.edit.advanced'
+                    : 'base.configuration.edit.basic';
+            })
+            .toPromise();
+        },
+        failState: 'signin',
+        tfMetaTags: {
+            title: 'Configuration'
+        }
+    })
+    .state('base.configuration.edit.basic', {
+        url: '/basic',
+        component: 'pageConfigureBasic',
+        permission: 'configuration',
+        resolve: {
+            _shortCaches: shortCachesResolve
+        },
+        resolvePolicy: {
+            async: 'NOWAIT'
+        },
+        tfMetaTags: {
+            title: 'Basic Configuration'
+        }
+    })
+    .state('base.configuration.edit.advanced', {
+        url: '/advanced',
+        component: 'pageConfigureAdvanced',
+        permission: 'configuration',
+        redirectTo: 'base.configuration.edit.advanced.cluster'
+    })
+    .state('base.configuration.edit.advanced.cluster', {
+        url: '/cluster',
+        component: pageConfigureAdvancedClusterComponent.name,
+        permission: 'configuration',
+        resolve: {
+            _shortCaches: shortCachesResolve
+        },
+        resolvePolicy: {
+            async: 'NOWAIT'
+        },
+        tfMetaTags: {
+            title: 'Configure Cluster'
+        }
+    })
+    .state('base.configuration.edit.advanced.caches', {
+        url: '/caches',
+        permission: 'configuration',
+        component: pageConfigureAdvancedCachesComponent.name,
+        resolve: {
+            _shortCachesAndModels: ['ConfigSelectors', 'ConfigureState', 'ConfigEffects',
'$transition$', (ConfigSelectors, ConfigureState, {etp}, $transition$) => {
+                if ($transition$.params().clusterID === 'new') return Promise.resolve();
+                return Observable.fromPromise($transition$.injector().getAsync('_cluster'))
+                .switchMap(() => ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1))
+                .map((cluster) => {
+                    return Promise.all([
+                        etp('LOAD_SHORT_CACHES', {ids: cluster.caches, clusterID: cluster._id}),
+                        etp('LOAD_SHORT_MODELS', {ids: cluster.models, clusterID: cluster._id}),
+                        etp('LOAD_SHORT_IGFSS', {ids: cluster.igfss, clusterID: cluster._id})
+                    ]);
+                })
+                .toPromise();
+            }]
+        },
+        resolvePolicy: {
+            async: 'NOWAIT'
+        },
+        tfMetaTags: {
+            title: 'Configure Caches'
+        }
+    })
+    .state('base.configuration.edit.advanced.caches.cache', {
+        url: `/{cacheID:${idRegex}}`,
+        permission: 'configuration',
+        resolve: {
+            _cache: ['ConfigEffects', '$transition$', ({etp}, $transition$) => {
+                const {clusterID, cacheID} = $transition$.params();
+                if (cacheID === 'new') return Promise.resolve();
+                return etp('LOAD_CACHE', {cacheID});
+            }]
+        },
+        data: {
+            errorState: 'base.configuration.edit.advanced.caches'
+        },
+        resolvePolicy: {
+            async: 'NOWAIT'
+        },
+        tfMetaTags: {
+            title: 'Configure Caches'
+        }
+    })
+    .state('base.configuration.edit.advanced.models', {
+        url: '/models',
+        component: pageConfigureAdvancedModelsComponent.name,
+        permission: 'configuration',
+        resolve: {
+            _shortCachesAndModels: ['ConfigSelectors', 'ConfigureState', 'ConfigEffects',
'$transition$', (ConfigSelectors, ConfigureState, {etp}, $transition$) => {
+                if ($transition$.params().clusterID === 'new') return Promise.resolve();
+                return Observable.fromPromise($transition$.injector().getAsync('_cluster'))
+                .switchMap(() => ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1))
+                .map((cluster) => {
+                    return Promise.all([
+                        etp('LOAD_SHORT_CACHES', {ids: cluster.caches, clusterID: cluster._id}),
+                        etp('LOAD_SHORT_MODELS', {ids: cluster.models, clusterID: cluster._id})
+                    ]);
+                })
+                .toPromise();
+            }]
+        },
+        resolvePolicy: {
+            async: 'NOWAIT'
+        },
+        tfMetaTags: {
+            title: 'Configure SQL Schemes'
+        }
+    })
+    .state('base.configuration.edit.advanced.models.model', {
+        url: `/{modelID:${idRegex}}`,
+        resolve: {
+            _cache: ['ConfigEffects', '$transition$', ({etp}, $transition$) => {
+                const {clusterID, modelID} = $transition$.params();
+                if (modelID === 'new') return Promise.resolve();
+                return etp('LOAD_MODEL', {modelID});
+            }]
+        },
+        data: {
+            errorState: 'base.configuration.edit.advanced.models'
+        },
+        permission: 'configuration',
+        resolvePolicy: {
+            async: 'NOWAIT'
+        }
+    })
+    .state('base.configuration.edit.advanced.igfs', {
+        url: '/igfs',
+        component: pageConfigureAdvancedIGFSComponent.name,
+        permission: 'configuration',
+        resolve: {
+            _shortIGFSs: ['ConfigSelectors', 'ConfigureState', 'ConfigEffects', '$transition$',
(ConfigSelectors, ConfigureState, {etp}, $transition$) => {
+                if ($transition$.params().clusterID === 'new') return Promise.resolve();
+                return Observable.fromPromise($transition$.injector().getAsync('_cluster'))
+                .switchMap(() => ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1))
+                .map((cluster) => {
+                    return Promise.all([
+                        etp('LOAD_SHORT_IGFSS', {ids: cluster.igfss, clusterID: cluster._id})
+                    ]);
+                })
+                .toPromise();
+            }]
+        },
+        resolvePolicy: {
+            async: 'NOWAIT'
+        },
+        tfMetaTags: {
+            title: 'Configure IGFS'
+        }
+    })
+    .state('base.configuration.edit.advanced.igfs.igfs', {
+        url: `/{igfsID:${idRegex}}`,
+        permission: 'configuration',
+        resolve: {
+            _igfs: ['ConfigEffects', '$transition$', ({etp}, $transition$) => {
+                const {clusterID, igfsID} = $transition$.params();
+                if (igfsID === 'new') return Promise.resolve();
+                return etp('LOAD_IGFS', {igfsID});
+            }]
+        },
+        data: {
+            errorState: 'base.configuration.edit.advanced.igfs'
+        },
+        resolvePolicy: {
+            async: 'NOWAIT'
+        }
     });
 }
 
-initConfiguration.$inject = ['IgniteActivitiesData', '$uiRouter'];
+registerStates.$inject = ['$stateProvider'];
 
-angular.module('ignite-console.states.configuration', ['ui.router'])
-    .directive(...previewPanel)
-    // Services.
-    .service('IgniteSummaryZipper', IgniteSummaryZipper)
-    .service('IgniteConfigurationResource', ConfigurationResource)
-    .run(initConfiguration)
-    // Configure state provider.
-    .config(['$stateProvider', ($stateProvider) => {
-        // Setup the states.
-        $stateProvider
-            .state('base.configuration', {
-                abstract: true,
-                permission: 'configuration',
-                url: '/configuration',
-                onEnter: ['ConfigureState', (ConfigureState) => ConfigureState.dispatchAction({type:
'PRELOAD_STATE', state: {}})],
-                views: {
-                    '@': {
-                        template: base2
-                    }
-                },
-                resolve: {
-                    _shortClusters: ['ConfigEffects', ({etp}) => {
-                        return etp('LOAD_USER_CLUSTERS');
-                    }]
-                },
-                resolvePolicy: {
-                    async: 'NOWAIT'
-                }
-            })
-            .state('base.configuration.overview', {
-                url: '/overview',
-                component: 'pageConfigureOverview',
-                permission: 'configuration',
-                tfMetaTags: {
-                    title: 'Configuration'
-                }
-            })
-            .state('base.configuration.edit', {
-                url: `/{clusterID:${idRegex}}`,
-                permission: 'configuration',
-                component: 'pageConfigure',
-                resolve: {
-                    _cluster: ['ConfigEffects', '$transition$', ({etp}, $transition$) =>
{
-                        return $transition$.injector().getAsync('_shortClusters').then(()
=> {
-                            return etp('LOAD_AND_EDIT_CLUSTER', {clusterID: $transition$.params().clusterID});
-                        });
-                    }]
-                },
-                data: {
-                    errorState: 'base.configuration.overview'
-                },
-                redirectTo: ($transition$) => {
-                    const [ConfigureState, ConfigSelectors] = ['ConfigureState', 'ConfigSelectors'].map((t)
=> $transition$.injector().get(t));
-                    const waitFor = ['_cluster', '_shortClusters'].map((t) => $transition$.injector().getAsync(t));
-                    return Observable.fromPromise(Promise.all(waitFor)).switchMap(() =>
{
-                        return Observable.combineLatest(
-                            ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1),
-                            ConfigureState.state$.let(ConfigSelectors.selectShortClusters()).take(1)
-                        );
-                    })
-                    .map(([cluster = {caches: []}, clusters]) => {
-                        return (clusters.value.size > 10 || cluster.caches.length >
5)
-                            ? 'base.configuration.edit.advanced'
-                            : 'base.configuration.edit.basic';
-                    })
-                    .toPromise();
-                },
-                failState: 'signin',
-                tfMetaTags: {
-                    title: 'Configuration'
-                }
-            })
-            .state('base.configuration.edit.basic', {
-                url: '/basic',
-                component: 'pageConfigureBasic',
-                permission: 'configuration',
-                resolve: {
-                    _shortCaches: shortCachesResolve
-                },
-                resolvePolicy: {
-                    async: 'NOWAIT'
-                },
-                tfMetaTags: {
-                    title: 'Basic Configuration'
-                }
-            })
-            .state('base.configuration.edit.advanced', {
-                url: '/advanced',
-                component: 'pageConfigureAdvanced',
-                permission: 'configuration',
-                redirectTo: 'base.configuration.edit.advanced.cluster'
-            })
-            .state('base.configuration.edit.advanced.cluster', {
-                url: '/cluster',
-                component: pageConfigureAdvancedClusterComponent.name,
-                permission: 'configuration',
-                resolve: {
-                    _shortCaches: shortCachesResolve
-                },
-                resolvePolicy: {
-                    async: 'NOWAIT'
-                },
-                tfMetaTags: {
-                    title: 'Configure Cluster'
-                }
-            })
-            .state('base.configuration.edit.advanced.caches', {
-                url: '/caches',
-                permission: 'configuration',
-                component: pageConfigureAdvancedCachesComponent.name,
-                resolve: {
-                    _shortCachesAndModels: ['ConfigSelectors', 'ConfigureState', 'ConfigEffects',
'$transition$', (ConfigSelectors, ConfigureState, {etp}, $transition$) => {
-                        if ($transition$.params().clusterID === 'new') return Promise.resolve();
-                        return Observable.fromPromise($transition$.injector().getAsync('_cluster'))
-                        .switchMap(() => ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1))
-                        .map((cluster) => {
-                            return Promise.all([
-                                etp('LOAD_SHORT_CACHES', {ids: cluster.caches, clusterID:
cluster._id}),
-                                etp('LOAD_SHORT_MODELS', {ids: cluster.models, clusterID:
cluster._id}),
-                                etp('LOAD_SHORT_IGFSS', {ids: cluster.igfss, clusterID: cluster._id})
-                            ]);
-                        })
-                        .toPromise();
-                    }]
-                },
-                resolvePolicy: {
-                    async: 'NOWAIT'
-                },
-                tfMetaTags: {
-                    title: 'Configure Caches'
-                }
-            })
-            .state('base.configuration.edit.advanced.caches.cache', {
-                url: `/{cacheID:${idRegex}}`,
-                permission: 'configuration',
-                resolve: {
-                    _cache: ['ConfigEffects', '$transition$', ({etp}, $transition$) =>
{
-                        const {clusterID, cacheID} = $transition$.params();
-                        if (cacheID === 'new') return Promise.resolve();
-                        return etp('LOAD_CACHE', {cacheID});
-                    }]
-                },
-                data: {
-                    errorState: 'base.configuration.edit.advanced.caches'
-                },
-                resolvePolicy: {
-                    async: 'NOWAIT'
-                },
-                tfMetaTags: {
-                    title: 'Configure Caches'
-                }
-            })
-            .state('base.configuration.edit.advanced.models', {
-                url: '/models',
-                component: pageConfigureAdvancedModelsComponent.name,
-                permission: 'configuration',
-                resolve: {
-                    _shortCachesAndModels: ['ConfigSelectors', 'ConfigureState', 'ConfigEffects',
'$transition$', (ConfigSelectors, ConfigureState, {etp}, $transition$) => {
-                        if ($transition$.params().clusterID === 'new') return Promise.resolve();
-                        return Observable.fromPromise($transition$.injector().getAsync('_cluster'))
-                        .switchMap(() => ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1))
-                        .map((cluster) => {
-                            return Promise.all([
-                                etp('LOAD_SHORT_CACHES', {ids: cluster.caches, clusterID:
cluster._id}),
-                                etp('LOAD_SHORT_MODELS', {ids: cluster.models, clusterID:
cluster._id})
-                            ]);
-                        })
-                        .toPromise();
-                    }]
-                },
-                resolvePolicy: {
-                    async: 'NOWAIT'
-                },
-                tfMetaTags: {
-                    title: 'Configure SQL Schemes'
-                }
-            })
-            .state('base.configuration.edit.advanced.models.model', {
-                url: `/{modelID:${idRegex}}`,
-                resolve: {
-                    _cache: ['ConfigEffects', '$transition$', ({etp}, $transition$) =>
{
-                        const {clusterID, modelID} = $transition$.params();
-                        if (modelID === 'new') return Promise.resolve();
-                        return etp('LOAD_MODEL', {modelID});
-                    }]
-                },
-                data: {
-                    errorState: 'base.configuration.edit.advanced.models'
-                },
-                permission: 'configuration',
-                resolvePolicy: {
-                    async: 'NOWAIT'
-                }
-            })
-            .state('base.configuration.edit.advanced.igfs', {
-                url: '/igfs',
-                component: pageConfigureAdvancedIGFSComponent.name,
-                permission: 'configuration',
-                resolve: {
-                    _shortIGFSs: ['ConfigSelectors', 'ConfigureState', 'ConfigEffects', '$transition$',
(ConfigSelectors, ConfigureState, {etp}, $transition$) => {
-                        if ($transition$.params().clusterID === 'new') return Promise.resolve();
-                        return Observable.fromPromise($transition$.injector().getAsync('_cluster'))
-                        .switchMap(() => ConfigureState.state$.let(ConfigSelectors.selectCluster($transition$.params().clusterID)).take(1))
-                        .map((cluster) => {
-                            return Promise.all([
-                                etp('LOAD_SHORT_IGFSS', {ids: cluster.igfss, clusterID: cluster._id})
-                            ]);
-                        })
-                        .toPromise();
-                    }]
-                },
-                resolvePolicy: {
-                    async: 'NOWAIT'
-                },
-                tfMetaTags: {
-                    title: 'Configure IGFS'
-                }
-            })
-            .state('base.configuration.edit.advanced.igfs.igfs', {
-                url: `/{igfsID:${idRegex}}`,
-                permission: 'configuration',
-                resolve: {
-                    _igfs: ['ConfigEffects', '$transition$', ({etp}, $transition$) =>
{
-                        const {clusterID, igfsID} = $transition$.params();
-                        if (igfsID === 'new') return Promise.resolve();
-                        return etp('LOAD_IGFS', {igfsID});
-                    }]
-                },
-                data: {
-                    errorState: 'base.configuration.edit.advanced.igfs'
-                },
-                resolvePolicy: {
-                    async: 'NOWAIT'
-                }
-            });
-    }]);
+export {registerStates};


Mime
View raw message