Skip to content

Commit

Permalink
Replaced with the new context selectore
Browse files Browse the repository at this point in the history
Bugzilla: 1629520
tendrl-github-id: Tendrl#1065
  • Loading branch information
gnehapk committed Sep 17, 2018
1 parent ee557b4 commit ff23f10
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 96 deletions.
7 changes: 3 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ gulp.task("jsLibraries", function() {
"node_modules/jquery/dist/jquery.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js", // For dropdown : temporary
"node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.js",
"node_modules/bootstrap-select/dist/js/bootstrap-select.js",
"node_modules/angular/angular.js",
"node_modules/angular-ui-bootstrap/dist/ui-bootstrap.min.js",
"node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js",
Expand All @@ -110,7 +109,8 @@ gulp.task("jsLibraries", function() {
"node_modules/angular-bootstrap-switch/dist/angular-bootstrap-switch.min.js",
"node_modules/angular-patternfly/node_modules/angular-drag-and-drop-lists/angular-drag-and-drop-lists.js",
"node_modules/datatables/media/js/jquery.dataTables.js",
"node_modules/angular-patternfly/node_modules/angularjs-datatables/dist/angular-datatables.js"
"node_modules/angular-patternfly/node_modules/angularjs-datatables/dist/angular-datatables.js",
"node_modules/bootstrap-select/dist/js/bootstrap-select.js"
])
.pipe(uglify())
.pipe(concat("libraries.js"))
Expand All @@ -121,9 +121,8 @@ gulp.task("jsLibraries", function() {
gulp.task("cssLibraries", function() {
return gulp.src([
"node_modules/patternfly/dist/css/patternfly.css",
"node_modules/patternfly/dist/css/patternfly-additions.css",
"node_modules/angular-patternfly/styles/angular-patternfly.css",
"node_modules/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css"
"node_modules/patternfly/dist/css/patternfly-additions.css"
])
.pipe(postCss([autoprefixer({ browsers: browsers })]))
.pipe(buildMode === "dev" ? noop() : minifyCSS())
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"angular-ui-bootstrap": "~2.2.0",
"bootstrap": "^3.3.7",
"bootstrap-datepicker": "~1.6.4",
"bootstrap-select": "^1.12.4",
"bootstrap-select": "1.12.2",
"bootstrap-tooltip": "~3.1.1",
"c3": "~0.4.11",
"c3-angular": "git://github.com/jettro/c3-angular-directive#1.3.1",
Expand Down
4 changes: 2 additions & 2 deletions src/commons/js/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//# sourceURL=storage-management-plugin.js
(function() {

var storageModule = angular.module("TendrlModule", ["ui.router", "ui.bootstrap", "frapontillo.bootstrap-switch", "gridshore.c3js.chart", "patternfly.charts", "patternfly.card", "patternfly.form", "patternfly.notification", "patternfly.table", "patternfly.filters", "patternfly.modals"]);
var storageModule = angular.module("TendrlModule", ["ui.router", "ui.bootstrap", "frapontillo.bootstrap-switch", "patternfly.charts", "patternfly.card", "patternfly.form", "patternfly.notification", "patternfly.table", "patternfly.filters", "patternfly.modals"]);

/* Setting up provider for getting config data */
storageModule.provider("config", function() {

Expand Down
10 changes: 9 additions & 1 deletion src/commons/services/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.service("utils", utils);

/*@ngInject*/
function utils($http, $rootScope, $state, $filter, config, AuthManager, $location) {
function utils($http, $rootScope, $state, $filter, $timeout, $location, config, AuthManager) {

/* Cache the reference to this pointer */
var vm = this,
Expand Down Expand Up @@ -309,5 +309,13 @@
}

};

vm.refershSelector = function() {
$timeout(function() {
//This will refersh the selectpicker in order to select the correct options
//TODO: Find an alternate way to do it
$(".selectpicker").selectpicker("refresh");
});
}
};
})();
6 changes: 5 additions & 1 deletion src/commons/stores/cluster-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
clusterFactory.getClusterList()
.then(function(data) {
$rootScope.clusterData = store.formatClusterData(data.clusters);

//Required to make the event listen in header.js file
$rootScope.$broadcast("GotClusterData", $rootScope.clusterData);

deferred.resolve($rootScope.clusterData);
}).catch(function(e) {
deferred.reject(e);
Expand Down Expand Up @@ -328,4 +332,4 @@
}
}

})();
})();
4 changes: 1 addition & 3 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<title>Tendrl</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- inject:css -->
<!-- endinject -->
<link rel="stylesheet" type="text/css" href="cssLibraries/libraries.css">
<link href="commons/scss/main.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="jsLibraries/libraries.js"></script>
Expand Down Expand Up @@ -38,4 +36,4 @@ <h1> Tendrl API is not reachable. </h1>
</div> -->
</body>

</html>
</html>
15 changes: 8 additions & 7 deletions src/modules/base/header/header.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<nav class="navbar-pf-vertical tendrl-header-container">
<nav class="navbar navbar-pf-vertical navbar-pf-contextselector tendrl-header-container">
<div class="navbar-header">
<button ng-if="!$root.forceHideNav()" ng-class="{'navigation-hide': $root.forceHideNav()}" class="navbar-toggle" type="button" href="" ng-click="header.toggleNav($event)">
<span class="sr-only">Toggle navigation</span>
Expand All @@ -9,12 +9,13 @@
<a class="navbar-brand" ng-click="header.homePage()" class="nav-brand-name-link">
<img class="nav-brand-name brand-name-img" src="../images/name.png" alt="tendrl | Unified Storage Manager" />
</a>
<select id="repeatSelect" ng-model="$root.selectedClusterOption" class="cluster-options btn btn-default dropdown-toggle filterSelect" ng-change="header.goToClusterPage()" uib-tooltip-html="header.getClusterName($root.selectedClusterOption)" tooltip-placement="auto bottom">
<option value="" disabled ng-selected="!$root.selectedClusterOption">Select a cluster...</option>
<option value="allClusters" ng-selected="$root.selectedClusterOption === 'allClusters'">All Clusters</option>
<option ng-repeat="cluster in $root.clusterData" value="{{cluster.clusterId}}" ng-selected="$root.selectedClusterOption === '{{cluster.clusterId}}'" ng-show="cluster.managed === 'Yes' && cluster.jobType !== 'UnmanageCluster'">{{cluster.name}}</option>
<!-- To filter managed clusters : | filter: {is_managed: 'yes'}-->
</select>
<div class="nav contextselector-pf">
<select class="selectpicker" data-live-search="true" ng-model="$root.selectedClusterOption" ng-change="header.goToClusterPage()" uib-tooltip-html="header.getClusterName($root.selectedClusterOption)" tooltip-placement="auto bottom">
<option value="" disabled ng-selected="!$root.selectedClusterOption">Select a cluster...</option>
<option value="allClusters" ng-selected="$root.selectedClusterOption === 'allClusters'">All Clusters</option>
<option ng-repeat="cluster in $root.clusterData" value="{{cluster.clusterId}}" ng-selected="$root.selectedClusterOption === '{{cluster.clusterId}}'" ng-show="cluster.managed === 'Yes' && cluster.jobType !== 'UnmanageCluster'">{{cluster.name}}</option>
</select>
</div>
</div>
<nav class="collapse navbar-collapse">
<span class="pull-right">
Expand Down
96 changes: 50 additions & 46 deletions src/modules/base/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
}
});

