Skip to content

Commit

Permalink
use relative paths in angular #28
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Jun 10, 2019
1 parent bf004a9 commit 752564a
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
'name': 'uSync',
'alias': 'uSync',
'icon': 'icon-infinity',
'view': '/App_plugins/usync8/settings/default.html',
'view': Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + '/usync8/settings/default.html',
'active': true
},
{
'name': 'Settings',
'alias': 'settings',
'icon': 'icon-settings',
'view': '/App_Plugins/uSync8/settings/settings.html'
'view': Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + '/uSync8/settings/settings.html'
},
{
'name': 'Add ons',
'alias': 'expansion',
'icon': 'icon-box',
'view': '/App_plugins/usync8/settings/expansion.html'
'view': Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + '/usync8/settings/expansion.html'
}
]
};
Expand Down
4 changes: 2 additions & 2 deletions uSync8.BackOffice/App_Plugins/uSync8/uSyncHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
function uSyncHub($rootScope, $q, assetsService) {

var scripts = [
'/umbraco/lib/signalr/jquery.signalR.js',
'/umbraco/backoffice/signalr/hubs'];
Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/lib/signalr/jquery.signalR.js',
Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/backoffice/signalr/hubs'];

var resource = {
initHub: initHub
Expand Down
2 changes: 1 addition & 1 deletion uSync8.BackOffice/App_Plugins/uSync8/uSyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

function uSyncServiceController($http) {

var serviceRoot = 'backoffice/uSync/uSyncDashboardApi/';
var serviceRoot = Umbraco.Sys.ServerVariables.uSync.uSyncService;

var service = {
getSettings: getSettings,
Expand Down
5 changes: 5 additions & 0 deletions uSync8.BackOffice/Controllers/uSyncDashboardApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public uSyncDashboardApiController(
uSyncConfig.Reloaded += BackOfficeConfig_Reloaded;
}

public bool GetApi()
{
return true;
}

private void BackOfficeConfig_Reloaded(uSyncSettings settings)
{
this.settings = settings;
Expand Down
27 changes: 26 additions & 1 deletion uSync8.BackOffice/uSyncBackofficeComponent.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Web;
using Umbraco.Web.JavaScript;

using uSync8.BackOffice.Configuration;
using uSync8.BackOffice.Controllers;
using uSync8.BackOffice.Services;
using uSync8.BackOffice.SyncHandlers;

Expand Down Expand Up @@ -38,6 +47,8 @@ public uSyncBackofficeComponent(

public void Initialize()
{
ServerVariablesParser.Parsing += ServerVariablesParser_Parsing;

if (runtimeState.Level <= RuntimeLevel.Run)
{
logger.Info<uSyncBackofficeComponent>("Umbraco is not in Run Mode {0} so uSync is not going to run", runtimeState.Level);
Expand All @@ -54,9 +65,23 @@ public void Initialize()
{
InitBackOffice();
}

}

private void ServerVariablesParser_Parsing(object sender, Dictionary<string, object> e)
{
if (HttpContext.Current == null)
throw new InvalidOperationException("This method requires that an HttpContext be active");

var urlHelper = new UrlHelper(new RequestContext(new HttpContextWrapper(HttpContext.Current), new RouteData()));

e.Add("uSync", new Dictionary<string, object>
{
{ "uSyncService", urlHelper.GetUmbracoApiServiceBaseUrl<uSyncDashboardApiController>(controller => controller.GetApi()) }
});
}

private void InitBackOffice()
private void InitBackOffice()
{
if (globalSettings.ExportAtStartup || (globalSettings.ExportOnSave && !syncFileService.RootExists(globalSettings.RootFolder)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
'name': 'uSync',
'alias': 'uSync',
'icon': 'icon-infinity',
'view': '/App_plugins/usync8/settings/default.html',
'view': Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + '/usync8/settings/default.html',
'active': true
},
{
'name': 'Settings',
'alias': 'settings',
'icon': 'icon-settings',
'view': '/App_Plugins/uSync8/settings/settings.html'
'view': Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + '/uSync8/settings/settings.html'
},
{
'name': 'Add ons',
'alias': 'expansion',
'icon': 'icon-box',
'view': '/App_plugins/usync8/settings/expansion.html'
'view': Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + '/usync8/settings/expansion.html'
}
]
};
Expand Down
4 changes: 2 additions & 2 deletions uSync8.Site/App_Plugins/uSync8/uSyncHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
function uSyncHub($rootScope, $q, assetsService) {

var scripts = [
'/umbraco/lib/signalr/jquery.signalR.js',
'/umbraco/backoffice/signalr/hubs'];
Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/lib/signalr/jquery.signalR.js',
Umbraco.Sys.ServerVariables.umbracoSettings.umbracoPath + '/backoffice/signalr/hubs'];

var resource = {
initHub: initHub
Expand Down
2 changes: 1 addition & 1 deletion uSync8.Site/App_Plugins/uSync8/uSyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

function uSyncServiceController($http) {

var serviceRoot = 'backoffice/uSync/uSyncDashboardApi/';
var serviceRoot = Umbraco.Sys.ServerVariables.uSync.uSyncService;

var service = {
getSettings: getSettings,
Expand Down

0 comments on commit 752564a

Please sign in to comment.