Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user to history #253 delay history load #180 #259

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Jumoo.uSync.BackOffice/App_Plugins/uSync/uSyncDashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<li ng-repeat="tab in settings.addOnTabs track by $index">
<a href="#usync_tab_{{$index}}" data-toggle="tab">{{tab.name}}</a>
</li>
<li><a href="#usync_history" data-toggle="tab">History</a></li>
<li><a href="#usync_history" data-toggle="tab" ng-click="initHistory();">History</a></li>
<li><a href="#usync_config" data-toggle="tab">Config</a></li>
<li><a href="#usync_about" data-toggle="tab">About <i ng-show="!settings.licenced" class="icon-alert-alt color-red"></i></a></li>
</ul>
Expand Down Expand Up @@ -196,6 +196,7 @@ <h3 class="page-header">uSync Actions</h3>
<thead>
<tr>
<th>Name</th>
<th>User</th>
<th>Changes</th>
<th>Sync Type</th>
<th>Date</th>
Expand All @@ -205,6 +206,7 @@ <h3 class="page-header">uSync Actions</h3>
<tbody ng-repeat="item in history">
<tr>
<td>{{item.name}}</td>
<td>{{item.user}}</td>
<td>{{getChangeCount(item.actions)}}</td>
<td>{{item.type}}</td>
<td>{{item.date}}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@
$scope.getuSyncMode();
$scope.loading = false;

$scope.loadHistory();
// $scope.loadHistory();
});
}

$scope.historyLoaded = false;

$scope.initHistory = function () {
if (!$scope.historyLoaded) {
$scope.historyLoaded = true;
$scope.loadHistory();
}
}

