Skip to content

Commit

Permalink
Code to get the content for the addons page.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed May 3, 2019
1 parent 74d1378 commit 79f754e
Show file tree
Hide file tree
Showing 23 changed files with 365 additions and 28 deletions.
2 changes: 1 addition & 1 deletion uSync8.BackOffice/App_Plugins/uSync8/addons.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"intro": "Get more out of uSync",
"intro": "Get more out of uSync (Local)",
"expansions": [
{
"name": "uSync Content Edition",
Expand Down
2 changes: 1 addition & 1 deletion uSync8.BackOffice/App_Plugins/uSync8/package.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"javascript": [
"~/app_plugins/uSync8/backoffice/uSync8/uSyncDashboardController.js",
"~/app_plugins/uSync8/settings/settingsController.js",
"~/app_plugins/uSync8/settings/expansionController.js",
"~/app_plugins/uSync8/settings/uSyncController.js",


"~/app_plugins/uSync8/uSyncService.js",
"~/app_plugins/uSync8/uSyncHub.js",
"~/app_plugins/uSync8/changeDialogController.js"
Expand Down
45 changes: 39 additions & 6 deletions uSync8.BackOffice/App_Plugins/uSync8/settings/expansion.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
<umb-box>
<umb-box-header title="Expansion Packs"></umb-box-header>
<umb-box-content>
This is the placeholder for the Expansion packs page, things like uSync.Snapshots, and Audit.
</umb-box-content>
</umb-box>
<div ng-controller="uSyncExpansionController as vm">
<umb-load-indicator ng-if="vm.loading"></umb-load-indicator>
<div ng-if="!vm.loading">
<umb-box>
<umb-box-header title="Expansion Packs"></umb-box-header>
<umb-box-content>
{{vm.addons.intro}}
</umb-box-content>
</umb-box>

<div class="usync-boxes">
<umb-box class="usync-box" ng-repeat="expansion in vm.addons.expansions"
ng-class="{'usync-box-inprogress' : expansion.state === 'working'}">
<umb-box-header title="{{expansion.name}}"
description="{{expansion.summary}}"></umb-box-header>
<umb-box-content>
<div class="usync-box-icon">
<i class="icon {{expansion.icon}}"></i>
</div>
<div>
{{expansion.description}}
</div>
<div ng-if="expansion.state !== 'working'">
<a href="{{expansion.url}}" target="_blank">More Info</a>
</div>
<div class="usync-box-nuget" ng-if="expansion.state !== 'working'">
<a href="https://nuget.org/packages/{{expansion.package}}">
install-package {{expansion.package}}
<span ng-if="expansion.state === 'preview'">pre</span>
</a>
</div>
<div ng-if="expansion.state === 'working'" class="text-success">
Coming Soon!
</div>
</umb-box-content>
</umb-box>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(function () {

'use strict';

function expansionController($scope, uSync8DashboardService) {

var vm = this;
vm.loading = true;
///

uSync8DashboardService.getAddOnSplash()
.then(function (result) {
vm.addons = result.data;
vm.loading = false;
});
}

angular.module('umbraco')
.controller('uSyncExpansionController', expansionController);
})();
8 changes: 7 additions & 1 deletion uSync8.BackOffice/App_Plugins/uSync8/uSyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
importItems: importItems,
saveSettings: saveSettings,
getLoadedHandlers: getLoadedHandlers,
getAddOns: getAddOns
getAddOns: getAddOns,
getAddOnSplash: getAddOnSplash
};

return service;
Expand All @@ -46,6 +47,11 @@
return $http.get(serviceRoot + 'GetAddOns');
}

function getAddOnSplash() {
return $http.get(serviceRoot + 'GetAddOnSplash');
}


function report(clientId) {
return $http.post(serviceRoot + 'report', { clientId: clientId });
}
Expand Down
49 changes: 49 additions & 0 deletions uSync8.BackOffice/App_Plugins/uSync8/usync.css
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,52 @@
.usync-not-animated .bar {
transition: none;
}


.usync-boxes {
display: grid;
grid-gap: 0;
grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
margin-left: -10px;
margin-right: -10px;
}

.usync-box {
max-width: 100%;
padding: 10px;
margin: 10px;
box-sizing: border-box;
}

.usync-box-icon {
font-size: 40px;
}

.usync-box .umb-box-content {
display: flex;
flex-direction: column;
align-items: center;
}

.usync-box .umb-box-content > * {
padding: 10px 0;
}

.usync-box-nuget {
width: 100%;
text-align: left;
}

.usync-box-nuget a {
background-color: black;
display: block;
color: #fff;
font-family: monospace;
padding: 10px 10px;
border-radius: 4px;
margin: 10px 0;
}

.usync-box-inprogress {
opacity: 0.5;
}
1 change: 1 addition & 0 deletions uSync8.BackOffice/Configuration/BackOfficeConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public uSyncSettings LoadSettings()
settings.UseGuidNames = node.Element("UseGuidFilenames").ValueOrDefault(false);
settings.BatchSave = node.Element("BatchSave").ValueOrDefault(false);
settings.ReportDebug = node.Element("ReportDebug").ValueOrDefault(false);
settings.AddOnPing = node.Element("AddOnPing").ValueOrDefault(true);

var handlerConfig = node.Element("Handlers");

Expand Down
2 changes: 2 additions & 0 deletions uSync8.BackOffice/Configuration/uSyncSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class uSyncSettings
public List<HandlerSettings> Handlers { get; set; } = new List<HandlerSettings>();

public bool ReportDebug { get; set; } = false;

public bool AddOnPing { get; set; } = true;
}

}
68 changes: 67 additions & 1 deletion uSync8.BackOffice/Controllers/uSyncDashboardApiController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
using Umbraco.Web.WebApi.Filters;
Expand Down Expand Up @@ -119,6 +125,66 @@ public void SaveSettings(uSyncSettings settings)
Config.SaveSettings(settings, true);
}

