Skip to content

Commit

Permalink
Merge pull request #119 from Jumoo/wip/dashboard-flow
Browse files Browse the repository at this point in the history
Wip/dashboard flow
  • Loading branch information
KevinJump authored May 12, 2023
2 parents e2a0d1d + 22ab90e commit 4c0660a
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 30 deletions.
1 change: 1 addition & 0 deletions uSync.Migrations/Composing/SyncMigrationsManifestFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void Filter(List<PackageManifest> manifests)
Scripts = new[]
{
uSyncMigrations.PluginFolder + "/migration.service.js",
uSyncMigrations.PluginFolder + "/migration.helpers.js",
uSyncMigrations.PluginFolder + "/backoffice/uSyncMigrations/dashboard.controller.js",
uSyncMigrations.PluginFolder + "/migrate.controller.js",
uSyncMigrations.PluginFolder + "/dialogs/handlerPicker.controller.js",
Expand Down
2 changes: 2 additions & 0 deletions uSync.Migrations/wwwroot/uSyncMigrations/Lang/en-us.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
<key alias="statusPlan">Migration Plan</key>
<key alias="statusDesc">Migration plan to use for conversion</key>

<key alias="showValidation">Validation results</key>

<!-- migrations list -->
<key alias="listName">Name</key>
<key alias="listFolder">Folder</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@
}

function canBeImported() {
if (vm.migrationStatus?.migrated == true) { return true; }

return false;
return (vm.step != 'migrating' && vm.migrationStatus?.migrated == true);
}

function importing() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div ng-controller="uSyncMigrationDashboardController as vm">
<umb-editor-view footer="false">
<umb-editor-view>

<umb-editor-header name="'uSync.Migrations 🪛'"
description="'You can migrate your own way.'"
Expand All @@ -11,19 +11,14 @@

<umb-editor-container class="form-horizontal">

<div class="alert alert-warning flex items-center">
<div class="alert alert-warning flex items-center"
style="margin:-20px; margin-bottom: 10px;">
<div class="mr2">
<umb-icon icon="icon-lab"></umb-icon>
</div>
<div><localize key="usyncmigrate_beta"></localize></div>
</div>

<umb-box ng-if="vm.step != 'init'">
<umb-box-header ng-click="vm.goBack()"
title="&laquo; back"
style="cursor: pointer;"></umb-box-header>

</umb-box>

<div ng-if="vm.step == 'init'">
<div class="usync-group-actions">
Expand Down Expand Up @@ -96,7 +91,15 @@ <h2><localize key="usyncmigrate_convertTitle"></localize></h2>
</umb-box-header>
<umb-box-content>
<umb-control-group label="@usyncmigrate_statusSource">
<div class="umb-textstring umb-property-editor">{{vm.migrationStatus.source}}</div>
<div class="flex justify-between">
<div class="umb-textstring umb-property-editor">{{vm.migrationStatus.source}}</div>
<div>
<umb-button action="vm.showValidation = !vm.showValidation"
label-key="usyncmigrate_showValidation"
button-style="link"></umb-button>

</div>
</div>
</umb-control-group>
<umb-control-group label="@usyncmigrate_statusVersion">
<div class="umb-textstring umb-property-editor">{{vm.migrationStatus.version}}</div>
Expand Down Expand Up @@ -131,11 +134,15 @@ <h2><localize key="usyncmigrate_convertTitle"></localize></h2>
</umb-box-content>
</umb-box>

<usync-migration-results results="vm.validation"
action="Validation"
is-valid="vm.sourceValid">
</usync-migration-results>

<div ng-if="!vm.migrationStatus.migrated || vm.showValidation">
<usync-migration-results results="vm.validation"
action="Validation"
is-valid="vm.sourceValid">
</usync-migration-results>
</div>
</div>

<div ng-if="vm.sourceValid && !vm.migrationStatus.migrated">
<div class="flex justify-center flex-column items-center">
<umb-button action="vm.migrate()"
Expand Down Expand Up @@ -189,5 +196,15 @@ <h2><localize key="usyncmigrate_convertTitle"></localize></h2>
</div>

</umb-editor-container>

