Finally got somewhere with U4-4011 Package installation will require either a full app refresh or we will need to re-lazy load in all of the assets - took ages to get this going, now to get it working when packages have custom screens.

This commit is contained in:
Shannon
2014-01-16 18:33:31 +11:00
parent 076d90ddc4
commit 2b1a43b40a
5 changed files with 100 additions and 34 deletions

View File

@@ -71,31 +71,6 @@ angular.module('umbraco.services')
return deferred.promise;
},
/** Internal method. This is used after installing a package to reload the application assets so we don't have to reload the whole window */
_reloadApplicationAssets: function() {
var deferred = $q.defer();
umbRequestHelper.resourcePromise(
$http.get(umbRequestHelper.getApiUrl("manifestAssetList", "", "")),
'Failed to get manifest list').then(function(data) {
//ok so we have the list of assets, now we'll use yepnope to go get them. Anything that is already loaded should remain loaded
// and this should just load anything that is newly installed.
yepnope({
load: data,
complete: function () {
//resolve the promise
deferred.resolve(data);
}
});
});
return deferred.promise;
},
/**
* @ngdoc method
* @name umbraco.services.assetsService#loadCss

View File

@@ -616,6 +616,7 @@
<Compile Include="Umbraco\TreeInit.aspx.designer.cs">
<DependentUpon>treeInit.aspx</DependentUpon>
</Compile>
<Content Include="Umbraco\ClientRedirect.aspx" />
<Content Include="Umbraco\create.aspx" />
<Content Include="Umbraco\Logout.aspx" />
<Content Include="Umbraco\umbraco.aspx" />

View File

@@ -0,0 +1,23 @@
<%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %>
<%--
This page is required because we cannot reload the angular app with a changed Hash since it just detects the hash and doesn't reload.
So this is used purely for a full reload of an angular app with a changed hash.
--%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Redirecting...</title>
<script type="text/javascript">
var parts = window.location.href.split("?redirectUrl=");
if (parts.length != 2) {
window.location.href = "/";
}
else {
window.location.href = parts[1];
}
</script>
</head>
<body>
<small>Redirecting...</small>
</body>
</html>

View File

@@ -1,6 +1,7 @@
<%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master" CodeBehind="installer.aspx.cs"
<%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master"
AutoEventWireup="True" Inherits="umbraco.presentation.developer.packages.Installer"
Trace="false" ValidateRequest="false" %>
<%@ Import Namespace="umbraco" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<asp:Content ContentPlaceHolderID="head" runat="server">
@@ -261,11 +262,8 @@
<cc1:Pane ID="pane_success" runat="server" Text="Package is installed" Visible="false">
<cc1:PropertyPanel runat="server">
<%--This is a hack to fix this currently until we can replace the installer with a native angular editor
http://issues.umbraco.org/issue/U4-4011
--%>
<script type="text/javascript">
UmbClientMgr.mainWindow().UmbClientMgr._packageInstalled();
//UmbClientMgr.mainWindow().UmbClientMgr._packageInstalled();
</script>
<p>
@@ -282,6 +280,35 @@
</cc1:PropertyPanel>
</cc1:Pane>
<cc1:Pane ID="pane_refresh" runat="server" Text="Browser is reloading" Visible="false">
<cc1:PropertyPanel runat="server">
<div class="alert alert-block">
Please wait while the browser is reloaded...
</div>
<script type="text/javascript">
//This is all a bit zany with double encoding because we have a URL in a hash (#) url part
// but it works and maintains query strings
var refreshQuery = decodeURIComponent("<%=RefreshQueryString%>");
var umbPath = "<%=GlobalSettings.Path%>";
setTimeout(function () {
var mainWindow = UmbClientMgr.mainWindow();
var refreshUrl = mainWindow.location.href +
encodeURIComponent(encodeURIComponent("?" + refreshQuery));
var redirectUrl = umbPath + "/ClientRedirect.aspx?redirectUrl=" + refreshUrl;
mainWindow.location.href = redirectUrl;
}, 2000);
</script>
</cc1:PropertyPanel>
</cc1:Pane>
<input id="tempFile" type="hidden" name="tempFile" runat="server" /><input id="processState"
type="hidden" name="processState" runat="server" />
</cc1:UmbracoPanel>

View File

@@ -36,6 +36,8 @@ namespace umbraco.presentation.developer.packages
private readonly cms.businesslogic.packager.Installer _installer = new cms.businesslogic.packager.Installer();
private string _tempFileName = "";
protected string RefreshQueryString { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
var ex = new Exception();
@@ -234,7 +236,7 @@ namespace umbraco.presentation.developer.packages
}
else
{
Response.Redirect("installer.aspx?installing=finished&dir=" + dir + "&pId=" + packageId.ToString() + "&customUrl=" + Server.UrlEncode(_installer.Url));
Response.Redirect("installer.aspx?installing=refresh&dir=" + dir + "&pId=" + packageId.ToString() + "&customUrl=" + Server.UrlEncode(_installer.Url));
}
break;
case "customInstaller":
@@ -261,9 +263,12 @@ namespace umbraco.presentation.developer.packages
{
//if the custom installer control is empty here (though it should never be because we've already checked for it previously)
//then we should run the normal FinishedAction
PerformFinishedAction(packageId, dir, Request.GetItemAsString("customUrl"));
PerformRefreshAction(packageId, dir, Request.GetItemAsString("customUrl"));
}
break;
case "refresh":
PerformRefreshAction(packageId, dir, Request.GetItemAsString("customUrl"));
break;
case "finished":
PerformFinishedAction(packageId, dir, Request.GetItemAsString("customUrl"));
break;
@@ -295,6 +300,39 @@ namespace umbraco.presentation.developer.packages
PerformPostInstallCleanup(packageId, dir);
}
/// <summary>
/// Perform the 'Refresh' action of the installer
/// </summary>
/// <param name="packageId"></param>
/// <param name="dir"></param>
/// <param name="url"></param>
private void PerformRefreshAction(int packageId, string dir, string url)
{
HideAllPanes();
//create the URL to refresh to
// /umbraco/developer/packages/installer.aspx?installing=finished
// &dir=X:\Projects\Umbraco\Umbraco_7.0\src\Umbraco.Web.UI\App_Data\aef8c41f-63a0-494b-a1e2-10d761647033
// &pId=3
// &customUrl=http:%2f%2four.umbraco.org%2fprojects%2fwebsite-utilities%2fmerchello
RefreshQueryString = Server.UrlEncode(string.Format(
"installing=finished&dir={0}&pId={1}&customUrl={2}",
dir, packageId, url));
pane_refresh.Visible = true;
PerformPostInstallCleanup(packageId, dir);
}
/// <summary>
/// Runs Post refresh actions such reloading the correct tree nodes, etc...
/// </summary>
private void PerformPostRefreshAction()
{
BasePage.Current.ClientTools.ReloadActionNode(true, true);
}
/// <summary>
/// Runs Post install actions such as clearning any necessary cache, reloading the correct tree nodes, etc...
/// </summary>
@@ -302,9 +340,8 @@ namespace umbraco.presentation.developer.packages
/// <param name="dir"></param>
private void PerformPostInstallCleanup(int packageId, string dir)
{
BasePage.Current.ClientTools.ReloadActionNode(true, true);
_installer.InstallCleanUp(packageId, dir);
//clear the tree cache
//clear the tree cache - we'll do this here even though the browser will reload, but just in case it doesn't can't hurt.
ClientTools.ClearClientTreeCache().RefreshTree("packager");
TreeDefinitionCollection.Instance.ReRegisterTrees();
BizLogicAction.ReRegisterActionsAndHandlers();
@@ -339,6 +376,7 @@ namespace umbraco.presentation.developer.packages
pane_installing.Visible = false;
pane_optional.Visible = false;
pane_success.Visible = false;
pane_refresh.Visible = false;
pane_upload.Visible = false;
}
@@ -724,6 +762,8 @@ namespace umbraco.presentation.developer.packages
/// </remarks>
protected global::umbraco.uicontrols.Pane pane_success;
protected global::umbraco.uicontrols.Pane pane_refresh;
/// <summary>
/// bt_viewInstalledPackage control.
/// </summary>