Web Console integration

This commit is contained in:
sergey 2013-05-28 15:50:32 +03:00
parent d933862a05
commit 440af2bf77
25 changed files with 2260 additions and 409 deletions

View file

@ -123,4 +123,20 @@
<data name="SelectWebEngine.Text" xml:space="preserve">
<value>Select web application engine to set up</value>
</data>
<data name="gvInstalledApplicationsEnableConsole.Header" xml:space="preserve">
<value>Web console</value>
</data>
<data name="gvInstalledApplicationsConsoleUrl.Header" xml:space="preserve">
<value>Web console url</value>
</data>
<data name="btnEnable.Text" xml:space="preserve">
<value>Enable console for 1 day</value>
</data>
<data name="btnDisable.Text" xml:space="preserve">
<value>Disable</value>
</data>
<data name="EnableWebConsole.Text" xml:space="preserve">
<value>Enable web console</value>
</data>
</root>

View file

@ -89,10 +89,12 @@ span.ValidationMessageBlock {
<fieldset>
<legend>
<span>Helicon Zoo engine quotas settings</span>
<span>Helicon Zoo settings</span>
</legend>
<div class="FormBody">
<asp:CheckBox runat="server" ID="QuotasEnabled" Text="Enable Quotas"/>
<asp:CheckBox runat="server" ID="QuotasEnabled" Text="Enable hosting plan controls for web engines."/>
<br />
<asp:CheckBox runat="server" ID="WebCosoleEnabled" Text="Enable web console."/>
</div>
</fieldset>

View file

@ -114,6 +114,8 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
// bind 'Enable quotas' checkbox
bool enabled = ES.Services.HeliconZoo.IsEnginesEnabled(PanelRequest.ServiceId);
QuotasEnabled.Checked = !enabled;
WebCosoleEnabled.Checked = ES.Services.HeliconZoo.IsWebCosoleEnabled(PanelRequest.ServiceId);
}
else
{
@ -139,6 +141,8 @@ public partial class HeliconZoo_Settings : WebsitePanelControlBase, IHostingServ
// save switcher
ES.Services.HeliconZoo.SwithEnginesEnabled(PanelRequest.ServiceId, !QuotasEnabled.Checked);
ES.Services.HeliconZoo.SetWebCosoleEnabled(PanelRequest.ServiceId, WebCosoleEnabled.Checked);
}
protected void ClearEngineForm()

View file

