From db7709c7baf2f17fbfe32c1f3a5c1fb08ebcf9aa Mon Sep 17 00:00:00 2001 From: Kevin Jump Date: Wed, 26 Jun 2019 14:00:14 +0100 Subject: [PATCH] Add Component views for common UI --- .../uSync8/components/uSyncProgressView.html | 27 +++++ .../uSync8/components/uSyncReportView.html | 77 +++++++++++++ .../components/uSyncReportViewComponent.js | 63 +++++++++++ .../components/usyncProgressViewComponent.js | 30 +++++ .../App_Plugins/uSync8/package.manifest | 5 +- .../App_Plugins/uSync8/settings/default.html | 104 +----------------- uSync8.BackOffice/uSync8.BackOffice.csproj | 4 + .../uSync8/components/uSyncProgressView.html | 27 +++++ .../uSync8/components/uSyncReportView.html | 77 +++++++++++++ .../components/uSyncReportViewComponent.js | 63 +++++++++++ .../components/usyncProgressViewComponent.js | 30 +++++ .../App_Plugins/uSync8/package.manifest | 5 +- .../App_Plugins/uSync8/settings/default.html | 104 +----------------- 13 files changed, 418 insertions(+), 198 deletions(-) create mode 100644 uSync8.BackOffice/App_Plugins/uSync8/components/uSyncProgressView.html create mode 100644 uSync8.BackOffice/App_Plugins/uSync8/components/uSyncReportView.html create mode 100644 uSync8.BackOffice/App_Plugins/uSync8/components/uSyncReportViewComponent.js create mode 100644 uSync8.BackOffice/App_Plugins/uSync8/components/usyncProgressViewComponent.js create mode 100644 uSync8.Site/App_Plugins/uSync8/components/uSyncProgressView.html create mode 100644 uSync8.Site/App_Plugins/uSync8/components/uSyncReportView.html create mode 100644 uSync8.Site/App_Plugins/uSync8/components/uSyncReportViewComponent.js create mode 100644 uSync8.Site/App_Plugins/uSync8/components/usyncProgressViewComponent.js diff --git a/uSync8.BackOffice/App_Plugins/uSync8/components/uSyncProgressView.html b/uSync8.BackOffice/App_Plugins/uSync8/components/uSyncProgressView.html new file mode 100644 index 00000000..45413a79 --- /dev/null +++ b/uSync8.BackOffice/App_Plugins/uSync8/components/uSyncProgressView.html @@ -0,0 +1,27 @@ +
+
+
+ +
{{handler.Name}}
+
+
{{handler.Changes}}
+
+
+
+
+
+
+

{{vm.status.Message}}

+ {{vm.update.Message}} +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/uSync8.BackOffice/App_Plugins/uSync8/components/uSyncReportView.html b/uSync8.BackOffice/App_Plugins/uSync8/components/uSyncReportView.html new file mode 100644 index 00000000..de1edf2a --- /dev/null +++ b/uSync8.BackOffice/App_Plugins/uSync8/components/uSyncReportView.html @@ -0,0 +1,77 @@ +
+ +
+
+
{{vm.action}}
+
{{vm.countChanges(vm.results)}} changes across {{vm.results.length}} items
+
+ +
+ +
+
+
+
+
+
+ Type +
+
+ Name +
+
+ Change +
+
+ Message +
+
+
+
+
+
+
+
+ + + +
+
+ {{vm.getTypeName(result.ItemType)}} +
+
+ {{result.Name}} +
+
+ {{result.Change}} +
+
+ {{result.Message}} +
+
+ +
+ ({{result.Details.length}} items) +
+
+
+
+
+
+
+

No Changes

