mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
Inventory refactor: fixed activity stream display on inventory edit page.
This commit is contained in:
parent
b9cde9cc42
commit
8f5642e13e
@ -303,7 +303,8 @@ InventoriesAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$lo
|
||||
function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateList, ClearScope, InventoryGroups, InventoryHosts, BuildTree, Wait,
|
||||
GetSyncStatusMsg, InjectHosts, HostsReload, GroupsAdd, GroupsEdit, GroupsDelete, Breadcrumbs, LoadBreadCrumbs, Empty,
|
||||
Rest, ProcessErrors, InventoryUpdate, Alert, ToggleChildren, ViewUpdateStatus, GroupsCancelUpdate, Find,
|
||||
HostsCreate, EditInventoryProperties, HostsEdit, HostsDelete, ToggleHostEnabled, CopyMoveGroup, CopyMoveHost)
|
||||
HostsCreate, EditInventoryProperties, HostsEdit, HostsDelete, ToggleHostEnabled, CopyMoveGroup, CopyMoveHost,
|
||||
Stream, GetBasePath)
|
||||
{
|
||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||
//scope.
|
||||
@ -502,6 +503,16 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
||||
$scope.toggleHostEnabled = function(host_id, external_source) {
|
||||
ToggleHostEnabled({ scope: $scope, host_id: host_id, external_source: external_source });
|
||||
}
|
||||
|
||||
$scope.showHostActivity = function() {
|
||||
var url = GetBasePath('activity_stream') + '?host__inventory__id=' + $scope.inventory_id;
|
||||
Stream({ inventory_name: $scope.inventory_name, url: url });
|
||||
}
|
||||
|
||||
$scope.showGroupActivity = function() {
|
||||
var url = GetBasePath('activity_stream') + '?group__inventory__id=' + $scope.inventory_id;
|
||||
Stream({ inventory_name: $scope.inventory_name, url: url });
|
||||
}
|
||||
|
||||
//Load tree data for the first time
|
||||
BuildTree({ scope: $scope, inventory_id: $scope.inventory_id, refresh: false });
|
||||
@ -512,6 +523,6 @@ InventoriesEdit.$inject = [ '$scope', '$location', '$routeParams', '$compile', '
|
||||
'BuildTree', 'Wait', 'GetSyncStatusMsg', 'InjectHosts', 'HostsReload', 'GroupsAdd', 'GroupsEdit', 'GroupsDelete',
|
||||
'Breadcrumbs', 'LoadBreadCrumbs', 'Empty', 'Rest', 'ProcessErrors', 'InventoryUpdate', 'Alert', 'ToggleChildren',
|
||||
'ViewUpdateStatus', 'GroupsCancelUpdate', 'Find', 'HostsCreate', 'EditInventoryProperties', 'HostsEdit',
|
||||
'HostsDelete', 'ToggleHostEnabled', 'CopyMoveGroup', 'CopyMoveHost'
|
||||
'HostsDelete', 'ToggleHostEnabled', 'CopyMoveGroup', 'CopyMoveHost', 'Stream', 'GetBasePath'
|
||||
];
|
||||
|
||||
|
||||
@ -546,10 +546,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
|
||||
// Call after modal dialogs to remove any lingering callbacks
|
||||
scope.searchCleanup = function() {
|
||||
console.log('search cleanup!');
|
||||
scope.removeDoSearch();
|
||||
//scope.removeFoundObject();
|
||||
//scope.removeResultWarning();
|
||||
scope.removePrepareSearch();
|
||||
scope.removePrepareSearch2();
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ angular.module('InventoryGroupsDefinition', [])
|
||||
ngClick: "refreshGroups()"
|
||||
},
|
||||
stream: {
|
||||
ngClick: "showActivity()",
|
||||
ngClick: "showGroupActivity()",
|
||||
awToolTip: "View Activity Stream",
|
||||
mode: 'all',
|
||||
ngShow: "user_is_superuser"
|
||||
|
||||
@ -66,7 +66,7 @@ angular.module('InventoryHostsDefinition', [])
|
||||
fieldActions: {
|
||||
enabled_flag: {
|
||||
//label: 'Enabled',
|
||||
iconClass: "\{\{ 'fa icon-enabled-' + host.enabled \}\}",
|
||||
iconClass: "\{\{ 'fa icon-enabled-' + host.enabled \}\}",
|
||||
dataPlacement: 'top',
|
||||
awToolTip: "\{\{ host.enabledToolTip \}\}",
|
||||
dataTipWatch: "host.enabledToolTip",
|
||||
@ -83,7 +83,6 @@ angular.module('InventoryHostsDefinition', [])
|
||||
//label: 'Edit',
|
||||
ngClick: "editHost(\{\{ host.id \}\})",
|
||||
icon: 'icon-edit',
|
||||
"class": 'btn-xs btn-primary',
|
||||
awToolTip: 'Edit host',
|
||||
dataPlacement: 'top'
|
||||
},
|
||||
@ -91,7 +90,6 @@ angular.module('InventoryHostsDefinition', [])
|
||||
//label: 'Delete',
|
||||
ngClick: "deleteHost(\{\{ host.id \}\},'\{\{ host.name \}\}')",
|
||||
icon: 'icon-trash',
|
||||
"class": 'btn-xs btn-primary',
|
||||
awToolTip: 'Delete host',
|
||||
dataPlacement: 'top'
|
||||
}
|
||||
@ -106,7 +104,7 @@ angular.module('InventoryHostsDefinition', [])
|
||||
},
|
||||
stream: {
|
||||
mode: 'all',
|
||||
ngClick: "showActivity()",
|
||||
ngClick: "showHostActivity()",
|
||||
awToolTip: "View Activity Stream",
|
||||
ngShow: "user_is_superuser"
|
||||
},
|
||||
|
||||
@ -51,7 +51,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
||||
stream.hide('slide', {'direction': 'left'}, {'duration': 500, 'queue': false });
|
||||
|
||||
// Completely destroy the container so we don't experience random flashes of it later.
|
||||
// There was some sort weirdness with the tab 'show' causing the stream to slide in when
|
||||
// There was some sort of weirdness with the tab 'show' causing the stream to slide in when
|
||||
// a tab was clicked, after the stream had been hidden. Seemed like timing- wait long enough
|
||||
// before clicking a tab, and it would not happen.
|
||||
setTimeout( function() {
|
||||
@ -67,7 +67,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
||||
|
||||
.factory('StreamBreadCrumbs', ['$rootScope', '$location', function($rootScope, $location) {
|
||||
return function() {
|
||||
// Load the breadcrumbs array. We have to do things a bit different than our standing Utilities.LoadBreadcrumbs.
|
||||
// Load the breadcrumbs array. We have to do things a bit different than Utilities.LoadBreadcrumbs.
|
||||
// Rather than botch that all up, we'll do our own thing here.
|
||||
$rootScope.breadcrumbs = [];
|
||||
var paths = $location.path().split('/');
|
||||
@ -82,8 +82,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
||||
}
|
||||
for (j=0; j < $rootScope.crumbCache.length; j++) {
|
||||
if ($rootScope.crumbCache[j].path == path) {
|
||||
title = $rootScope.crumbCache[j].title;
|
||||
break;
|
||||
title = $rootScope.crumbCache[j].title;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!title) {
|
||||
@ -221,61 +221,82 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
||||
|
||||
.factory('Stream', ['$rootScope', '$location', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', 'StreamList', 'SearchInit',
|
||||
'PaginateInit', 'GenerateList', 'FormatDate', 'ShowStream', 'HideStream', 'BuildDescription', 'FixUrl', 'BuildUrl',
|
||||
'ShowDetail', 'StreamBreadCrumbs', 'setStreamHeight',
|
||||
'ShowDetail', 'StreamBreadCrumbs', 'setStreamHeight', 'Find',
|
||||
function($rootScope, $location, Rest, GetBasePath, ProcessErrors, Wait, StreamList, SearchInit, PaginateInit, GenerateList,
|
||||
FormatDate, ShowStream, HideStream, BuildDescription, FixUrl, BuildUrl, ShowDetail, StreamBreadCrumbs, setStreamHeight) {
|
||||
FormatDate, ShowStream, HideStream, BuildDescription, FixUrl, BuildUrl, ShowDetail, StreamBreadCrumbs, setStreamHeight,
|
||||
Find) {
|
||||
return function(params) {
|
||||
|
||||
var list = StreamList;
|
||||
var defaultUrl = GetBasePath('activity_stream');
|
||||
var view = GenerateList;
|
||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||
|
||||
// pass in an inventory name to fix breadcrumb display
|
||||
var inventory_name = (params) ? params.inventory_name : null;
|
||||
|
||||
// url will override the attempt to compute an activity_stream query
|
||||
var url = (params) ? params.url : null;
|
||||
|
||||
$rootScope.flashMessage = null;
|
||||
|
||||
if ($location.path() !== '/home') {
|
||||
// Restrict what we're looking at based on the path
|
||||
var type = (base == 'inventories') ? 'inventory' : base.replace(/s$/,'');
|
||||
var paths = $location.path().split('/');
|
||||
paths.splice(0,1);
|
||||
if (paths.length > 1 && /^\d+/.test(paths[paths.length - 1])) {
|
||||
type = paths[paths.length - 2];
|
||||
type = (type == 'inventories') ? 'inventory' : type.replace(/s$/,'');
|
||||
//defaultUrl += '?object1=' + type + '&object1__id=' +
|
||||
defaultUrl += '?' + type + '__id=' + paths[paths.length - 1];
|
||||
}
|
||||
else if (paths.length > 1) {
|
||||
type = paths[paths.length - 1];
|
||||
type = (type == 'inventories') ? 'inventory' : type.replace(/s$/,'');
|
||||
defaultUrl += '?or__object1=' + type + '&or__object2=' + type;
|
||||
}
|
||||
else {
|
||||
defaultUrl += '?or__object1=' + type + '&or__object2=' + type;
|
||||
}
|
||||
|
||||
if (url) {
|
||||
defaultUrl = url;
|
||||
}
|
||||
|
||||
else {
|
||||
if ($location.path() !== '/home') {
|
||||
// Restrict what we're looking at based on the path
|
||||
var type = (base == 'inventories') ? 'inventory' : base.replace(/s$/,'');
|
||||
var paths = $location.path().split('/');
|
||||
paths.splice(0,1);
|
||||
if (paths.length > 1 && /^\d+/.test(paths[paths.length - 1])) {
|
||||
type = paths[paths.length - 2];
|
||||
type = (type == 'inventories') ? 'inventory' : type.replace(/s$/,'');
|
||||
//defaultUrl += '?object1=' + type + '&object1__id=' +
|
||||
defaultUrl += '?' + type + '__id=' + paths[paths.length - 1];
|
||||
}
|
||||
else if (paths.length > 1) {
|
||||
type = paths[paths.length - 1];
|
||||
type = (type == 'inventories') ? 'inventory' : type.replace(/s$/,'');
|
||||
defaultUrl += '?or__object1=' + type + '&or__object2=' + type;
|
||||
}
|
||||
else {
|
||||
defaultUrl += '?or__object1=' + type + '&or__object2=' + type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a container for the stream widget
|
||||
$('#tab-content-container').append('<div id="stream-container"><div id=\"stream-content\"></div></div><!-- Stream widget -->');
|
||||
|
||||
StreamBreadCrumbs();
|
||||
|
||||
// Fix inventory name. The way we're doing breadcrumbs doesn't support bind variables.
|
||||
if (inventory_name) {
|
||||
var itm = Find({ list: $rootScope.breadcrumbs, key: 'title', val: '{{ inventory_name }}' });
|
||||
if (itm) {
|
||||
itm.title = inventory_name;
|
||||
}
|
||||
}
|
||||
|
||||
ShowStream();
|
||||
|
||||
// Generate the list
|
||||
var scope = view.inject(list, {
|
||||
mode: 'edit',
|
||||
id: 'stream-content',
|
||||
breadCrumbs: true,
|
||||
searchSize: 'col-lg-3',
|
||||
secondWidget: true,
|
||||
activityStream: true
|
||||
});
|
||||
|
||||
|
||||
scope.closeStream = function(inUrl) {
|
||||
HideStream();
|
||||
if (inUrl) {
|
||||
$location.path(inUrl);
|
||||
if (scope.searchCleanup)
|
||||
scope.searchCleanup();
|
||||
if (inUrl)
|
||||
$location.path(inUrl);
|
||||
}
|
||||
}
|
||||
|
||||
scope.refreshStream = function() {
|
||||
scope.search(list.iterator);
|
||||
|
||||
@ -921,6 +921,7 @@ input[type="checkbox"].checkbox-no-label {
|
||||
|
||||
.icon-enabled-true {
|
||||
color: @green;
|
||||
width: 14px;
|
||||
|
||||
}
|
||||
.icon-enabled-false:before {
|
||||
@ -929,6 +930,7 @@ input[type="checkbox"].checkbox-no-label {
|
||||
|
||||
.icon-enabled-false{
|
||||
color: @red;
|
||||
width: 14px;
|
||||
}
|
||||
|
||||
/* Inventory cloud sourced? indicator */
|
||||
|
||||
@ -378,14 +378,14 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
|
||||
.factory('Breadcrumbs', ['Attr', function(Attr) {
|
||||
return function(params) {
|
||||
|
||||
// Generats breadcrumbs using the list-generator.js method.
|
||||
// Generate breadcrumbs using the list-generator.js method.
|
||||
|
||||
var list = params.list;
|
||||
var mode = params.mode;
|
||||
var html = '';
|
||||
|
||||
html += "<div class=\"nav-path\">\n";
|
||||
html += "<ul class=\"breadcrumb\">\n";
|
||||
html += "<ul class=\"breadcrumb\" id=\"breadcrumb-list\">\n";
|
||||
html += "<li ng-repeat=\"crumb in breadcrumbs\"><a href=\"{{ '#' + crumb.path }}\">{{ crumb.title | capitalize }}</a></li>\n";
|
||||
|
||||
if (list.navigationLinks) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user