mirror of
https://github.com/ansible/awx.git
synced 2026-03-27 22:05:07 -02:30
Activity Stream: Initiated by is now a link when actor is available. Refactored event detail view for much better use of space. Only thing left is formatting the json object.
This commit is contained in:
@@ -17,18 +17,8 @@ angular.module('ActivityDetailDefinition', [])
|
|||||||
formLabelSize: 'col-lg-2',
|
formLabelSize: 'col-lg-2',
|
||||||
|
|
||||||
fields: {
|
fields: {
|
||||||
timestamp: {
|
|
||||||
label: 'Time',
|
|
||||||
type: 'text',
|
|
||||||
readonly: true
|
|
||||||
},
|
|
||||||
user: {
|
user: {
|
||||||
label: 'Initiated By',
|
label: "Initiated by",
|
||||||
type: 'text',
|
|
||||||
readonly: true
|
|
||||||
},
|
|
||||||
id: {
|
|
||||||
label: 'Event ID',
|
|
||||||
type: 'text',
|
type: 'text',
|
||||||
readonly: true
|
readonly: true
|
||||||
},
|
},
|
||||||
@@ -37,30 +27,18 @@ angular.module('ActivityDetailDefinition', [])
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
readonly: true
|
readonly: true
|
||||||
},
|
},
|
||||||
object1: {
|
/*object1_name: {
|
||||||
label: 'Resource',
|
label: '\{\{ object1 \}\}',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
ngHide: '!object1',
|
ngHide: '!object1',
|
||||||
readonly: true
|
readonly: true
|
||||||
},
|
},
|
||||||
object1_name: {
|
object2_name: {
|
||||||
label: 'Name',
|
label: '\{\{ object2 \}\}',
|
||||||
type: 'text',
|
|
||||||
ngHide: '!object1_name',
|
|
||||||
readonly: true
|
|
||||||
},
|
|
||||||
object2: {
|
|
||||||
label: 'Related',
|
|
||||||
type: 'text',
|
type: 'text',
|
||||||
ngHide: '!object2',
|
ngHide: '!object2',
|
||||||
readonly: true
|
readonly: true
|
||||||
},
|
},*/
|
||||||
object2_name: {
|
|
||||||
label: 'Name',
|
|
||||||
type: 'text',
|
|
||||||
ngHide: '!object2_name',
|
|
||||||
readonly: true
|
|
||||||
},
|
|
||||||
changes: {
|
changes: {
|
||||||
label: 'Changes',
|
label: 'Changes',
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
|
|||||||
@@ -545,7 +545,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
|||||||
console.log('search cleanup!');
|
console.log('search cleanup!');
|
||||||
scope.removeDoSearch();
|
scope.removeDoSearch();
|
||||||
//scope.removeFoundObject();
|
//scope.removeFoundObject();
|
||||||
scope.removeResultWarning();
|
//scope.removeResultWarning();
|
||||||
scope.removePrepareSearch();
|
scope.removePrepareSearch();
|
||||||
scope.removePrepareSearch2();
|
scope.removePrepareSearch2();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ angular.module('StreamListDefinition', [])
|
|||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
label: 'Initiated by',
|
label: 'Initiated by',
|
||||||
//ngBindHtml: 'activity.user',
|
ngBindHtml: 'activity.user',
|
||||||
sourceModel: 'actor',
|
sourceModel: 'actor',
|
||||||
sourceField: 'username',
|
sourceField: 'username',
|
||||||
//awToolTip: "\{\{ userToolTip \}\}",
|
//awToolTip: "\{\{ userToolTip \}\}",
|
||||||
|
|||||||
@@ -136,105 +136,84 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
.factory('BuildDescription', ['FixUrl', 'BuildUrl', function(FixUrl, BuildUrl) {
|
.factory('BuildDescription', ['FixUrl', 'BuildUrl', function(FixUrl, BuildUrl) {
|
||||||
return function(activity) {
|
return function(activity) {
|
||||||
var descr = '';
|
var descr = '';
|
||||||
/*if (activity.summary_fields.user) {
|
var descr_nolink;
|
||||||
// this is a user transaction
|
|
||||||
var usr = FixUrl(activity.related.user);
|
|
||||||
descr += 'User <a href=\"' + usr + '\">' + activity.summary_fields.user.username + '</a> ';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
descr += 'System ';
|
|
||||||
}*/
|
|
||||||
descr += activity.operation;
|
descr += activity.operation;
|
||||||
descr += (/e$/.test(activity.operation)) ? 'd ' : 'ed ';
|
descr += (/e$/.test(activity.operation)) ? 'd ' : 'ed ';
|
||||||
|
descr_nolink = descr;
|
||||||
var obj1 = activity.object1;
|
var obj1 = activity.object1;
|
||||||
var obj2 = activity.object2;
|
var obj2 = activity.object2;
|
||||||
if (activity.summary_fields[obj2] && activity.summary_fields[obj2][0].name) {
|
if (activity.summary_fields[obj2] && activity.summary_fields[obj2][0].name) {
|
||||||
activity.summary_fields[obj2][0].base = obj2;
|
activity.summary_fields[obj2][0]['base'] = obj2;
|
||||||
descr += obj2 + ' <a href=\"' + BuildUrl(activity.summary_fields[obj2]) + '\">'
|
descr += obj2 + ' <a href=\"' + BuildUrl(activity.summary_fields[obj2][0]) + '\">'
|
||||||
+ activity.summary_fields[obj2][0].name + '</a>' + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' );
|
+ activity.summary_fields[obj2][0].name + '</a>' + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' );
|
||||||
|
descr_nolink += obj2 + ' ' + activity.summary_fields[obj2][0].name + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' );
|
||||||
}
|
}
|
||||||
else if (activity.object2) {
|
else if (activity.object2) {
|
||||||
descr += activity.object2[0] + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' );
|
descr += activity.object2[0] + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' );
|
||||||
|
descr_nolink += activity.object2[0] + ( (activity.operation == 'disassociate') ? ' from ' : ' to ' );
|
||||||
}
|
}
|
||||||
if (activity.summary_fields[obj1] && activity.summary_fields[obj1][0].name) {
|
if (activity.summary_fields[obj1] && activity.summary_fields[obj1][0].name) {
|
||||||
activity.summary_fields[obj1][0].base = obj2;
|
activity.summary_fields[obj1][0]['base'] = obj1;
|
||||||
descr += obj1 + ' <a href=\"' + BuildUrl(activity.summary_fields[obj1]) + '\">'
|
descr += obj1 + ' <a href=\"' + BuildUrl(activity.summary_fields[obj1][0]) + '\">'
|
||||||
+ activity.summary_fields[obj1][0].name + '</a>';
|
+ activity.summary_fields[obj1][0].name + '</a>';
|
||||||
|
descr_nolink += obj1 + ' ' + activity.summary_fields[obj1][0].name;
|
||||||
}
|
}
|
||||||
else if (activity.object1) {
|
else if (activity.object1) {
|
||||||
descr += activity.object1;
|
descr += activity.object1;
|
||||||
|
descr_nolink += activity.object1;
|
||||||
}
|
}
|
||||||
return descr;
|
activity['description'] = descr;
|
||||||
|
activity['description_nolink'] = descr_nolink;
|
||||||
}
|
}
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('ShowDetail', ['$rootScope', 'Rest', 'Alert', 'GenerateForm', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'ActivityDetailForm',
|
.factory('ShowDetail', ['$rootScope', 'Rest', 'Alert', 'GenerateForm', 'ProcessErrors', 'GetBasePath', 'FormatDate',
|
||||||
'Empty',
|
'ActivityDetailForm', 'Empty', 'Find',
|
||||||
function($rootScope, Rest, Alert, GenerateForm, ProcessErrors, GetBasePath, FormatDate, ActivityDetailForm, Empty) {
|
function($rootScope, Rest, Alert, GenerateForm, ProcessErrors, GetBasePath, FormatDate, ActivityDetailForm, Empty, Find) {
|
||||||
return function(activity_id) {
|
return function(params) {
|
||||||
|
|
||||||
|
var activity_id = params.activity_id;
|
||||||
|
var parent_scope = params.scope;
|
||||||
|
|
||||||
var generator = GenerateForm;
|
var generator = GenerateForm;
|
||||||
var form = ActivityDetailForm;
|
var form = ActivityDetailForm;
|
||||||
var scope;
|
var activity = Find({list: parent_scope.activities, key: 'id', val: activity_id });
|
||||||
|
|
||||||
var url = GetBasePath('activity_stream') + activity_id + '/';
|
// Setup changes field
|
||||||
|
activity['changes'] = JSON.stringify(activity['changes'], null, '\t');
|
||||||
|
var n = activity['changes'].match(/\n/g);
|
||||||
|
var rows = (n) ? n.length : 1;
|
||||||
|
rows = (rows < 1) ? 3 : 10;
|
||||||
|
form.fields['changes'].rows = 10;
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Load the form
|
||||||
Rest.setUrl(url);
|
var scope = generator.inject(form, { mode: 'edit', modal: true, related: false });
|
||||||
Rest.get()
|
scope['changes'] = activity['changes'];
|
||||||
.success( function(data, status, headers, config) {
|
scope['user'] = ( (activity.summary_fields.actor) ? activity.summary_fields.actor.username : 'system' ) +
|
||||||
// load up the form
|
' on ' + FormatDate(new Date(activity['timestamp']));
|
||||||
var results = data;
|
scope['operation'] = activity['description_nolink'];
|
||||||
$rootScope.flashMessage = null;
|
|
||||||
|
|
||||||
$('#form-modal').on('show.bs.modal', function (e) {
|
scope.formModalAction = function() {
|
||||||
$('#form-modal-body').css({
|
$('#form-modal').modal("hide");
|
||||||
width:'auto', //probably not needed
|
}
|
||||||
height:'auto', //probably not needed
|
|
||||||
'max-height':'100%'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//var n = results['changes'].match(/\n/g);
|
$('#form-modal').on('show.bs.modal', function (e) {
|
||||||
//var rows = (n) ? n.length : 1;
|
$('#form-modal-body').css({
|
||||||
//rows = (rows < 1) ? 3 : 10;
|
width:'auto', //probably not needed
|
||||||
form.fields['changes'].rows = 10;
|
height:'auto', //probably not needed
|
||||||
scope = generator.inject(form, { mode: 'edit', modal: true, related: false});
|
'max-height':'100%'
|
||||||
generator.reset();
|
|
||||||
for (var fld in form.fields) {
|
|
||||||
if (results[fld]) {
|
|
||||||
if (fld == 'timestamp') {
|
|
||||||
scope[fld] = FormatDate(new Date(results[fld]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scope[fld] = results[fld];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (results.summary_fields.object1) {
|
|
||||||
scope['object1_name'] = results.summary_fields.object1.name;
|
|
||||||
}
|
|
||||||
if (results.summary_fields.object2) {
|
|
||||||
scope['object2_name'] = results.summary_fields.object2.name;
|
|
||||||
}
|
|
||||||
scope['user'] = (results.summary_fields.user) ? results.summary_fields.user.username : 'system';
|
|
||||||
scope['changes'] = JSON.stringify(results['changes'], null, '\t');
|
|
||||||
scope.formModalAction = function() {
|
|
||||||
$('#form-modal').modal("hide");
|
|
||||||
}
|
|
||||||
scope.formModalActionLabel = 'OK';
|
|
||||||
scope.formModalCancelShow = false;
|
|
||||||
scope.formModalInfo = false;
|
|
||||||
//scope.formModalHeader = results.summary_fields.project.name + '<span class="subtitle"> - SCM Status</span>';
|
|
||||||
if (!scope.$$phase) {
|
|
||||||
scope.$digest();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
$('#form-modal').modal("hide");
|
|
||||||
ProcessErrors(scope, data, status, form,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve activity: ' + activity_id + '. GET status: ' + status });
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
scope.formModalActionLabel = 'OK';
|
||||||
|
scope.formModalCancelShow = false;
|
||||||
|
scope.formModalInfo = false;
|
||||||
|
scope.formModalHeader = "Event " + activity.id;
|
||||||
|
|
||||||
|
if (!scope.$$phase) {
|
||||||
|
scope.$digest();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}])
|
}])
|
||||||
|
|
||||||
@@ -300,7 +279,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
}
|
}
|
||||||
|
|
||||||
scope.showDetail = function(id) {
|
scope.showDetail = function(id) {
|
||||||
ShowDetail(id);
|
ShowDetail({ scope: scope, activity_id: id });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope.removeStreamPostRefresh) {
|
if (scope.removeStreamPostRefresh) {
|
||||||
@@ -321,7 +300,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
scope['activities'][i].user + "</a>";
|
scope['activities'][i].user + "</a>";
|
||||||
}*/
|
}*/
|
||||||
if (scope['activities'][i]['summary_fields']['actor']) {
|
if (scope['activities'][i]['summary_fields']['actor']) {
|
||||||
scope['activities'][i]['user'] = scope['activities'][i]['summary_fields']['actor']['username'];
|
scope['activities'][i]['user'] = "<a href=\"/#/users/" + scope['activities'][i]['summary_fields']['actor']['id'] + "\">" +
|
||||||
|
scope['activities'][i]['summary_fields']['actor']['username'] + "</a>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scope['activities'][i]['user'] = 'system';
|
scope['activities'][i]['user'] = 'system';
|
||||||
@@ -357,8 +337,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
scope['activities'][i].objects += ", " + scope['activities'][i].object2;
|
scope['activities'][i].objects += ", " + scope['activities'][i].object2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Description
|
BuildDescription(scope['activities'][i]);
|
||||||
scope['activities'][i].description = BuildDescription(scope['activities'][i]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// Give ng-repeate a chance to show the data before adjusting the page size.
|
// Give ng-repeate a chance to show the data before adjusting the page size.
|
||||||
|
|||||||
@@ -1051,7 +1051,7 @@ input[type="checkbox"].checkbox-no-label {
|
|||||||
border-right: 1px solid #ddd;
|
border-right: 1px solid #ddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
#groups_table .actions .cancel { padding-right: 0; }
|
#groups_table .actions .cancel { padding-right: 2px; }
|
||||||
|
|
||||||
.node-toggle, .node-no-toggle {
|
.node-toggle, .node-no-toggle {
|
||||||
/* also used on job evetns */
|
/* also used on job evetns */
|
||||||
|
|||||||
Reference in New Issue
Block a user