First work on System Settings
This commit is contained in:
@@ -47,14 +47,25 @@ namespace Swarmops.Logic.Security
|
||||
Financials,
|
||||
|
||||
/// <summary>
|
||||
/// Access to personal details about people in org
|
||||
/// Access to send various correspondence, w/o necessarily knowing the recipients
|
||||
/// </summary>
|
||||
Correspondence,
|
||||
|
||||
/// <summary>
|
||||
/// Access to personal details about people in an organization
|
||||
/// </summary>
|
||||
PersonData,
|
||||
|
||||
/// <summary>
|
||||
/// Access to change organization's fundamental operating parameters
|
||||
/// </summary>
|
||||
Administration
|
||||
Administration,
|
||||
|
||||
/// <summary>
|
||||
/// Access to this Swarmops installation and its operating parameters
|
||||
/// </summary>
|
||||
System
|
||||
|
||||
}
|
||||
|
||||
public enum AccessType
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="Menu5_Administration_OrganizationClusters" xml:space="preserve">
|
||||
<value>Organization Clusters</value>
|
||||
</data>
|
||||
<data name="Menu5_Admin_SystemSettings" xml:space="preserve">
|
||||
<value>System-Wide Settings</value>
|
||||
</data>
|
||||
<data name="Menu5_Communications" xml:space="preserve">
|
||||
<value>Communications</value>
|
||||
</data>
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AjaxTextBox.ascx.cs" Inherits="Swarmops.Frontend.Controls.v5.Base.AjaxTextBox" %>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
|
||||
var _initVal_<%=this.TextInput.ClientID%> = $('#<%=this.TextInput.ClientID%>').val();
|
||||
|
||||
$('#<%=this.TextInput.ClientID%>').blur(function () {
|
||||
|
||||
var currentValue = $('#<%=this.TextInput.ClientID%>').val();
|
||||
|
||||
if (currentValue != _initVal_<%=this.TextInput.ClientID%>) {
|
||||
var jsonData = {};
|
||||
jsonData.newString = currentValue;
|
||||
jsonData.cookie = '<%=this.Cookie%>';
|
||||
|
||||
// The AJAX call expects the following function prototype:
|
||||
//
|
||||
// [WebMethod]
|
||||
// public static AjaxTextBox.AjaxResult FunctionName (string newString, string cookie);
|
||||
//
|
||||
// The page must include IncludedControls.JsonParameters and IncludedControls.ColorAnimation among its script.
|
||||
//
|
||||
// The AJAX return value expects this structure:
|
||||
//
|
||||
// msg.d {
|
||||
// int ResultCode; // 0 - Unknown, 1 - Success, 2 - [Value was] Changed, 3 - Invalid [value], 4 - NoPermission
|
||||
// string NewData; // string as it should be displayed after change - overrides input and current value
|
||||
// };
|
||||
|
||||
$(this).css('background-color', '#FFFFE0');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<%=this.AjaxCallbackUrl%>",
|
||||
data: $.toJSON(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: $.proxy(function (msg) {
|
||||
if (msg.d.ResultCode == 3 || msg.d.ResultCode == 4) { // Invalid or NoPermission
|
||||
if (msg.d.DisplayMessage != null)
|
||||
{
|
||||
alertify.error (msg.d.DisplayMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
alertify.error("There was an error attempting to set this value."); // TODO: Localize
|
||||
}
|
||||
$(this).css('background-color', '#FFA0A0');
|
||||
} else { // msg.d.Result should be Changed or Success here
|
||||
if (msg.d.DisplayMessage != null)
|
||||
{
|
||||
alertify.log (msg.d.DisplayMessage);
|
||||
}
|
||||
$(this).css('background-color', '#E0FFE0');
|
||||
_initVal_<%=this.TextInput.ClientID%> = msg.d.NewData;
|
||||
}
|
||||
$(this).val(modalAccountInitialBalance);
|
||||
$(this).animate({ backgroundColor: "#FFFFFF" }, 250);
|
||||
}, this),
|
||||
error: $.proxy(function (msg) {
|
||||
alertify.error("There was an error calling the server to set the new value. Is the server reachable?"); // TODO: Localize
|
||||
$(this).val (_initVal_<%=this.TextInput.ClientID%>);
|
||||
$(this).css('background-color', '#FFA0A0');
|
||||
$(this).animate({ backgroundColor: "#FFFFFF" }, 250);
|
||||
}, this)
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<asp:TextBox ID="TextInput" runat="server" />
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace Swarmops.Frontend.Controls.v5.Base
|
||||
{
|
||||
public partial class AjaxTextBox : System.Web.UI.UserControl
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return this.TextInput.Text; }
|
||||
set { this.TextInput.Text = value; }
|
||||
}
|
||||
|
||||
public void Focus()
|
||||
{
|
||||
this.TextInput.Focus();
|
||||
}
|
||||
|
||||
public string Cookie { set; get; }
|
||||
public string AjaxCallbackUrl { set; get; }
|
||||
|
||||
// Ajax result codes and classes
|
||||
|
||||
public const int CodeUnknown = 0;
|
||||
public const int CodeSuccess = 1;
|
||||
public const int CodeChanged = 2;
|
||||
public const int CodeInvalid = 3;
|
||||
public const int CodeNoPermission = 4;
|
||||
|
||||
public class AjaxResult
|
||||
{
|
||||
public int ResultCode { get; set; }
|
||||
public string DisplayMessage { get; set; } // may be empty
|
||||
public string NewData { get; set; }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -401,6 +401,22 @@
|
||||
<Children />
|
||||
</MainMenuItem>
|
||||
|
||||
<MainMenuItem>
|
||||
<UserLevel>4</UserLevel>
|
||||
<Type>Separator</Type>
|
||||
<Children />
|
||||
</MainMenuItem>
|
||||
|
||||
<MainMenuItem>
|
||||
<ResourceKey>Admin_SystemSettings</ResourceKey>
|
||||
<UserLevel>4</UserLevel>
|
||||
<Permissions />
|
||||
<ImageUrl>iconshock-battery-drill</ImageUrl>
|
||||
<NavigateUrl>/Pages/v5/Admin/Settings.aspx</NavigateUrl>
|
||||
<Type>Link</Type>
|
||||
<Children />
|
||||
</MainMenuItem>
|
||||
|
||||
<MainMenuItem>
|
||||
<UserLevel>1</UserLevel>
|
||||
<Type>Separator</Type>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="Settings.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.Settings" %>
|
||||
<%@ Register tagPrefix="Swarmops5" tagName="AjaxTextBox" src="~/Controls/v5/Base/AjaxTextBox.ascx" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#divTabs').tabs();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</asp:Content>
|
||||
|
||||
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
|
||||
<div id="divTabs" class="easyui-tabs" data-options="tabWidth:70,tabHeight:70">
|
||||
<div title="<img src='/Images/Icons/iconshock-mail-open-64px.png' />">
|
||||
<h2>Correspondence transmission settings</h2>
|
||||
<div class="entryFields">
|
||||
<Swarmops5:AjaxTextBox runat="server" ID="TextSmtpServer" Cookie="Smtp" AjaxCallbackUrl="/Pages/v5/Admin/Settings.aspx" />​<br/>
|
||||
</div>
|
||||
<div class="entryLabels">
|
||||
SMTP server (user:pass@host:port)<br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
||||
|
||||
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
|
||||
</asp:Content>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Swarmops.Logic;
|
||||
using Swarmops.Logic.Support;
|
||||
using Swarmops.Logic.Security;
|
||||
|
||||
namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
{
|
||||
public partial class Settings : PageV5Base
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
// HACK: The organization part must be removed once proper access control is in place
|
||||
this.PageAccessRequired = new Access(this.CurrentOrganization, AccessAspect.System, AccessType.Write);
|
||||
this.IncludedControlsUsed = IncludedControl.JsonParameters | IncludedControl.SwitchButton;
|
||||
this.EasyUIControlsUsed = EasyUIControl.Tabs;
|
||||
|
||||
if (!Page.IsPostBack)
|
||||
{
|
||||
this.TextSmtpServer.Text = Persistence.Key["SmtpServer"];
|
||||
string smtpPort = Persistence.Key["SmtpPort"];
|
||||
if (smtpPort != "25")
|
||||
{
|
||||
this.TextSmtpServer.Text += ":" + smtpPort;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user