~allenap/maas/regiond-leader

« back to all changes in this revision

Viewing changes to src/maasserver/static/js/angular/controllers/nodes_list.js

[r=allenap][bug=1449043][author=ubuntudotcom1] Address bug 1449043 by adding a client-side notification when the user attempts to deploy a node but does not have at least one SSH key installed. We are doing this because previously the node action 'Deploy' was hidden when keys were not installed, but without explanation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
angular.module('MAAS').controller('NodesListController', [
8
8
    '$scope', '$rootScope', '$routeParams', 'NodesManager', 'DevicesManager',
9
9
    'GeneralManager', 'ManagerHelperService', 'SearchService', 'ZonesManager',
 
10
    'UsersManager',
10
11
    function($scope, $rootScope, $routeParams, NodesManager, DevicesManager,
11
 
        GeneralManager, ManagerHelperService, SearchService, ZonesManager) {
 
12
        GeneralManager, ManagerHelperService, SearchService, ZonesManager,
 
13
        UsersManager) {
12
14
 
13
15
        // Mapping of device.ip_assignment to viewable text.
14
16
        var DEVICE_IP_ASSIGNMENT = {
311
313
        $scope.isActionError = function(tab) {
312
314
            if(angular.isObject($scope.tabs[tab].actionOption) &&
313
315
                $scope.tabs[tab].actionOption.name === "deploy" &&
314
 
                $scope.osinfo.osystems.length === 0 &&
315
 
                $scope.tabs[tab].actionErrorCount === 0) {
 
316
                $scope.tabs[tab].actionErrorCount === 0 &&
 
317
                ($scope.osinfo.osystems.length === 0 ||
 
318
                UsersManager.getSSHKeyCount() === 0)) {
316
319
                return true;
317
320
            }
318
321
            return $scope.tabs[tab].actionErrorCount !== 0;
331
334
            return false;
332
335
        };
333
336
 
 
337
        // Return True if unable to deploy because of missing ssh keys.
 
338
        $scope.isSSHKeyError = function(tab) {
 
339
            if($scope.tabs[tab].actionErrorCount !== 0) {
 
340
                return false;
 
341
            }
 
342
            if(angular.isObject($scope.tabs[tab].actionOption) &&
 
343
                $scope.tabs[tab].actionOption.name === "deploy" &&
 
344
                UsersManager.getSSHKeyCount() === 0) {
 
345
                return true;
 
346
            }
 
347
            return false;
 
348
        };
 
349
 
334
350
        // Called when the current action is cancelled.
335
351
        $scope.actionCancel = function(tab) {
336
352
            leaveViewSelected(tab);
401
417
 
402
418
        // Load NodesManager, DevicesManager, GeneralManager and ZonesManager.
403
419
        ManagerHelperService.loadManagers(
404
 
            [NodesManager, DevicesManager, GeneralManager, ZonesManager]).then(
 
420
            [NodesManager, DevicesManager, GeneralManager, ZonesManager,
 
421
            UsersManager]).then(
405
422
            function() {
406
423
                $scope.loading = false;
407
424
            });