[HttpGet]
public JObject GetAddOnSplash()
{
try
{
return JsonConvert.DeserializeObject<JObject>(GetContent());
}
catch(Exception ex)
{
// we need to just fail :(
}

return new JObject();
}

private string GetContent()
{
if (!Config.Settings.AddOnPing) return GetLocal();

var cachedContent = AppCaches.RuntimeCache.GetCacheItem<string>("usync_addon");
if (!string.IsNullOrEmpty(cachedContent)) return cachedContent;

var remote = "https://jumoo.co.uk/usync/addon/";
try
{
using (var client = new WebClient())
{
var content = client.DownloadString(remote);
if (!string.IsNullOrWhiteSpace(content))
{
AppCaches.RuntimeCache.InsertCacheItem<string>("usync_addon", () => content);
}

return content;
}
}
catch
{
return GetLocal();
}
}

private string GetLocal()
{
try
{
var localFile = IOHelper.MapPath("~/App_Plugins/uSync8/addons.json");
if (File.Exists(localFile))
{
return File.ReadAllText(localFile);
}
}
catch
{
}

return "{}";
}

[HttpGet]
public AddOnInfo GetAddOns()
{
var addOnInfo = new AddOnInfo();
Expand Down
4 changes: 2 additions & 2 deletions uSync8.BackOffice/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.0.0.042919")]
[assembly: AssemblyFileVersion("8.0.0.042919")]
[assembly: AssemblyVersion("8.0.0.030519")]
[assembly: AssemblyFileVersion("8.0.0.030519")]
2 changes: 1 addition & 1 deletion uSync8.BackOffice/uSync.Backoffice.Core.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<description>Just the core dll's from uSync (for extension development purposes)</description>
<summary></summary>
<releaseNotes>
8.0 - Beta release for Umbraco 8
8.0 - Release for Umbraco 8
</releaseNotes>
<dependencies>
<dependency id="uSync.Core" version="$depends$"/>
Expand Down
2 changes: 1 addition & 1 deletion uSync8.BackOffice/uSync.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<description>Database syncing for Umbraco</description>
<summary></summary>
<releaseNotes>
8.0 - Beta release for Umbraco 8
8.0 - Release for Umbraco 8
</releaseNotes>
<dependencies>
<dependency id="uSync.Core" version="$depends$"/>
Expand Down
2 changes: 2 additions & 0 deletions uSync8.BackOffice/uSync8.BackOffice.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,15 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="App_Plugins\uSync8\addons.json" />
<None Include="App_Plugins\uSync8\package.manifest" />
<Content Include="App_Plugins\uSync8\backoffice\uSync8\dashboard.html" />
<Content Include="App_Plugins\uSync8\backoffice\uSync8\uSyncDashboardController.js" />
<Content Include="App_Plugins\uSync8\changeDialog.html" />
<Content Include="App_Plugins\uSync8\changeDialogController.js" />
<Content Include="App_Plugins\uSync8\settings\default.html" />
<Content Include="App_Plugins\uSync8\settings\expansion.html" />
<Content Include="App_Plugins\uSync8\settings\expansionController.js" />
<Content Include="App_Plugins\uSync8\settings\settings.html" />
<Content Include="App_Plugins\uSync8\settings\settingsController.js" />
<Content Include="App_Plugins\uSync8\settings\uSyncController.js" />
Expand Down
4 changes: 2 additions & 2 deletions uSync8.ContentEdition/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.0.0.043019")]
[assembly: AssemblyFileVersion("8.0.0.043019")]
[assembly: AssemblyVersion("8.0.0.030519")]
[assembly: AssemblyFileVersion("8.0.0.030519")]
2 changes: 1 addition & 1 deletion uSync8.ContentEdition/uSync.ContentEdition.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<description>Database syncing for Umbraco Content, Media and Dictionary Items</description>
<summary></summary>
<releaseNotes>
8.0 - Beta release for Umbraco 8
8.0 - Release for Umbraco 8
</releaseNotes>
<dependencies>
<dependency id="uSync" version="$depends$" />
Expand Down
4 changes: 2 additions & 2 deletions uSync8.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.0.0.042919")]
[assembly: AssemblyFileVersion("8.0.0.042919")]
[assembly: AssemblyVersion("8.0.0.030519")]
[assembly: AssemblyFileVersion("8.0.0.030519")]
50 changes: 50 additions & 0 deletions uSync8.Site/App_Plugins/uSync8/addons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"intro": "Get more out of uSync (Local)",
"expansions": [
{
"name": "uSync Content Edition",
"summary": "Add content to your sync",
"icon": "icon-document",
"description": "Add Content, Media, Dictionary Items and Domain Settings to your uSync syncs",
"url": "https://jumoo.co.uk/usync/content/",
"package": "uSync.ContentEdition",
"state": "preview"
},
{
"name": "uSync Snapshots",
"summary": "Moment in time snapshots of your umbraco state",
"icon": "icon-flash",
"description": "Take moment in time snapshots of your umbraco site, and combine and apply them to target sites",
"url": "https://jumoo.co.uk/usync/snapshots/",
"package": "uSync.Snapshots",
"state": "working"
},
{
"name": "uSync Audit",
"summary": "Keep track of things",
"icon": "icon-ordered-list",
"description": "Log and audit the changes to your doctypes, datatypes and more, with links to slack",
"url": "https://jumoo.co.uk/usync/audit",
"package": "uSync.Audit",
"state": "working"
},
{
"name": "uSync People Edition",
"summary": "Users and Members",
"icon": "icon-user",
"description": "Sync user and membership accounts",
"url": "https://jumoo.co.uk/usync/people",
"package": "uSync.PeopleEdition",
"state": "working"
},
{
"name": "More soon",
"summary": "We're always adding options",
"icon": "icon-add",
"description": "Keep an eye out for new uSync expansion packages",
"url": "https://jumoo.co.uk/usync/expansion",
"package": " ",
"state": "working"
}
]
}
2 changes: 1 addition & 1 deletion uSync8.Site/App_Plugins/uSync8/package.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"javascript": [
"~/app_plugins/uSync8/backoffice/uSync8/uSyncDashboardController.js",
"~/app_plugins/uSync8/settings/settingsController.js",
"~/app_plugins/uSync8/settings/expansionController.js",
"~/app_plugins/uSync8/settings/uSyncController.js",


"~/app_plugins/uSync8/uSyncService.js",
"~/app_plugins/uSync8/uSyncHub.js",
"~/app_plugins/uSync8/changeDialogController.js"
Expand Down
Loading

0 comments on commit 79f754e

Please sign in to comment.