From aec5a2ba731467f21721c01bcdf452ac985d722a Mon Sep 17 00:00:00 2001 From: chris Houseknecht Date: Fri, 17 Jan 2014 13:02:46 -0500 Subject: [PATCH] Activity stream: show detail will not be displayed if the selected activity cannot be found- this shouldn't happe, but just in case. Viewing detail no longer users an API call. Instead it retrieves the record from memory. It might be possible for this to break if the user clicks browser refresh. Inventory refactor: fixed drag-n-drop so that an object cannot be dropped onto two groups at the same time. --- awx/ui/static/js/widgets/Stream.js | 68 +++++++++++++------------ awx/ui/static/less/ansible-ui.less | 2 +- awx/ui/static/lib/ansible/directives.js | 5 +- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/awx/ui/static/js/widgets/Stream.js b/awx/ui/static/js/widgets/Stream.js index 51f1a8444f..7a911bce5f 100644 --- a/awx/ui/static/js/widgets/Stream.js +++ b/awx/ui/static/js/widgets/Stream.js @@ -178,40 +178,42 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti var generator = GenerateForm; var form = ActivityDetailForm; var activity = Find({list: parent_scope.activities, key: 'id', val: 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; - - // Load the form - var scope = generator.inject(form, { mode: 'edit', modal: true, related: false }); - scope['changes'] = activity['changes']; - scope['user'] = ( (activity.summary_fields.actor) ? activity.summary_fields.actor.username : 'system' ) + - ' on ' + FormatDate(new Date(activity['timestamp'])); - scope['operation'] = activity['description_nolink']; - - scope.formModalAction = function() { - $('#form-modal').modal("hide"); - } - - $('#form-modal').on('show.bs.modal', function (e) { - $('#form-modal-body').css({ - width:'auto', //probably not needed - height:'auto', //probably not needed - 'max-height':'100%' - }); - }); - scope.formModalActionLabel = 'OK'; - scope.formModalCancelShow = false; - scope.formModalInfo = false; - scope.formModalHeader = "Event " + activity.id; - - if (!scope.$$phase) { - scope.$digest(); + if (activity) { + // 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; + + // Load the form + var scope = generator.inject(form, { mode: 'edit', modal: true, related: false }); + scope['changes'] = activity['changes']; + scope['user'] = ( (activity.summary_fields.actor) ? activity.summary_fields.actor.username : 'system' ) + + ' on ' + FormatDate(new Date(activity['timestamp'])); + scope['operation'] = activity['description_nolink']; + + scope.formModalAction = function() { + $('#form-modal').modal("hide"); + } + + $('#form-modal').on('show.bs.modal', function (e) { + $('#form-modal-body').css({ + width:'auto', //probably not needed + height:'auto', //probably not needed + 'max-height':'100%' + }); + }); + + scope.formModalActionLabel = 'OK'; + scope.formModalCancelShow = false; + scope.formModalInfo = false; + scope.formModalHeader = "Event " + activity.id; + + if (!scope.$$phase) { + scope.$digest(); + } } } diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index 414a1ebeea..a9d5760afb 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -1078,7 +1078,7 @@ input[type="checkbox"].checkbox-no-label { .droppable-hover { background-color: @info; color: @info-color; - padding: 5px; + padding: 6px; border: 1px solid @info-border; border-radius: 4px; } diff --git a/awx/ui/static/lib/ansible/directives.js b/awx/ui/static/lib/ansible/directives.js index 3f506fa9dd..4bfae109d5 100644 --- a/awx/ui/static/lib/ansible/directives.js +++ b/awx/ui/static/lib/ansible/directives.js @@ -534,7 +534,8 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService']) start: function(e, ui) { ui.helper.addClass('draggable-clone'); }, - zIndex: 100 + zIndex: 100, + cursorAt: { left: -1 } }); } @@ -607,7 +608,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService']) scope.$emit('CopyMoveHost', $(this).attr('data-tree-id'), ui.draggable.attr('data-host-id')); } }, - tolerance: 'touch' + tolerance: 'pointer' }); }