$rootScope.$on("GotClusterData", function(event, data) {
//To refresh the selector selected option
utils.refershSelector();
});

/*BEGIN user setting modal*/
vm.userScope = {};
vm.currentState = $state.current.name;
Expand All @@ -60,58 +65,57 @@
vm.isForm = true;

vm.userSettingActionButtons = [{
label: "Cancel",
isCancel: true
}, {
label: "Save",
class: "btn-primary custom-class",
actionFn: function() {
vm.userScope.formSubmitInProgress = true;
if (_validateUIFields()) {
vm.userScope.user.notification = vm.userScope.user.email_notifications;
userStore.editUser(vm.userScope.user)
.then(function(data) {
vm.showUserSetting = false;
if (vm.currentState === "users") {
userStore.getUserList()
.then(function(data) {
if (data !== null) {
$rootScope.$broadcast("UpdatedUserList", data);
}

});
}
Notifications.message("success", "", " Profile updated Successfully.");
}).catch(function(e) {
var keys,
messages;

if (e.status === 422) {
keys = Object.keys(e.data.errors);
messages = Object.values(e.data.errors)[0];

if (keys.indexOf("email") !== -1) {
if (messages.indexOf("is taken") !== -1) {
vm.userScope.errorMsg = "Email is already taken. Please use different one.";
} else if (messages.indexOf("is invalid") !== -1) {
vm.userScope.errorMsg = "Please enter a valid Email Id";
label: "Cancel",
isCancel: true
}, {
label: "Save",
class: "btn-primary custom-class",
actionFn: function() {
vm.userScope.formSubmitInProgress = true;
if (_validateUIFields()) {
vm.userScope.user.notification = vm.userScope.user.email_notifications;
userStore.editUser(vm.userScope.user)
.then(function(data) {
vm.showUserSetting = false;
if (vm.currentState === "users") {
userStore.getUserList()
.then(function(data) {
if (data !== null) {
$rootScope.$broadcast("UpdatedUserList", data);
}
} else if (keys.indexOf("name") !== -1) {
vm.userScope.errorMsg = "Name is too short (minimum is 4 characters).";

});
}
Notifications.message("success", "", " Profile updated Successfully.");
}).catch(function(e) {
var keys,
messages;

if (e.status === 422) {
keys = Object.keys(e.data.errors);
messages = Object.values(e.data.errors)[0];

if (keys.indexOf("email") !== -1) {
if (messages.indexOf("is taken") !== -1) {
vm.userScope.errorMsg = "Email is already taken. Please use different one.";
} else if (messages.indexOf("is invalid") !== -1) {
vm.userScope.errorMsg = "Please enter a valid Email Id";
}
} else {
vm.showUserSetting = false;
Notifications.message("danger", "", " Failed to update profile.");
} else if (keys.indexOf("name") !== -1) {
vm.userScope.errorMsg = "Name is too short (minimum is 4 characters).";
}
});
} else {
vm.showUserSetting = false;
Notifications.message("danger", "", " Failed to update profile.");
}
});


} else {
vm.userScope.formSubmitInProgress = false;
}
} else {
vm.userScope.formSubmitInProgress = false;
}
}
];
}];

function userSetting() {
vm.userScope.typePassword = false;
Expand Down Expand Up @@ -283,4 +287,4 @@
}
}

})();
})();
2 changes: 1 addition & 1 deletion src/modules/base/header/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@
cursor: default;
visibility: hidden;
}
}
}
4 changes: 3 additions & 1 deletion src/modules/clusters/cluster-hosts/cluster-hosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@
_setClusterDetail();
vm.isDataLoading = false;
}

