Skip to content

Commit

Permalink
Add task restoration feature to audit log
Browse files Browse the repository at this point in the history
  • Loading branch information
setaou committed Jan 29, 2016
1 parent 6fff778 commit 76c9cd5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
14 changes: 14 additions & 0 deletions js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,20 @@ monetaControllers.controller('NewTaskCtrl', ['$scope', '$http', '$state', '$stat
}
}]);

monetaControllers.controller('RestoreTaskCtrl', ['$scope', '$http', '$state', 'config', 'alert', function ($scope, $http, $state, config, alert) {
$scope.restoreTask = function() {
if (confirm("You are about to restore task \"" + $scope.task.name + "\"")) {
$http.put(config.backend + '/tasks/' + $scope.taskId, $scope.task)
.success(function(data, status, headers, config) {
alert.add({'type': 'success', 'message': 'The task has been restored.', 'timeout': 3000});
$state.go('task.view', { 'taskId': $scope.taskId }, { 'reload': true});
}).error(function(data, status, headers, config) {
alert.add({'type': 'alert', 'message': 'An error occured, please try again !'});
});
}
};
}]);

monetaControllers.controller('AuditLogCtrl', ['$scope', '$http', 'config', 'alert', function ($scope, $http, config, alert) {
fetchLog = function() {
from = moment($scope.from).startOf('day').toISOString();
Expand Down
2 changes: 1 addition & 1 deletion templates/events/moneta-task-created.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div class="mon-auditlog-event" ng-init="task = event.config" ng-include="'templates/task-view.html'"></div>
<div class="mon-auditlog-event" ng-init="task = event.config; taskId = event.task; restorebutton = true;" ng-include="'templates/task-view.html'"></div>
2 changes: 1 addition & 1 deletion templates/events/moneta-task-deleted.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div class="mon-auditlog-event" ng-init="task = event.config" ng-include="'templates/task-view.html'"></div>
<div class="mon-auditlog-event" ng-init="task = event.config; taskId = event.task; restorebutton = true;" ng-include="'templates/task-view.html'"></div>
4 changes: 2 additions & 2 deletions templates/events/moneta-task-updated.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<li class="tab-title" ng-class="{active: tab != 'old'}" ><a href="" ng-click="tab = 'new'">New</a></li>
<li class="tab-title" ng-class="{active: tab == 'old'}" ><a href="" ng-click="tab = 'old'">Old</a></li>
</ul>
<div class="tabs-content" ng-if="tab != 'old'" ng-init="task = event.config" ng-include="'templates/task-view.html'"></div>
<div class="tabs-content" ng-if="tab == 'old'" ng-init="task = event.oldconfig" ng-include="'templates/task-view.html'"></div>
<div class="tabs-content" ng-if="tab != 'old'" ng-init="task = event.config; taskId = event.task;" ng-include="'templates/task-view.html'"></div>
<div class="tabs-content" ng-if="tab == 'old'" ng-init="task = event.oldconfig; taskId = event.task; restorebutton = true;" ng-include="'templates/task-view.html'"></div>
</div>
6 changes: 6 additions & 0 deletions templates/task-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,9 @@ <h3>Reporting</h3>
</tr>
</tbody>
</table>

<div class="row" ng-if="restorebutton" ng-controller="RestoreTaskCtrl">
<div class="columns large-12 text-center">
<a href="" class="button alert" ng-click="restoreTask()">Restore this version</a>
</div>
</div>

0 comments on commit 76c9cd5

Please sign in to comment.