Skip to content

Commit

Permalink
chore(angularjs): Explicitly annotate directive controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Feb 26, 2019
1 parent a987786 commit d828a53
Show file tree
Hide file tree
Showing 23 changed files with 456 additions and 394 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@ import { InfrastructureCaches } from '@spinnaker/core';

module.exports = angular
.module('spinnaker.azure.serverGroup.configure.loadBalancer.directive', [])
.directive('azureServerGroupLoadBalancersSelector', function(azureServerGroupConfigurationService) {
return {
restrict: 'E',
scope: {
command: '=',
},
templateUrl: require('./serverGroupLoadBalancersSelector.directive.html'),
link: function(scope) {
scope.getLoadBalancerRefreshTime = function() {
return InfrastructureCaches.get('loadBalancers').getStats().ageMax;
};
.directive('azureServerGroupLoadBalancersSelector', [
'azureServerGroupConfigurationService',
function(azureServerGroupConfigurationService) {
return {
restrict: 'E',
scope: {
command: '=',
},
templateUrl: require('./serverGroupLoadBalancersSelector.directive.html'),
link: function(scope) {
scope.getLoadBalancerRefreshTime = function() {
return InfrastructureCaches.get('loadBalancers').getStats().ageMax;
};

scope.refreshLoadBalancers = function() {
scope.refreshing = true;
azureServerGroupConfigurationService.refreshLoadBalancers(scope.command).then(function() {
scope.refreshing = false;
});
};
},
};
});
scope.refreshLoadBalancers = function() {
scope.refreshing = true;
azureServerGroupConfigurationService.refreshLoadBalancers(scope.command).then(function() {
scope.refreshing = false;
});
};
},
};
},
]);
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,29 @@ import { FirewallLabels, InfrastructureCaches } from '@spinnaker/core';