utils.refershSelector();
}

/***Private Functions***/

/**
* @name _setClusterDetail
* @desc set cluster detail
* @memberOf clusterDetailController
* @memberOf clusterHostsController
*/
function _setClusterDetail() {
vm.clusterObj = clusterStore.getClusterDetails(vm.clusterId);
Expand Down
1 change: 1 addition & 0 deletions src/modules/hosts/host-list/host-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@

var clusters;
clusters = $rootScope.clusterData;
$rootScope.selectedClusterOption = vm.clusterId;

clusterStore.getCluster(vm.clusterId)
.then(function(data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>
<div class="form-group required">
<label class="col-sm-3 col-md-1 detail-label">Status:</label>
<label class="col-sm-4 col-md-1 status-value"><i ng-class="{'pficon pficon-ok status-icon': (glbTaskDetailCntrl.taskDetail.status === 'finished')}"></i>{{glbTaskDetailCntrl.taskDetail.status === 'finished' ? "Completed": glbTaskDetailCntrl.taskDetail.status}}</label>
<label class="col-sm-4 col-md-2 status-value"><i ng-class="{'pficon pficon-ok status-icon': (glbTaskDetailCntrl.taskDetail.status === 'finished')}"></i>{{glbTaskDetailCntrl.taskDetail.status === 'finished' ? "Completed": glbTaskDetailCntrl.taskDetail.status}}</label>
<label class="col-sm-4 col-md-2" ng-show="(glbTaskDetailCntrl.taskDetail.flow === 'ImportCluster') && (glbTaskDetailCntrl.taskDetail.status === 'finished') &&(!$root.selectedClusterOption)"><span class="spinner spinner-xs spinner-inline" ng-show="glbTaskDetailCntrl.showLoadingIcon"></span> <a href="" ng-click="glbTaskDetailCntrl.goToClusterDetail()">View cluster details</a></label>
</div>
</form>
Expand Down
6 changes: 4 additions & 2 deletions src/modules/tasks/global-task-detail/global-task-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
});

/*@ngInject*/
function globalTaskDetailController($rootScope, $scope, $interval, $state, $stateParams, taskStore, config, clusterStore) {
function globalTaskDetailController($rootScope, $scope, $interval, $state, $stateParams, taskStore, config, clusterStore, utils) {

var vm = this,
statusTimer,
Expand All @@ -28,6 +28,8 @@
vm.taskDetail = [];
vm.goToClusterDetail = goToClusterDetail;

//To refresh the selector selected option
utils.refershSelector();
init();

function init() {
Expand Down Expand Up @@ -117,4 +119,4 @@
}
}

})();
})();
53 changes: 27 additions & 26 deletions src/modules/users/user-list/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
});