<umb-editor-footer>
<umb-editor-footer-content-left>
<umb-button ng-if="vm.step != 'init'"
action="vm.goBack()"
label-key="general_back"
icon="icon-arrow-left"
button-style="link"></umb-button>
</umb-editor-footer-content-left>
</umb-editor-footer>
</umb-editor-view>
</div>
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<div>
<div class="flex justify-center">
<h4>[{{vm.folder}}]</h4>
</div>
<umb-box>
<umb-box-content class="flex justify-center">
<div>Working folder:</div><div class="ml2"><strong>{{vm.folder}}</strong></div>
</umb-box-content>
</umb-box>

<div class="usync-group-actions" ng-if="!vm.loading"
ng-class="{'usync-working' : vm.working === true}">


<umb-box class="usync-group-box" ng-repeat="group in vm.groups">
<umb-box-content>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
controller: uSyncMigrationResultController
};

function uSyncMigrationResultController($scope)
function uSyncMigrationResultController($scope, usyncMigrationHelpers)
{
var vm = this;

Expand Down Expand Up @@ -50,6 +50,15 @@
vm.showAll = true;
}
}

vm.copyReport = copyReport;
function copyReport() {
usyncMigrationHelpers.copyResults(vm.results.messages);

}



}

angular.module('umbraco')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
<umb-box-header title="{{vm.action}} Reuslts"
ng-click="vm.showResults = !vm.showResults"
style="cursor: pointer;">
<div class="flex items-center flx-row">
<div class="mr2" ng-if="vm.counts.Success > 0"><i class="icon-check color-green"></i> {{vm.counts.Success}} Passed</div>
<div class="mr2" ng-if="vm.counts.Warning > 0"><i class="icon-alert color-orange"></i> {{vm.counts.Warning}} Warnings</div>
<div class="mr2" ng-if="vm.counts.Error > 0"><i class="icon-wrong color-red"></i> {{vm.counts.Error}} Errors</div>

<i ng-if="!vm.showResults" class="icon icon-navigation-down"></i>
<i ng-if="vm.showResults" class="icon icon-navigation-up"></i>
<div>
<div class="flex items-center flx-row">
<div class="mr2" ng-if="vm.counts.Success > 0"><i class="icon-check color-green"></i> {{vm.counts.Success}} Passed</div>
<div class="mr2" ng-if="vm.counts.Warning > 0"><i class="icon-alert color-orange"></i> {{vm.counts.Warning}} Warnings</div>
<div class="mr2" ng-if="vm.counts.Error > 0"><i class="icon-wrong color-red"></i> {{vm.counts.Error}} Errors</div>
<i ng-if="!vm.showResults" class="icon icon-navigation-down"></i>
<i ng-if="vm.showResults" class="icon icon-navigation-up"></i>
</div>
</div>
</umb-box-header>
<umb-box-content ng-if="vm.showResults">
Expand Down Expand Up @@ -37,6 +38,12 @@
</div>
</div>
</div>

<div class="flex justify-end mt2">
<umb-button action="vm.copyReport()"
label-key="general_copy"
button-style="link"></umb-button>
</div>
</umb-box-content>
</umb-box>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
controller: statusController
};

function statusController($scope, editorService, uSyncMigrationService) {
function statusController($scope, editorService,
uSyncMigrationService) {

var vm = this;

Expand Down Expand Up @@ -104,8 +105,6 @@
vm.plans = result.data;
});
}


}

angular.module('umbraco')
Expand Down
61 changes: 61 additions & 0 deletions uSync.Migrations/wwwroot/uSyncMigrations/migration.helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
(function () {
'use strict';

function migrationHelpers(notificationsService) {

return {
copyResults : copyResults

};

function copyResults(results) {

if (results.length > 0) {
var report = objectKeys(results[0]).toString() + '\n'
}

results.forEach(function (message) {
var arr = objectToArray(message);
report += arr.toString() + '\n';
});

navigator.clipboard.writeText(report);
notificationsService.success('copied', 'report copied to clipboard');

}


function objectKeys(obj) {

var arr = [];
for (let k in obj) {
if (Object.prototype.hasOwnProperty.call(obj, k)) {
if (!k.startsWith('$$')) {
arr.push(k);
}
}
}

return arr;
}

function objectToArray(obj) {
var arr = [];
for (let p in obj) {
if (Object.prototype.hasOwnProperty.call(obj, p)) {
if (!p.startsWith('$$')) {
arr.push(obj[p]);
}
}
}

return arr;

}

}


angular.module('umbraco').factory('usyncMigrationHelpers', migrationHelpers);

})();

0 comments on commit 4c0660a

Please sign in to comment.