diff --git a/app/scripts/modules/core/src/cluster/allClusters.controller.js b/app/scripts/modules/core/src/cluster/allClusters.controller.js index 8fa63969d67..26fcec23610 100644 --- a/app/scripts/modules/core/src/cluster/allClusters.controller.js +++ b/app/scripts/modules/core/src/cluster/allClusters.controller.js @@ -31,24 +31,24 @@ module.exports = angular.module('spinnaker.core.cluster.allClusters.controller', require('@uirouter/angularjs').default, ]) .controller('AllClustersCtrl', function($scope, app, $uibModal, $timeout, providerSelectionService, clusterFilterService, $state, scrollToService, $stateParams, - ClusterFilterModel, MultiselectModel, InsightFilterStateModel, serverGroupCommandBuilder, cloudProviderRegistry) { + clusterFilterModel, MultiselectModel, insightFilterStateModel, serverGroupCommandBuilder, cloudProviderRegistry) { this.$onInit = () => { - InsightFilterStateModel.filtersHidden = true; // hidden to prevent filter flashing for on-demand apps + insightFilterStateModel.filtersHidden = true; // hidden to prevent filter flashing for on-demand apps const groupsUpdatedSubscription = clusterFilterService.groupsUpdatedStream.subscribe(() => clusterGroupsUpdated()); this.application = app; - ClusterFilterModel.activate(); + clusterFilterModel.activate(); this.initialized = false; this.dataSource = app.getDataSource('serverGroups'); this.application = app; - $scope.sortFilter = ClusterFilterModel.sortFilter; + $scope.sortFilter = clusterFilterModel.sortFilter; this.createLabel = 'Create Server Group'; app.getDataSource('serverGroups').ready().then( () => { - InsightFilterStateModel.filtersHidden = false; + insightFilterStateModel.filtersHidden = false; updateClusterGroups(); // Automatically scrolls server group into view if deep linked; // $timeout because the updateClusterGroups method is debounced by 25ms @@ -67,14 +67,14 @@ module.exports = angular.module('spinnaker.core.cluster.allClusters.controller', $scope.$on('$destroy', () => { app.activeState = app; MultiselectModel.clearAll(); - InsightFilterStateModel.filtersHidden = false; + insightFilterStateModel.filtersHidden = false; groupsUpdatedSubscription.unsubscribe(); }); }; let updateClusterGroups = () => { if (app.getDataSource('serverGroups').fetchOnDemand) { - InsightFilterStateModel.filtersHidden = true; + insightFilterStateModel.filtersHidden = true; } clusterFilterService.updateClusterGroups(app); clusterGroupsUpdated(); @@ -84,13 +84,13 @@ module.exports = angular.module('spinnaker.core.cluster.allClusters.controller', let clusterGroupsUpdated = () => { $scope.$applyAsync(() => { - $scope.groups = ClusterFilterModel.groups; - $scope.tags = ClusterFilterModel.tags; + $scope.groups = clusterFilterModel.groups; + $scope.tags = clusterFilterModel.tags; }); }; this.toggleMultiselect = () => { - ClusterFilterModel.sortFilter.multiselect = !ClusterFilterModel.sortFilter.multiselect; + clusterFilterModel.sortFilter.multiselect = !clusterFilterModel.sortFilter.multiselect; MultiselectModel.syncNavigation(); updateClusterGroups(); }; diff --git a/app/scripts/modules/core/src/cluster/cluster.service.spec.ts b/app/scripts/modules/core/src/cluster/cluster.service.spec.ts index 3a7c14cffc4..c770b89f877 100644 --- a/app/scripts/modules/core/src/cluster/cluster.service.spec.ts +++ b/app/scripts/modules/core/src/cluster/cluster.service.spec.ts @@ -1,11 +1,12 @@ -import {IHttpBackendService, mock} from 'angular'; -import {find} from 'lodash'; +import { IHttpBackendService, mock } from 'angular'; +import { find } from 'lodash'; -import {CLUSTER_SERVICE, ClusterService} from './cluster.service'; -import {APPLICATION_MODEL_BUILDER, ApplicationModelBuilder} from 'core/application/applicationModel.builder'; +import { ClusterFilterModel } from './filter/clusterFilter.model'; +import { CLUSTER_SERVICE, ClusterService } from './cluster.service'; +import { APPLICATION_MODEL_BUILDER, ApplicationModelBuilder } from 'core/application/applicationModel.builder'; import { IInstanceCounts, IServerGroup } from 'core/domain'; -import {Application} from 'core/application/application.model'; -import {Api} from '../api/api.service'; +import { Application } from 'core/application/application.model'; +import { Api } from '../api/api.service'; describe('Service: Cluster', function () { beforeEach( @@ -13,7 +14,7 @@ describe('Service: Cluster', function () { ); let clusterService: ClusterService; - let ClusterFilterModel: any; + let clusterFilterModel: ClusterFilterModel; let $http: IHttpBackendService; let API: Api; let application: Application; @@ -27,12 +28,12 @@ describe('Service: Cluster', function () { }; } - beforeEach(mock.inject(($httpBackend: IHttpBackendService, _API_: Api, _ClusterFilterModel_: any, + beforeEach(mock.inject(($httpBackend: IHttpBackendService, _API_: Api, _clusterFilterModel_: ClusterFilterModel, _clusterService_: ClusterService, applicationModelBuilder: ApplicationModelBuilder) => { $http = $httpBackend; API = _API_; clusterService = _clusterService_; - ClusterFilterModel = _ClusterFilterModel_; + clusterFilterModel = _clusterFilterModel_; application = applicationModelBuilder.createApplication( 'app', @@ -73,17 +74,17 @@ describe('Service: Cluster', function () { }); it('converts clusters parameter to q and account params when there are fewer than 251 clusters', () => { - spyOn(ClusterFilterModel.asFilterModel, 'applyParamsToUrl').and.callFake(() => {}); + spyOn(clusterFilterModel.asFilterModel, 'applyParamsToUrl').and.callFake(() => {}); const clusters = Array(250); - ClusterFilterModel.sortFilter.clusters = {'test:myapp': true}; + clusterFilterModel.asFilterModel.sortFilter.clusters = {'test:myapp': true}; $http.expectGET(API.baseUrl + '/applications/app/clusters').respond(200, {test: clusters}); $http.expectGET(API.baseUrl + '/applications/app/serverGroups').respond(200, []); let serverGroups: IServerGroup[] = null; clusterService.loadServerGroups(application).then((result: IServerGroup[]) => serverGroups = result); $http.flush(); expect(application.serverGroups.fetchOnDemand).toBe(false); - expect(ClusterFilterModel.sortFilter.filter).toEqual('clusters:myapp'); - expect(ClusterFilterModel.sortFilter.account.test).toBe(true); + expect(clusterFilterModel.asFilterModel.sortFilter.filter).toEqual('clusters:myapp'); + expect(clusterFilterModel.asFilterModel.sortFilter.account.test).toBe(true); }); }); diff --git a/app/scripts/modules/core/src/cluster/cluster.service.ts b/app/scripts/modules/core/src/cluster/cluster.service.ts index 0341930c2c3..5415e69a753 100644 --- a/app/scripts/modules/core/src/cluster/cluster.service.ts +++ b/app/scripts/modules/core/src/cluster/cluster.service.ts @@ -17,7 +17,7 @@ export class ClusterService { private API: Api, private serverGroupTransformer: any, private namingService: NamingService, - private ClusterFilterModel: ClusterFilterModel, + private clusterFilterModel: ClusterFilterModel, private filterModelService: any) { 'ngInject'; } @@ -30,7 +30,7 @@ export class ClusterService { if (dataSource.fetchOnDemand) { dataSource.clusters = clusters; serverGroupLoader.withParams({ - clusters: this.filterModelService.getCheckValues(this.ClusterFilterModel.asFilterModel.sortFilter.clusters).join() + clusters: this.filterModelService.getCheckValues(this.clusterFilterModel.asFilterModel.sortFilter.clusters).join() }); } else { this.reconcileClusterDeepLink(); @@ -46,7 +46,7 @@ export class ClusterService { // if the application is deep linked via "clusters:", but the app is not "fetchOnDemand" sized, convert the parameters // to the normal, filterable structure private reconcileClusterDeepLink() { - const selectedClusters: string[] = this.filterModelService.getCheckValues(this.ClusterFilterModel.asFilterModel.sortFilter.clusters); + const selectedClusters: string[] = this.filterModelService.getCheckValues(this.clusterFilterModel.asFilterModel.sortFilter.clusters); if (selectedClusters && selectedClusters.length) { const clusterNames: string[] = []; const accountNames: string[] = []; @@ -58,10 +58,10 @@ export class ClusterService { } }); if (clusterNames.length) { - accountNames.forEach(account => this.ClusterFilterModel.asFilterModel.sortFilter.account[account] = true); - this.ClusterFilterModel.asFilterModel.sortFilter.filter = `clusters:${clusterNames.join()}`; - this.ClusterFilterModel.asFilterModel.sortFilter.clusters = {}; - this.ClusterFilterModel.asFilterModel.applyParamsToUrl(); + accountNames.forEach(account => this.clusterFilterModel.asFilterModel.sortFilter.account[account] = true); + this.clusterFilterModel.asFilterModel.sortFilter.filter = `clusters:${clusterNames.join()}`; + this.clusterFilterModel.asFilterModel.sortFilter.clusters = {}; + this.clusterFilterModel.asFilterModel.applyParamsToUrl(); } } } diff --git a/app/scripts/modules/core/src/cluster/clusterPod.component.ts b/app/scripts/modules/core/src/cluster/clusterPod.component.ts index defe88402ad..ee7059ec2fc 100644 --- a/app/scripts/modules/core/src/cluster/clusterPod.component.ts +++ b/app/scripts/modules/core/src/cluster/clusterPod.component.ts @@ -1,8 +1,9 @@ -import {module, IComponentController, IComponentOptions} from 'angular'; +import { module, IComponentController, IComponentOptions } from 'angular'; -import {Application} from 'core/application/application.model'; -import {URL_BUILDER_SERVICE, UrlBuilderService} from 'core/navigation/urlBuilder.service'; -import {SERVER_GROUP_COMPONENT} from 'core/serverGroup/serverGroup.component'; +import { Application } from 'core/application/application.model'; +import { ClusterFilterModel } from 'core/cluster/filter/clusterFilter.model'; +import { URL_BUILDER_SERVICE, UrlBuilderService } from 'core/navigation/urlBuilder.service'; +import { SERVER_GROUP_COMPONENT } from 'core/serverGroup/serverGroup.component'; class ClusterPodController implements IComponentController { public grouping: any; @@ -13,7 +14,7 @@ class ClusterPodController implements IComponentController { public permalink: string; public showCloseButton = false; - constructor(private urlBuilderService: UrlBuilderService, private ClusterFilterModel: any) { 'ngInject'; } + constructor(private urlBuilderService: UrlBuilderService, private clusterFilterModel: ClusterFilterModel) { 'ngInject'; } public $onInit(): void { // using location.host here b/c it provides the port, $location.host() does not. @@ -31,8 +32,8 @@ class ClusterPodController implements IComponentController { } public close(): void { - delete this.ClusterFilterModel.sortFilter.clusters[`${this.parentHeading}:${this.grouping.heading}`]; - this.ClusterFilterModel.applyParamsToUrl(); + delete this.clusterFilterModel.asFilterModel.sortFilter.clusters[`${this.parentHeading}:${this.grouping.heading}`]; + this.clusterFilterModel.asFilterModel.applyParamsToUrl(); this.application.getDataSource('serverGroups').refresh(); } } diff --git a/app/scripts/modules/core/src/cluster/filter/clusterFilter.component.ts b/app/scripts/modules/core/src/cluster/filter/clusterFilter.component.ts index 87b97b53bb4..ece61160ffd 100644 --- a/app/scripts/modules/core/src/cluster/filter/clusterFilter.component.ts +++ b/app/scripts/modules/core/src/cluster/filter/clusterFilter.component.ts @@ -32,7 +32,7 @@ class ClusterFilterCtrl { constructor(public $scope: IScope, public clusterFilterService: ClusterFilterService, - public ClusterFilterModel: ClusterFilterModel, + public clusterFilterModel: ClusterFilterModel, public $rootScope: IScope, public clusterDependentFilterHelper: any, public dependentFilterService: any, @@ -41,8 +41,8 @@ class ClusterFilterCtrl { } public $onInit(): void { - const { $scope, $rootScope, ClusterFilterModel, clusterFilterService, app } = this; - const filterModel = ClusterFilterModel.asFilterModel; + const { $scope, $rootScope, clusterFilterModel, clusterFilterService, app } = this; + const filterModel = clusterFilterModel.asFilterModel; this.sortFilter = filterModel.sortFilter; this.tags = filterModel.tags; @@ -65,10 +65,10 @@ class ClusterFilterCtrl { } public updateClusterGroups(applyParamsToUrl = true): void { - const { dependentFilterService, ClusterFilterModel, clusterDependentFilterHelper, clusterFilterService, app } = this; + const { dependentFilterService, clusterFilterModel, clusterDependentFilterHelper, clusterFilterService, app } = this; const { providerType, instanceType, account, availabilityZone, region } = dependentFilterService.digestDependentFilters({ - sortFilter: ClusterFilterModel.asFilterModel.sortFilter, + sortFilter: clusterFilterModel.asFilterModel.sortFilter, dependencyOrder: ['providerType', 'account', 'region', 'availabilityZone', 'instanceType'], pool: clusterDependentFilterHelper.poolBuilder(app.serverGroups.data) }); @@ -79,7 +79,7 @@ class ClusterFilterCtrl { this.regionHeadings = region; this.instanceTypeHeadings = instanceType; if (applyParamsToUrl) { - ClusterFilterModel.asFilterModel.applyParamsToUrl(); + clusterFilterModel.asFilterModel.applyParamsToUrl(); } clusterFilterService.updateClusterGroups(app); } diff --git a/app/scripts/modules/core/src/cluster/filter/clusterFilter.model.ts b/app/scripts/modules/core/src/cluster/filter/clusterFilter.model.ts index 82851166a56..75ce82773ba 100644 --- a/app/scripts/modules/core/src/cluster/filter/clusterFilter.model.ts +++ b/app/scripts/modules/core/src/cluster/filter/clusterFilter.model.ts @@ -106,4 +106,4 @@ export class ClusterFilterModel { module(CLUSTER_FILTER_MODEL, [ require('core/filterModel/filter.model.service'), -]).service('ClusterFilterModel', ClusterFilterModel); +]).service('clusterFilterModel', ClusterFilterModel); diff --git a/app/scripts/modules/core/src/cluster/filter/clusterFilter.service.spec.ts b/app/scripts/modules/core/src/cluster/filter/clusterFilter.service.spec.ts index 6dcb7c2cc31..a0c092aa987 100644 --- a/app/scripts/modules/core/src/cluster/filter/clusterFilter.service.spec.ts +++ b/app/scripts/modules/core/src/cluster/filter/clusterFilter.service.spec.ts @@ -1,10 +1,10 @@ -import {mock} from 'angular'; +import { mock } from 'angular'; import * as _ from 'lodash'; -import {CLUSTER_FILTER_SERVICE, ClusterFilterService} from 'core/cluster/filter/clusterFilter.service'; -import {CLUSTER_SERVICE} from 'core/cluster/cluster.service'; -import {Application} from 'core/application/application.model'; -import {APPLICATION_MODEL_BUILDER, ApplicationModelBuilder} from 'core/application/applicationModel.builder'; -import {CLUSTER_FILTER_MODEL} from './clusterFilter.model'; +import { CLUSTER_FILTER_SERVICE, ClusterFilterService } from 'core/cluster/filter/clusterFilter.service'; +import { CLUSTER_SERVICE } from 'core/cluster/cluster.service'; +import { Application } from 'core/application/application.model'; +import { APPLICATION_MODEL_BUILDER, ApplicationModelBuilder } from 'core/application/applicationModel.builder'; +import { CLUSTER_FILTER_MODEL, ClusterFilterModel } from './clusterFilter.model'; // Most of this logic has been moved to filter.model.service.js, so these act more as integration tests now describe('Service: clusterFilterService', function () { @@ -12,7 +12,7 @@ describe('Service: clusterFilterService', function () { let service: ClusterFilterService; let clusterService: any; - let ClusterFilterModel: any; + let clusterFilterModel: ClusterFilterModel; let MultiselectModel: any; let applicationJSON: any; let groupedJSON: any; @@ -28,15 +28,15 @@ describe('Service: clusterFilterService', function () { require('./mockApplicationData.js') ); mock.inject( - function (clusterFilterService: ClusterFilterService, _ClusterFilterModel_: any, _MultiselectModel_: any, + function (clusterFilterService: ClusterFilterService, _clusterFilterModel_: ClusterFilterModel, _MultiselectModel_: any, _applicationJSON_: any, _groupedJSON_: any, _clusterService_: any, _applicationModelBuilder_: ApplicationModelBuilder) { service = clusterFilterService; clusterService = _clusterService_; - ClusterFilterModel = _ClusterFilterModel_; + clusterFilterModel = _clusterFilterModel_; MultiselectModel = _MultiselectModel_; applicationModelBuilder = _applicationModelBuilder_; - ClusterFilterModel.groups = []; + clusterFilterModel.asFilterModel.groups = []; applicationJSON = _applicationJSON_; groupedJSON = _groupedJSON_; @@ -57,7 +57,7 @@ describe('Service: clusterFilterService', function () { }; this.verifyTags = function(expectedTags: any[]) { - const actual: any = ClusterFilterModel.tags; + const actual: any = clusterFilterModel.asFilterModel.tags; expect(actual.length).toBe(expectedTags.length); expectedTags.forEach(function(expected: any) { expect(actual.some(function(test: any) { @@ -74,27 +74,27 @@ describe('Service: clusterFilterService', function () { it('no filter: should be transformed', function (done) { service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(groupedJSON); + expect(clusterFilterModel.asFilterModel.groups).toEqual(groupedJSON); done(); }, debounceTimeout); }); describe('filter by cluster', function () { it('should filter by cluster name as an exact match', function (done) { - ClusterFilterModel.sortFilter.filter = 'cluster:in-us-west-1-only'; + clusterFilterModel.asFilterModel.sortFilter.filter = 'cluster:in-us-west-1-only'; const expected: any = _.filter(groupedJSON, {subgroups: [{heading: 'in-us-west-1-only' }]}); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(expected); + expect(clusterFilterModel.asFilterModel.groups).toEqual(expected); done(); }, debounceTimeout); }); it('should not match on partial cluster name', function (done) { - ClusterFilterModel.sortFilter.filter = 'cluster:in-us-west-1'; + clusterFilterModel.asFilterModel.sortFilter.filter = 'cluster:in-us-west-1'; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual([]); + expect(clusterFilterModel.asFilterModel.groups).toEqual([]); done(); }, debounceTimeout); }); @@ -103,20 +103,20 @@ describe('Service: clusterFilterService', function () { describe('filter by vpc', function () { it('should filter by vpc name as an exact match', function (done) { - ClusterFilterModel.sortFilter.filter = 'vpc:main'; + clusterFilterModel.asFilterModel.sortFilter.filter = 'vpc:main'; const expected: any = _.filter(groupedJSON, {subgroups: [{heading: 'in-us-west-1-only' }]}); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(expected); + expect(clusterFilterModel.asFilterModel.groups).toEqual(expected); done(); }, debounceTimeout); }); it('should not match on partial vpc name', function (done) { - ClusterFilterModel.sortFilter.filter = 'vpc:main-old'; + clusterFilterModel.asFilterModel.sortFilter.filter = 'vpc:main-old'; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual([]); + expect(clusterFilterModel.asFilterModel.groups).toEqual([]); done(); }, debounceTimeout); }); @@ -124,29 +124,29 @@ describe('Service: clusterFilterService', function () { describe('filter by clusters', function () { it('should filter by cluster names as an exact match', function (done) { - ClusterFilterModel.sortFilter.filter = 'clusters:in-us-west-1-only'; + clusterFilterModel.asFilterModel.sortFilter.filter = 'clusters:in-us-west-1-only'; const expected: any = _.filter(groupedJSON, {subgroups: [{heading: 'in-us-west-1-only' }]}); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(expected); + expect(clusterFilterModel.asFilterModel.groups).toEqual(expected); done(); }, debounceTimeout); }); it('should not match on partial cluster name', function (done) { - ClusterFilterModel.sortFilter.filter = 'clusters:in-us-west-1'; + clusterFilterModel.asFilterModel.sortFilter.filter = 'clusters:in-us-west-1'; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual([]); + expect(clusterFilterModel.asFilterModel.groups).toEqual([]); done(); }, debounceTimeout); }); it('should perform an OR match on comma separated list, ignoring spaces', function (done) { - ClusterFilterModel.sortFilter.filter = 'clusters:in-us-west-1-only, in-eu-east-2-only'; + clusterFilterModel.asFilterModel.sortFilter.filter = 'clusters:in-us-west-1-only, in-eu-east-2-only'; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(groupedJSON); + expect(clusterFilterModel.asFilterModel.groups).toEqual(groupedJSON); done(); }, debounceTimeout); }); @@ -154,11 +154,11 @@ describe('Service: clusterFilterService', function () { describe('filtering by account type', function () { it('1 account filter: should be transformed showing only prod accounts', function (done) { - ClusterFilterModel.sortFilter.account = {prod: true}; + clusterFilterModel.asFilterModel.sortFilter.account = {prod: true}; const expectedProd: any = _.filter(groupedJSON, {heading: 'prod'}); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(expectedProd); + expect(clusterFilterModel.asFilterModel.groups).toEqual(expectedProd); this.verifyTags([ { key: 'account', label: 'account', value: 'prod' } ]); @@ -167,10 +167,10 @@ describe('Service: clusterFilterService', function () { }); it('All account filters: should show all accounts', function (done) { - ClusterFilterModel.sortFilter.account = {prod: true, test: true}; + clusterFilterModel.asFilterModel.sortFilter.account = {prod: true, test: true}; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(groupedJSON); + expect(clusterFilterModel.asFilterModel.groups).toEqual(groupedJSON); this.verifyTags([ { key: 'account', label: 'account', value: 'prod' }, { key: 'account', label: 'account', value: 'test' }, @@ -183,11 +183,11 @@ describe('Service: clusterFilterService', function () { describe('filter by region', function () { it('1 region: should filter by that region ', function (done) { - ClusterFilterModel.sortFilter.region = {'us-west-1' : true}; + clusterFilterModel.asFilterModel.sortFilter.region = {'us-west-1' : true}; const expected: any = _.filter(groupedJSON, {subgroups: [{heading: 'in-us-west-1-only' }]}); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(expected); + expect(clusterFilterModel.asFilterModel.groups).toEqual(expected); this.verifyTags([ { key: 'region', label: 'region', value: 'us-west-1' }, ]); @@ -198,7 +198,7 @@ describe('Service: clusterFilterService', function () { describe('filter by healthy status', function () { it('should filter by health if checked', function (done) { - ClusterFilterModel.sortFilter.status = {healthy : true }; + clusterFilterModel.asFilterModel.sortFilter.status = {healthy : true }; const expected: any = _.filter(groupedJSON, { subgroups: [{ @@ -212,7 +212,7 @@ describe('Service: clusterFilterService', function () { ); service.updateClusterGroups(application) setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(expected); + expect(clusterFilterModel.asFilterModel.groups).toEqual(expected); this.verifyTags([ { key: 'status', label: 'status', value: 'healthy' }, ]); @@ -221,10 +221,10 @@ describe('Service: clusterFilterService', function () { }); it('should not filter by healthy if unchecked', function (done) { - ClusterFilterModel.sortFilter.status = {healthy : false}; + clusterFilterModel.asFilterModel.sortFilter.status = {healthy : false}; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(groupedJSON); + expect(clusterFilterModel.asFilterModel.groups).toEqual(groupedJSON); this.verifyTags([]); done(); }, debounceTimeout); @@ -233,7 +233,7 @@ describe('Service: clusterFilterService', function () { describe('filter by unhealthy status', function () { it('should filter by unhealthy status if checked', function (done) { - ClusterFilterModel.sortFilter.status = {unhealthy: true}; + clusterFilterModel.asFilterModel.sortFilter.status = {unhealthy: true}; const expected: any = _.filter(groupedJSON, { subgroups: [{ @@ -248,7 +248,7 @@ describe('Service: clusterFilterService', function () { service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(expected); + expect(clusterFilterModel.asFilterModel.groups).toEqual(expected); this.verifyTags([ { key: 'status', label: 'status', value: 'unhealthy' }, ]); @@ -257,10 +257,10 @@ describe('Service: clusterFilterService', function () { }); it('should not filter by unhealthy if unchecked', function (done) { - ClusterFilterModel.sortFilter.status = {unhealthy : false}; + clusterFilterModel.asFilterModel.sortFilter.status = {unhealthy : false}; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(groupedJSON); + expect(clusterFilterModel.asFilterModel.groups).toEqual(groupedJSON); this.verifyTags([]); done(); }, debounceTimeout); @@ -270,7 +270,7 @@ describe('Service: clusterFilterService', function () { describe('filter by both healthy and unhealthy status', function () { it('should not filter by healthy if unchecked', function (done) { - ClusterFilterModel.sortFilter.status = {unhealthy : true, healthy: true}; + clusterFilterModel.asFilterModel.sortFilter.status = {unhealthy : true, healthy: true}; const expected: any = _.filter(groupedJSON, { subgroups: [{ @@ -284,7 +284,7 @@ describe('Service: clusterFilterService', function () { ); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(expected); + expect(clusterFilterModel.asFilterModel.groups).toEqual(expected); this.verifyTags([ { key: 'status', label: 'status', value: 'healthy' }, { key: 'status', label: 'status', value: 'unhealthy' }, @@ -296,7 +296,7 @@ describe('Service: clusterFilterService', function () { describe('filter by disabled status', function () { it('should filter by disabled status if checked', function (done) { - ClusterFilterModel.sortFilter.status = {Disabled: true}; + clusterFilterModel.asFilterModel.sortFilter.status = {Disabled: true}; const expected: any = _.filter(groupedJSON, { subgroups: [{ @@ -310,7 +310,7 @@ describe('Service: clusterFilterService', function () { ); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(expected); + expect(clusterFilterModel.asFilterModel.groups).toEqual(expected); this.verifyTags([ { key: 'status', label: 'status', value: 'Disabled' }, ]); @@ -319,10 +319,10 @@ describe('Service: clusterFilterService', function () { }); it('should not filter if the status is unchecked', function (done) { - ClusterFilterModel.sortFilter.status = { Disabled: false }; + clusterFilterModel.asFilterModel.sortFilter.status = { Disabled: false }; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(groupedJSON); + expect(clusterFilterModel.asFilterModel.groups).toEqual(groupedJSON); this.verifyTags([]); done(); }, debounceTimeout); @@ -335,17 +335,17 @@ describe('Service: clusterFilterService', function () { serverGroup = application.getDataSource('serverGroups').data[0]; serverGroup.instances.push(starting); - ClusterFilterModel.sortFilter.status = {Starting: true}; + clusterFilterModel.asFilterModel.sortFilter.status = {Starting: true}; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual([]); + expect(clusterFilterModel.asFilterModel.groups).toEqual([]); starting.healthState = 'Starting'; serverGroup.instanceCounts.starting = 1; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(1); this.verifyTags([ { key: 'status', label: 'status', value: 'Starting' }, ]); @@ -361,10 +361,10 @@ describe('Service: clusterFilterService', function () { serverGroup = application.getDataSource('serverGroups').data[0]; serverGroup.instances.push(starting); - ClusterFilterModel.sortFilter.status = {OutOfService: true}; + clusterFilterModel.asFilterModel.sortFilter.status = {OutOfService: true}; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual([]); + expect(clusterFilterModel.asFilterModel.groups).toEqual([]); done(); }, debounceTimeout); }); @@ -376,10 +376,10 @@ describe('Service: clusterFilterService', function () { serverGroup = application.getDataSource('serverGroups').data[0]; serverGroup.instances.push(starting); - ClusterFilterModel.sortFilter.status = {Unknown: true}; + clusterFilterModel.asFilterModel.sortFilter.status = {Unknown: true}; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual([]); + expect(clusterFilterModel.asFilterModel.groups).toEqual([]); done(); }, debounceTimeout); }); @@ -387,7 +387,7 @@ describe('Service: clusterFilterService', function () { describe('filtered by provider type', function () { it('should filter by aws if checked', function (done) { - ClusterFilterModel.sortFilter.providerType = {aws: true}; + clusterFilterModel.asFilterModel.sortFilter.providerType = {aws: true}; const expected: any = _.filter(groupedJSON, { subgroups: [{ @@ -401,7 +401,7 @@ describe('Service: clusterFilterService', function () { ); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(expected); + expect(clusterFilterModel.asFilterModel.groups).toEqual(expected); this.verifyTags([ { key: 'providerType', label: 'provider', value: 'aws' }, ]); @@ -410,20 +410,20 @@ describe('Service: clusterFilterService', function () { }); it('should not filter if no provider type is selected', function (done) { - ClusterFilterModel.sortFilter.providerType = undefined; + clusterFilterModel.asFilterModel.sortFilter.providerType = undefined; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(groupedJSON); + expect(clusterFilterModel.asFilterModel.groups).toEqual(groupedJSON); this.verifyTags([]); done(); }, debounceTimeout); }); it('should not filter if all provider are selected', function (done) { - ClusterFilterModel.sortFilter.providerType = {aws: true, gce: true}; + clusterFilterModel.asFilterModel.sortFilter.providerType = {aws: true, gce: true}; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(groupedJSON); + expect(clusterFilterModel.asFilterModel.groups).toEqual(groupedJSON); this.verifyTags([ { key: 'providerType', label: 'provider', value: 'aws' }, { key: 'providerType', label: 'provider', value: 'gce' }, @@ -435,7 +435,7 @@ describe('Service: clusterFilterService', function () { describe('filtered by instance type', function () { it('should filter by m3.large if checked', function (done) { - ClusterFilterModel.sortFilter.instanceType = {'m3.large': true}; + clusterFilterModel.asFilterModel.sortFilter.instanceType = {'m3.large': true}; const expected: any = _.filter(groupedJSON, { subgroups: [{ @@ -449,7 +449,7 @@ describe('Service: clusterFilterService', function () { ); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(expected); + expect(clusterFilterModel.asFilterModel.groups).toEqual(expected); this.verifyTags([ { key: 'instanceType', label: 'instance type', value: 'm3.large' }, ]); @@ -458,20 +458,20 @@ describe('Service: clusterFilterService', function () { }); it('should not filter if no instance type selected', function (done) { - ClusterFilterModel.sortFilter.instanceType = undefined; + clusterFilterModel.asFilterModel.sortFilter.instanceType = undefined; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(groupedJSON); + expect(clusterFilterModel.asFilterModel.groups).toEqual(groupedJSON); this.verifyTags([]); done(); }, debounceTimeout); }); it('should not filter if the instance type is unchecked', function (done) { - ClusterFilterModel.sortFilter.instanceType = {'m3.large' : false}; + clusterFilterModel.asFilterModel.sortFilter.instanceType = {'m3.large' : false}; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual(groupedJSON); + expect(clusterFilterModel.asFilterModel.groups).toEqual(groupedJSON); this.verifyTags([]); done(); }, debounceTimeout); @@ -481,10 +481,10 @@ describe('Service: clusterFilterService', function () { describe('filter by instance counts', function () { it('should filter by min instances', function (done) { - ClusterFilterModel.sortFilter.minInstances = 1; + clusterFilterModel.asFilterModel.sortFilter.minInstances = 1; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual([groupedJSON[1]]); + expect(clusterFilterModel.asFilterModel.groups).toEqual([groupedJSON[1]]); this.verifyTags([ { key: 'minInstances', label: 'instance count (min)', value: 1 } ]); @@ -493,10 +493,10 @@ describe('Service: clusterFilterService', function () { }); it('should filter by max instances', function(done) { - ClusterFilterModel.sortFilter.maxInstances = 0; + clusterFilterModel.asFilterModel.sortFilter.maxInstances = 0; service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups).toEqual([groupedJSON[0]]); + expect(clusterFilterModel.asFilterModel.groups).toEqual([groupedJSON[0]]); this.verifyTags([ { key: 'maxInstances', label: 'instance count (max)', value: 0 } ]); @@ -508,12 +508,12 @@ describe('Service: clusterFilterService', function () { describe('multiInstance filtering', function () { beforeEach(function() { this.navigationSynced = false; - ClusterFilterModel.sortFilter.multiselect = true; + clusterFilterModel.asFilterModel.sortFilter.multiselect = true; spyOn(MultiselectModel, 'syncNavigation').and.callFake(() => this.navigationSynced = true); }); it('should remove all instanceIds if server group is no longer visible, and add back when visible again', function (done) { - ClusterFilterModel.sortFilter.listInstances = true; + clusterFilterModel.asFilterModel.sortFilter.listInstances = true; const serverGroup = application.getDataSource('serverGroups').data[0], multiselectGroup = MultiselectModel.getOrCreateInstanceGroup(serverGroup); @@ -521,12 +521,12 @@ describe('Service: clusterFilterService', function () { MultiselectModel.toggleSelectAll(serverGroup, ['i-1234']); expect(multiselectGroup.instanceIds).toEqual(['i-1234']); - ClusterFilterModel.sortFilter.region['us-east-3'] = true; + clusterFilterModel.asFilterModel.sortFilter.region['us-east-3'] = true; service.updateClusterGroups(application); setTimeout(() => { expect(multiselectGroup.instanceIds).toEqual([]); - ClusterFilterModel.sortFilter.region['us-east-3'] = false; + clusterFilterModel.asFilterModel.sortFilter.region['us-east-3'] = false; service.updateClusterGroups(application); setTimeout(() => { @@ -537,7 +537,7 @@ describe('Service: clusterFilterService', function () { }); it('should remove instances that are no longer visible', function (done) { - ClusterFilterModel.sortFilter.listInstances = true; + clusterFilterModel.asFilterModel.sortFilter.listInstances = true; const serverGroup = application.getDataSource('serverGroups').data[0]; MultiselectModel.toggleInstance(serverGroup, 'i-1234'); @@ -561,7 +561,7 @@ describe('Service: clusterFilterService', function () { }); it('should add all instances when selectAll is selected and new instances appear in server group', function (done) { - ClusterFilterModel.sortFilter.listInstances = true; + clusterFilterModel.asFilterModel.sortFilter.listInstances = true; const serverGroup = application.getDataSource('serverGroups').data[0]; MultiselectModel.getOrCreateInstanceGroup(serverGroup).selectAll = true; @@ -581,7 +581,7 @@ describe('Service: clusterFilterService', function () { }); it('should remove all instance groups when listInstances is false', function (done) { - ClusterFilterModel.sortFilter.listInstances = false; + clusterFilterModel.asFilterModel.sortFilter.listInstances = false; const serverGroup = application.getDataSource('serverGroups').data[0]; MultiselectModel.toggleInstance(serverGroup, 'i-1234'); @@ -598,19 +598,13 @@ describe('Service: clusterFilterService', function () { }); describe('clear all filters', function () { - - beforeEach(function () { - ClusterFilterModel.sortFilters = undefined; - }); - it('should clear set providerType filter', function () { - ClusterFilterModel.sortFilter.providerType = {aws: true}; - expect(ClusterFilterModel.sortFilter.providerType).toBeDefined(); + clusterFilterModel.asFilterModel.sortFilter.providerType = {aws: true}; + expect(clusterFilterModel.asFilterModel.sortFilter.providerType).toBeDefined(); service.clearFilters(); - expect(ClusterFilterModel.sortFilter.providerType).toBeUndefined(); + expect(clusterFilterModel.asFilterModel.sortFilter.providerType).toBeUndefined(); this.verifyTags([]); }); - }); describe('group diffing', function() { @@ -619,7 +613,7 @@ describe('Service: clusterFilterService', function () { this.clusterB = { account: 'prod', category: 'serverGroup', name: 'cluster-b' }; this.serverGroup001 = { cluster: 'cluster-a', name: 'cluster-a-v001', account: 'prod', region: 'us-east-1', stringVal: 'original', category: 'serverGroup', instances: [] }; this.serverGroup000 = { cluster: 'cluster-a', name: 'cluster-a-v000', account: 'prod', region: 'us-east-1', stringVal: 'should be deleted', category: 'serverGroup', instances: [] }; - ClusterFilterModel.groups = [ + clusterFilterModel.asFilterModel.groups = [ { heading: 'prod', key: 'prod', @@ -661,14 +655,14 @@ describe('Service: clusterFilterService', function () { service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(2); - expect(ClusterFilterModel.groups[1].heading).toBe('test'); - expect(ClusterFilterModel.groups[1].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[1].subgroups[0].heading).toBe('cluster-a'); - expect(ClusterFilterModel.groups[1].subgroups[0].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[1].subgroups[0].subgroups[0].heading).toBe('us-east-1'); - expect(ClusterFilterModel.groups[1].subgroups[0].subgroups[0].serverGroups.length).toBe(1); - expect(ClusterFilterModel.groups[1].subgroups[0].subgroups[0].serverGroups[0].name).toBe('cluster-a-v003'); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(2); + expect(clusterFilterModel.asFilterModel.groups[1].heading).toBe('test'); + expect(clusterFilterModel.asFilterModel.groups[1].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[1].subgroups[0].heading).toBe('cluster-a'); + expect(clusterFilterModel.asFilterModel.groups[1].subgroups[0].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[1].subgroups[0].subgroups[0].heading).toBe('us-east-1'); + expect(clusterFilterModel.asFilterModel.groups[1].subgroups[0].subgroups[0].serverGroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[1].subgroups[0].subgroups[0].serverGroups[0].name).toBe('cluster-a-v003'); done(); }, debounceTimeout); }); @@ -687,13 +681,13 @@ describe('Service: clusterFilterService', function () { }); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups.length).toBe(2); - expect(ClusterFilterModel.groups[0].subgroups[1].heading).toBe('cluster-b'); - expect(ClusterFilterModel.groups[0].subgroups[1].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[1].subgroups[0].heading).toBe('us-east-1'); - expect(ClusterFilterModel.groups[0].subgroups[1].subgroups[0].serverGroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[1].subgroups[0].serverGroups[0].name).toBe('cluster-a-v003'); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups.length).toBe(2); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[1].heading).toBe('cluster-b'); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[1].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[1].subgroups[0].heading).toBe('us-east-1'); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[1].subgroups[0].serverGroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[1].subgroups[0].serverGroups[0].name).toBe('cluster-a-v003'); done(); }, debounceTimeout); }); @@ -709,12 +703,12 @@ describe('Service: clusterFilterService', function () { application.clusters = clusterService.createServerGroupClusters(application.getDataSource('serverGroups').data); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups.length).toBe(2); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[1].heading).toBe('us-west-1'); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[1].serverGroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[1].serverGroups[0].name).toBe('cluster-a-v003'); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups.length).toBe(2); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[1].heading).toBe('us-west-1'); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[1].serverGroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[1].serverGroups[0].name).toBe('cluster-a-v003'); done(); }, debounceTimeout); }); @@ -730,11 +724,11 @@ describe('Service: clusterFilterService', function () { application.clusters = clusterService.createServerGroupClusters(application.getDataSource('serverGroups').data); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups.length).toBe(3); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[2].name).toBe('cluster-a-v003'); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups.length).toBe(3); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[2].name).toBe('cluster-a-v003'); done(); }, debounceTimeout); }); @@ -751,13 +745,13 @@ describe('Service: clusterFilterService', function () { service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(2); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(2); application.getDataSource('serverGroups').data.splice(0, 2); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(1); - expect(ClusterFilterModel.groups[0].heading).toBe('test'); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].heading).toBe('test'); done(); }, debounceTimeout); }, debounceTimeout); @@ -775,16 +769,16 @@ describe('Service: clusterFilterService', function () { service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups.length).toBe(2); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups.length).toBe(2); application.getDataSource('serverGroups').data.splice(0, 2); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[0].heading).toBe('cluster-b'); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].heading).toBe('cluster-b'); done(); }, debounceTimeout); }, debounceTimeout); @@ -802,18 +796,18 @@ describe('Service: clusterFilterService', function () { service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups.length).toBe(2); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups.length).toBe(2); application.getDataSource('serverGroups').data.splice(0, 2); service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].heading).toBe('us-west-1'); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].heading).toBe('us-west-1'); done(); }, debounceTimeout); }, debounceTimeout); @@ -829,11 +823,11 @@ describe('Service: clusterFilterService', function () { service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups.length).toBe(1); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0].name).toBe('cluster-a-v001'); + expect(clusterFilterModel.asFilterModel.groups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups.length).toBe(1); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0].name).toBe('cluster-a-v001'); done(); }, debounceTimeout); }); @@ -849,8 +843,8 @@ describe('Service: clusterFilterService', function () { service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0]).toBe(this.serverGroup000); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[1]).toBe(this.serverGroup001); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0]).toBe(this.serverGroup000); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[1]).toBe(this.serverGroup001); done(); }, debounceTimeout); }); @@ -866,9 +860,9 @@ describe('Service: clusterFilterService', function () { service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0]).not.toBe(this.serverGroup000); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0]).toBe(application.getDataSource('serverGroups').data[0]); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[1]).toBe(this.serverGroup001); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0]).not.toBe(this.serverGroup000); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0]).toBe(application.getDataSource('serverGroups').data[0]); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[1]).toBe(this.serverGroup001); done(); }, debounceTimeout); }); @@ -889,9 +883,9 @@ describe('Service: clusterFilterService', function () { service.updateClusterGroups(application); setTimeout(() => { - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0]).toBe(this.serverGroup001); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0].runningTasks).toBe(runningTasks); - expect(ClusterFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0].runningExecutions).toBe(executions); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0]).toBe(this.serverGroup001); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0].runningTasks).toBe(runningTasks); + expect(clusterFilterModel.asFilterModel.groups[0].subgroups[0].subgroups[0].serverGroups[0].runningExecutions).toBe(executions); done(); }, debounceTimeout); }); diff --git a/app/scripts/modules/core/src/cluster/filter/clusterFilter.service.ts b/app/scripts/modules/core/src/cluster/filter/clusterFilter.service.ts index 48265c1c40b..237ac57215a 100644 --- a/app/scripts/modules/core/src/cluster/filter/clusterFilter.service.ts +++ b/app/scripts/modules/core/src/cluster/filter/clusterFilter.service.ts @@ -48,7 +48,7 @@ export class ClusterFilterService { private isFilterable: (sortFilter: any) => boolean = this.filterModelService.isFilterable; - public constructor(private ClusterFilterModel: ClusterFilterModel, + public constructor(private clusterFilterModel: ClusterFilterModel, private MultiselectModel: any, private $log: ILogService, private $stateParams: StateParams, @@ -115,31 +115,31 @@ export class ClusterFilterService { }); this.sortGroupsByHeading(groups); - this.ClusterFilterModel.asFilterModel.addTags(); + this.clusterFilterModel.asFilterModel.addTags(); this.lastApplication = application; this.addHealthFlags(); this.groupsUpdatedStream.next(groups); } public clearFilters(): void { - this.ClusterFilterModel.asFilterModel.clearFilters(); - this.ClusterFilterModel.asFilterModel.applyParamsToUrl(); + this.clusterFilterModel.asFilterModel.clearFilters(); + this.clusterFilterModel.asFilterModel.applyParamsToUrl(); } public shouldShowInstance(instance: IInstance): boolean { - if (this.isFilterable(this.ClusterFilterModel.asFilterModel.sortFilter.availabilityZone)) { - const checkedAvailabilityZones: string[] = this.filterModelService.getCheckValues(this.ClusterFilterModel.asFilterModel.sortFilter.availabilityZone); + if (this.isFilterable(this.clusterFilterModel.asFilterModel.sortFilter.availabilityZone)) { + const checkedAvailabilityZones: string[] = this.filterModelService.getCheckValues(this.clusterFilterModel.asFilterModel.sortFilter.availabilityZone); if (!checkedAvailabilityZones.includes(instance.availabilityZone)) { return false; } } - if (this.isFilterable(this.ClusterFilterModel.asFilterModel.sortFilter.status)) { - const allCheckedValues: string[] = this.filterModelService.getCheckValues(this.ClusterFilterModel.asFilterModel.sortFilter.status); + if (this.isFilterable(this.clusterFilterModel.asFilterModel.sortFilter.status)) { + const allCheckedValues: string[] = this.filterModelService.getCheckValues(this.clusterFilterModel.asFilterModel.sortFilter.status); const checkedStatus = allCheckedValues.filter(s => s !== 'Disabled'); if (!checkedStatus.length) { return true; } - if (this.ClusterFilterModel.asFilterModel.sortFilter.status.Disabled) { + if (this.clusterFilterModel.asFilterModel.sortFilter.status.Disabled) { // filtering should be performed on the server group; always show instances return true; } @@ -150,33 +150,33 @@ export class ClusterFilterService { public overrideFiltersForUrl(result: any): void { if (result.href.includes('/clusters')) { - this.ClusterFilterModel.asFilterModel.clearFilters(); - this.ClusterFilterModel.asFilterModel.sortFilter.filter = result.serverGroup ? result.serverGroup : + this.clusterFilterModel.asFilterModel.clearFilters(); + this.clusterFilterModel.asFilterModel.sortFilter.filter = result.serverGroup ? result.serverGroup : result.cluster ? 'cluster:' + result.cluster : ''; if (result.account) { const acct: any = {}; acct[result.account] = true; - this.ClusterFilterModel.asFilterModel.sortFilter.account = acct; + this.clusterFilterModel.asFilterModel.sortFilter.account = acct; } if (result.region) { const reg: any = {}; reg[result.region] = true; - this.ClusterFilterModel.asFilterModel.sortFilter.region = reg; + this.clusterFilterModel.asFilterModel.sortFilter.region = reg; } if (result.stack) { const stack: any = {}; stack[result.stack] = true; - this.ClusterFilterModel.asFilterModel.sortFilter.stack = stack; + this.clusterFilterModel.asFilterModel.sortFilter.stack = stack; } if (result.detail) { const detail: any = {}; detail[result.detail] = true; - this.ClusterFilterModel.asFilterModel.sortFilter.detail = detail; + this.clusterFilterModel.asFilterModel.sortFilter.detail = detail; } if (result.category) { const category: any = {}; category[result.category] = true; - this.ClusterFilterModel.asFilterModel.sortFilter.category = category; + this.clusterFilterModel.asFilterModel.sortFilter.category = category; } if (this.$stateParams.application === result.application) { this.updateClusterGroups(); @@ -187,11 +187,11 @@ export class ClusterFilterService { private filterServerGroupsForDisplay(serverGroups: IServerGroup[]): IServerGroup[] { const filtered: IServerGroup[] = serverGroups.filter(g => this.textFilter(g)) .filter(g => this.instanceCountFilter(g)) - .filter(g => this.filterModelService.checkAccountFilters(this.ClusterFilterModel)(g)) - .filter(g => this.filterModelService.checkRegionFilters(this.ClusterFilterModel)(g)) - .filter(g => this.filterModelService.checkStackFilters(this.ClusterFilterModel)(g)) - .filter(g => this.filterModelService.checkStatusFilters(this.ClusterFilterModel)(g)) - .filter(g => this.filterModelService.checkProviderFilters(this.ClusterFilterModel)(g)) + .filter(g => this.filterModelService.checkAccountFilters(this.clusterFilterModel)(g)) + .filter(g => this.filterModelService.checkRegionFilters(this.clusterFilterModel)(g)) + .filter(g => this.filterModelService.checkStackFilters(this.clusterFilterModel)(g)) + .filter(g => this.filterModelService.checkStatusFilters(this.clusterFilterModel)(g)) + .filter(g => this.filterModelService.checkProviderFilters(this.clusterFilterModel)(g)) .filter(g => this.instanceTypeFilters(g)) .filter(g => this.instanceFilters(g)); @@ -204,7 +204,7 @@ export class ClusterFilterService { private updateMultiselectInstanceGroups(serverGroups: IServerGroup[]): void { // removes instance groups, selection of instances that are no longer visible; // adds new instance ids if selectAll is enabled for an instance group - if (this.ClusterFilterModel.asFilterModel.sortFilter.listInstances && this.ClusterFilterModel.asFilterModel.sortFilter.multiselect) { + if (this.clusterFilterModel.asFilterModel.sortFilter.listInstances && this.clusterFilterModel.asFilterModel.sortFilter.multiselect) { let instancesSelected = 0; this.MultiselectModel.instanceGroups.forEach((instanceGroup: any) => { const match = serverGroups.find((serverGroup) => { @@ -238,7 +238,7 @@ export class ClusterFilterService { } private updateMultiselectServerGroups(serverGroups: IServerGroup[]): void { - if (this.ClusterFilterModel.asFilterModel.sortFilter.multiselect) { + if (this.clusterFilterModel.asFilterModel.sortFilter.multiselect) { if (this.MultiselectModel.serverGroups.length) { const remainingKeys = serverGroups.map(s => this.MultiselectModel.makeServerGroupKey(s)); const toRemove: number[] = []; @@ -256,8 +256,8 @@ export class ClusterFilterService { } private instanceTypeFilters(serverGroup: IServerGroup): boolean { - if (this.isFilterable(this.ClusterFilterModel.asFilterModel.sortFilter.instanceType)) { - const checkedInstanceTypes: string[] = this.filterModelService.getCheckValues(this.ClusterFilterModel.asFilterModel.sortFilter.instanceType); + if (this.isFilterable(this.clusterFilterModel.asFilterModel.sortFilter.instanceType)) { + const checkedInstanceTypes: string[] = this.filterModelService.getCheckValues(this.clusterFilterModel.asFilterModel.sortFilter.instanceType); return checkedInstanceTypes.includes(serverGroup.instanceType); } else { return true; @@ -269,25 +269,25 @@ export class ClusterFilterService { } private shouldFilterInstances(): boolean { - return this.isFilterable(this.ClusterFilterModel.asFilterModel.sortFilter.availabilityZone) || - (this.isFilterable(this.ClusterFilterModel.asFilterModel.sortFilter.status) && - !this.ClusterFilterModel.asFilterModel.sortFilter.status.hasOwnProperty('Disabled')); + return this.isFilterable(this.clusterFilterModel.asFilterModel.sortFilter.availabilityZone) || + (this.isFilterable(this.clusterFilterModel.asFilterModel.sortFilter.status) && + !this.clusterFilterModel.asFilterModel.sortFilter.status.hasOwnProperty('Disabled')); } private instanceCountFilter(serverGroup: IServerGroup): boolean { let shouldInclude = true; - if (this.ClusterFilterModel.asFilterModel.sortFilter.minInstances && !isNaN(this.ClusterFilterModel.asFilterModel.sortFilter.minInstances)) { - shouldInclude = serverGroup.instances.length >= this.ClusterFilterModel.asFilterModel.sortFilter.minInstances; + if (this.clusterFilterModel.asFilterModel.sortFilter.minInstances && !isNaN(this.clusterFilterModel.asFilterModel.sortFilter.minInstances)) { + shouldInclude = serverGroup.instances.length >= this.clusterFilterModel.asFilterModel.sortFilter.minInstances; } - if (shouldInclude && this.ClusterFilterModel.asFilterModel.sortFilter.maxInstances !== null - && !isNaN(this.ClusterFilterModel.asFilterModel.sortFilter.maxInstances)) { - shouldInclude = serverGroup.instances.length <= this.ClusterFilterModel.asFilterModel.sortFilter.maxInstances; + if (shouldInclude && this.clusterFilterModel.asFilterModel.sortFilter.maxInstances !== null + && !isNaN(this.clusterFilterModel.asFilterModel.sortFilter.maxInstances)) { + shouldInclude = serverGroup.instances.length <= this.clusterFilterModel.asFilterModel.sortFilter.maxInstances; } return shouldInclude; } private textFilter(serverGroup: IServerGroup): boolean { - const filter: string = this.ClusterFilterModel.asFilterModel.sortFilter.filter.toLowerCase(); + const filter: string = this.clusterFilterModel.asFilterModel.sortFilter.filter.toLowerCase(); if (!filter) { return true; } @@ -361,13 +361,13 @@ export class ClusterFilterService { } private sortGroupsByHeading(groups: IClusterGroup[]): void { - this.diffSubgroups(this.ClusterFilterModel.asFilterModel.groups, groups); + this.diffSubgroups(this.clusterFilterModel.asFilterModel.groups, groups); // sort groups in place so Angular doesn't try to update the world - this.ClusterFilterModel.asFilterModel.groups.sort((a: IClusterGroup, b: IClusterGroup) => a.heading.localeCompare(b.heading)); + this.clusterFilterModel.asFilterModel.groups.sort((a: IClusterGroup, b: IClusterGroup) => a.heading.localeCompare(b.heading)); } private addHealthFlags(): void { - this.ClusterFilterModel.asFilterModel.groups.forEach((group: IClusterGroup) => { + this.clusterFilterModel.asFilterModel.groups.forEach((group: IClusterGroup) => { group.subgroups.forEach((subgroup: IClusterSubgroup) => { subgroup.hasDiscovery = subgroup.subgroups.some(g => this.hasDiscovery(g)); subgroup.hasLoadBalancers = subgroup.subgroups.some(g => this.hasLoadBalancers(g)); diff --git a/app/scripts/modules/core/src/cluster/filter/multiselect.model.js b/app/scripts/modules/core/src/cluster/filter/multiselect.model.js index 96d211a56cd..30ed4a98568 100644 --- a/app/scripts/modules/core/src/cluster/filter/multiselect.model.js +++ b/app/scripts/modules/core/src/cluster/filter/multiselect.model.js @@ -10,7 +10,7 @@ module.exports = angular require('@uirouter/angularjs').default, CLUSTER_FILTER_MODEL, ]) - .factory('MultiselectModel', function ($state, ClusterFilterModel) { + .factory('MultiselectModel', function ($state, clusterFilterModel) { this.instanceGroups = []; this.instancesStream = new Subject(); @@ -19,13 +19,13 @@ module.exports = angular this.serverGroupsStream = new Subject(); this.syncNavigation = () => { - if ($state.includes('**.multipleInstances') && !ClusterFilterModel.sortFilter.multiselect) { + if ($state.includes('**.multipleInstances') && !clusterFilterModel.sortFilter.multiselect) { this.deselectAllInstances(); $state.go('^'); return; } - if ($state.includes('**.multipleServerGroups') && !ClusterFilterModel.sortFilter.multiselect) { + if ($state.includes('**.multipleServerGroups') && !clusterFilterModel.sortFilter.multiselect) { this.clearAllServerGroups(); $state.go('^'); return; @@ -122,7 +122,7 @@ module.exports = angular }; this.toggleServerGroup = (serverGroup) => { - if (!ClusterFilterModel.sortFilter.multiselect) { + if (!clusterFilterModel.sortFilter.multiselect) { let params = { provider: serverGroup.type, accountId: serverGroup.account, @@ -159,7 +159,7 @@ module.exports = angular }; this.toggleInstance = (serverGroup, instanceId) => { - if (!ClusterFilterModel.sortFilter.multiselect) { + if (!clusterFilterModel.sortFilter.multiselect) { let params = {provider: serverGroup.type, instanceId: instanceId}; if (isClusterChildState()) { if ($state.includes('**.instanceDetails', params)) { diff --git a/app/scripts/modules/core/src/cluster/filter/multiselect.model.spec.ts b/app/scripts/modules/core/src/cluster/filter/multiselect.model.spec.ts index b880ae8e448..a9a2efc58d8 100644 --- a/app/scripts/modules/core/src/cluster/filter/multiselect.model.spec.ts +++ b/app/scripts/modules/core/src/cluster/filter/multiselect.model.spec.ts @@ -5,16 +5,16 @@ import { ClusterFilterModel } from './clusterFilter.model'; describe('Multiselect Model', () => { - let MultiselectModel: any, ClusterFilterModel: ClusterFilterModel, $state: StateService; + let MultiselectModel: any, clusterFilterModel: ClusterFilterModel, $state: StateService; beforeEach(mock.module( require('./multiselect.model') )); beforeEach( - mock.inject((_MultiselectModel_: any, _$state_: StateService, _ClusterFilterModel_: ClusterFilterModel) => { + mock.inject((_MultiselectModel_: any, _$state_: StateService, _clusterFilterModel_: ClusterFilterModel) => { MultiselectModel = _MultiselectModel_; - ClusterFilterModel = _ClusterFilterModel_; + clusterFilterModel = _clusterFilterModel_; $state = _$state_; }) ); @@ -22,7 +22,7 @@ describe('Multiselect Model', () => { describe('navigation management', () => { let result: any, currentStates: any[], currentParams: any; beforeEach(() => { - ClusterFilterModel.asFilterModel.sortFilter.multiselect = true; + clusterFilterModel.asFilterModel.sortFilter.multiselect = true; result = null; currentStates = []; currentParams = {}; @@ -129,14 +129,14 @@ describe('Multiselect Model', () => { }); it('navigates to details child view when multiselect is not enabled and not in clusters child view', () => { - ClusterFilterModel.asFilterModel.sortFilter.multiselect = false; + clusterFilterModel.asFilterModel.sortFilter.multiselect = false; currentStates.push('.clusters'); MultiselectModel.toggleServerGroup(serverGroup); expect(result).toBe('.serverGroup'); }); it('navigates to details sibling view when multiselect is not enabled and in clusters child view', () => { - ClusterFilterModel.asFilterModel.sortFilter.multiselect = false; + clusterFilterModel.asFilterModel.sortFilter.multiselect = false; currentStates = ['**.clusters.*']; MultiselectModel.toggleServerGroup(serverGroup); expect(result).toBe('^.serverGroup'); diff --git a/app/scripts/modules/core/src/cluster/onDemand/onDemandClusterPicker.component.ts b/app/scripts/modules/core/src/cluster/onDemand/onDemandClusterPicker.component.ts index bf00049a305..fc090061f78 100644 --- a/app/scripts/modules/core/src/cluster/onDemand/onDemandClusterPicker.component.ts +++ b/app/scripts/modules/core/src/cluster/onDemand/onDemandClusterPicker.component.ts @@ -1,7 +1,8 @@ -import {IComponentController, IComponentOptions, IScope, module} from 'angular'; -import {Application} from 'core/application/application.model'; -import {IClusterSummary} from 'core/domain/ICluster'; -import {CLUSTER_FILTER_MODEL} from '../filter/clusterFilter.model'; +import { IComponentController, IComponentOptions, IScope, module } from 'angular'; + +import { Application } from 'core/application/application.model'; +import { IClusterSummary } from 'core/domain/ICluster'; +import { CLUSTER_FILTER_MODEL, ClusterFilterModel } from '../filter/clusterFilter.model'; import './onDemandClusterPicker.component.less'; @@ -12,7 +13,7 @@ class OnDemandClusterPickerController implements IComponentController { public totalClusterCount: number; public optionTemplate: string = require('./onDemandOptionTemplate.html'); - constructor(private $scope: IScope, private ClusterFilterModel: any) { 'ngInject'; } + constructor(private $scope: IScope, private clusterFilterModel: ClusterFilterModel) { 'ngInject'; } public $onInit(): void { this.setAvailableClusters(); @@ -21,14 +22,14 @@ class OnDemandClusterPickerController implements IComponentController { private setAvailableClusters(): void { this.totalClusterCount = this.application.getDataSource('serverGroups').clusters.length; - const selectedClusters: string[] = Object.keys(this.ClusterFilterModel.sortFilter.clusters); + const selectedClusters: string[] = Object.keys(this.clusterFilterModel.asFilterModel.sortFilter.clusters); this.availableClusters = this.application.getDataSource('serverGroups').clusters .filter((cluster: IClusterSummary) => !selectedClusters.includes(this.makeKey(cluster))); } public selectCluster(cluster: IClusterSummary): void { this.lastSelection = undefined; - this.ClusterFilterModel.sortFilter.clusters[this.makeKey(cluster)] = true; + this.clusterFilterModel.asFilterModel.sortFilter.clusters[this.makeKey(cluster)] = true; this.application.getDataSource('serverGroups').refresh(); } diff --git a/app/scripts/modules/core/src/delivery/executions/executions.controller.js b/app/scripts/modules/core/src/delivery/executions/executions.controller.js index f3caa172246..a5d37c3771d 100644 --- a/app/scripts/modules/core/src/delivery/executions/executions.controller.js +++ b/app/scripts/modules/core/src/delivery/executions/executions.controller.js @@ -21,7 +21,7 @@ module.exports = angular.module('spinnaker.core.delivery.executions.controller', .controller('ExecutionsCtrl', function($scope, $state, $q, $uibModal, $stateParams, pipelineConfigService, scrollToService, $timeout, executionService, executionFilterModel, executionFilterService, - InsightFilterStateModel) { + insightFilterStateModel) { this.$onInit = () => { const { application } = this; @@ -90,7 +90,7 @@ module.exports = angular.module('spinnaker.core.delivery.executions.controller', }); }; - this.InsightFilterStateModel = InsightFilterStateModel; + this.insightFilterStateModel = insightFilterStateModel; this.executionFilterModel = executionFilterModel; this.filter = executionFilterModel.sortFilter; diff --git a/app/scripts/modules/core/src/delivery/executions/executions.html b/app/scripts/modules/core/src/delivery/executions/executions.html index ea96dc66759..a97f9b0aec5 100644 --- a/app/scripts/modules/core/src/delivery/executions/executions.html +++ b/app/scripts/modules/core/src/delivery/executions/executions.html @@ -1,23 +1,23 @@