More work on Signup
This commit is contained in:
@@ -19,10 +19,10 @@
|
||||
<link href='https://fonts.googleapis.com/css?family=Arimo:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css' />
|
||||
|
||||
<!-- page title -->
|
||||
<title>Swarmops - Signup</title>
|
||||
<title><%=Organization.Name %> - Signup</title>
|
||||
|
||||
<link href="/Style/style-v5.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../v5/Init/WizardStyle.css" rel="stylesheet" type="text/css" />
|
||||
<link href="WizardStyle.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<!-- initialize all modal popups -->
|
||||
<script language="javascript" type="text/javascript">
|
||||
@@ -55,482 +55,84 @@
|
||||
<asp:ScriptManager runat="server" ID="ScriptManagerBlahblah" />
|
||||
<script type="text/javascript">
|
||||
|
||||
var databaseInitComplete = false;
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#<%=this.TextCredentialsReadDatabase.ClientID %>').focusout(function () {
|
||||
var dbValue = $('#<%=this.TextCredentialsReadDatabase.ClientID %>').val();
|
||||
$('#<%=this.TextCredentialsWriteDatabase.ClientID %>').val(dbValue);
|
||||
$('#<%=this.TextCredentialsAdminDatabase.ClientID %>').val(dbValue);
|
||||
});
|
||||
|
||||
$('#<%=this.TextCredentialsReadServer.ClientID %>').focusout(function () {
|
||||
var serverValue = $('#<%=this.TextCredentialsReadServer.ClientID %>').val();
|
||||
$('#<%=this.TextCredentialsWriteServer.ClientID %>').val(serverValue);
|
||||
$('#<%=this.TextCredentialsAdminServer.ClientID %>').val(serverValue);
|
||||
});
|
||||
// Initialize Smart Wizard
|
||||
$('#wizard').smartWizard({
|
||||
transitionEffect: 'fade',
|
||||
keyNavigation: false,
|
||||
onLeaveStep: leaveAStepCallback,
|
||||
onFinish: onFinishCallback
|
||||
});
|
||||
|
||||
// Initialize Smart Wizard
|
||||
$('#wizard').smartWizard({
|
||||
transitionEffect: 'fade',
|
||||
keyNavigation: false,
|
||||
onLeaveStep: leaveAStepCallback,
|
||||
onFinish: onFinishCallback
|
||||
});
|
||||
function leaveAStepCallback(obj) {
|
||||
if (disableNext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function leaveAStepCallback(obj) {
|
||||
if (disableNext) {
|
||||
return false;
|
||||
var stepNum = obj.attr('rel');
|
||||
return validateStep(stepNum);
|
||||
}
|
||||
|
||||
var stepNum = obj.attr('rel');
|
||||
return validateStep(stepNum);
|
||||
}
|
||||
function onFinishCallback(obj) {
|
||||
// $('#LOGINBUTTONID').click();
|
||||
}
|
||||
|
||||
function onFinishCallback(obj) {
|
||||
$('#<%=this.ButtonLogin.ClientID %>').click();
|
||||
}
|
||||
function validateStep(stepNumber) {
|
||||
var isValid = true; // assume true and set false underway
|
||||
|
||||
function validateStep(stepNumber) {
|
||||
var isValid = false;
|
||||
var textBoxes;
|
||||
var loop;
|
||||
var fieldContents;
|
||||
var hostName = $('#<%=this.TextServerName.ClientID %>').val();
|
||||
var hostAddress = $('#<%=this.TextServerAddress.ClientID %>').val();
|
||||
if (stepNumber == 1) {
|
||||
isValid = true;
|
||||
// Blah
|
||||
|
||||
if (stepNumber == 1) {
|
||||
// Validate Hostname, Host Address
|
||||
} else if (stepNumber == 2) {
|
||||
isValid = true; // assume true, make false as we go
|
||||
|
||||
if (hostName && hostName.length > 0 && hostAddress && hostAddress.length > 0) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/VerifyHostNameAndAddress",
|
||||
data: "{'name': '" + escape(hostName) + "', 'address': '" + escape(hostAddress) + "'}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
async: false, // blocks until function returns - race conditions otherwise
|
||||
success: function (msg) {
|
||||
if (msg.d == true) {
|
||||
isValid = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else if (stepNumber == 3) {
|
||||
isValid = true;
|
||||
|
||||
} else if (stepNumber == 4) {
|
||||
isValid = true; // assume true, make false as we go
|
||||
|
||||
} else if (stepNumber == 5) {
|
||||
// If we get here, we're always good
|
||||
|
||||
isValid = true;
|
||||
}
|
||||
|
||||
|
||||
if (!isValid) {
|
||||
$('#<%=this.TextServerName.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
$('#<%=this.TextServerAddress.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
} else {
|
||||
$('#<%=this.TextServerName.ClientID %>').css('background-image', "none");
|
||||
$('#<%=this.TextServerAddress.ClientID %>').css('background-image', "none");
|
||||
}
|
||||
|
||||
if (isValid) { // Validate writability of config file
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/IsConfigurationFileWritable",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
async: false, // blocks until function returns - race conditions otherwise
|
||||
success: function (msg) {
|
||||
if (msg.d == true) {
|
||||
|
||||
// Yes, config is writable. Hide "unwritable" div, show "writable" div, all is nice
|
||||
$('#DivDatabaseUnwritable').css('display', 'none');
|
||||
$('#DivDatabaseRootConfig').css('display', 'inline');
|
||||
setTimeout('$("#TextMysqlServerHost").focus();', 250);
|
||||
//$('#<%=this.TextCredentialsReadDatabase.ClientID %>').focus();
|
||||
} else {
|
||||
// Config is NOT writable. Keep the error on-screen and keep re-checking every two seconds.
|
||||
|
||||
setTimeout('recheckConfigurationWritability();', 5000); // 5s until first re-check
|
||||
DisableNext();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
else if (stepNumber == 2) {
|
||||
isValid = true; // assume true, make false as we go
|
||||
|
||||
textBoxes = [];
|
||||
|
||||
if (autoConfigMode) {
|
||||
textBoxes = ["TextMysqlServerHost", "TextMysqlRootPassword"];
|
||||
} else {
|
||||
textBoxes = [
|
||||
"<%=this.TextCredentialsReadDatabase.ClientID %>", "<%=this.TextCredentialsReadServer.ClientID %>", "<%=this.TextCredentialsReadUser.ClientID %>", "<%=this.TextCredentialsReadPassword.ClientID %>",
|
||||
"<%=this.TextCredentialsWriteDatabase.ClientID %>", "<%=this.TextCredentialsWriteServer.ClientID %>", "<%=this.TextCredentialsWriteUser.ClientID %>", "<%=this.TextCredentialsWritePassword.ClientID %>",
|
||||
"<%=this.TextCredentialsAdminDatabase.ClientID %>", "<%=this.TextCredentialsAdminServer.ClientID %>", "<%=this.TextCredentialsAdminUser.ClientID %>", "<%=this.TextCredentialsAdminPassword.ClientID %>"
|
||||
];
|
||||
}
|
||||
|
||||
for (loop = 0; loop < textBoxes.length; loop++) {
|
||||
fieldContents = $('#' + textBoxes[loop]).val();
|
||||
|
||||
if (fieldContents && fieldContents.length > 0) {
|
||||
$('#' + textBoxes[loop]).css('background-image', "none");
|
||||
} else {
|
||||
$('#' + textBoxes[loop]).css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify database credentials are good and permissions correct
|
||||
|
||||
if (isValid) {
|
||||
DisableNext(); // block Next during synchro call - it may take a while
|
||||
// also, won't get re-enabled no matter the outcome
|
||||
|
||||
var jsonData = {};
|
||||
jsonData.serverName = hostName;
|
||||
jsonData.ipAddress = hostAddress;
|
||||
|
||||
if (autoConfigMode) {
|
||||
jsonData.mysqlHostName = $('#TextMysqlServerHost').val();
|
||||
jsonData.rootPassword = $('#TextMysqlRootPassword').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/CreateDatabaseFromRoot",
|
||||
data: $.toJSON(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
async: false, // blocks until function returns - race conditions otherwise
|
||||
success: function (msg) {
|
||||
if (msg.d != true) {
|
||||
|
||||
// Credentials problem.
|
||||
$('#TextMysqlRootPassword, #TextMysqlServerHost').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
EnableNext();
|
||||
isValid = false;
|
||||
} else {
|
||||
// re-enable Next only on exit of step 3
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
jsonData.readDatabase = $('#<%=this.TextCredentialsReadDatabase.ClientID %>').val();
|
||||
jsonData.readServer = $('#<%=this.TextCredentialsReadServer.ClientID %>').val();
|
||||
jsonData.readUser = $('#<%=this.TextCredentialsReadUser.ClientID %>').val();
|
||||
jsonData.readPassword = $('#<%=this.TextCredentialsReadPassword.ClientID %>').val();
|
||||
jsonData.writeDatabase = $('#<%=this.TextCredentialsWriteDatabase.ClientID %>').val();
|
||||
jsonData.writeServer = $('#<%=this.TextCredentialsWriteServer.ClientID %>').val();
|
||||
jsonData.writeUser = $('#<%=this.TextCredentialsWriteUser.ClientID %>').val();
|
||||
jsonData.writePassword = $('#<%=this.TextCredentialsWritePassword.ClientID %>').val();
|
||||
jsonData.adminDatabase = $('#<%=this.TextCredentialsAdminDatabase.ClientID %>').val();
|
||||
jsonData.adminServer = $('#<%=this.TextCredentialsAdminServer.ClientID %>').val();
|
||||
jsonData.adminUser = $('#<%=this.TextCredentialsAdminUser.ClientID %>').val();
|
||||
jsonData.adminPassword = $('#<%=this.TextCredentialsAdminPassword.ClientID %>').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/FirstCredentialsTest",
|
||||
data: $.toJSON(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
async: false, // blocks until function returns - race conditions otherwise
|
||||
success: function (msg) {
|
||||
if (msg.d.AllPermissionsOk != true) {
|
||||
|
||||
// We have a permissions problem. Block further progress and display the problem.
|
||||
updatePermissionsAnalysisDisplay(msg.d);
|
||||
$('#DivDatabaseManualConfig').fadeOut(400, 'swing', function () { $('#DivDatabasePermissionProblem').fadeIn(200); });
|
||||
setTimeout('recheckDatabasePermissionsAnalysis();', 5000); // 5s until first re-check
|
||||
isValid = false;
|
||||
} else {
|
||||
// re-enable Next only on exit of step 3
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isValid) {
|
||||
$('#DivProgressDatabase').progressbar({ value: 0, max: 100 });
|
||||
setTimeout('updateInitProgressBar();', 1000);
|
||||
setTimeout('updateInitProgressMessage();', 1500);
|
||||
beginInitDatabase();
|
||||
DisableNext();
|
||||
}
|
||||
|
||||
}
|
||||
else if (stepNumber == 3) {
|
||||
isValid = databaseInitComplete;
|
||||
|
||||
if (isValid) {
|
||||
$('#<%=this.TextFirstUserName.ClientID %>').focus();
|
||||
}
|
||||
}
|
||||
else if (stepNumber == 4) {
|
||||
isValid = true; // assume true, make false as we go
|
||||
|
||||
// Check that all four boxes are filled in, and that Password1 and Password2 equal each other.
|
||||
|
||||
textBoxes = ["<%=this.TextFirstUserName.ClientID %>", "<%=this.TextFirstUserMail.ClientID %>", "<%=this.TextFirstUserPassword1.ClientID %>", "<%=this.TextFirstUserPassword2.ClientID %>"];
|
||||
|
||||
for (loop = 0; loop < textBoxes.length; loop++) {
|
||||
fieldContents = $('#' + textBoxes[loop]).val();
|
||||
|
||||
if (fieldContents && fieldContents.length > 0) {
|
||||
$('#' + textBoxes[loop]).css('background-image', "none");
|
||||
} else {
|
||||
$('#' + textBoxes[loop]).css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
// As we exit the zero-length check, fieldContents contains Password2.Text, so we can compare it to Password1.Text right away.
|
||||
|
||||
if (isValid) {
|
||||
if (fieldContents != $('#<%=this.TextFirstUserPassword1.ClientID %>').val()) {
|
||||
$('#<%=this.TextFirstUserPassword1.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
$('#<%=this.TextFirstUserPassword2.ClientID %>').css('background-image', "url('/Images/Icons/iconshock-cross-12px.png')").css('background-position', 'right center').css('background-repeat', 'no-repeat');
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
// If all is valid, create the first user.
|
||||
|
||||
if (isValid) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/CreateFirstUser",
|
||||
data: "{'name': '" + escape($('#<%=this.TextFirstUserName.ClientID %>').val()) + "', 'mail': '" + escape($('#<%=this.TextFirstUserMail.ClientID %>').val()) + "', 'password': '" + escape($('#<%=this.TextFirstUserPassword1.ClientID %>').val()) + "'}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
// Don't care
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (stepNumber == 5) {
|
||||
// If we get here, we're always good
|
||||
|
||||
isValid = true;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
}); // end of document.ready
|
||||
|
||||
var disableNext = false;
|
||||
var stopRechecking = false;
|
||||
var disableNext = false;
|
||||
|
||||
function DisableNext() {
|
||||
$('a.buttonNext').addClass("buttonDisabled");
|
||||
disableNext = true;
|
||||
}
|
||||
|
||||
function EnableNext() {
|
||||
$('a.buttonNext').removeClass("buttonDisabled");
|
||||
disableNext = false;
|
||||
}
|
||||
|
||||
function ClickNext() {
|
||||
$('a.buttonNext').click();
|
||||
}
|
||||
|
||||
|
||||
function ReturnToCredentials() {
|
||||
stopRechecking = true;
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/ResetTestCredentials",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
$('#DivDatabasePermissionProblem').fadeOut(200, 'swing', function () { $('#DivDatabaseManualConfig').fadeIn(200); EnableNext(); });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function recheckConfigurationWritability() {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/IsConfigurationFileWritable",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
if (msg.d == true) {
|
||||
|
||||
// Yes, config is writable. Hide "unwritable" div, show "config" div, all is nice
|
||||
$('#DivDatabaseUnwritable').css('display', 'none');
|
||||
$('#DivDatabaseManualConfig').fadeIn('slow');
|
||||
setTimeout('$("#TextMysqlServerHost").focus();', 250);
|
||||
EnableNext();
|
||||
} else {
|
||||
// Config is NOT writable. Keep the error on-screen and keep re-checking every two seconds.
|
||||
|
||||
setTimeout('recheckConfigurationWritability();', 2000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateInitProgressBar() {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/GetInitProgress",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
if (msg.d > 99) {
|
||||
$("#DivProgressDatabase .ui-progressbar-value").animate(
|
||||
{
|
||||
width: "100%"
|
||||
}, { queue: false });
|
||||
databaseInitComplete = true;
|
||||
EnableNext(); // re-enable - it has been disabled throughout Init
|
||||
ClickNext();
|
||||
} else {
|
||||
// We're not done yet. Keep the progress bar on-screen and keep re-checking.
|
||||
|
||||
if (msg.d == 1) {
|
||||
$('#DivProgressDatabase').progressbar("value", msg.d);
|
||||
} else {
|
||||
$("#DivProgressDatabase .ui-progressbar-value").animate(
|
||||
{
|
||||
width: msg.d + "%"
|
||||
}, { queue: false });
|
||||
}
|
||||
|
||||
setTimeout('updateInitProgressBar();', 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateInitProgressMessage() {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/GetInitProgressMessage",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
$('#SpanInitProgressMessage').text(msg.d);
|
||||
|
||||
if (msg.d == 'Complete.') {
|
||||
|
||||
// We're done. Do nothing, the progress bar updater will do this step.
|
||||
|
||||
} else {
|
||||
|
||||
// We're not done yet. Keep the progress bar on-screen and keep re-checking.
|
||||
setTimeout('updateInitProgressMessage();', 500);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function recheckDatabasePermissionsAnalysis() {
|
||||
|
||||
if (stopRechecking) {
|
||||
stopRechecking = false;
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/RecheckDatabasePermissions",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function (msg) {
|
||||
updatePermissionsAnalysisDisplay(msg.d);
|
||||
if (!msg.d.AllPermissionsOk) {
|
||||
setTimeout('recheckDatabasePermissionsAnalysis();', 2000);
|
||||
} else {
|
||||
EnableNext();
|
||||
ClickNext();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updatePermissionsAnalysisDisplay(testResults) {
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionReadCredentialCanLogin', testResults.ReadCredentialsCanLogin);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionReadCredentialCanSelect', testResults.ReadCredentialsCanSelect);
|
||||
updateOneDatabasePermissionExpectedFailure('CellPermissionReadCredentialCanExecute', testResults.ReadCredentialsCanExecute);
|
||||
updateOneDatabasePermissionExpectedFailure('CellPermissionReadCredentialCanAdmin', testResults.ReadCredentialsCanAdmin);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionWriteCredentialCanLogin', testResults.WriteCredentialsCanLogin);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionWriteCredentialCanSelect', testResults.WriteCredentialsCanSelect);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionWriteCredentialCanExecute', testResults.WriteCredentialsCanExecute);
|
||||
updateOneDatabasePermissionExpectedFailure('CellPermissionWriteCredentialCanAdmin', testResults.WriteCredentialsCanAdmin);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionAdminCredentialCanLogin', testResults.AdminCredentialsCanLogin);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionAdminCredentialCanSelect', testResults.AdminCredentialsCanSelect);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionAdminCredentialCanExecute', testResults.AdminCredentialsCanExecute);
|
||||
updateOneDatabasePermissionExpectedSuccess('CellPermissionAdminCredentialCanAdmin', testResults.AdminCredentialsCanAdmin);
|
||||
}
|
||||
|
||||
function updateOneDatabasePermissionExpectedSuccess(cellName, result) {
|
||||
if (result) {
|
||||
$('#' + cellName).html('YES <img src="/Images/Icons/iconshock-greentick-16px.png" />');
|
||||
} else {
|
||||
$('#' + cellName).html('NO <img src="/Images/Icons/iconshock-redcross-16px.png" />');
|
||||
}
|
||||
}
|
||||
|
||||
function updateOneDatabasePermissionExpectedFailure(cellName, result) {
|
||||
if (result) {
|
||||
$('#' + cellName).html('YES <img src="/Images/Icons/iconshock-redcross-16px.png" />');
|
||||
} else {
|
||||
$('#' + cellName).html('NO <img src="/Images/Icons/iconshock-greentick-16px.png" />');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function beginInitDatabase() {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Init/Default.aspx/InitDatabase",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function () {
|
||||
function DisableNext() {
|
||||
$('a.buttonNext').addClass("buttonDisabled");
|
||||
disableNext = true;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function goManualCredentials() {
|
||||
autoConfigMode = false;
|
||||
$('#DivDatabaseRootConfig').css('display', 'none');
|
||||
$('#DivDatabaseManualConfig').fadeIn('slow');
|
||||
setTimeout('$("#<%=this.TextCredentialsReadDatabase.ClientID %>").focus();', 250);
|
||||
function EnableNext() {
|
||||
$('a.buttonNext').removeClass("buttonDisabled");
|
||||
disableNext = false;
|
||||
}
|
||||
|
||||
var autoConfigMode = true;
|
||||
function ClickNext() {
|
||||
$('a.buttonNext').click();
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Main menu, dynamically constructed -->
|
||||
|
||||
<div class="center980px">
|
||||
<div class="currentuserinfo"><div style="background-image:url('/Images/Icons/iconshock-user-16px.png');background-repeat:no-repeat;padding-left:16px;float:left"><asp:Label ID="LabelCurrentUserName" runat="server" /> | </div><div style="background-image:url('/Images/Icons/iconshock-workchair-16px.png');background-repeat:no-repeat;padding-left:17px;float:left"><asp:Label ID="LabelCurrentOrganizationName" runat="server" /> | </div><div style="background-image:url('/Images/Icons/iconshock-gamepad-16px.png');background-repeat:no-repeat;padding-left:20px;float:left"><asp:Label ID="LabelPreferences" runat="server" /> | </div><asp:Image ID="ImageCultureIndicator" runat="server" ImageUrl="~/Images/Flags/uk-24px.png" /></div>
|
||||
<div class="logoimage"><a href="/"><img style="border:none" src="/Images/Logo-Stock.png" alt="Swarmops Logo" /></a></div>
|
||||
<div class="break"></div>
|
||||
<div class="topmenu">
|
||||
<div class="searchbox"><asp:TextBox ID="SearchBox" runat="server" /></div>
|
||||
<div class="topmenu" style="margin-top: -4px; padding-left: 30px; padding-top: 12px; color: white; font-family: Ubuntu; font-weight: 300; font-size: 24px; letter-spacing: 1px">
|
||||
SIGNING UP FOR <%= Organization.Name.ToUpperInvariant() %>
|
||||
</div>
|
||||
|
||||
<div class="mainbar">
|
||||
@@ -578,130 +180,23 @@ function goManualCredentials() {
|
||||
</a></li>
|
||||
</ul>
|
||||
<div id="step-1">
|
||||
<h2>Welcome to OrganizationName</h2>
|
||||
<p>This is the organization's custom welcome text. It is set in Admin / Org Settings.</p> <asp:Label runat="server" ID="LabelTest" />
|
||||
|
||||
<div class="entryLabelsAdmin" style="width:250px">
|
||||
What is this server's /etc/hostname?<br />
|
||||
What is this server's internal IP?<br />
|
||||
What is your favorite color?
|
||||
</div>
|
||||
<div class="entryFieldsAdmin">
|
||||
<asp:TextBox CssClass="textinput" ID="TextServerName" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextServerAddress" runat="server" /> <br />
|
||||
<asp:DropDownList ID="DropFavoriteColor" runat="server" /> <br />
|
||||
</div>
|
||||
<h2>Welcome to <%= Organization.Name %></h2>
|
||||
<p>This is the organization's custom welcome text. It has not yet been written; it is set in Admin / Org Settings.</p>
|
||||
</div>
|
||||
<div id="step-2">
|
||||
<div id="DivDatabaseUnwritable">
|
||||
<h2>Fix File Permissions</h2>
|
||||
<asp:Image ImageUrl="~/Images/Icons/iconshock-cross-96px.png" ID="FailWriteConfig" runat="server" ImageAlign="Left" /><p>The bad news is that we can't write to the configuration file. This is fairly normal for a new installation. The good news is that you can fix that, so we can continue installing. Please open a shell to the Swarmops server and execute the following commands:</p><br/>
|
||||
<p><strong>cd /etc/swarmops<br/>sudo chown www-data:www-data database.config</strong></p>
|
||||
<p>The installation will continue when it detects that these steps have been taken.</p>
|
||||
</div>
|
||||
<div id="DivDatabasePermissionProblem" style="display:none">
|
||||
<h2>Fix Database Permissions</h2>
|
||||
<asp:Image ImageUrl="~/Images/Icons/iconshock-cross-96px.png" ID="Image1" runat="server" ImageAlign="Left" /><p>There seems to be an error with the database credentials, or more likely, the permissions for those credentials. <strong>Edit the database permissions until you have green ticks in all boxes below.</strong> (If you made a mistake filling in the database credentials, you can <a href="javascript:ReturnToCredentials();">return to entering credentials</a>.)</p>
|
||||
<p>The installation will continue when it detects this has been corrected, and the table below will update continuously as you change database permissions.</p>
|
||||
<table>
|
||||
<thead><tr><th> </th><th>Can login?</th><th>Can SELECT?</th><th>Can EXECUTE?</th><th>Can alter schema?</th></tr></thead>
|
||||
<tr>
|
||||
<td class="PermissionsErrorCredentials">Read credentials</td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionReadCredentialCanLogin"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionReadCredentialCanSelect"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionReadCredentialCanExecute"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionReadCredentialCanAdmin"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="PermissionsErrorCredentials">Write credentials</td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionWriteCredentialCanLogin"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionWriteCredentialCanSelect"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionWriteCredentialCanExecute"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionWriteCredentialCanAdmin"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="PermissionsErrorCredentials">Admin credentials</td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionAdminCredentialCanLogin"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionAdminCredentialCanSelect"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionAdminCredentialCanExecute"> </td>
|
||||
<td class="PermissionsErrorResults" id="CellPermissionAdminCredentialCanAdmin"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="DivDatabaseRootConfig" style="display:none">
|
||||
<h2>Create the database and users</h2>
|
||||
<p>The Swarmops install sequence can set up the database and users for you, if you provide a root password to the MySQL database server.</p>
|
||||
<p>(If you don't trust the Swarmops install to do that, that's fine, go to <a href="javascript:goManualCredentials();">manual account credentials</a>.)</p>
|
||||
<div class="entryLabelsAdmin" style="width:250px">Hostname of MySQL database server<br/>Root password for that MySQL server<br/> </div>
|
||||
<div class="entryFieldsAdmin"><input type="text" id="TextMysqlServerHost" value="localhost"/> <br/><input type="password" id="TextMysqlRootPassword"/> </div>
|
||||
</div>
|
||||
<div id="DivDatabaseManualConfig" style="display:none">
|
||||
<h2>Connect to existing database</h2>
|
||||
<p>Before you fill this in, you will need to have created a database on a MySQL server that this web server can access, and set up user accounts that can access it. For security reasons, we <strong>require</strong> having three separate accounts - one for reading (SELECT permissions only), one for writing (SELECT and EXECUTE), and one for admin. All three accounts also need SELECT permissions on the mysql database.</p>
|
||||
|
||||
<div class="entryLabelsAdmin" style="width:120px">
|
||||
<br/>
|
||||
Database<br />
|
||||
Server<br />
|
||||
User<br/>
|
||||
Password
|
||||
</div>
|
||||
<div class="entryFieldsAdmin" style="width:80px">
|
||||
<strong>Read access</strong><br/>
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadDatabase" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadServer" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadUser" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsReadPassword" TextMode="Password" runat="server" /> <br />
|
||||
</div>
|
||||
<div class="entryFieldsAdmin" style="width:80px;margin-left:10px">
|
||||
<strong>Write access</strong><br/>
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsWriteDatabase" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsWriteServer" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsWriteUser" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsWritePassword" TextMode="Password" runat="server" /> <br />
|
||||
</div>
|
||||
<div class="entryFieldsAdmin" style="width:80px;margin-left:10px">
|
||||
<strong>Admin access</strong><br/>
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminDatabase" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminServer" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminUser" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextCredentialsAdminPassword" TextMode="Password" runat="server" /> <br />
|
||||
</div>
|
||||
</div>
|
||||
<h2>Initializing database</h2>
|
||||
|
||||
</div>
|
||||
<div id="step-3">
|
||||
<h2>Initializing database</h2>
|
||||
<div id="DivProgressDatabase"></div>
|
||||
<p>Please wait while the database is being initialized with schemas and geographic data from the Swarmops servers. This is going to take a <strong>significant</strong> amount of time; we're loading tons of geodata onto your new server.</p>
|
||||
<p><span id="SpanInitProgressMessage">Initializing...</span></p>
|
||||
</div>
|
||||
<div id="step-4">
|
||||
<h2>Creating the first user</h2>
|
||||
<p>Your new Swarmops server has been loaded with the geographic layout of the countries we're active in, and the first organization - the <em>Sandbox</em> - has been created. We are now going to create your user account, which will become the systems administrator account of this Swarmops installation.</p>
|
||||
|
||||
<p>(You can add other people to the <em>System Administrator</em> role later.)</p>
|
||||
|
||||
<div class="entryLabelsAdmin" style="width:250px">
|
||||
Your full name<br />
|
||||
Your email<br />
|
||||
Your password<br/>
|
||||
Repeat password
|
||||
</div>
|
||||
<div class="entryFieldsAdmin">
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserName" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserMail" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword1" TextMode="Password" runat="server" /> <br />
|
||||
<asp:TextBox CssClass="textinput" ID="TextFirstUserPassword2" TextMode="Password" runat="server" /> <br />
|
||||
</div>
|
||||
</div>
|
||||
<div id="step-5" style="display:none">
|
||||
<h2>All done - ready to login</h2>
|
||||
<p>Your Swarmops installation is ready! Press Finish to log in as your new user and start using it.</p>
|
||||
<div style="display:none"><asp:Button runat="server" ID="ButtonLogin" OnClick="ButtonLogin_Click" Text="This button is invisible."/></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<asp:Label ID="LabelDashboardTemporaryContent" runat="server" /> <a href="/Pages/v5/Governance/Vote.aspx"><asp:Label ID="LabelGoThere2" runat="server" /></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Swarmops.Logic.Structure;
|
||||
|
||||
namespace Swarmops.Frontend.Pages.Public
|
||||
{
|
||||
@@ -11,7 +12,20 @@ namespace Swarmops.Frontend.Pages.Public
|
||||
{
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
this.Organization = Organization.FromVanityDomain (Request.Url.Host);
|
||||
|
||||
if (this.Organization == null)
|
||||
{
|
||||
int organizationId = Convert.ToInt32 (Request["OrganizationId"]); // may throw - not pretty but ok for now. // TODO
|
||||
this.Organization = Organization.FromIdentity (organizationId); // may also throw, as above
|
||||
}
|
||||
|
||||
if (this.Organization == null)
|
||||
{
|
||||
throw new ArgumentException("Organization not specified"); // TODO: make a friendly landing page instead
|
||||
}
|
||||
}
|
||||
|
||||
protected Organization Organization;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user