mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 12:20:45 -03:30
First attempt at accessing /activity_stream. Modified /list/Stream.js to match the API and to start providing some of the translation we'll need.
This commit is contained in:
parent
bd942e540a
commit
9505768bf6
@ -70,9 +70,11 @@ angular.module('PaginateHelper', ['RefreshHelper', 'ngCookies'])
|
||||
|
||||
scope[iterator + 'Page'] = 0;
|
||||
var new_url = url.replace(/\?page_size\=\d+/,'');
|
||||
var connect = (/\/$/.test(new_url)) ? '?' : '&';
|
||||
console.log('new_url: ' + new_url);
|
||||
var connect = (/\/$/.test(new_url)) ? '?' : '&';
|
||||
new_url += (scope[iterator + 'SearchParams']) ? connect + scope[iterator + 'SearchParams'] + '&page_size=' + scope[iterator + 'PageSize' ] :
|
||||
+ connect + 'page_size=' + scope[iterator + 'PageSize' ];
|
||||
connect + 'page_size=' + scope[iterator + 'PageSize' ];
|
||||
console.log('new_url: ' + new_url);
|
||||
Refresh({ scope: scope, set: set, iterator: iterator, url: new_url });
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,17 +19,20 @@ angular.module('StreamListDefinition', [])
|
||||
"class": "table-condensed",
|
||||
|
||||
fields: {
|
||||
event_time: {
|
||||
key: true,
|
||||
label: 'When'
|
||||
},
|
||||
user: {
|
||||
label: 'Who',
|
||||
label: 'User',
|
||||
linkTo: "\{\{ activity.userLink \}\}",
|
||||
sourceModel: 'user',
|
||||
sourceField: 'username'
|
||||
sourceField: 'username',
|
||||
awToolTip: "\{\{ userToolTip \}\}",
|
||||
dataPlacement: 'top'
|
||||
},
|
||||
operation: {
|
||||
label: 'Operation'
|
||||
timestamp: {
|
||||
label: 'Event Time',
|
||||
},
|
||||
objects: {
|
||||
label: 'Objects',
|
||||
ngBindHtml: 'activity.objects'
|
||||
},
|
||||
description: {
|
||||
label: 'Description'
|
||||
|
||||
@ -61,7 +61,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
||||
return function(params) {
|
||||
|
||||
var list = StreamList;
|
||||
var defaultUrl = $basePath + 'html/event_log.html/';
|
||||
var defaultUrl = GetBasePath('activity_stream');
|
||||
var view = GenerateList;
|
||||
|
||||
// Push the current page onto browser histor. If user clicks back button, restore current page without
|
||||
@ -84,9 +84,10 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
||||
}
|
||||
|
||||
scope.refreshStream = function() {
|
||||
scope['activities'].splice(10,10);
|
||||
//scope.search(list.iterator);
|
||||
}
|
||||
scope.search(list.iterator);
|
||||
}
|
||||
|
||||
function fixUrl(u) { return u.replace(/\/api\/v1\//,'/#/'); }
|
||||
|
||||
if (scope.removePostRefresh) {
|
||||
scope.removePostRefresh();
|
||||
@ -94,10 +95,26 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
||||
scope.removePostRefresh = scope.$on('PostRefresh', function() {
|
||||
for (var i=0; i < scope['activities'].length; i++) {
|
||||
// Convert event_time date to local time zone
|
||||
cDate = new Date(scope['activities'][i].event_time);
|
||||
scope['activities'][i].event_time = FormatDate(cDate);
|
||||
cDate = new Date(scope['activities'][i].timestamp);
|
||||
scope['activities'][i].timestamp = FormatDate(cDate);
|
||||
// Display username
|
||||
scope['activities'][i].user = scope.activities[i].summary_fields.user.username;
|
||||
scope['activities'][i].user = (scope['activities'][i].summary_fields.user) ? scope['activities'][i].summary_fields.user.username :
|
||||
'System';
|
||||
if (scope['activities'][i].user !== 'System') {
|
||||
scope['activities'][i].userLink = (scope['activities'][i].summary_fields.user) ? fixUrl(scope['activities'][i].related.user) :
|
||||
"";
|
||||
}
|
||||
|
||||
// Objects
|
||||
var href;
|
||||
if (scope['activities'][i].summary_fields.object1) {
|
||||
href = fixUrl(scope['activities'][i].related.object_1);
|
||||
scope['activities'][i].objects = "<a href=\"" + href + "\">" + scope['activities'][i].summary_fields.object1.name + "</a>";
|
||||
}
|
||||
if (scope['activities'][i].summary_fields.object2) {
|
||||
href = fixUrl(scope['activities'][i].related.object_2);
|
||||
scope['activities'][i].objects += ", <a href=\"" + href + "\">" + scope['activities'][i].summary_fields.object2.name + "</a>";
|
||||
}
|
||||
}
|
||||
ShowStream();
|
||||
});
|
||||
|
||||
@ -340,6 +340,7 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
|
||||
html += (field.ngClass) ? Attr(field, 'ngClass') : "";
|
||||
html += (options.mode == 'lookup' || options.mode == 'select') ? " ng-click=\"toggle_" + list.iterator +"({{ " + list.iterator + ".id }})\"" : "";
|
||||
html += (field.columnShow) ? Attr(field, 'columnShow') : "";
|
||||
html += (field.ngBindHtml) ? "ng-bind-html-unsafe=\"" + field.ngBindHtml + "\" " : "";
|
||||
html += ">\n";
|
||||
|
||||
// Add ngShow
|
||||
@ -359,7 +360,7 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
|
||||
|
||||
// Start the Link
|
||||
if ( (field.key || field.link || field.linkTo || field.ngClick || field.ngHref) &&
|
||||
options['mode'] != 'lookup' && options['mode'] != 'select' && !field.noLink ) {
|
||||
options['mode'] != 'lookup' && options['mode'] != 'select' && !field.noLink && !field.ngBindHtml) {
|
||||
var cap=false;
|
||||
if (field.linkTo) {
|
||||
html += "<a href=\"" + field.linkTo + "\" ";
|
||||
@ -397,7 +398,7 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
|
||||
}
|
||||
|
||||
// Add data binds
|
||||
if (field.showValue == undefined || field.showValue == true) {
|
||||
if (!field.ngBindHtml && (field.showValue == undefined || field.showValue == true)) {
|
||||
if (field.ngBind) {
|
||||
html += "{{ " + field.ngBind + " }}";
|
||||
}
|
||||
@ -417,7 +418,7 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
|
||||
|
||||
// close the link
|
||||
if ( (field.key || field.link || field.linkTo || field.ngClick || field.ngHref )
|
||||
&& options.mode != 'lookup' && options.mode != 'select' && !field.noLink ) {
|
||||
&& options.mode != 'lookup' && options.mode != 'select' && !field.noLink && !field.ngBindHtml ) {
|
||||
html += "</a>";
|
||||
}
|
||||
// close ngShow
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user