module.exports = angular
.module('spinnaker.azure.serverGroup.configure.securityGroupSelector.directive', [])
.directive('azureServerGroupSecurityGroupsSelector', function(azureServerGroupConfigurationService) {
return {
restrict: 'E',
scope: {
command: '=',
},
templateUrl: require('./serverGroupSecurityGroupsSelector.directive.html'),
link: function(scope) {
scope.firewallLabel = FirewallLabels.get('firewall');
.directive('azureServerGroupSecurityGroupsSelector', [
'azureServerGroupConfigurationService',
function(azureServerGroupConfigurationService) {
return {
restrict: 'E',
scope: {
command: '=',
},
templateUrl: require('./serverGroupSecurityGroupsSelector.directive.html'),
link: function(scope) {
scope.firewallLabel = FirewallLabels.get('firewall');

scope.getSecurityGroupRefreshTime = function() {
return InfrastructureCaches.get('securityGroups').getStats().ageMax;
};
scope.getSecurityGroupRefreshTime = function() {
return InfrastructureCaches.get('securityGroups').getStats().ageMax;
};

scope.refreshSecurityGroups = function() {
scope.refreshing = true;
azureServerGroupConfigurationService.refreshSecurityGroups(scope.command).then(function() {
scope.refreshing = false;
});
};
},
};
});
scope.refreshSecurityGroups = function() {
scope.refreshing = true;
azureServerGroupConfigurationService.refreshSecurityGroups(scope.command).then(function() {
scope.refreshing = false;
});
};
},
};
},
]);
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ module.exports = angular
state: '=',
},
controllerAs: 'vm',
controller: function($scope) {
this.getIcon = () => (this.state.expanded ? 'down' : 'right');
controller: [
'$scope',
function($scope) {
this.getIcon = () => (this.state.expanded ? 'down' : 'right');

let getAccountType = () => {
AccountService.challengeDestructiveActions(this.account).then(challenge => {
this.accountType = challenge ? 'prod' : $scope.account;
});
};
let getAccountType = () => {
AccountService.challengeDestructiveActions(this.account).then(challenge => {
this.accountType = challenge ? 'prod' : $scope.account;
});
};

$scope.$watch(() => this.account, getAccountType);
},
$scope.$watch(() => this.account, getAccountType);
},
],
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@ module.exports = angular
require('../modal/editApplication.controller.modal').name,
OVERRIDE_REGISTRY,
])
.directive('applicationAttributes', function(overrideRegistry) {
return {
restrict: 'E',
templateUrl: overrideRegistry.getTemplate(
'applicationAttributesDirective',
require('./applicationAttributes.directive.html'),
),
scope: {},
bindToController: {
application: '=',
},
controller: 'ApplicationAttributesCtrl',
controllerAs: 'vm',
};
})
.directive('applicationAttributes', [
'overrideRegistry',
function(overrideRegistry) {
return {
restrict: 'E',
templateUrl: overrideRegistry.getTemplate(
'applicationAttributesDirective',
require('./applicationAttributes.directive.html'),
),
scope: {},
bindToController: {
application: '=',
},
controller: 'ApplicationAttributesCtrl',
controllerAs: 'vm',
};
},
])
.controller('ApplicationAttributesCtrl', [
'$uibModal',
'overrideRegistry',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ module.exports = angular
CACHE_INITIALIZER_SERVICE,
OVERRIDE_REGISTRY,
])
.directive('applicationCacheManagement', function(overrideRegistry) {
return {
restrict: 'E',
templateUrl: overrideRegistry.getTemplate(
'applicationCacheManagementDirective',
require('./applicationCacheManagement.directive.html'),
),
scope: {},
bindToController: {
application: '=',
},
controller: 'ApplicationCacheManagementCtrl',
controllerAs: 'vm',
};
})
.directive('applicationCacheManagement', [
'overrideRegistry',
function(overrideRegistry) {
return {
restrict: 'E',
templateUrl: overrideRegistry.getTemplate(
'applicationCacheManagementDirective',
require('./applicationCacheManagement.directive.html'),
),
scope: {},
bindToController: {
application: '=',
},
controller: 'ApplicationCacheManagementCtrl',
controllerAs: 'vm',
};
},
])
.controller('ApplicationCacheManagementCtrl', [
'$log',
'cacheInitializer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ import { OVERRIDE_REGISTRY } from 'core/overrideRegistry/override.registry';

module.exports = angular
.module('spinnaker.core.application.config.notifications.directive', [OVERRIDE_REGISTRY])
.directive('applicationNotifications', function(overrideRegistry) {
return {
restrict: 'E',
templateUrl: overrideRegistry.getTemplate(
'applicationNotificationsDirective',
require('./applicationNotifications.directive.html'),
),
scope: {},
bindToController: {
application: '=',
notifications: '=',
},
controllerAs: 'vm',
controller: angular.noop,
};
});
.directive('applicationNotifications', [
'overrideRegistry',
function(overrideRegistry) {
return {
restrict: 'E',
templateUrl: overrideRegistry.getTemplate(
'applicationNotificationsDirective',
require('./applicationNotifications.directive.html'),
),
scope: {},
bindToController: {
application: '=',
notifications: '=',
},
controllerAs: 'vm',
controller: angular.noop,
};
},
]);
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@ module.exports = angular
CONFIRMATION_MODAL_SERVICE,
OVERRIDE_REGISTRY,
])
.directive('deleteApplicationSection', function(overrideRegistry) {
return {
restrict: 'E',
templateUrl: overrideRegistry.getTemplate(
'deleteApplicationSectionDirective',
require('./deleteApplicationSection.directive.html'),
),
scope: {},
bindToController: {
application: '=',
},
controllerAs: 'vm',
controller: 'DeleteApplicationSectionCtrl',
};
})
.directive('deleteApplicationSection', [
'overrideRegistry',
function(overrideRegistry) {
return {
restrict: 'E',
templateUrl: overrideRegistry.getTemplate(
'deleteApplicationSectionDirective',
require('./deleteApplicationSection.directive.html'),
),
scope: {},
bindToController: {
application: '=',
},
controllerAs: 'vm',
controller: 'DeleteApplicationSectionCtrl',
};
},
])
.controller('DeleteApplicationSectionCtrl', [
'$state',
'confirmationModalService',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,39 @@ import './providerSelection.modal.less';

module.exports = angular
.module('spinnaker.providerSelection.directive', [])
.directive('providerSelector', function($q) {
return {
restrict: 'E',
scope: {
component: '=',
field: '@',
readOnly: '=',
providers: '=?',
onChange: '&',
},
templateUrl: require('./providerSelector.html'),
link: function(scope) {
scope.initialized = false;
var getProviderList = scope.providers ? $q.when(scope.providers.sort()) : AccountService.listProviders();
getProviderList.then(function(providers) {
scope.initialized = true;
if (!providers.length) {
scope.component[scope.field] = 'aws';
}
if (providers.length === 1) {
scope.component[scope.field] = providers[0];
}
if (providers.length > 1) {
scope.providers = providers;
scope.showSelector = true;
}
});
},
};
})
.directive('providerSelector', [
'$q',
function($q) {
return {
restrict: 'E',
scope: {
component: '=',
field: '@',
readOnly: '=',
providers: '=?',
onChange: '&',
},
templateUrl: require('./providerSelector.html'),
link: function(scope) {
scope.initialized = false;
var getProviderList = scope.providers ? $q.when(scope.providers.sort()) : AccountService.listProviders();
getProviderList.then(function(providers) {
scope.initialized = true;
if (!providers.length) {
scope.component[scope.field] = 'aws';
}
if (providers.length === 1) {
scope.component[scope.field] = providers[0];
}
if (providers.length > 1) {
scope.providers = providers;
scope.showSelector = true;
}
});
},
};
},
])
.controller('ProviderSelectCtrl', [
'$scope',
'$uibModalInstance',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const angular = require('angular');
* <input autofocus/> will focus in the vast majority of browsers (not Angular - this is just HTML)
*
*/
module.exports = angular
.module('spinnaker.core.forms.autoFocus.directive', [])
.directive('autoFocus', function($timeout) {
module.exports = angular.module('spinnaker.core.forms.autoFocus.directive', []).directive('autoFocus', [
'$timeout',
function($timeout) {
return {
restrict: 'A',
link: function(scope, elem, attrs) {
Expand All @@ -21,4 +21,5 @@ module.exports = angular
}
},
};
});
},
]);
Loading

0 comments on commit d828a53

Please sign in to comment.