From fb276d5f8a65b8ae8f1a393cf88c1d743d1a7d0f Mon Sep 17 00:00:00 2001 From: Justin Reynolds Date: Mon, 17 Jul 2017 11:36:03 -0700 Subject: [PATCH] refactor(core): Update tslint to 5.5 (#3925) --- .../src/cluster/allClusters.controller.js | 20 +- .../core/src/cluster/cluster.service.spec.ts | 27 +- .../core/src/cluster/cluster.service.ts | 14 +- .../core/src/cluster/clusterPod.component.ts | 15 +- .../cluster/filter/clusterFilter.component.ts | 12 +- .../src/cluster/filter/clusterFilter.model.ts | 2 +- .../filter/clusterFilter.service.spec.ts | 274 +++++++++--------- .../cluster/filter/clusterFilter.service.ts | 74 ++--- .../src/cluster/filter/multiselect.model.js | 10 +- .../cluster/filter/multiselect.model.spec.ts | 12 +- .../onDemandClusterPicker.component.ts | 15 +- .../executions/executions.controller.js | 4 +- .../src/delivery/executions/executions.html | 10 +- .../filter/executionFilter.service.ts | 2 +- .../src/insight/insightFilter.component.html | 6 +- .../src/insight/insightFilter.component.ts | 2 +- .../src/insight/insightFilterState.model.ts | 2 +- .../src/insight/insightLayout.component.html | 4 +- .../src/insight/insightLayout.component.ts | 2 +- .../src/instance/instanceList.directive.js | 4 +- .../instance/instanceListBody.directive.js | 6 +- .../core/src/presentation/LabelComponent.tsx | 4 +- .../securityGroup/AllSecurityGroupsCtrl.js | 10 +- .../filter/securityGroup.filter.component.ts | 18 +- .../filter/securityGroup.filter.service.js | 24 +- .../securityGroup.filter.service.spec.js | 56 ++-- .../filter/securityGroupFilter.model.ts | 2 +- .../securityGroup/securityGroup.directive.js | 4 +- .../multipleServerGroups.controller.spec.js | 4 +- .../src/serverGroup/serverGroup.component.ts | 4 +- .../serverGroupWriter.service.spec.ts | 4 +- app/scripts/modules/core/src/utils/debug.ts | 4 +- package.json | 2 +- tslint.json | 2 +- yarn.lock | 44 +-- 35 files changed, 350 insertions(+), 349 deletions(-) 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 @@
+ ng-class="$ctrl.insightFilterStateModel.filtersExpanded ? 'filters-expanded' : 'filters-collapsed'"> -
+

Pipelines

diff --git a/app/scripts/modules/core/src/delivery/filter/executionFilter.service.ts b/app/scripts/modules/core/src/delivery/filter/executionFilter.service.ts index c31ff6d4836..f7ddc1ca53e 100644 --- a/app/scripts/modules/core/src/delivery/filter/executionFilter.service.ts +++ b/app/scripts/modules/core/src/delivery/filter/executionFilter.service.ts @@ -158,7 +158,7 @@ export class ExecutionFilterService { if (this.executionFilterModel.asFilterModel.sortFilter.groupBy === 'name') { const executionGroups = groupBy(executions, 'name'); forOwn(executionGroups, (groupExecutions, key) => { - const matchId = (config: IPipeline) => config.id === groupExecutions[0].pipelineConfigId; + const matchId = (pipelineConfig: IPipeline) => pipelineConfig.id === groupExecutions[0].pipelineConfigId; const config = application.pipelineConfigs.data.find(matchId) || get(application, 'strategyConfigs.data', []).find(matchId); groupExecutions.sort((a, b) => this.executionSorter(a, b)); groups.push({ diff --git a/app/scripts/modules/core/src/insight/insightFilter.component.html b/app/scripts/modules/core/src/insight/insightFilter.component.html index 555175e7e45..f9bed89da1d 100644 --- a/app/scripts/modules/core/src/insight/insightFilter.component.html +++ b/app/scripts/modules/core/src/insight/insightFilter.component.html @@ -1,7 +1,7 @@

@@ -9,8 +9,8 @@

+ ng-click="$ctrl.insightFilterStateModel.pinFilters(!$ctrl.insightFilterStateModel.filtersPinned)" + ng-show="$ctrl.insightFilterStateModel.filtersExpanded"> diff --git a/app/scripts/modules/core/src/insight/insightFilter.component.ts b/app/scripts/modules/core/src/insight/insightFilter.component.ts index 1dc3d08140e..5a6c0ba665a 100644 --- a/app/scripts/modules/core/src/insight/insightFilter.component.ts +++ b/app/scripts/modules/core/src/insight/insightFilter.component.ts @@ -2,7 +2,7 @@ import {InsightFilterStateModel} from './insightFilterState.model'; import {INSIGHT_NGMODULE} from './insight.module'; export class InsightFilterCtrl { - constructor(public InsightFilterStateModel: InsightFilterStateModel) { 'ngInject'; } + constructor(public insightFilterStateModel: InsightFilterStateModel) { 'ngInject'; } } INSIGHT_NGMODULE.component('insightFilter', { diff --git a/app/scripts/modules/core/src/insight/insightFilterState.model.ts b/app/scripts/modules/core/src/insight/insightFilterState.model.ts index 8c028a6df2c..83b7b69b8b3 100644 --- a/app/scripts/modules/core/src/insight/insightFilterState.model.ts +++ b/app/scripts/modules/core/src/insight/insightFilterState.model.ts @@ -51,4 +51,4 @@ export const INSIGHT_FILTER_STATE_MODEL = 'spinnaker.core.insight.insightFilterS module(INSIGHT_FILTER_STATE_MODEL, [ COLLAPSIBLE_SECTION_STATE_CACHE ]) - .service('InsightFilterStateModel', InsightFilterStateModel); + .service('insightFilterStateModel', InsightFilterStateModel); diff --git a/app/scripts/modules/core/src/insight/insightLayout.component.html b/app/scripts/modules/core/src/insight/insightLayout.component.html index 74a237519a0..b88d9911a34 100644 --- a/app/scripts/modules/core/src/insight/insightLayout.component.html +++ b/app/scripts/modules/core/src/insight/insightLayout.component.html @@ -1,6 +1,6 @@
- + ng-class="$ctrl.insightFilterStateModel.filtersExpanded ? 'filters-expanded' : 'filters-collapsed'"> +
diff --git a/app/scripts/modules/core/src/insight/insightLayout.component.ts b/app/scripts/modules/core/src/insight/insightLayout.component.ts index 0616c1cd606..a9402213583 100644 --- a/app/scripts/modules/core/src/insight/insightLayout.component.ts +++ b/app/scripts/modules/core/src/insight/insightLayout.component.ts @@ -7,7 +7,7 @@ class InsightLayoutCtrl { public app: Application; public ready = false; - constructor(public InsightFilterStateModel: InsightFilterStateModel) { 'ngInject'; } + constructor(public insightFilterStateModel: InsightFilterStateModel) { 'ngInject'; } public $onInit() { this.app.ready().then(() => this.ready = true); diff --git a/app/scripts/modules/core/src/instance/instanceList.directive.js b/app/scripts/modules/core/src/instance/instanceList.directive.js index c2ba831cb8c..299c6045223 100644 --- a/app/scripts/modules/core/src/instance/instanceList.directive.js +++ b/app/scripts/modules/core/src/instance/instanceList.directive.js @@ -8,7 +8,7 @@ module.exports = angular.module('spinnaker.core.instance.instanceList.directive' require('../cluster/filter/multiselect.model'), require('./instanceListBody.directive'), ]) - .directive('instanceList', function (ClusterFilterModel, MultiselectModel) { + .directive('instanceList', function (clusterFilterModel, MultiselectModel) { return { restrict: 'E', templateUrl: require('./instanceList.directive.html'), @@ -36,7 +36,7 @@ module.exports = angular.module('spinnaker.core.instance.instanceList.directive' MultiselectModel.toggleSelectAll(serverGroup, scope.instances.map((instance) => instance.id)); }; - scope.applyParamsToUrl = ClusterFilterModel.applyParamsToUrl; + scope.applyParamsToUrl = clusterFilterModel.applyParamsToUrl; scope.showProviderHealth = !scope.hasDiscovery && !scope.hasLoadBalancers; scope.columnWidth = { diff --git a/app/scripts/modules/core/src/instance/instanceListBody.directive.js b/app/scripts/modules/core/src/instance/instanceListBody.directive.js index a52b0f34aff..c525a7c7879 100644 --- a/app/scripts/modules/core/src/instance/instanceListBody.directive.js +++ b/app/scripts/modules/core/src/instance/instanceListBody.directive.js @@ -13,7 +13,7 @@ module.exports = angular.module('spinnaker.core.instance.instanceListBody.direct CLUSTER_FILTER_MODEL, ]) .directive('instanceListBody', function ($timeout, $filter, $rootScope, $state, clusterFilterService, - ClusterFilterModel, MultiselectModel) { + clusterFilterModel, MultiselectModel) { return { restrict: 'C', scope: { @@ -36,7 +36,7 @@ module.exports = angular.module('spinnaker.core.instance.instanceListBody.direct }; function toggleSelection(instance, $targetRow) { - if ($targetRow && !ClusterFilterModel.sortFilter.multiselect) { + if ($targetRow && !clusterFilterModel.sortFilter.multiselect) { activeInstance = instance; $targetRow.addClass('active'); } @@ -48,7 +48,7 @@ module.exports = angular.module('spinnaker.core.instance.instanceListBody.direct } function buildInstanceCheckboxCell(instance) { - if (!ClusterFilterModel.sortFilter.multiselect) { + if (!clusterFilterModel.sortFilter.multiselect) { return ''; } let isChecked = MultiselectModel.instanceIsSelected(scope.serverGroup, instance.id); diff --git a/app/scripts/modules/core/src/presentation/LabelComponent.tsx b/app/scripts/modules/core/src/presentation/LabelComponent.tsx index 034050f7a22..a18bc09b2d5 100644 --- a/app/scripts/modules/core/src/presentation/LabelComponent.tsx +++ b/app/scripts/modules/core/src/presentation/LabelComponent.tsx @@ -8,7 +8,7 @@ export interface ILabelComponentProps { export class LabelComponent extends React.Component { public render() { - const LabelComponent = this.props.stage.labelComponent; - return (
); + const SubLabelComponent = this.props.stage.labelComponent; + return (
); } } diff --git a/app/scripts/modules/core/src/securityGroup/AllSecurityGroupsCtrl.js b/app/scripts/modules/core/src/securityGroup/AllSecurityGroupsCtrl.js index bc681550818..794c639aa4c 100644 --- a/app/scripts/modules/core/src/securityGroup/AllSecurityGroupsCtrl.js +++ b/app/scripts/modules/core/src/securityGroup/AllSecurityGroupsCtrl.js @@ -18,18 +18,18 @@ module.exports = angular.module('spinnaker.core.securityGroup.all.controller', [ ]) .controller('AllSecurityGroupsCtrl', function($scope, app, $uibModal, $timeout, providerSelectionService, cloudProviderRegistry, - SecurityGroupFilterModel, securityGroupFilterService) { + securityGroupFilterModel, securityGroupFilterService) { this.$onInit = () => { const groupsUpdatedSubscription = securityGroupFilterService.groupsUpdatedStream.subscribe(() => groupsUpdated()); - SecurityGroupFilterModel.activate(); + securityGroupFilterModel.activate(); this.initialized = false; $scope.application = app; - $scope.sortFilter = SecurityGroupFilterModel.sortFilter; + $scope.sortFilter = securityGroupFilterModel.sortFilter; handleRefresh(); @@ -58,8 +58,8 @@ module.exports = angular.module('spinnaker.core.securityGroup.all.controller', [ let groupsUpdated = () => { $scope.$applyAsync(() => { - $scope.groups = SecurityGroupFilterModel.groups; - $scope.tags = SecurityGroupFilterModel.tags; + $scope.groups = securityGroupFilterModel.groups; + $scope.tags = securityGroupFilterModel.tags; }); }; diff --git a/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.component.ts b/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.component.ts index 51de173b46c..f6e950f71d6 100644 --- a/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.component.ts +++ b/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.component.ts @@ -27,7 +27,7 @@ export class SecurityGroupFilterCtrl { private locationChangeUnsubscribe: () => void; constructor(private securityGroupFilterService: any, - private SecurityGroupFilterModel: SecurityGroupFilterModel, + private securityGroupFilterModel: SecurityGroupFilterModel, private dependentFilterService: any, private securityGroupDependentFilterHelper: any, private $scope: IScope, @@ -37,19 +37,19 @@ export class SecurityGroupFilterCtrl { } public $onInit(): void { - const { $scope, $rootScope, app, SecurityGroupFilterModel, securityGroupFilterService } = this; + const { $scope, $rootScope, app, securityGroupFilterModel, securityGroupFilterService } = this; - this.sortFilter = SecurityGroupFilterModel.asFilterModel.sortFilter; - this.tags = SecurityGroupFilterModel.asFilterModel.tags; + this.sortFilter = securityGroupFilterModel.asFilterModel.sortFilter; + this.tags = securityGroupFilterModel.asFilterModel.tags; this.groupsUpdatedSubscription = securityGroupFilterService.groupsUpdatedStream - .subscribe(() => this.tags = SecurityGroupFilterModel.asFilterModel.tags); + .subscribe(() => this.tags = securityGroupFilterModel.asFilterModel.tags); this.initialize(); app.securityGroups.onRefresh($scope, () => this.initialize()); this.locationChangeUnsubscribe = $rootScope.$on('$locationChangeSuccess', () => { - SecurityGroupFilterModel.asFilterModel.activate(); + securityGroupFilterModel.asFilterModel.activate(); securityGroupFilterService.updateSecurityGroups(app); }); @@ -63,14 +63,14 @@ export class SecurityGroupFilterCtrl { private updateSecurityGroups(applyParamsToUrl = true): void { const { dependentFilterService, - SecurityGroupFilterModel, + securityGroupFilterModel, securityGroupFilterService, securityGroupDependentFilterHelper, app, } = this; const { account, region } = dependentFilterService.digestDependentFilters({ - sortFilter: SecurityGroupFilterModel.asFilterModel.sortFilter, + sortFilter: securityGroupFilterModel.asFilterModel.sortFilter, dependencyOrder: ['providerType', 'account', 'region'], pool: securityGroupDependentFilterHelper.poolBuilder(app.securityGroups.data) }); @@ -79,7 +79,7 @@ export class SecurityGroupFilterCtrl { this.regionHeadings = region; if (applyParamsToUrl) { - SecurityGroupFilterModel.asFilterModel.applyParamsToUrl(); + securityGroupFilterModel.asFilterModel.applyParamsToUrl(); } securityGroupFilterService.updateSecurityGroups(app); }; diff --git a/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.service.js b/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.service.js index d5084e0a914..f375524637f 100644 --- a/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.service.js +++ b/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.service.js @@ -11,7 +11,7 @@ module.exports = angular SECURITY_GROUP_FILTER_MODEL, require('core/filterModel/filter.model.service'), ]) - .factory('securityGroupFilterService', function (SecurityGroupFilterModel, filterModelService) { + .factory('securityGroupFilterService', function (securityGroupFilterModel, filterModelService) { var lastApplication = null; @@ -31,7 +31,7 @@ module.exports = angular } function checkSearchTextFilter(securityGroup) { - var filter = SecurityGroupFilterModel.sortFilter.filter; + var filter = securityGroupFilterModel.sortFilter.filter; if (!filter) { return true; } @@ -50,10 +50,10 @@ module.exports = angular function filterSecurityGroupsForDisplay(securityGroups) { return _.chain(securityGroups) .filter(checkSearchTextFilter) - .filter(filterModelService.checkAccountFilters(SecurityGroupFilterModel)) - .filter(filterModelService.checkRegionFilters(SecurityGroupFilterModel)) - .filter(filterModelService.checkStackFilters(SecurityGroupFilterModel)) - .filter(filterModelService.checkProviderFilters(SecurityGroupFilterModel)) + .filter(filterModelService.checkAccountFilters(securityGroupFilterModel)) + .filter(filterModelService.checkRegionFilters(securityGroupFilterModel)) + .filter(filterModelService.checkStackFilters(securityGroupFilterModel)) + .filter(filterModelService.checkProviderFilters(securityGroupFilterModel)) .value(); } @@ -72,7 +72,7 @@ module.exports = angular var groups = []; - var filter = SecurityGroupFilterModel.sortFilter.filter.toLowerCase(); + var filter = securityGroupFilterModel.sortFilter.filter.toLowerCase(); var securityGroups = filterSecurityGroupsForDisplay(application.securityGroups.data, filter); var grouped = _.groupBy(securityGroups, 'account'); @@ -103,7 +103,7 @@ module.exports = angular }); sortGroupsByHeading(groups); - SecurityGroupFilterModel.addTags(); + securityGroupFilterModel.addTags(); lastApplication = application; groupsUpdatedStream.next(groups); return groups; @@ -137,10 +137,10 @@ module.exports = angular } function sortGroupsByHeading(groups) { - diffSubgroups(SecurityGroupFilterModel.groups, groups); + diffSubgroups(securityGroupFilterModel.groups, groups); // sort groups in place so Angular doesn't try to update the world - SecurityGroupFilterModel.groups.sort(function(a, b) { + securityGroupFilterModel.groups.sort(function(a, b) { if (a.heading < b.heading) { return -1; } @@ -152,8 +152,8 @@ module.exports = angular } function clearFilters() { - SecurityGroupFilterModel.clearFilters(); - SecurityGroupFilterModel.applyParamsToUrl(); + securityGroupFilterModel.clearFilters(); + securityGroupFilterModel.applyParamsToUrl(); } return { diff --git a/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.service.spec.js b/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.service.spec.js index 0a422b06417..a005ea6878b 100644 --- a/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.service.spec.js +++ b/app/scripts/modules/core/src/securityGroup/filter/securityGroup.filter.service.spec.js @@ -6,7 +6,7 @@ import _ from 'lodash'; describe('Service: securityGroupFilterService', function () { var service; - var SecurityGroupFilterModel; + var securityGroupFilterModel; var app; var resultJson; var $timeout; @@ -17,9 +17,9 @@ describe('Service: securityGroupFilterService', function () { require('./securityGroup.filter.service') ); window.inject( - function (securityGroupFilterService, _SecurityGroupFilterModel_, _$timeout_) { + function (securityGroupFilterService, _securityGroupFilterModel_, _$timeout_) { service = securityGroupFilterService; - SecurityGroupFilterModel = _SecurityGroupFilterModel_; + securityGroupFilterModel = _securityGroupFilterModel_; $timeout = _$timeout_; } ); @@ -38,7 +38,7 @@ describe('Service: securityGroupFilterService', function () { { heading: 'us-west-1 (main)', vpcName: 'main', securityGroup: app.securityGroups.data[1], }, { heading: 'us-east-1', vpcName: '', securityGroup: app.securityGroups.data[2], } ]; - SecurityGroupFilterModel.clearFilters(); + securityGroupFilterModel.clearFilters(); }); describe('Updating the security group group', function () { @@ -54,7 +54,7 @@ describe('Service: securityGroupFilterService', function () { ]; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual(expected); + expect(securityGroupFilterModel.groups).toEqual(expected); }); describe('filter by search', function () { @@ -63,7 +63,7 @@ describe('Service: securityGroupFilterService', function () { app.securityGroups.data.forEach((group) => { expect(group.searchField).toBeUndefined(); }); - SecurityGroupFilterModel.sortFilter.filter = 'main'; + securityGroupFilterModel.sortFilter.filter = 'main'; service.updateSecurityGroups(app); $timeout.flush(); app.securityGroups.data.forEach((group) => { @@ -74,10 +74,10 @@ describe('Service: securityGroupFilterService', function () { describe('filter by vpc', function () { it('should filter by vpc name as an exact match', function () { - SecurityGroupFilterModel.sortFilter.filter = 'vpc:main'; + securityGroupFilterModel.sortFilter.filter = 'vpc:main'; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([ + expect(securityGroupFilterModel.groups).toEqual([ { heading: 'test', subgroups: [ { heading: 'sg-1', subgroups: [ resultJson[1] ]} ]} @@ -85,19 +85,19 @@ describe('Service: securityGroupFilterService', function () { }); it('should not match on partial vpc name', function () { - SecurityGroupFilterModel.sortFilter.filter = 'vpc:main-old'; + securityGroupFilterModel.sortFilter.filter = 'vpc:main-old'; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([]); + expect(securityGroupFilterModel.groups).toEqual([]); }); }); describe('filtering by account type', function () { it('1 account filter: should be transformed showing only prod accounts', function () { - SecurityGroupFilterModel.sortFilter.account = {prod: true}; + securityGroupFilterModel.sortFilter.account = {prod: true}; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([ + expect(securityGroupFilterModel.groups).toEqual([ { heading: 'prod', subgroups: [ { heading: 'sg-2', subgroups: [ resultJson[2] ]} ]} @@ -105,10 +105,10 @@ describe('Service: securityGroupFilterService', function () { }); it('All account filters: should show all accounts', function () { - SecurityGroupFilterModel.sortFilter.account = {prod: true, test: true}; + securityGroupFilterModel.sortFilter.account = {prod: true, test: true}; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([ + expect(securityGroupFilterModel.groups).toEqual([ { heading: 'prod', subgroups: [ { heading: 'sg-2', subgroups: [ resultJson[2] ]} ]}, @@ -122,11 +122,11 @@ describe('Service: securityGroupFilterService', function () { describe('filter by region', function () { it('1 region: should filter by that region', function () { - SecurityGroupFilterModel.sortFilter.region = {'us-east-1' : true}; + securityGroupFilterModel.sortFilter.region = {'us-east-1' : true}; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([ + expect(securityGroupFilterModel.groups).toEqual([ { heading: 'prod', subgroups: [ { heading: 'sg-2', subgroups: [ resultJson[2] ]} ]}, @@ -137,11 +137,11 @@ describe('Service: securityGroupFilterService', function () { }); it('All regions: should show all load balancers', function () { - SecurityGroupFilterModel.sortFilter.region = {'us-east-1' : true, 'us-west-1': true}; + securityGroupFilterModel.sortFilter.region = {'us-east-1' : true, 'us-west-1': true}; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([ + expect(securityGroupFilterModel.groups).toEqual([ { heading: 'prod', subgroups: [ { heading: 'sg-2', subgroups: [ resultJson[2] ]} ]}, @@ -159,10 +159,10 @@ describe('Service: securityGroupFilterService', function () { app.securityGroups.data[2].provider = 'aws'; }); it('should filter by aws if checked', function () { - SecurityGroupFilterModel.sortFilter.providerType = {aws : true}; + securityGroupFilterModel.sortFilter.providerType = {aws : true}; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([ + expect(securityGroupFilterModel.groups).toEqual([ { heading: 'prod', subgroups: [ { heading: 'sg-2', subgroups: [ resultJson[2] ]} ]}, @@ -173,10 +173,10 @@ describe('Service: securityGroupFilterService', function () { }); it('should not filter if no provider type is selected', function () { - SecurityGroupFilterModel.sortFilter.providerType = undefined; + securityGroupFilterModel.sortFilter.providerType = undefined; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([ + expect(securityGroupFilterModel.groups).toEqual([ { heading: 'prod', subgroups: [ { heading: 'sg-2', subgroups: [ resultJson[2] ]} ]}, @@ -187,10 +187,10 @@ describe('Service: securityGroupFilterService', function () { }); it('should not filter if all provider are selected', function () { - SecurityGroupFilterModel.sortFilter.providerType = {aws: true, gce: true}; + securityGroupFilterModel.sortFilter.providerType = {aws: true, gce: true}; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([ + expect(securityGroupFilterModel.groups).toEqual([ { heading: 'prod', subgroups: [ { heading: 'sg-2', subgroups: [ resultJson[2] ]} ]}, @@ -205,7 +205,7 @@ describe('Service: securityGroupFilterService', function () { beforeEach(function() { app.securityGroups.data[0].stringVal = 'original'; app.securityGroups.data[1].stringVal = 'should be deleted'; - SecurityGroupFilterModel.groups = [ + securityGroupFilterModel.groups = [ { heading: 'prod', subgroups: [ { heading: 'sg-2', subgroups: [resultJson[2]] } ]}, @@ -226,7 +226,7 @@ describe('Service: securityGroupFilterService', function () { ]}; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([ + expect(securityGroupFilterModel.groups).toEqual([ newGroup, { heading: 'prod', subgroups: [ { heading: 'sg-2', subgroups: [resultJson[2]] } @@ -244,7 +244,7 @@ describe('Service: securityGroupFilterService', function () { var newSubGroup = { heading: 'sg-3', subgroups: [{heading: 'eu-west-1', vpcName: '', securityGroup: app.securityGroups.data[3], }]}; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([ + expect(securityGroupFilterModel.groups).toEqual([ { heading: 'prod', subgroups: [ { heading: 'sg-2', subgroups: [resultJson[2]] }, newSubGroup @@ -262,7 +262,7 @@ describe('Service: securityGroupFilterService', function () { var newSubsubGroup = { heading: 'eu-west-1', vpcName: '', securityGroup: app.securityGroups.data[3], }; service.updateSecurityGroups(app); $timeout.flush(); - expect(SecurityGroupFilterModel.groups).toEqual([ + expect(securityGroupFilterModel.groups).toEqual([ { heading: 'prod', subgroups: [ {heading: 'sg-2', subgroups: [resultJson[2]] } diff --git a/app/scripts/modules/core/src/securityGroup/filter/securityGroupFilter.model.ts b/app/scripts/modules/core/src/securityGroup/filter/securityGroupFilter.model.ts index 54c21ede9a9..5f12e6922ee 100644 --- a/app/scripts/modules/core/src/securityGroup/filter/securityGroupFilter.model.ts +++ b/app/scripts/modules/core/src/securityGroup/filter/securityGroupFilter.model.ts @@ -98,4 +98,4 @@ export class SecurityGroupFilterModel { module(SECURITY_GROUP_FILTER_MODEL, [ require('core/filterModel/filter.model.service'), -]).service('SecurityGroupFilterModel', SecurityGroupFilterModel); +]).service('securityGroupFilterModel', SecurityGroupFilterModel); diff --git a/app/scripts/modules/core/src/securityGroup/securityGroup.directive.js b/app/scripts/modules/core/src/securityGroup/securityGroup.directive.js index 8759b43d665..698c8ed9942 100644 --- a/app/scripts/modules/core/src/securityGroup/securityGroup.directive.js +++ b/app/scripts/modules/core/src/securityGroup/securityGroup.directive.js @@ -3,7 +3,7 @@ const angular = require('angular'); module.exports = angular.module('spinnaker.core.securityGroup.directive', []) - .directive('securityGroup', function ($rootScope, $timeout, SecurityGroupFilterModel) { + .directive('securityGroup', function ($rootScope, $timeout, securityGroupFilterModel) { return { restrict: 'E', replace: true, @@ -15,7 +15,7 @@ module.exports = angular.module('spinnaker.core.securityGroup.directive', []) heading: '=', }, link: function (scope) { - scope.sortFilter = SecurityGroupFilterModel.sortFilter; + scope.sortFilter = securityGroupFilterModel.sortFilter; scope.$state = $rootScope.$state; const securityGroup = scope.securityGroup; diff --git a/app/scripts/modules/core/src/serverGroup/details/multipleServerGroups.controller.spec.js b/app/scripts/modules/core/src/serverGroup/details/multipleServerGroups.controller.spec.js index 10b4b39b8fd..a4334562c27 100644 --- a/app/scripts/modules/core/src/serverGroup/details/multipleServerGroups.controller.spec.js +++ b/app/scripts/modules/core/src/serverGroup/details/multipleServerGroups.controller.spec.js @@ -16,10 +16,10 @@ describe('Controller: MultipleServerGroups', function () { ); beforeEach( - window.inject(function ($rootScope, $controller, _$q_, _MultiselectModel_, ClusterFilterModel, applicationModelBuilder) { + window.inject(function ($rootScope, $controller, _$q_, _MultiselectModel_, clusterFilterModel, applicationModelBuilder) { scope = $rootScope.$new(); MultiselectModel = _MultiselectModel_; - ClusterFilterModel.sortFilter.multiselect = true; + clusterFilterModel.sortFilter.multiselect = true; this.createController = function (serverGroups) { let application = applicationModelBuilder.createApplication('app', {key: 'serverGroups', lazy: true}); diff --git a/app/scripts/modules/core/src/serverGroup/serverGroup.component.ts b/app/scripts/modules/core/src/serverGroup/serverGroup.component.ts index 975d8dcf5b7..4db8090a3b2 100644 --- a/app/scripts/modules/core/src/serverGroup/serverGroup.component.ts +++ b/app/scripts/modules/core/src/serverGroup/serverGroup.component.ts @@ -43,7 +43,7 @@ export class ServerGroupController implements IComponentController { private $filter: IFilterService, private clusterFilterService: any, private MultiselectModel: any, - private ClusterFilterModel: ClusterFilterModel, + private clusterFilterModel: ClusterFilterModel, private serverGroupTransformer: any) { 'ngInject'; } @@ -51,7 +51,7 @@ export class ServerGroupController implements IComponentController { public $onInit(): void { // TODO: Remove $scope. Keeping it here so we can use $watch for now. // Eventually, there should be events fired when filters change. - this.sortFilter = this.ClusterFilterModel.asFilterModel.sortFilter; + this.sortFilter = this.clusterFilterModel.asFilterModel.sortFilter; this.$scope.$watch(() => this.sortFilter, () => this.setViewModel(), true); this.setViewModel(); diff --git a/app/scripts/modules/core/src/serverGroup/serverGroupWriter.service.spec.ts b/app/scripts/modules/core/src/serverGroup/serverGroupWriter.service.spec.ts index cb5c9f1f140..5cc3be69491 100644 --- a/app/scripts/modules/core/src/serverGroup/serverGroupWriter.service.spec.ts +++ b/app/scripts/modules/core/src/serverGroup/serverGroupWriter.service.spec.ts @@ -58,7 +58,7 @@ describe('serverGroupWriter', function () { describe('clone server group submit', function () { - function postTask(command: IServerGroupCommand): ITaskCommand { + function postTask(serverGroupCommand: IServerGroupCommand): ITaskCommand { let submitted: ITaskCommand = {}; $httpBackend.expectPOST(`${API.baseUrl}/applications/app/tasks`, (body: string) => { submitted = JSON.parse(body); @@ -73,7 +73,7 @@ describe('serverGroupWriter', function () { $httpBackend.expectGET(API.baseUrl + '/tasks/1').respond({}); - serverGroupWriter.cloneServerGroup(command, application); + serverGroupWriter.cloneServerGroup(serverGroupCommand, application); $httpBackend.flush(); return submitted; diff --git a/app/scripts/modules/core/src/utils/debug.ts b/app/scripts/modules/core/src/utils/debug.ts index 480c27756db..dbdff9c391f 100644 --- a/app/scripts/modules/core/src/utils/debug.ts +++ b/app/scripts/modules/core/src/utils/debug.ts @@ -22,7 +22,7 @@ const getMethodName = (target: any, propertyKey: string) => { export const DebugTiming = (label?: string) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => { const fn = descriptor.value; label = padStart(label ? label : getMethodName(target, propertyKey), 50); - descriptor.value = function DebugTiming() { + descriptor.value = function() { const start = now(); const result = fn.apply(this, arguments); const delta = now() - start; @@ -47,7 +47,7 @@ export const DebugTimingCumulative = (label?: string, logInterval = 5000) => (ta label = padStart(label ? label : getMethodName(target, propertyKey), 50); let cumulativeTime = 0; setInterval(() => log(`${label} ${padStart('' + count, 10)} calls in ${cumulativeTime} ms`), logInterval); - descriptor.value = function DebugTimingCumulative() { + descriptor.value = function() { count++; const start = now(); const result = fn.apply(this, arguments); diff --git a/package.json b/package.json index c9ed6ada84a..90d5d38a301 100644 --- a/package.json +++ b/package.json @@ -144,7 +144,7 @@ "react-test-renderer": "^15.5.4", "rimraf": "^2.5.4", "style-loader": "^0.17.0", - "tslint": "^5.2.0", + "tslint": "^5.5.0", "tslint-loader": "^3.4.3", "tslint-react": "^3.0.0", "typescript": "^2.2.2", diff --git a/tslint.json b/tslint.json index 344b3a300d8..0d77e0bda03 100644 --- a/tslint.json +++ b/tslint.json @@ -44,7 +44,7 @@ "no-switch-case-fall-through": true, "no-trailing-whitespace": true, "no-unused-expression": [true, "allow-fast-null-checks"], - "no-use-before-declare": true, + "no-use-before-declare": false, "no-var-keyword": true, "object-literal-sort-keys": false, "one-line": [ diff --git a/yarn.lock b/yarn.lock index 6c822a3b613..03a5e80dfef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1580,6 +1580,10 @@ commander@2.9.x, commander@^2.5.0: dependencies: graceful-readlink ">= 1.0.0" +commander@^2.9.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" + commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" @@ -2727,12 +2731,6 @@ find-up@^1.0.0: path-exists "^2.0.0" pinkie-promise "^2.0.0" -findup-sync@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.3.0.tgz#37930aa5d816b777c03445e1966cc6790a4c0b16" - dependencies: - glob "~5.0.0" - flat-cache@^1.2.1: version "1.2.2" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.2.tgz#fa86714e72c21db88601761ecf2f555d1abc6b96" @@ -2886,7 +2884,7 @@ glob-parent@^2.0.0: dependencies: is-glob "^2.0.0" -glob@^5.0.15, glob@~5.0.0: +glob@^5.0.15: version "5.0.15" resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" dependencies: @@ -3961,7 +3959,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" -"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2: +"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: @@ -4310,7 +4308,7 @@ opn@4.0.2: object-assign "^4.0.1" pinkie-promise "^2.0.0" -optimist@^0.6.1, optimist@~0.6.0, optimist@~0.6.1: +optimist@^0.6.1, optimist@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" dependencies: @@ -5899,10 +5897,14 @@ tryor@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/tryor/-/tryor-0.1.2.tgz#8145e4ca7caff40acde3ccf946e8b8bb75b4172b" -tslib@^1.6.0, tslib@^1.6.1: +tslib@^1.6.1: version "1.7.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.0.tgz#6e8366695f72961252b35167b0dd4fbeeafba491" +tslib@^1.7.1: + version "1.7.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.1.tgz#bc8004164691923a79fe8378bbeb3da2017538ec" + tslint-loader@^3.4.3: version "3.5.3" resolved "https://registry.yarnpkg.com/tslint-loader/-/tslint-loader-3.5.3.tgz#343f74122d94f356b689457d3f59f64a69ab606f" @@ -5917,24 +5919,26 @@ tslint-react@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/tslint-react/-/tslint-react-3.0.0.tgz#00c48ab7f22e91533b62bdef2c162b49447af00a" -tslint@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.2.0.tgz#16a2addf20cb748385f544e9a0edab086bc34114" +tslint@^5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.5.0.tgz#10e8dab3e3061fa61e9442e8cee3982acf20a6aa" dependencies: babel-code-frame "^6.22.0" colors "^1.1.2" + commander "^2.9.0" diff "^3.2.0" - findup-sync "~0.3.0" glob "^7.1.1" - optimist "~0.6.0" + minimatch "^3.0.4" resolve "^1.3.2" semver "^5.3.0" - tslib "^1.6.0" - tsutils "^1.8.0" + tslib "^1.7.1" + tsutils "^2.5.1" -tsutils@^1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.8.0.tgz#bf8118ed8e80cd5c9fc7d75728c7963d44ed2f52" +tsutils@^2.5.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.7.1.tgz#411a0e9466525a2b2869260a55620d7292155e24" + dependencies: + tslib "^1.7.1" tty-browserify@0.0.0: version "0.0.0"