Skip to content

Commit

Permalink
refactor(core): Update tslint to 5.5 (spinnaker#3925)
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Reynolds authored Jul 17, 2017
1 parent bac1b30 commit fb276d5
Show file tree
Hide file tree
Showing 35 changed files with 350 additions and 349 deletions.
20 changes: 10 additions & 10 deletions app/scripts/modules/core/src/cluster/allClusters.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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();
};
Expand Down
27 changes: 14 additions & 13 deletions app/scripts/modules/core/src/cluster/cluster.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
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(
mock.module(CLUSTER_SERVICE, APPLICATION_MODEL_BUILDER)
);

let clusterService: ClusterService;
let ClusterFilterModel: any;
let clusterFilterModel: ClusterFilterModel;
let $http: IHttpBackendService;
let API: Api;
let application: Application;
Expand All @@ -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',
Expand Down Expand Up @@ -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);
});
});

Expand Down
14 changes: 7 additions & 7 deletions app/scripts/modules/core/src/cluster/cluster.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand All @@ -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();
Expand All @@ -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[] = [];
Expand All @@ -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();
}
}
}
Expand Down
15 changes: 8 additions & 7 deletions app/scripts/modules/core/src/cluster/clusterPod.component.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.
Expand All @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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)
});
Expand All @@ -79,7 +79,7 @@ class ClusterFilterCtrl {
this.regionHeadings = region;
this.instanceTypeHeadings = instanceType;
if (applyParamsToUrl) {
ClusterFilterModel.asFilterModel.applyParamsToUrl();
clusterFilterModel.asFilterModel.applyParamsToUrl();
}
clusterFilterService.updateClusterGroups(app);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ export class ClusterFilterModel {

module(CLUSTER_FILTER_MODEL, [
require('core/filterModel/filter.model.service'),
]).service('ClusterFilterModel', ClusterFilterModel);
]).service('clusterFilterModel', ClusterFilterModel);
Loading

0 comments on commit fb276d5

Please sign in to comment.