/*@ngInject*/
function userController($scope, $rootScope, $state, $uibModal, $interval, config, userStore, AuthManager, Notifications) {
function userController($scope, $rootScope, $state, $uibModal, $interval, config, userStore, AuthManager, Notifications, utils) {

var vm = this,
userList,
Expand Down Expand Up @@ -59,32 +59,31 @@
vm.deleteUserModalId = "deleteUserModal";
vm.deleteUserModalTemplate = "/modules/users/delete-user/delete-user.html";
vm.deleteUserModalActionButtons = [{
label: "Cancel",
isCancel: true
}, {
label: "Delete",
class: "btn-danger custom-class",
actionFn: function() {
userStore.deleteUser(vm.deleteUser.username)
.then(function(data) {
vm.showDeleteUserModal = false;
userStore.getUserList()
.then(function(data) {
if (data !== null) {
$rootScope.$broadcast("UpdatedUserList", data);
}
Notifications.message("success", "", vm.deleteUser.username + " deleted Successfully.");
});

}).catch(function(e) {
vm.showDeleteUserModal = false;
Notifications.message("danger", "", "Error deleting " + vm.deleteUser.username);
});

}
label: "Cancel",
isCancel: true
}, {
label: "Delete",
class: "btn-danger custom-class",
actionFn: function() {
userStore.deleteUser(vm.deleteUser.username)
.then(function(data) {
vm.showDeleteUserModal = false;
userStore.getUserList()
.then(function(data) {
if (data !== null) {
$rootScope.$broadcast("UpdatedUserList", data);
}
Notifications.message("success", "", vm.deleteUser.username + " deleted Successfully.");
});

}).catch(function(e) {
vm.showDeleteUserModal = false;
Notifications.message("danger", "", "Error deleting " + vm.deleteUser.username);
});

}
];

}];

function deleteUser(username) {
vm.showDeleteUserModal = true;
Expand All @@ -95,9 +94,11 @@
function closeDeleteUserModal(dismissCause) {
vm.showDeleteUserModal = false;
}

/*END Delete User modal*/


//To refresh the selector selected option
utils.refershSelector();
init();

function init() {
Expand Down

0 comments on commit ff23f10

Please sign in to comment.