Skip to content

Commit

Permalink
Tidy up Content App and Stats pages
Browse files Browse the repository at this point in the history
  • Loading branch information
rickbutterfield authored Nov 12, 2024
1 parent 50e6e53 commit e0478e7
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms" Version="10.8.0" />
<PackageReference Include="Umbraco.Cms" Version="10.8.7" />
<PackageReference Include="Umbraco.TheStarterKit" Version="10.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms" Version="11.0.0" />
<PackageReference Include="Umbraco.Cms" Version="11.5.0" />
<PackageReference Include="Umbraco.TheStarterKit" Version="11.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms" Version="12.0.0" />
<PackageReference Include="Umbraco.Cms" Version="12.3.10" />
<PackageReference Include="Umbraco.TheStarterKit" Version="12.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms" Version="13.0.0" />
<PackageReference Include="Umbraco.Cms" Version="13.5.2" />
<PackageReference Include="Umbraco.TheStarterKit" Version="13.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public enum ResourceGroupType
Scripts,
[Display(Name = "Links")]
Links,
[Display(Name = "Css")]
[Display(Name = "CSS")]
Css,
[Display(Name = "Other")]
Other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ public void Filter(List<PackageManifest> manifests)
Version = assembly.GetName()?.Version?.ToString(3) ?? "0.1.0",
AllowPackageTelemetry = true,
Scripts = new string[] {
// List any Script files
// Urls should start '/App_Plugins/UmbracoCommunitySustainability/' not '/wwwroot/UmbracoCommunitySustainability/', e.g.
"/App_Plugins/UmbracoCommunitySustainability/js/sustainability.resource.js",
"/App_Plugins/UmbracoCommunitySustainability/js/sustainability-stats.controller.js",
"/App_Plugins/UmbracoCommunitySustainability/js/sustainability-overview.controller.js",
"/App_Plugins/UmbracoCommunitySustainability/js/sustainability-content-app.controller.js"
},
Stylesheets = new string[]
{
// List any Stylesheet files
// Urls should start '/App_Plugins/UmbracoCommunitySustainability/' not '/wwwroot/Umbraco.Community.Sustainability/', e.g.
// "/App_Plugins/UmbracoCommunitySustainability/Styles/styles.css"
"/App_Plugins/UmbracoCommunitySustainability/css/sustainability.styles.css"
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

<umb-editor-view footer="false">

<umb-editor-header name="vm.name"
name-locked="true"
hide-alias="true"
hide-description="true"
hide-icon="true">
<umb-editor-header name="vm.name" name-locked="true" hide-alias="true" hide-description="true" hide-icon="true">
</umb-editor-header>

<umb-editor-container>
Expand All @@ -18,50 +14,53 @@

<uui-table-head-cell>
<button style="display: contents; font-weight: bold; padding: var(--uui-size-4) var(--uui-size-5);"
ng-click="vm.sortingHandler('RequestDate')">
ng-click="vm.sortingHandler('RequestDate')">
Last Run Date
<uui-symbol-sort ng-attr-active="{{vm.sortingColumn === 'RequestDate' || undefined}}"
ng-attr-descending="{{vm.sortingDesc || undefined}}">
ng-attr-descending="{{vm.sortingDesc || undefined}}">
</uui-symbol-sort>
</button>
</uui-table-head-cell>

<uui-table-head-cell>
<button style="display: contents; font-weight: bold; padding: var(--uui-size-4) var(--uui-size-5);"
ng-click="vm.sortingHandler('CarbonRating')">
ng-click="vm.sortingHandler('CarbonRating')">
Carbon Rating
<uui-symbol-sort ng-attr-active="{{vm.sortingColumn === 'CarbonRating' || undefined}}"
ng-attr-descending="{{vm.sortingDesc || undefined}}">
ng-attr-descending="{{vm.sortingDesc || undefined}}">
</uui-symbol-sort>
</button>
</uui-table-head-cell>
<uui-table-head-cell>Scripts</uui-table-head-cell>

<uui-table-head-cell>Images</uui-table-head-cell>
<uui-table-head-cell>Styles</uui-table-head-cell>
<uui-table-head-cell>Scripts</uui-table-head-cell>
<uui-table-head-cell>Links</uui-table-head-cell>
<uui-table-head-cell>Css</uui-table-head-cell>
<uui-table-head-cell>Other</uui-table-head-cell>
<uui-table-head-cell style="text-align: right;">
<button style="display: contents; font-weight: bold; padding: var(--uui-size-4) var(--uui-size-5);"
ng-click="vm.sortingHandler('TotalSize')">
ng-click="vm.sortingHandler('TotalSize')">
Page Size
<uui-symbol-sort ng-attr-active="{{vm.sortingColumn === 'TotalSize' || undefined}}"
ng-attr-descending="{{vm.sortingDesc || undefined}}">
ng-attr-descending="{{vm.sortingDesc || undefined}}">
</uui-symbol-sort>
</button>
</uui-table-head-cell>
<uui-table-head-cell style="text-align: right;">
<button style="display: contents; font-weight: bold; padding: var(--uui-size-4) var(--uui-size-5);"
ng-click="vm.sortingHandler('TotalEmissions')">
ng-click="vm.sortingHandler('TotalEmissions')">
CO₂ per page view
<uui-symbol-sort ng-attr-active="{{vm.sortingColumn === 'TotalEmissions' || undefined}}"
ng-attr-descending="{{vm.sortingDesc || undefined}}">
ng-attr-descending="{{vm.sortingDesc || undefined}}">
</uui-symbol-sort>
</button>
</uui-table-head-cell>
</uui-table-head>

<uui-table-row ng-repeat="data in vm.sustainabilityData">
<uui-table-cell>
<a style="text-decoration: underline;" href="/umbraco/#/content/content/edit/{{data.NodeKey}}">{{data.NodeName}}</a>
<a style="text-decoration: underline;"
href="/umbraco/#/content/content/edit/{{data.NodeKey}}">{{data.NodeName}}</a>
</uui-table-cell>

<uui-table-cell>
Expand All @@ -74,16 +73,20 @@
</uui-tag>
</uui-table-cell>

<uui-table-cell>
{{data.Images}}
</uui-table-cell>

<uui-table-cell>
{{data.Scripts}}
</uui-table-cell>

<uui-table-cell>
{{data.Images}}
{{data.Links}}
</uui-table-cell>

<uui-table-cell>
{{data.Styles}}
{{data.Css}}
</uui-table-cell>

<uui-table-cell>
Expand All @@ -103,14 +106,12 @@
</uui-box>

<div ng-if="!vm.loading" class="flex justify-center">
<umb-pagination page-number="vm.pageNumber"
total-pages="vm.totalPages"
on-change="vm.changePageNumber(pageNumber)">
<umb-pagination page-number="vm.pageNumber" total-pages="vm.totalPages"
on-change="vm.changePageNumber(pageNumber)">
</umb-pagination>
</div>

<umb-empty-state ng-if="vm.sustainabilityData.length == 0"
position="center">
<umb-empty-state ng-if="vm.sustainabilityData.length == 0" position="center">
<p>No data to show yet.</p>
</umb-empty-state>
</umb-editor-container>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
angular.module('umbraco').controller('Umbraco.Sustainability.Stats.Controller',
['$scope', '$routeParams', 'navigationService', 'Umbraco.Sustainability.Resources.SustainabilityResource',
angular
.module("umbraco")
.controller("Umbraco.Sustainability.Stats.Controller", [
"$scope",
"$routeParams",
"navigationService",
"Umbraco.Sustainability.Resources.SustainabilityResource",
function ($scope, $routeParams, navigationService, sustainabilityResource) {

navigationService.syncTree({ tree: $routeParams.tree, path: [-1, $routeParams.method], forceReload: false });
navigationService.syncTree({
tree: $routeParams.tree,
path: [-1, $routeParams.method],
forceReload: false,
});

let vm = this;

Expand All @@ -12,7 +20,7 @@ angular.module('umbraco').controller('Umbraco.Sustainability.Stats.Controller',
vm.pageSize = 10;
vm.sustainabilityData = [];
vm.sortingDesc = false;
vm.sortingColumn = 'CarbonRating';
vm.sortingColumn = "CarbonRating";

vm.changePageNumber = changePageNumber;
vm.getTagColour = sustainabilityResource.getTagColour;
Expand All @@ -21,29 +29,46 @@ angular.module('umbraco').controller('Umbraco.Sustainability.Stats.Controller',
init();

function init() {
sustainabilityResource.getOverviewData(vm.pageNumber, vm.pageSize, vm.sortingColumn, vm.sortingDesc).then(function (data) {
vm.sustainabilityData = data.items;
sustainabilityResource
.getOverviewData(
vm.pageNumber,
vm.pageSize,
vm.sortingColumn,
vm.sortingDesc
)
.then(function (data) {
vm.sustainabilityData = data.items;

vm.pageNumber = data.pageNumber;
vm.pageSize = data.pageSize;
vm.totalItems = data.totalItems;
vm.totalPages = data.totalPages;
vm.pageNumber = data.pageNumber;
vm.pageSize = data.pageSize;
vm.totalItems = data.totalItems;
vm.totalPages = data.totalPages;

angular.forEach(vm.sustainabilityData, function (item) {
item.RequestDate = moment(item.RequestDate).format(
"MMM Do YYYY HH:mm:ss"
);
angular.forEach(vm.sustainabilityData, function (item) {
item.RequestDate = moment(item.RequestDate).format(
"MMM Do YYYY HH:mm:ss"
);

item.PageData = JSON.parse(item.PageData);
item.Scripts = item.PageData.ResourceGroups.find(x => x.Name === 'Scripts').Resources.length;
item.Images = item.PageData.ResourceGroups.find(x => x.Name === 'Images').Resources.length;
item.Styles = item.PageData.ResourceGroups.find(x => x.Name === 'Styles').Resources.length;
item.Other = item.PageData.ResourceGroups.find(x => x.Name === 'Other').Resources.length;
item.PageData = JSON.parse(item.PageData);
item.Scripts = item.PageData.ResourceGroups.find(
(x) => x.Name === "Scripts"
)?.Resources?.length;
item.Images = item.PageData.ResourceGroups.find(
(x) => x.Name === "Images"
)?.Resources?.length;
item.Css = item.PageData.ResourceGroups.find(
(x) => x.Name === "Css"
)?.Resources?.length;
item.Links = item.PageData.ResourceGroups.find(
(x) => x.Name === "Links"
)?.Resources?.length;
item.Other = item.PageData.ResourceGroups.find(
(x) => x.Name === "Other"
)?.Resources?.length;
});

vm.loading = false;
});

vm.loading = false;
});
}

function changePageNumber(pageNumber) {
Expand All @@ -54,17 +79,16 @@ angular.module('umbraco').controller('Umbraco.Sustainability.Stats.Controller',
function getTagColour(carbonRating) {
if (carbonRating == "E" || carbonRating == "F") {
return "danger";
}
else if (carbonRating == "D") {
} else if (carbonRating == "D") {
return "warning";
}
else return "positive";
} else return "positive";
}

function sortingHandler(columnName) {
vm.sortingDesc = vm.sortingColumn === columnName ? !vm.sortingDesc : false;
vm.sortingDesc =
vm.sortingColumn === columnName ? !vm.sortingDesc : false;
vm.sortingColumn = columnName;
init();
}
}
},
]);

0 comments on commit e0478e7

Please sign in to comment.