mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 20:30:46 -03:30
Started fixing/finishing input group delete. Started moving socket status to header.
This commit is contained in:
parent
557b92ef05
commit
65859fa446
@ -408,12 +408,12 @@ angular.module('Tower', [
|
||||
});
|
||||
}
|
||||
])
|
||||
.run(['$cookieStore', '$rootScope', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'ViewLicense',
|
||||
.run(['$compile', '$cookieStore', '$rootScope', '$log', 'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'ViewLicense',
|
||||
'Timer', 'ClearScope', 'HideStream', 'Socket',
|
||||
function ($cookieStore, $rootScope, CheckLicense, $location, Authorization, LoadBasePaths, ViewLicense,
|
||||
function ($compile, $cookieStore, $rootScope, $log, CheckLicense, $location, Authorization, LoadBasePaths, ViewLicense,
|
||||
Timer, ClearScope, HideStream, Socket) {
|
||||
|
||||
var base, sock;
|
||||
var base, e, html, sock;
|
||||
|
||||
LoadBasePaths();
|
||||
|
||||
@ -496,6 +496,12 @@ angular.module('Tower', [
|
||||
$('#' + tabs + ' #' + tab).tab('show');
|
||||
};
|
||||
|
||||
html = "<a href=\"\" aw-pop-over=\"{{ socketTip }}\" aw-pop-over-watch=\"socketTip\" data-placement=\"bottom\" data-trigger=\"hover\" " +
|
||||
"data-popover-title=\"Live Updates\" data-container=\"body\" style=\"font-size: 10px;\"><i class=\"fa icon-socket-{{ socketStatus }}\"></i></a>";
|
||||
e = angular.element(document.getElementById('socket-beacon'));
|
||||
e.empty().append(html);
|
||||
$compile(e)($rootScope);
|
||||
|
||||
// Listen for job changes and issue callbacks to initiate
|
||||
// DOM updates
|
||||
function openSocket() {
|
||||
@ -505,6 +511,7 @@ angular.module('Tower', [
|
||||
$rootScope.$apply(function() {
|
||||
sock.checkStatus();
|
||||
$rootScope.$emit('SocketErrorEncountered');
|
||||
$log.debug('socket status: ' + $rootScope.socketStatus);
|
||||
});
|
||||
});
|
||||
sock.on("status_changed", function(data) {
|
||||
|
||||
@ -1299,7 +1299,7 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
|
||||
"class": "btn btn-default",
|
||||
"id": "group-delete-cancel-button"
|
||||
},{
|
||||
label: "Continue",
|
||||
label: "Delete",
|
||||
onClick: function() {
|
||||
scope.performDelete();
|
||||
},
|
||||
|
||||
@ -76,18 +76,19 @@ angular.module('ProjectsListDefinition', [])
|
||||
awToolTip: 'Click for help',
|
||||
awTipPlacement: 'top'
|
||||
},*/
|
||||
/*refresh: {
|
||||
refresh: {
|
||||
mode: 'all',
|
||||
awToolTip: "Refresh the page",
|
||||
ngClick: "refresh()"
|
||||
},*/
|
||||
socket: {
|
||||
ngClick: "refresh()",
|
||||
ngShow: "socketStatus == 'error'"
|
||||
},
|
||||
/*socket: {
|
||||
mode: 'all',
|
||||
iconClass: "{{ 'fa fa-power-off fa-lg socket-' + socketStatus }}",
|
||||
awToolTip: "{{ socketTip }}",
|
||||
dataTipWatch: "socketTip",
|
||||
ngClick: "socketToggle()",
|
||||
},
|
||||
},*/
|
||||
stream: {
|
||||
ngClick: "showActivity()",
|
||||
awToolTip: "View Activity Stream",
|
||||
|
||||
@ -1066,6 +1066,19 @@ input[type="checkbox"].checkbox-no-label {
|
||||
content: "\f04b";
|
||||
}
|
||||
|
||||
.icon-socket-ok:before {
|
||||
content: "\f111";
|
||||
color: @green;
|
||||
}
|
||||
.icon-socket-error:before {
|
||||
content: "\f111";
|
||||
color: @red;
|
||||
}
|
||||
.icon-socket-connecting:before {
|
||||
content: "\f042";
|
||||
color: @warning;
|
||||
}
|
||||
|
||||
.badge {
|
||||
padding: 2px 3px 3px 4px;
|
||||
font-size: 10px;
|
||||
@ -1203,18 +1216,6 @@ input[type="checkbox"].checkbox-no-label {
|
||||
}
|
||||
/* end */
|
||||
|
||||
/* Socket icon */
|
||||
.socket-ok {
|
||||
color: @green;
|
||||
}
|
||||
.socket-error {
|
||||
color: @red;
|
||||
}
|
||||
.socket-connecting {
|
||||
color: @warning
|
||||
}
|
||||
/* end */
|
||||
|
||||
.field-success {
|
||||
color: #5bb75b;
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ angular.module('InventoryTree', ['Utilities', 'RestServices', 'GroupsHelper', 'P
|
||||
}
|
||||
|
||||
function getShowState(key) {
|
||||
var result = true;
|
||||
var result = null;
|
||||
local_child_store.every(function(child) {
|
||||
if (child.key === key) {
|
||||
result = (child.show !== undefined) ? child.show : true;
|
||||
@ -129,6 +129,20 @@ angular.module('InventoryTree', ['Utilities', 'RestServices', 'GroupsHelper', 'P
|
||||
|
||||
expand = (sorted[i].children.length > 0) ? getExpandState(sorted[i].id) : false;
|
||||
show = getShowState(sorted[i].id);
|
||||
if (show === null) {
|
||||
// this is a node we haven't seen before, so check the parent expand/collapse state
|
||||
// If parent is not expanded, then child should be hidden.
|
||||
show = true;
|
||||
if (parent > 0) {
|
||||
groups.every(function(g) {
|
||||
if (g.id === parent) {
|
||||
show = getExpandState(g.key);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
group = {
|
||||
name: sorted[i].name,
|
||||
@ -173,18 +187,6 @@ angular.module('InventoryTree', ['Utilities', 'RestServices', 'GroupsHelper', 'P
|
||||
group.ngicon = 'fa fa-square-o node-no-toggle';
|
||||
}
|
||||
if (new_group_id && group.group_id === new_group_id) {
|
||||
// For new group
|
||||
// Find parent's expand state and set the show property accordingly.
|
||||
// If parent is not expanded, then child should be hidden.
|
||||
if (parent > 0) {
|
||||
scope.groups.every(function(g) {
|
||||
if (g.id === group.parent) {
|
||||
group.show = getExpandState(g.key);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
scope.selected_tree_id = id;
|
||||
scope.selected_group_id = group.group_id;
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
angular.module('SocketIO', ['AuthService', 'Utilities'])
|
||||
|
||||
.factory('Socket', ['$rootScope', '$location', '$log', 'Authorization', 'Alert', function ($rootScope, $location, $log, Authorization, Alert) {
|
||||
.factory('Socket', ['$rootScope', '$location', '$log', 'Authorization', function ($rootScope, $location, $log, Authorization) {
|
||||
return function(params) {
|
||||
var scope = params.scope,
|
||||
host = $location.host(),
|
||||
@ -23,17 +23,23 @@ angular.module('SocketIO', ['AuthService', 'Utilities'])
|
||||
if (scope.removeSocketErrorEncountered) {
|
||||
scope.removeSocketErrorEncountered();
|
||||
}
|
||||
scope.removeSocketErrorEncountered = scope.$on('SocketErrorEncountered', function(e, reason) {
|
||||
if (reason === 'Session expired') {
|
||||
// encountered expired token, ask user to log in again
|
||||
$rootScope.sessionTimer.expireSession();
|
||||
$location.url('/login');
|
||||
scope.removeSocketErrorEncountered = scope.$on('socketStatusChange', function() {
|
||||
switch(scope.socketStatus) {
|
||||
case 'error':
|
||||
scope.socketTip = "There was an error connecting to the websocket server. Click for troubleshooting help.";
|
||||
break;
|
||||
case 'connecting':
|
||||
scope.socketTip = "Attempting to connect to the websocket server. Click for troubleshooting help.";
|
||||
break;
|
||||
case "ok":
|
||||
scope.socketTip = "Connected to the websocket server. Pages containing job status information for playbook runs, SCM updates and inventory " +
|
||||
"sync processes will automatically update in real-time.";
|
||||
}
|
||||
else if (scope.socketStatus === 'error') {
|
||||
/*else if (scope.socketStatus === 'error') {
|
||||
Alert("Connection Error", "Error encountered while attempting to connect to the websocket server. Confirm the server " +
|
||||
"is up. Use the <i class=\"fa fa-power-off\"></i> button found on the Inventories, Projects and Jobs pages to reconnect.",
|
||||
"alert-danger");
|
||||
}
|
||||
}*/
|
||||
});
|
||||
|
||||
return {
|
||||
@ -61,14 +67,14 @@ angular.module('SocketIO', ['AuthService', 'Utilities'])
|
||||
$log.debug('Socket connecting...');
|
||||
self.scope.$apply(function () {
|
||||
self.scope.socketStatus = 'connecting';
|
||||
self.scope.socketTip = 'Connecting. Click to cancel.';
|
||||
self.scope.$emit('socketStatusChange');
|
||||
});
|
||||
});
|
||||
self.socket.on('connect', function() {
|
||||
$log.debug('Socket connection established');
|
||||
self.scope.$apply(function () {
|
||||
self.scope.socketStatus = 'ok';
|
||||
self.scope.socketTip = 'Connected. Click to close.';
|
||||
self.scope.$emit('socketStatusChange');
|
||||
});
|
||||
});
|
||||
self.socket.on('connect_failed', function(reason) {
|
||||
@ -76,8 +82,7 @@ angular.module('SocketIO', ['AuthService', 'Utilities'])
|
||||
$log.error('Socket connection failed: ' + r);
|
||||
self.scope.$apply(function () {
|
||||
self.scope.socketStatus = 'error';
|
||||
self.scope.socketTip = 'Connection failed. Click to retry.';
|
||||
self.scope.$emit('SocketErrorEncountered');
|
||||
self.scope.$emit('socketStatusChange');
|
||||
});
|
||||
|
||||
});
|
||||
@ -85,8 +90,7 @@ angular.module('SocketIO', ['AuthService', 'Utilities'])
|
||||
$log.debug('Socket disconnected');
|
||||
self.scope.$apply(function() {
|
||||
self.socketStatus = 'error';
|
||||
self.socketTip = 'Disconnected. Click to connect.';
|
||||
self.scope.$emit('SocketErrorEncountered');
|
||||
self.scope.$emit('socketStatusChange');
|
||||
});
|
||||
});
|
||||
self.socket.on('error', function(reason) {
|
||||
@ -94,36 +98,35 @@ angular.module('SocketIO', ['AuthService', 'Utilities'])
|
||||
$log.debug('Socket error: ' + r);
|
||||
self.scope.$apply(function() {
|
||||
self.scope.socketStatus = 'error';
|
||||
self.scope.socketTip = 'Connection error encountered. Click to retry.';
|
||||
self.scope.$emit('SocketErrorEncountered');
|
||||
self.scope.$emit('socketStatusChange');
|
||||
});
|
||||
});
|
||||
self.socket.on('reconnecting', function() {
|
||||
$log.debug('Socket attempting reconnect...');
|
||||
self.scope.$apply(function() {
|
||||
self.scope.socketStatus = 'connecting';
|
||||
self.scope.socketTip = 'Connecting. Click to cancel.';
|
||||
self.scope.$emit('socketStatusChange');
|
||||
});
|
||||
});
|
||||
self.socket.on('reconnect', function() {
|
||||
$log.debug('Socket reconnected');
|
||||
self.scope.$apply(function() {
|
||||
self.scope.socketStatus = 'ok';
|
||||
self.scope.socketTip = 'Connected. Click to close.';
|
||||
self.scope.$emit('socketStatusChange');
|
||||
});
|
||||
});
|
||||
self.socket.on('reconnect_failed', function(reason) {
|
||||
$log.error('Socket reconnect failed: ' + reason);
|
||||
self.scope.$apply(function() {
|
||||
self.scope.socketStatus = 'error';
|
||||
self.scope.socketTip = 'Connection failed. Click to retry.';
|
||||
self.scope.$emit('SocketErrorEncountered');
|
||||
});
|
||||
self.scope.$emit('socketStatusChange');
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Encountered expired token
|
||||
self.scope.$emit('SocketErrorEncountered', 'Session expired');
|
||||
// encountered expired token, redirect to login page
|
||||
$rootScope.sessionTimer.expireSession();
|
||||
$location.url('/login');
|
||||
}
|
||||
},
|
||||
checkStatus: function() {
|
||||
|
||||
@ -285,7 +285,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
||||
.directive('awPopOver', ['$compile', function($compile) {
|
||||
return function(scope, element, attrs) {
|
||||
var placement = (attrs.placement !== undefined && attrs.placement !== null) ? attrs.placement : 'left',
|
||||
title = (attrs.title !== undefined && attrs.title !== null) ? attrs.title : 'Help',
|
||||
title = (attrs.title) ? attrs.title : (attrs.popoverTitle) ? attrs.popoverTitle : 'Help',
|
||||
container = (attrs.container !== undefined) ? attrs.container : false,
|
||||
trigger = (attrs.trigger !== undefined) ? attrs.trigger : 'manual';
|
||||
if (attrs.awPopOverWatch) {
|
||||
|
||||
@ -54,42 +54,42 @@
|
||||
<div ng-show="groupsCount > 0 || hostsCount > 0">
|
||||
<div class="alert alert-info">
|
||||
<p>Deleting group <em>{{ group_name }}</em>.
|
||||
<span ng-show="groupsCount > 0 && hostsCount > 0"> This group has {{ groupsCount }} child groups and {{ hostsCount }} child hosts. </span>
|
||||
<span ng-show="groupsCount == 0 && hostsCount > 0"> This group has {{ hostsCount }} child hosts. </span>
|
||||
<span ng-show="groupsCopunt > 0 && hostsCount == 0"> This group has {{ groupsCount }} child groups. </span>
|
||||
<span ng-show="groupsCount > 0 && hostsCount > 0"> This group contains {{ groupsCount }} groups and {{ hostsCount }} hosts. </span>
|
||||
<span ng-show="groupsCount == 0 && hostsCount > 0"> This group contains {{ hostsCount }} hosts. </span>
|
||||
<span ng-show="groupsCopunt > 0 && hostsCount == 0"> This group contains {{ groupsCount }} groups. </span>
|
||||
Delete or preserve the group's children?</p>
|
||||
<div style="width: 50%; margin: 15px auto;">
|
||||
|
||||
<div class="radio" ng-show="groupsCount > 0 && hostsCount > 0">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option1" value="preserve-all"> Preserve child groups and hosts
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option1" value="preserve-all"> Preserve groups and hosts
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio" ng-show="groupsCount > 0 && hostsCount > 0">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option1" value="delete-all"> Delete child groups and hosts
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option1" value="delete-all"> Delete groups and hosts
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="radio" ng-show="groupsCount > 0 && hostsCount == 0">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option2" value="preserve-all"> Preserve child groups
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option2" value="preserve-all"> Preserve groups
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio" ng-show="groupsCount > 0 && hostsCount == 0">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option2" value="delete-all"> Delete child groups
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option2" value="delete-all"> Delete groups
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="radio" ng-show="groupsCount == 0 && hostsCount > 0">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option3" value="preserve-all"> Preserve child hosts
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option3" value="preserve-all"> Preserve hosts
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio" ng-show="groupsCount == 0 && hostsCount > 0">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option3" value="delete-all"> Delete child hosts
|
||||
<input type="radio" ng-model="deleteOption" name="delete_option3" value="delete-all"> Delete hosts
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
@ -179,6 +179,7 @@
|
||||
</div>
|
||||
<div class="collapse navbar-collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav pull-right">
|
||||
<li id="socket-beacon"></li>
|
||||
<li ng-show="current_user.username != null && current_user.username != undefined">
|
||||
<a id="main_view_user" href="" ng-click="viewCurrentUser()" ng-bind="'Hello! ' + current_user.username"></a></li>
|
||||
<li ng-show="userLoggedIn == true"><a id="main_view_license" href="" ng-click="viewLicense()">View License</a></li>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user