mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
Inventory refactor: fixed activity stream display on inventory edit page.
This commit is contained in:
@@ -303,7 +303,8 @@ InventoriesAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$lo
|
|||||||
function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateList, ClearScope, InventoryGroups, InventoryHosts, BuildTree, Wait,
|
function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateList, ClearScope, InventoryGroups, InventoryHosts, BuildTree, Wait,
|
||||||
GetSyncStatusMsg, InjectHosts, HostsReload, GroupsAdd, GroupsEdit, GroupsDelete, Breadcrumbs, LoadBreadCrumbs, Empty,
|
GetSyncStatusMsg, InjectHosts, HostsReload, GroupsAdd, GroupsEdit, GroupsDelete, Breadcrumbs, LoadBreadCrumbs, Empty,
|
||||||
Rest, ProcessErrors, InventoryUpdate, Alert, ToggleChildren, ViewUpdateStatus, GroupsCancelUpdate, Find,
|
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
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
@@ -502,6 +503,16 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis
|
|||||||
$scope.toggleHostEnabled = function(host_id, external_source) {
|
$scope.toggleHostEnabled = function(host_id, external_source) {
|
||||||
ToggleHostEnabled({ scope: $scope, host_id: host_id, external_source: 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
|
//Load tree data for the first time
|
||||||
BuildTree({ scope: $scope, inventory_id: $scope.inventory_id, refresh: false });
|
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',
|
'BuildTree', 'Wait', 'GetSyncStatusMsg', 'InjectHosts', 'HostsReload', 'GroupsAdd', 'GroupsEdit', 'GroupsDelete',
|
||||||
'Breadcrumbs', 'LoadBreadCrumbs', 'Empty', 'Rest', 'ProcessErrors', 'InventoryUpdate', 'Alert', 'ToggleChildren',
|
'Breadcrumbs', 'LoadBreadCrumbs', 'Empty', 'Rest', 'ProcessErrors', 'InventoryUpdate', 'Alert', 'ToggleChildren',
|
||||||
'ViewUpdateStatus', 'GroupsCancelUpdate', 'Find', 'HostsCreate', 'EditInventoryProperties', 'HostsEdit',
|
'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
|
// Call after modal dialogs to remove any lingering callbacks
|
||||||
scope.searchCleanup = function() {
|
scope.searchCleanup = function() {
|
||||||
console.log('search cleanup!');
|
|
||||||
scope.removeDoSearch();
|
scope.removeDoSearch();
|
||||||
//scope.removeFoundObject();
|
|
||||||
//scope.removeResultWarning();
|
|
||||||
scope.removePrepareSearch();
|
scope.removePrepareSearch();
|
||||||
scope.removePrepareSearch2();
|
scope.removePrepareSearch2();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ angular.module('InventoryGroupsDefinition', [])
|
|||||||
ngClick: "refreshGroups()"
|
ngClick: "refreshGroups()"
|
||||||
},
|
},
|
||||||
stream: {
|
stream: {
|
||||||
ngClick: "showActivity()",
|
ngClick: "showGroupActivity()",
|
||||||
awToolTip: "View Activity Stream",
|
awToolTip: "View Activity Stream",
|
||||||
mode: 'all',
|
mode: 'all',
|
||||||
ngShow: "user_is_superuser"
|
ngShow: "user_is_superuser"
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ angular.module('InventoryHostsDefinition', [])
|
|||||||
fieldActions: {
|
fieldActions: {
|
||||||
enabled_flag: {
|
enabled_flag: {
|
||||||
//label: 'Enabled',
|
//label: 'Enabled',
|
||||||
iconClass: "\{\{ 'fa icon-enabled-' + host.enabled \}\}",
|
iconClass: "\{\{ 'fa icon-enabled-' + host.enabled \}\}",
|
||||||
dataPlacement: 'top',
|
dataPlacement: 'top',
|
||||||
awToolTip: "\{\{ host.enabledToolTip \}\}",
|
awToolTip: "\{\{ host.enabledToolTip \}\}",
|
||||||
dataTipWatch: "host.enabledToolTip",
|
dataTipWatch: "host.enabledToolTip",
|
||||||
@@ -83,7 +83,6 @@ angular.module('InventoryHostsDefinition', [])
|
|||||||
//label: 'Edit',
|
//label: 'Edit',
|
||||||
ngClick: "editHost(\{\{ host.id \}\})",
|
ngClick: "editHost(\{\{ host.id \}\})",
|
||||||
icon: 'icon-edit',
|
icon: 'icon-edit',
|
||||||
"class": 'btn-xs btn-primary',
|
|
||||||
awToolTip: 'Edit host',
|
awToolTip: 'Edit host',
|
||||||
dataPlacement: 'top'
|
dataPlacement: 'top'
|
||||||
},
|
},
|
||||||
@@ -91,7 +90,6 @@ angular.module('InventoryHostsDefinition', [])
|
|||||||
//label: 'Delete',
|
//label: 'Delete',
|
||||||
ngClick: "deleteHost(\{\{ host.id \}\},'\{\{ host.name \}\}')",
|
ngClick: "deleteHost(\{\{ host.id \}\},'\{\{ host.name \}\}')",
|
||||||
icon: 'icon-trash',
|
icon: 'icon-trash',
|
||||||
"class": 'btn-xs btn-primary',
|
|
||||||
awToolTip: 'Delete host',
|
awToolTip: 'Delete host',
|
||||||
dataPlacement: 'top'
|
dataPlacement: 'top'
|
||||||
}
|
}
|
||||||
@@ -106,7 +104,7 @@ angular.module('InventoryHostsDefinition', [])
|
|||||||
},
|
},
|
||||||
stream: {
|
stream: {
|
||||||
mode: 'all',
|
mode: 'all',
|
||||||
ngClick: "showActivity()",
|
ngClick: "showHostActivity()",
|
||||||
awToolTip: "View Activity Stream",
|
awToolTip: "View Activity Stream",
|
||||||
ngShow: "user_is_superuser"
|
ngShow: "user_is_superuser"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
stream.hide('slide', {'direction': 'left'}, {'duration': 500, 'queue': false });
|
stream.hide('slide', {'direction': 'left'}, {'duration': 500, 'queue': false });
|
||||||
|
|
||||||
// Completely destroy the container so we don't experience random flashes of it later.
|
// 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
|
// 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.
|
// before clicking a tab, and it would not happen.
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
@@ -67,7 +67,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
|
|
||||||
.factory('StreamBreadCrumbs', ['$rootScope', '$location', function($rootScope, $location) {
|
.factory('StreamBreadCrumbs', ['$rootScope', '$location', function($rootScope, $location) {
|
||||||
return function() {
|
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.
|
// Rather than botch that all up, we'll do our own thing here.
|
||||||
$rootScope.breadcrumbs = [];
|
$rootScope.breadcrumbs = [];
|
||||||
var paths = $location.path().split('/');
|
var paths = $location.path().split('/');
|
||||||
@@ -82,8 +82,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
}
|
}
|
||||||
for (j=0; j < $rootScope.crumbCache.length; j++) {
|
for (j=0; j < $rootScope.crumbCache.length; j++) {
|
||||||
if ($rootScope.crumbCache[j].path == path) {
|
if ($rootScope.crumbCache[j].path == path) {
|
||||||
title = $rootScope.crumbCache[j].title;
|
title = $rootScope.crumbCache[j].title;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!title) {
|
if (!title) {
|
||||||
@@ -221,61 +221,82 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
|
|
||||||
.factory('Stream', ['$rootScope', '$location', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', 'StreamList', 'SearchInit',
|
.factory('Stream', ['$rootScope', '$location', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', 'StreamList', 'SearchInit',
|
||||||
'PaginateInit', 'GenerateList', 'FormatDate', 'ShowStream', 'HideStream', 'BuildDescription', 'FixUrl', 'BuildUrl',
|
'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,
|
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) {
|
return function(params) {
|
||||||
|
|
||||||
var list = StreamList;
|
var list = StreamList;
|
||||||
var defaultUrl = GetBasePath('activity_stream');
|
var defaultUrl = GetBasePath('activity_stream');
|
||||||
var view = GenerateList;
|
var view = GenerateList;
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
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;
|
$rootScope.flashMessage = null;
|
||||||
|
|
||||||
if ($location.path() !== '/home') {
|
if (url) {
|
||||||
// Restrict what we're looking at based on the path
|
defaultUrl = url;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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
|
// Add a container for the stream widget
|
||||||
$('#tab-content-container').append('<div id="stream-container"><div id=\"stream-content\"></div></div><!-- Stream widget -->');
|
$('#tab-content-container').append('<div id="stream-container"><div id=\"stream-content\"></div></div><!-- Stream widget -->');
|
||||||
|
|
||||||
StreamBreadCrumbs();
|
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();
|
ShowStream();
|
||||||
|
|
||||||
// Generate the list
|
// Generate the list
|
||||||
var scope = view.inject(list, {
|
var scope = view.inject(list, {
|
||||||
mode: 'edit',
|
mode: 'edit',
|
||||||
id: 'stream-content',
|
id: 'stream-content',
|
||||||
breadCrumbs: true,
|
|
||||||
searchSize: 'col-lg-3',
|
searchSize: 'col-lg-3',
|
||||||
secondWidget: true,
|
secondWidget: true,
|
||||||
activityStream: true
|
activityStream: true
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.closeStream = function(inUrl) {
|
scope.closeStream = function(inUrl) {
|
||||||
HideStream();
|
HideStream();
|
||||||
if (inUrl) {
|
if (scope.searchCleanup)
|
||||||
$location.path(inUrl);
|
scope.searchCleanup();
|
||||||
|
if (inUrl)
|
||||||
|
$location.path(inUrl);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
scope.refreshStream = function() {
|
scope.refreshStream = function() {
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|||||||
@@ -921,6 +921,7 @@ input[type="checkbox"].checkbox-no-label {
|
|||||||
|
|
||||||
.icon-enabled-true {
|
.icon-enabled-true {
|
||||||
color: @green;
|
color: @green;
|
||||||
|
width: 14px;
|
||||||
|
|
||||||
}
|
}
|
||||||
.icon-enabled-false:before {
|
.icon-enabled-false:before {
|
||||||
@@ -929,6 +930,7 @@ input[type="checkbox"].checkbox-no-label {
|
|||||||
|
|
||||||
.icon-enabled-false{
|
.icon-enabled-false{
|
||||||
color: @red;
|
color: @red;
|
||||||
|
width: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inventory cloud sourced? indicator */
|
/* Inventory cloud sourced? indicator */
|
||||||
|
|||||||
@@ -378,14 +378,14 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
|
|||||||
.factory('Breadcrumbs', ['Attr', function(Attr) {
|
.factory('Breadcrumbs', ['Attr', function(Attr) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
|
|
||||||
// Generats breadcrumbs using the list-generator.js method.
|
// Generate breadcrumbs using the list-generator.js method.
|
||||||
|
|
||||||
var list = params.list;
|
var list = params.list;
|
||||||
var mode = params.mode;
|
var mode = params.mode;
|
||||||
var html = '';
|
var html = '';
|
||||||
|
|
||||||
html += "<div class=\"nav-path\">\n";
|
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";
|
html += "<li ng-repeat=\"crumb in breadcrumbs\"><a href=\"{{ '#' + crumb.path }}\">{{ crumb.title | capitalize }}</a></li>\n";
|
||||||
|
|
||||||
if (list.navigationLinks) {
|
if (list.navigationLinks) {
|
||||||
|
|||||||
Reference in New Issue
Block a user