$scope.loadHistory = function () {
uSyncDashboardService.getHistory()
.then(function (response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public IEnumerable<uSyncAction> Export(bool deleteAction = false)
// we write a log - when there have been changes, a zero run doesn't get
// a file written to disk.
if (actions.Any(x => x.Change > ChangeType.NoChange))
uSyncActionLogger.SaveActionLog("Export", actions);
uSyncActionLogger.SaveActionLog("Export", Security?.CurrentUser?.Username, actions);

return actions;
}
Expand Down Expand Up @@ -89,7 +89,7 @@ public IEnumerable<uSyncAction> Import(bool force)
// we write a log - when there have been changes, a zero run doesn't get
// a file written to disk.
if (actions.Any(x => x.Change > ChangeType.NoChange))
uSyncActionLogger.SaveActionLog("Import", actions);
uSyncActionLogger.SaveActionLog("Import", Security?.CurrentUser?.Username, actions);

return actions;
}
Expand Down
7 changes: 6 additions & 1 deletion Jumoo.uSync.BackOffice/uSyncAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static uSyncAction ReportAction(bool willUpdate, string name, string mess

public class uSyncActionLogger
{
public static void SaveActionLog(string name, IEnumerable<uSyncAction> actions)
public static void SaveActionLog(string name, string user, IEnumerable<uSyncAction> actions)
{
try {
// creates an action log (xml file) of the actions...
Expand All @@ -142,6 +142,7 @@ public static void SaveActionLog(string name, IEnumerable<uSyncAction> actions)

XElement logFile = new XElement("uSync",
new XAttribute("Name", string.IsNullOrEmpty(name) ? "" : name),
new XAttribute("User", string.IsNullOrEmpty(user) ? "Background" : user),
new XAttribute("DateTime", DateTime.Now.ToString("U")));

XElement logNode = new XElement("Actions");
Expand Down Expand Up @@ -237,6 +238,7 @@ public static uSyncHistory LoadHistoryData(FileInfo file)
{
info.type = data.Attribute("Name").ValueOrDefault("");
info.date = data.Attribute("DateTime").ValueOrDefault("");
info.user = data.Attribute("User").ValueOrDefault("");

info.actions = new List<uSyncAction>();

Expand Down Expand Up @@ -308,6 +310,9 @@ public static void LogActions(List<uSyncAction> actions)
public class uSyncHistory
{
public string name { get; set; }

public string user { get; set; }

public string path { get; set; }
public string type { get; set; }
public string date { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Jumoo.uSync.BackOffice/uSyncApplicationEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void Setup()
// we write a log - when there have been changes, a zero run doesn't get
// a file written to disk.
if (setupActions.Any(x => x.Change > ChangeType.NoChange))
uSyncActionLogger.SaveActionLog("Startup", setupActions);
uSyncActionLogger.SaveActionLog("Startup", "", setupActions);


sw.Stop();
Expand Down
2 changes: 1 addition & 1 deletion Jumoo.uSync.Site/App_Plugins/uSync/package.manifest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
javascript: [
'~/App_Plugins/uSync/uSyncDashboardController.js',
'~/App_Plugins/uSync/uSyncDashboardService.js'
Expand Down
2 changes: 1 addition & 1 deletion Jumoo.uSync.Site/App_Plugins/uSync/uSyncDashboard.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.usync-dash .report-detail {
.usync-dash .report-detail {
padding-top: 1em;
}

Expand Down
6 changes: 4 additions & 2 deletions Jumoo.uSync.Site/App_Plugins/uSync/uSyncDashboard.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="uSyncDashboard" ng-controller="uSyncDashboardController" class="usync-dash">
<div id="uSyncDashboard" ng-controller="uSyncDashboardController" class="usync-dash">
<div ng-show="isInError" class="alert alert-danger">Error: {{errorMsg}}</div>

<div class="row">
Expand All @@ -8,7 +8,7 @@
<li ng-repeat="tab in settings.addOnTabs track by $index">
<a href="#usync_tab_{{$index}}" data-toggle="tab">{{tab.name}}</a>
</li>
<li><a href="#usync_history" data-toggle="tab">History</a></li>
<li><a href="#usync_history" data-toggle="tab" ng-click="initHistory();">History</a></li>
<li><a href="#usync_config" data-toggle="tab">Config</a></li>
<li><a href="#usync_about" data-toggle="tab">About <i ng-show="!settings.licenced" class="icon-alert-alt color-red"></i></a></li>
</ul>
Expand Down Expand Up @@ -196,6 +196,7 @@ <h3 class="page-header">uSync Actions</h3>
<thead>
<tr>
<th>Name</th>
<th>User</th>
<th>Changes</th>
<th>Sync Type</th>
<th>Date</th>
Expand All @@ -205,6 +206,7 @@ <h3 class="page-header">uSync Actions</h3>
<tbody ng-repeat="item in history">
<tr>
<td>{{item.name}}</td>
<td>{{item.user}}</td>
<td>{{getChangeCount(item.actions)}}</td>
<td>{{item.type}}</td>
<td>{{item.date}}</td>
Expand Down
13 changes: 11 additions & 2 deletions Jumoo.uSync.Site/App_Plugins/uSync/uSyncDashboardController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module('umbraco').controller('uSyncDashboardController',
angular.module('umbraco').controller('uSyncDashboardController',
function ($scope, $http, uSyncDashboardService) {

$scope.snapshotsUrl = "/app_plugins/usync/test.html";
Expand All @@ -23,10 +23,19 @@ angular.module('umbraco').controller('uSyncDashboardController',
$scope.getuSyncMode();
$scope.loading = false;

$scope.loadHistory();
// $scope.loadHistory();
});
}

$scope.historyLoaded = false;

$scope.initHistory = function () {
if (!$scope.historyLoaded) {
$scope.historyLoaded = true;
$scope.loadHistory();
}
}

$scope.loadHistory = function () {
uSyncDashboardService.getHistory()
.then(function (response) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module('umbraco.resources').factory('uSyncDashboardService',
angular.module('umbraco.resources').factory('uSyncDashboardService',
function ($q, $http) {

var serviceRoot = 'backoffice/uSync/uSyncApi/';
Expand Down