@ -1,32 +1,4 @@
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
@ -84,6 +56,15 @@ public partial class HeliconZoo_Settings {
/// </remarks>
protected global::System.Web.UI.WebControls.Label HostingPackagesLoadingError;
/// <summary>
/// EnginesPanel control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel EnginesPanel;
/// <summary>
/// QuotasEnabled control.
/// </summary>
@ -94,13 +75,13 @@ public partial class HeliconZoo_Settings {
protected global::System.Web.UI.WebControls.CheckBox QuotasEnabled;
/// <summary>
/// EnginesPanel control.
/// WebCosoleEnabled control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel EnginesPanel;
protected global::System.Web.UI.WebControls.CheckBox WebCosoleEnabled;
/// <summary>
/// ButtonAddEngine control.

View file

@ -28,12 +28,68 @@
--%>
<p>
<asp:Label runat="server" meta:resourcekey="SelectWebEngine" CssClass="NormalBold"></asp:Label>
<asp:Label ID="lblConsole" runat="server" meta:resourcekey="EnableWebConsole" CssClass="NormalBold"></asp:Label>
</p>
<br />
<%--<asp:GridView id="gvInstalledApplications" runat="server" AutoGenerateColumns="True" AllowPaging="true"
ShowHeader="false" CssSelectorClass="LightGridView" EmptyDataText="gvInstalledApplications.Empty"
>
</asp:GridView>--%>
<asp:GridView ID="gvInstalledApplications" runat="server"
EnableViewState="True" AutoGenerateColumns="false"
ShowHeader="true" CssSelectorClass="NormalGridView"
EmptyDataText="gvVirtualDirectories"
onrowcommand="gvInstalledApplications_RowCommand">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name">
<ItemStyle Width="60%" />
</asp:BoundField>
<asp:TemplateField HeaderText="gvInstalledApplicationsEnableConsole">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Button ID="btnEnable" runat="server"
Text='<%# GetLocalizedString("btnEnable.Text") %>' CssClass="Button1"
CommandArgument='<%# Eval("Name") %>'
CommandName="EnableConsole"
/>
<asp:Button ID="btnDisable" runat="server"
Text='<%# GetLocalizedString("btnDisable.Text") %>' CssClass="Button1"
CommandArgument='<%# Eval("Name") %>'
CommandName="DisableConsole"
Visible= '<%# !IsNullOrEmpty( (string)Eval("ConsoleUrl")) %>'
/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="gvInstalledApplicationsConsoleUrl">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:hyperlink CssClass="MediumBold" NavigateUrl='<%# GetConsoleFullUrl((string)Eval("ConsoleUrl")) %>' runat="server" ID="lnkAppDetails" ToolTip='<%# Eval("ConsoleUrl") %>' Target="_blank">
<%# Eval("ConsoleUrl") %>
</asp:hyperlink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<p>
<asp:Label runat="server" meta:resourcekey="SelectWebEngine" CssClass="NormalBold"></asp:Label>
</p>
<br />
<asp:GridView id="gvApplications" runat="server" AutoGenerateColumns="False" AllowPaging="true"
ShowHeader="false" CssSelectorClass="LightGridView" EmptyDataText="gvApplications" OnRowCommand="gvApplications_RowCommand"
ShowHeader="false" CssSelectorClass="LightGridView" EmptyDataText="There are no applications" OnRowCommand="gvApplications_RowCommand"
OnPageIndexChanging="gvApplications_PageIndexChanging">
<Columns>
<asp:TemplateField HeaderText="gvApplicationsApplication">

View file

@ -32,6 +32,7 @@ namespace WebsitePanel.Portal
ViewState["WebSitePackageId"] = site.PackageId;
BindEngines(site);
BindInstalledApplications();
BindApplications();
}
@ -42,12 +43,17 @@ namespace WebsitePanel.Portal
ES.Services.HeliconZoo.GetAllowedHeliconZooQuotasForPackage(site.PackageId);
Array.Sort(allowedEngineArray, new ShortHeliconZooEngineComparer());
// get enabled engines for this site
// get enabled engines for this site from applicationHost.config
string[] enabledEngineNames = ES.Services.HeliconZoo.GetEnabledEnginesForSite(site.SiteId, site.PackageId);
ViewState["EnabledEnginesNames"] = enabledEngineNames;
//console allowed in applicationHost.config
ViewState["IsZooWebConsoleEnabled"] = enabledEngineNames.Contains("console", StringComparer.OrdinalIgnoreCase);
//EnabledEnginesList.DataSource = enabledEngineNames;
//EnabledEnginesList.DataBind();
List<ShortHeliconZooEngine> allowedEngines = new List<ShortHeliconZooEngine>(allowedEngineArray);
@ -55,18 +61,41 @@ namespace WebsitePanel.Portal
foreach (ShortHeliconZooEngine engine in allowedEngines)
{
engine.Name = engine.Name.Replace("HeliconZoo.", "");
engine.Enabled = enabledEngineNames.Contains(engine.Name, StringComparer.OrdinalIgnoreCase);
//engine.Enabled = enabledEngineNames.Contains(engine.Name, StringComparer.OrdinalIgnoreCase);
if (engine.Name == "console")
{
//console allowed in hosting plan
ViewState["IsZooWebConsoleEnabled"] = engine.Enabled;
}
}
ViewState["AllowedEngines"] = allowedEngines;
//AllowedEnginesList.DataSource = allowedEngines;
//AllowedEnginesList.DataBind();
}
private void BindInstalledApplications()
{
if ((bool) ViewState["IsZooWebConsoleEnabled"])
{
gvInstalledApplications.DataSource = ES.Services.WebServers.GetZooApplications(PanelRequest.ItemID);
gvInstalledApplications.DataBind();
}
else
{
gvInstalledApplications.Visible = false;
lblConsole.Visible = false;
}
}
private void BindApplications()
{
WebAppGalleryHelpers helper = new WebAppGalleryHelpers();
GalleryApplicationsResult result = helper.GetGalleryApplications("ZooTemplate", PanelSecurity.PackageId);
List<GalleryApplication> applications = result.Value as List<GalleryApplication>;
@ -77,19 +106,34 @@ namespace WebsitePanel.Portal
{
foreach (GalleryApplication application in applications)
{
foreach (string keyword in application.Keywords)
{
bool appAlreadyAdded = false;
if (keyword.StartsWith("ZooEngine", StringComparison.OrdinalIgnoreCase))
{
string appEngine = keyword.Substring("ZooEngine".Length);
foreach (ShortHeliconZooEngine engine in allowedEngines)
{
if (!engine.Enabled)
{
continue; //skip
}
if (string.Equals(appEngine, engine.KeywordedName, StringComparison.OrdinalIgnoreCase))
{
filteredApplications.Add(application);
appAlreadyAdded = true;
break;
}
}
if (appAlreadyAdded)
{
break;
}
}
}
}
@ -195,5 +239,44 @@ namespace WebsitePanel.Portal
return "~/Default.aspx?" + String.Join("&", url.ToArray());
}
protected void gvInstalledApplications_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EnableConsole")
{
UpdatedAllowedEngines();
string appName = e.CommandArgument.ToString();
ES.Services.WebServers.SetZooConsoleEnabled(PanelRequest.ItemID, appName);
BindInstalledApplications();
}
if (e.CommandName == "DisableConsole")
{
UpdatedAllowedEngines();
string appName = e.CommandArgument.ToString();
ES.Services.WebServers.SetZooConsoleDisabled(PanelRequest.ItemID, appName);
BindInstalledApplications();
}
}
protected bool IsNullOrEmpty(string value)
{
return string.IsNullOrEmpty(value);
}
protected string GetConsoleFullUrl(string consoleUrl)
{
WebSite site = ES.Services.WebServers.GetWebSite(PanelRequest.ItemID);
return "http://" + site.Name + consoleUrl;
}
}
}

View file

@ -26,6 +26,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@ -40,6 +41,24 @@ namespace WebsitePanel.Portal {
public partial class WebSitesHeliconZooControl {
/// <summary>
/// lblConsole control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblConsole;
/// <summary>
/// gvInstalledApplications control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.GridView gvInstalledApplications;
/// <summary>
/// gvApplications control.
/// </summary>