mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 10:27:37 -02:30
AC-502 Fixed links on home page status widget. Added home/hosts page.
This commit is contained in:
@@ -83,7 +83,8 @@ angular.module('ansible', [
|
|||||||
'CredentialsHelper',
|
'CredentialsHelper',
|
||||||
'TimerService',
|
'TimerService',
|
||||||
'StreamListDefinition',
|
'StreamListDefinition',
|
||||||
'HomeGroupListDefinition'
|
'HomeGroupListDefinition',
|
||||||
|
'HomeHostListDefinition'
|
||||||
])
|
])
|
||||||
.config(['$routeProvider', function($routeProvider) {
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
$routeProvider.
|
$routeProvider.
|
||||||
@@ -251,6 +252,8 @@ angular.module('ansible', [
|
|||||||
|
|
||||||
when('/home/groups', { templateUrl: urlPrefix + 'partials/subhome.html', controller: HomeGroups }).
|
when('/home/groups', { templateUrl: urlPrefix + 'partials/subhome.html', controller: HomeGroups }).
|
||||||
|
|
||||||
|
when('/home/hosts', { templateUrl: urlPrefix + 'partials/subhome.html', controller: HomeHosts }).
|
||||||
|
|
||||||
otherwise({redirectTo: '/home'});
|
otherwise({redirectTo: '/home'});
|
||||||
}])
|
}])
|
||||||
.run(['$cookieStore', '$rootScope', 'CheckLicense', '$location', 'Authorization','LoadBasePaths', 'ViewLicense',
|
.run(['$cookieStore', '$rootScope', 'CheckLicense', '$location', 'Authorization','LoadBasePaths', 'ViewLicense',
|
||||||
|
|||||||
@@ -94,18 +94,12 @@ function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, Proce
|
|||||||
SearchInit({ scope: scope, set: 'groups', list: list, url: defaultUrl });
|
SearchInit({ scope: scope, set: 'groups', list: list, url: defaultUrl });
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||||
|
|
||||||
if ($routeParams['status']) {
|
if ($routeParams['has_active_failures']) {
|
||||||
// with status param, called post update-submit
|
scope[HomeGroupList.iterator + 'InputDisable'] = true;
|
||||||
scope[list.iterator + 'SearchField'] = 'status';
|
scope[HomeGroupList.iterator + 'SearchValue'] = $routeParams['has_active_failures'];
|
||||||
scope[list.iterator + 'SelectShow'] = true;
|
scope[HomeGroupList.iterator + 'SearchField'] = 'has_active_failures';
|
||||||
scope[list.iterator + 'SearchSelectOpts'] = list.fields['status'].searchOptions;
|
scope[HomeGroupList.iterator + 'SearchFieldLabel'] = HomeGroupList.fields['has_active_failures'].label;
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['status'].label.replace(/\<br\>/g,' ');
|
scope[HomeGroupList.iterator + 'SearchSelectValue'] = ($routeParams['has_active_failures'] == 'true') ? { value: 1 } : { value: 0 };
|
||||||
for (var opt in list.fields['status'].searchOptions) {
|
|
||||||
if (list.fields['status'].searchOptions[opt].value == $routeParams['status']) {
|
|
||||||
scope[list.iterator + 'SearchSelectValue'] = list.fields['status'].searchOptions[opt];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
@@ -120,3 +114,51 @@ HomeGroups.$inject = [ '$location', '$routeParams', 'HomeGroupList', 'GenerateLi
|
|||||||
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'HostsStatusMsg', 'UpdateStatusMsg', 'ViewUpdateStatus'
|
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'HostsStatusMsg', 'UpdateStatusMsg', 'ViewUpdateStatus'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||||
|
GetBasePath, SearchInit, PaginateInit, FormatDate, SetHostStatus) {
|
||||||
|
|
||||||
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
|
//scope.
|
||||||
|
|
||||||
|
var generator = GenerateList;
|
||||||
|
var list = HomeHostList;
|
||||||
|
var defaultUrl=GetBasePath('hosts');
|
||||||
|
|
||||||
|
var scope = generator.inject(list, { mode: 'edit' });
|
||||||
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
|
|
||||||
|
if (scope.removePostRefresh) {
|
||||||
|
scope.removePostRefresh();
|
||||||
|
}
|
||||||
|
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
||||||
|
for (var i=0; i < scope.hosts.length; i++) {
|
||||||
|
scope['hosts'][i]['inventory_name'] = scope['hosts'][i]['summary_fields']['inventory']['name'];
|
||||||
|
SetHostStatus(scope['hosts'][i]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
SearchInit({ scope: scope, set: 'hosts', list: list, url: defaultUrl });
|
||||||
|
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||||
|
|
||||||
|
if ($routeParams['has_active_failures']) {
|
||||||
|
scope[HomeHostList.iterator + 'InputDisable'] = true;
|
||||||
|
scope[HomeHostList.iterator + 'SearchValue'] = $routeParams['has_active_failures'];
|
||||||
|
scope[HomeHostList.iterator + 'SearchField'] = 'has_active_failures';
|
||||||
|
scope[HomeHostList.iterator + 'SearchFieldLabel'] = HomeHostList.fields['has_active_failures'].label;
|
||||||
|
scope[HomeHostList.iterator + 'SearchSelectValue'] = ($routeParams['has_active_failures'] == 'true') ? { value: 1 } : { value: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.search(list.iterator);
|
||||||
|
|
||||||
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
|
scope.viewUpdateStatus = function(id) { ViewUpdateStatus({ scope: scope, group_id: id }) };
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HomeGroups.$inject = [ '$location', '$routeParams', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
||||||
|
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'HostsStatusMsg', 'UpdateStatusMsg', 'ViewUpdateStatus',
|
||||||
|
'SetHostStatus'
|
||||||
|
];
|
||||||
|
|
||||||
@@ -27,6 +27,16 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
|
|
||||||
SearchInit({ scope: scope, set: 'inventories', list: list, url: defaultUrl });
|
SearchInit({ scope: scope, set: 'inventories', list: list, url: defaultUrl });
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||||
|
|
||||||
|
if ($routeParams['has_active_failures']) {
|
||||||
|
//scope.resetSearch(InventoryHostsForm.iterator);
|
||||||
|
scope[InventoryList.iterator + 'InputDisable'] = true;
|
||||||
|
scope[InventoryList.iterator + 'SearchValue'] = $routeParams['has_active_failures'];
|
||||||
|
scope[InventoryList.iterator + 'SearchField'] = 'has_active_failures';
|
||||||
|
scope[InventoryList.iterator + 'SearchFieldLabel'] = InventoryList.fields['has_active_failures'].label;
|
||||||
|
scope[InventoryList.iterator + 'SearchSelectValue'] = ($routeParams['has_active_failures'] == 'true') ? { value: 1 } : { value: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|||||||
@@ -14,6 +14,42 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
|||||||
'InventoryHostsFormDefinition'
|
'InventoryHostsFormDefinition'
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
.factory('SetHostStatus', [ function() {
|
||||||
|
return function(host) {
|
||||||
|
// Set status related fields on a host object
|
||||||
|
host.activeFailuresLink = '/#/hosts/' + host.id + '/job_host_summaries/?inventory=' + host.inventory +
|
||||||
|
'&host_name=' + escape(host.name);
|
||||||
|
if (host.has_active_failures == true) {
|
||||||
|
host.badgeToolTip = 'Most recent job failed. Click to view jobs.';
|
||||||
|
host.active_failures = 'failed';
|
||||||
|
}
|
||||||
|
else if (host.has_active_failures == false && host.last_job == null) {
|
||||||
|
host.has_active_failures = 'none';
|
||||||
|
host.badgeToolTip = "No job data available.";
|
||||||
|
host.active_failures = 'n/a';
|
||||||
|
}
|
||||||
|
else if (host.has_active_failures == false && host.last_job !== null) {
|
||||||
|
hast.badgeToolTip = "Most recent job successful. Click to view jobs.";
|
||||||
|
host.active_failures = 'success';
|
||||||
|
}
|
||||||
|
|
||||||
|
host.enabled_flag = host.enabled;
|
||||||
|
if (host.has_inventory_sources) {
|
||||||
|
// Inventory sync managed, so not clickable
|
||||||
|
host.enabledToolTip = (host.enabled) ? 'Ready! Availabe to running jobs.' :
|
||||||
|
'Out to lunch! This host is not available to running jobs.';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Clickable
|
||||||
|
host.enabledToolTip = (host.enabled) ? 'Ready! Available to running jobs. Click to toggle.' :
|
||||||
|
'Out to lunch! Host not available to running jobs. Click to toggle.';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}])
|
||||||
|
|
||||||
|
|
||||||
.factory('HostsList', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'HostList', 'GenerateList',
|
.factory('HostsList', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'HostList', 'GenerateList',
|
||||||
'Prompt', 'SearchInit', 'PaginateInit', 'ProcessErrors', 'GetBasePath', 'HostsAdd', 'HostsReload',
|
'Prompt', 'SearchInit', 'PaginateInit', 'ProcessErrors', 'GetBasePath', 'HostsAdd', 'HostsReload',
|
||||||
'SelectionInit',
|
'SelectionInit',
|
||||||
@@ -404,7 +440,8 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
|||||||
|
|
||||||
|
|
||||||
.factory('HostsReload', ['$location', '$routeParams', 'SearchInit', 'PaginateInit', 'InventoryHostsForm', 'GetBasePath', 'Wait',
|
.factory('HostsReload', ['$location', '$routeParams', 'SearchInit', 'PaginateInit', 'InventoryHostsForm', 'GetBasePath', 'Wait',
|
||||||
function($location, $routeParams, SearchInit, PaginateInit, InventoryHostsForm, GetBasePath, Wait) {
|
'SetHostStatus',
|
||||||
|
function($location, $routeParams, SearchInit, PaginateInit, InventoryHostsForm, GetBasePath, Wait, SetHostStatus) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
// Rerfresh the Hosts view on right side of page
|
// Rerfresh the Hosts view on right side of page
|
||||||
|
|
||||||
@@ -439,34 +476,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (var i=0; i < scope.hosts.length; i++) {
|
for (var i=0; i < scope.hosts.length; i++) {
|
||||||
// Add the value displayed in Job Status column
|
SetHostStatus(scope.hosts[i]);
|
||||||
scope.hosts[i].activeFailuresLink = '/#/hosts/' + scope.hosts[i].id + '/job_host_summaries/?inventory=' + scope['inventory_id'] +
|
|
||||||
'&host_name=' + escape(scope.hosts[i].name);
|
|
||||||
if (scope.hosts[i].has_active_failures == true) {
|
|
||||||
scope.hosts[i].badgeToolTip = 'Most recent job failed. Click to view jobs.';
|
|
||||||
scope.hosts[i].active_failures = 'failed';
|
|
||||||
}
|
|
||||||
else if (scope.hosts[i].has_active_failures == false && scope.hosts[i].last_job == null) {
|
|
||||||
scope.hosts[i].has_active_failures = 'none';
|
|
||||||
scope.hosts[i].badgeToolTip = "No job data available.";
|
|
||||||
scope.hosts[i].active_failures = 'n/a';
|
|
||||||
}
|
|
||||||
else if (scope.hosts[i].has_active_failures == false && scope.hosts[i].last_job !== null) {
|
|
||||||
scope.hosts[i].badgeToolTip = "Most recent job successful. Click to view jobs.";
|
|
||||||
scope.hosts[i].active_failures = 'success';
|
|
||||||
}
|
|
||||||
|
|
||||||
scope.hosts[i].enabled_flag = scope.hosts[i].enabled;
|
|
||||||
if (scope.hosts[i].has_inventory_sources) {
|
|
||||||
// Inventory sync managed, so not clickable
|
|
||||||
scope.hosts[i].enabledToolTip = (scope.hosts[i].enabled) ? 'Ready! Availabe to running jobs.' :
|
|
||||||
'Out to lunch! This host is not available to running jobs.';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Clickable
|
|
||||||
scope.hosts[i].enabledToolTip = (scope.hosts[i].enabled) ? 'Ready! Available to running jobs. Click to toggle.' :
|
|
||||||
'Out to lunch! Host not available to running jobs. Click to toggle.';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group_id == null || group_id == undefined) {
|
if (group_id == null || group_id == undefined) {
|
||||||
|
|||||||
93
awx/ui/static/js/lists/HomeHosts.js
Normal file
93
awx/ui/static/js/lists/HomeHosts.js
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/*********************************************
|
||||||
|
* Copyright (c) 2013 AnsibleWorks, Inc.
|
||||||
|
*
|
||||||
|
* HomeHosts.js
|
||||||
|
*
|
||||||
|
* List view object for Hosts data model. Used
|
||||||
|
* on the home tab.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
angular.module('HomeHostListDefinition', [])
|
||||||
|
.value(
|
||||||
|
'HomeHostList', {
|
||||||
|
|
||||||
|
name: 'hosts',
|
||||||
|
iterator: 'host',
|
||||||
|
selectTitle: 'Add Existing Hosts',
|
||||||
|
editTitle: 'Hosts',
|
||||||
|
index: true,
|
||||||
|
well: true,
|
||||||
|
|
||||||
|
fields: {
|
||||||
|
name: {
|
||||||
|
key: true,
|
||||||
|
label: 'Name',
|
||||||
|
columnClass: 'col-lg-3 col-md3 col-sm-2',
|
||||||
|
ngClick: "editHost(\{\{ host.id \}\}, '\{\{ host.name \}\}')"
|
||||||
|
},
|
||||||
|
inventory_name: {
|
||||||
|
label: 'Inventory',
|
||||||
|
sourceModel: 'inventory',
|
||||||
|
sourceField: 'name',
|
||||||
|
columnClass: 'col-lg-3 col-md3 col-sm-2',
|
||||||
|
linkTo: "\{\{ '/#/inventories/' + group.inventory \}\}"
|
||||||
|
},
|
||||||
|
active_failures: {
|
||||||
|
label: 'Job Status',
|
||||||
|
ngHref: "\{\{ host.activeFailuresLink \}\}",
|
||||||
|
awToolTip: "\{\{ host.badgeToolTip \}\}",
|
||||||
|
dataPlacement: 'top',
|
||||||
|
badgeNgHref: '\{\{ host.activeFailuresLink \}\}',
|
||||||
|
badgeIcon: "\{\{ 'icon-failures-' + host.has_active_failures \}\}",
|
||||||
|
badgePlacement: 'left',
|
||||||
|
badgeToolTip: "\{\{ host.badgeToolTip \}\}",
|
||||||
|
badgeTipPlacement: 'top',
|
||||||
|
searchable: false,
|
||||||
|
nosort: true
|
||||||
|
},
|
||||||
|
enabled_flag: {
|
||||||
|
label: 'Enabled',
|
||||||
|
badgeIcon: "\{\{ 'icon-enabled-' + host.enabled \}\}",
|
||||||
|
badgePlacement: 'left',
|
||||||
|
badgeToolTip: "\{\{ host.enabledToolTip \}\}",
|
||||||
|
badgeTipPlacement: "top",
|
||||||
|
ngClick: "toggle_host_enabled(\{\{ host.id \}\}, \{\{ host.has_inventory_sources \}\})",
|
||||||
|
searchable: false,
|
||||||
|
showValue: false
|
||||||
|
},
|
||||||
|
groups: {
|
||||||
|
label: 'Groups',
|
||||||
|
searchable: true,
|
||||||
|
sourceModel: 'groups',
|
||||||
|
sourceField: 'name',
|
||||||
|
nosort: true
|
||||||
|
},
|
||||||
|
enabled: {
|
||||||
|
label: 'Disabled?',
|
||||||
|
searchSingleValue: true,
|
||||||
|
searchType: 'boolean',
|
||||||
|
searchValue: 'false',
|
||||||
|
searchOnly: true
|
||||||
|
},
|
||||||
|
has_active_failures: {
|
||||||
|
label: 'Has failed jobs?',
|
||||||
|
searchSingleValue: true,
|
||||||
|
searchType: 'boolean',
|
||||||
|
searchValue: 'true',
|
||||||
|
searchOnly: true
|
||||||
|
},
|
||||||
|
has_inventory_sources: {
|
||||||
|
label: 'Has external source?',
|
||||||
|
searchSingleValue: true,
|
||||||
|
searchType: 'boolean',
|
||||||
|
searchValue: 'true',
|
||||||
|
searchOnly: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
},
|
||||||
|
|
||||||
|
fieldActions: {
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -74,10 +74,10 @@ angular.module('JobStatusWidget', ['RestServices', 'Utilities'])
|
|||||||
if (inventoryCount > 0) {
|
if (inventoryCount > 0) {
|
||||||
html += makeRow({
|
html += makeRow({
|
||||||
label: 'Inventories',
|
label: 'Inventories',
|
||||||
link: '/#/home/inventories',
|
link: '/#/inventories',
|
||||||
count: inventoryCount,
|
count: inventoryCount,
|
||||||
fail: inventoryFails,
|
fail: inventoryFails,
|
||||||
fail_link: '/#/home/inventories/?has_active_failures=true'
|
fail_link: '/#/inventories/?has_active_failures=true'
|
||||||
});
|
});
|
||||||
rowcount++;
|
rowcount++;
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ angular.module('JobStatusWidget', ['RestServices', 'Utilities'])
|
|||||||
if (hostCount > 0) {
|
if (hostCount > 0) {
|
||||||
html += makeRow({
|
html += makeRow({
|
||||||
label: 'Hosts',
|
label: 'Hosts',
|
||||||
link: '#/home/hosts',
|
link: '/#/home/hosts',
|
||||||
count: hostCount,
|
count: hostCount,
|
||||||
fail: hostFails,
|
fail: hostFails,
|
||||||
fail_link: '/#/home/hosts/?has_active_failures=true'
|
fail_link: '/#/home/hosts/?has_active_failures=true'
|
||||||
|
|||||||
@@ -92,6 +92,7 @@
|
|||||||
<script src="{{ STATIC_URL }}js/lists/Permissions.js"></script>
|
<script src="{{ STATIC_URL }}js/lists/Permissions.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/lists/Streams.js"></script>
|
<script src="{{ STATIC_URL }}js/lists/Streams.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/lists/HomeGroups.js"></script>
|
<script src="{{ STATIC_URL }}js/lists/HomeGroups.js"></script>
|
||||||
|
<script src="{{ STATIC_URL }}js/lists/HomeHosts.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/refresh-related.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/refresh-related.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/related-paginate.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/related-paginate.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/related-search.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/related-search.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user