+
+
+
+
\ No newline at end of file diff --git a/uSync8.BackOffice/App_Plugins/uSync8/components/uSyncReportViewComponent.js b/uSync8.BackOffice/App_Plugins/uSync8/components/uSyncReportViewComponent.js new file mode 100644 index 00000000..59f39848 --- /dev/null +++ b/uSync8.BackOffice/App_Plugins/uSync8/components/uSyncReportViewComponent.js @@ -0,0 +1,63 @@ +(function () { + 'use strict'; + + var uSyncReportViewComponent = { + templateUrl: Umbraco.Sys.ServerVariables.application.applicationPath + 'App_Plugins/uSync8/Components/uSyncReportView.html', + bindings: { + action: '<', + results: '<' + }, + controllerAs: 'vm', + controller: uSyncReportViewController + }; + + function uSyncReportViewController($scope, editorService) { + + var vm = this; + + vm.showChange = showChange; + vm.getTypeName = getTypeName; + vm.countChanges = countChanges; + vm.openDetail = openDetail; + vm.showAll = false; + + ///////// + + function showChange(change) { + return vm.showAll || (change !== 'NoChange' && change !== 'Removed'); + } + + function getTypeName(typeName) { + var umbType = typeName.substring(0, typeName.indexOf(',')); + return umbType.substring(umbType.lastIndexOf('.') + 1); + } + + function countChanges(changes) { + var count = 0; + angular.forEach(changes, function (val, key) { + if (val.Change !== 'NoChange') { + count++; + } + }); + + return count; + } + + function openDetail(item) { + + var options = { + item: item, + title: 'uSync Change', + view: "/App_Plugins/uSync8/changeDialog.html", + close: function () { + editorService.close(); + } + }; + editorService.open(options); + } + + } + + angular.module('umbraco') + .component('usyncReportView', uSyncReportViewComponent); +})(); \ No newline at end of file diff --git a/uSync8.BackOffice/App_Plugins/uSync8/components/usyncProgressViewComponent.js b/uSync8.BackOffice/App_Plugins/uSync8/components/usyncProgressViewComponent.js new file mode 100644 index 00000000..ebebe67b --- /dev/null +++ b/uSync8.BackOffice/App_Plugins/uSync8/components/usyncProgressViewComponent.js @@ -0,0 +1,30 @@ +(function () { + 'use strict'; + + var uSyncProgressViewComponent = { + templateUrl: Umbraco.Sys.ServerVariables.application.applicationPath + 'App_Plugins/uSync8/Components/uSyncProgressView.html', + bindings: { + status: '<', + update: '<', + hideLabels: '<' + }, + controllerAs: 'vm', + controller: uSyncProgressViewController + }; + + function uSyncProgressViewController() { + var vm = this; + + vm.calcPercentage = calcPercentage; + + function calcPercentage(status) { + if (status !== undefined) { + return (100 * status.Count) / status.Total; + } + return 1; + } + } + + angular.module('umbraco') + .component('usyncProgressView', uSyncProgressViewComponent); +})(); \ No newline at end of file diff --git a/uSync8.BackOffice/App_Plugins/uSync8/package.manifest b/uSync8.BackOffice/App_Plugins/uSync8/package.manifest index 2081eecf..07e0045f 100644 --- a/uSync8.BackOffice/App_Plugins/uSync8/package.manifest +++ b/uSync8.BackOffice/App_Plugins/uSync8/package.manifest @@ -7,7 +7,10 @@ "~/app_plugins/uSync8/uSyncService.js", "~/app_plugins/uSync8/uSyncHub.js", - "~/app_plugins/uSync8/changeDialogController.js" + "~/app_plugins/uSync8/changeDialogController.js", + + "~/app_plugins/uSync8/components/uSyncReportViewComponent.js", + "~/app_plugins/uSync8/components/uSyncProgressViewComponent.js" ], "css": [ "~/app_plugins/uSync8/usync.css" diff --git a/uSync8.BackOffice/App_Plugins/uSync8/settings/default.html b/uSync8.BackOffice/App_Plugins/uSync8/settings/default.html index 6e11adba..414b601c 100644 --- a/uSync8.BackOffice/App_Plugins/uSync8/settings/default.html +++ b/uSync8.BackOffice/App_Plugins/uSync8/settings/default.html @@ -30,106 +30,14 @@ -
-
- -
{{handler.Name}}
-
{{handler.Changes}}
-
-
-
-
-
-

{{vm.status.Message}}

- {{vm.update.Message}} -
-
-
-
-
-
-
-
+
- -
-
-
{{vm.action}}
-
{{vm.countChanges(vm.results)}} changes across {{vm.results.length}} items
-
- -
- -
-
-
-
-
-
- Type -
-
- Name -
-
- Change -
-
- Message -
-
-
-
-
-
-
-
- - - -
-
- {{vm.getTypeName(result.ItemType)}} -
-
- {{result.Name}} -
-
- {{result.Change}} -
-
- {{result.Message}} -
-
- -
- ({{result.Details.length}} items) -
-
-
-
-
-
-
-

No Changes

-
-
-
+
+ +
\ No newline at end of file diff --git a/uSync8.BackOffice/uSync8.BackOffice.csproj b/uSync8.BackOffice/uSync8.BackOffice.csproj index 17412d5a..fe7ac5e3 100644 --- a/uSync8.BackOffice/uSync8.BackOffice.csproj +++ b/uSync8.BackOffice/uSync8.BackOffice.csproj @@ -281,6 +281,10 @@ + + + + diff --git a/uSync8.Site/App_Plugins/uSync8/components/uSyncProgressView.html b/uSync8.Site/App_Plugins/uSync8/components/uSyncProgressView.html new file mode 100644 index 00000000..2031c0e0 --- /dev/null +++ b/uSync8.Site/App_Plugins/uSync8/components/uSyncProgressView.html @@ -0,0 +1,27 @@ +
+
+
+ +
{{handler.Name}}
+
+
{{handler.Changes}}
+
+
+
+
+
+
+

{{vm.status.Message}}

+ {{vm.update.Message}} +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/uSync8.Site/App_Plugins/uSync8/components/uSyncReportView.html b/uSync8.Site/App_Plugins/uSync8/components/uSyncReportView.html new file mode 100644 index 00000000..4228416f --- /dev/null +++ b/uSync8.Site/App_Plugins/uSync8/components/uSyncReportView.html @@ -0,0 +1,77 @@ +
+ +
+
+
{{vm.action}}
+
{{vm.countChanges(vm.results)}} changes across {{vm.results.length}} items
+
+ +
+ +
+
+
+
+
+
+ Type +
+
+ Name +
+
+ Change +
+
+ Message +
+
+
+
+
+
+
+
+ + + +
+
+ {{vm.getTypeName(result.ItemType)}} +
+
+ {{result.Name}} +
+
+ {{result.Change}} +
+
+ {{result.Message}} +
+
+ +
+ ({{result.Details.length}} items) +
+
+
+
+
+
+
+

No Changes

+
+
+
+
\ No newline at end of file diff --git a/uSync8.Site/App_Plugins/uSync8/components/uSyncReportViewComponent.js b/uSync8.Site/App_Plugins/uSync8/components/uSyncReportViewComponent.js new file mode 100644 index 00000000..16c41e04 --- /dev/null +++ b/uSync8.Site/App_Plugins/uSync8/components/uSyncReportViewComponent.js @@ -0,0 +1,63 @@ +(function () { + 'use strict'; + + var uSyncReportViewComponent = { + templateUrl: Umbraco.Sys.ServerVariables.application.applicationPath + 'App_Plugins/uSync8/Components/uSyncReportView.html', + bindings: { + action: '<', + results: '<' + }, + controllerAs: 'vm', + controller: uSyncReportViewController + }; + + function uSyncReportViewController($scope, editorService) { + + var vm = this; + + vm.showChange = showChange; + vm.getTypeName = getTypeName; + vm.countChanges = countChanges; + vm.openDetail = openDetail; + vm.showAll = false; + + ///////// + + function showChange(change) { + return vm.showAll || (change !== 'NoChange' && change !== 'Removed'); + } + + function getTypeName(typeName) { + var umbType = typeName.substring(0, typeName.indexOf(',')); + return umbType.substring(umbType.lastIndexOf('.') + 1); + } + + function countChanges(changes) { + var count = 0; + angular.forEach(changes, function (val, key) { + if (val.Change !== 'NoChange') { + count++; + } + }); + + return count; + } + + function openDetail(item) { + + var options = { + item: item, + title: 'uSync Change', + view: "/App_Plugins/uSync8/changeDialog.html", + close: function () { + editorService.close(); + } + }; + editorService.open(options); + } + + } + + angular.module('umbraco') + .component('usyncReportView', uSyncReportViewComponent); +})(); \ No newline at end of file diff --git a/uSync8.Site/App_Plugins/uSync8/components/usyncProgressViewComponent.js b/uSync8.Site/App_Plugins/uSync8/components/usyncProgressViewComponent.js new file mode 100644 index 00000000..4ba0fcd2 --- /dev/null +++ b/uSync8.Site/App_Plugins/uSync8/components/usyncProgressViewComponent.js @@ -0,0 +1,30 @@ +(function () { + 'use strict'; + + var uSyncProgressViewComponent = { + templateUrl: Umbraco.Sys.ServerVariables.application.applicationPath + 'App_Plugins/uSync8/Components/uSyncProgressView.html', + bindings: { + status: '<', + update: '<', + hideLabels: '<' + }, + controllerAs: 'vm', + controller: uSyncProgressViewController + }; + + function uSyncProgressViewController() { + var vm = this; + + vm.calcPercentage = calcPercentage; + + function calcPercentage(status) { + if (status !== undefined) { + return (100 * status.Count) / status.Total; + } + return 1; + } + } + + angular.module('umbraco') + .component('usyncProgressView', uSyncProgressViewComponent); +})(); \ No newline at end of file diff --git a/uSync8.Site/App_Plugins/uSync8/package.manifest b/uSync8.Site/App_Plugins/uSync8/package.manifest index 2081eecf..07e0045f 100644 --- a/uSync8.Site/App_Plugins/uSync8/package.manifest +++ b/uSync8.Site/App_Plugins/uSync8/package.manifest @@ -7,7 +7,10 @@ "~/app_plugins/uSync8/uSyncService.js", "~/app_plugins/uSync8/uSyncHub.js", - "~/app_plugins/uSync8/changeDialogController.js" + "~/app_plugins/uSync8/changeDialogController.js", + + "~/app_plugins/uSync8/components/uSyncReportViewComponent.js", + "~/app_plugins/uSync8/components/uSyncProgressViewComponent.js" ], "css": [ "~/app_plugins/uSync8/usync.css" diff --git a/uSync8.Site/App_Plugins/uSync8/settings/default.html b/uSync8.Site/App_Plugins/uSync8/settings/default.html index 1ddfe739..085e032a 100644 --- a/uSync8.Site/App_Plugins/uSync8/settings/default.html +++ b/uSync8.Site/App_Plugins/uSync8/settings/default.html @@ -30,106 +30,14 @@ -
-
- -
{{handler.Name}}
-
{{handler.Changes}}
-
-
-
-
-
-

{{vm.status.Message}}

- {{vm.update.Message}} -
-
-
-
-
-
-
-
+
- -
-
-
{{vm.action}}
-
{{vm.countChanges(vm.results)}} changes across {{vm.results.length}} items
-
- -
- -
-
-
-
-
-
- Type -
-
- Name -
-
- Change -
-
- Message -
-
-
-
-
-
-
-
- - - -
-
- {{vm.getTypeName(result.ItemType)}} -
-
- {{result.Name}} -
-
- {{result.Change}} -
-
- {{result.Message}} -
-
- -
- ({{result.Details.length}} items) -
-
-
-
-
-
-
-

No Changes

-
-
-
+
+ +
\ No newline at end of file