This commit is contained in:
2021-08-13 18:24:14 +00:00
parent 5a155c11fd
commit 5ea07cd003
4 changed files with 151 additions and 146 deletions

View File

@@ -18,6 +18,7 @@ namespace AyaNova.PlugIn.V8
private async void btnTest_Click(object sender, EventArgs e)
{
if (!ValidateAndCleanServerAddress()) return;
btnOk.Enabled=btnTest.Enabled = false;
var result = await util.TestUrlAsync(edServerUrl.Text);
btnOk.Enabled = btnTest.Enabled = true;
@@ -32,6 +33,7 @@ namespace AyaNova.PlugIn.V8
}
private async void btnOk_Click(object sender, EventArgs e)
{
if (!ValidateAndCleanServerAddress()) return;
btnOk.Enabled = btnTest.Enabled = false;
if (!util.Initialized)
{
@@ -39,6 +41,7 @@ namespace AyaNova.PlugIn.V8
if (result != "OK")
{
MessageBox.Show("Server could not be reached at that URL\n" + result);
btnOk.Enabled = btnTest.Enabled = true;
return;
}
}
@@ -46,6 +49,7 @@ namespace AyaNova.PlugIn.V8
if (!res)
{
MessageBox.Show("AyaNova 8 SuperUser account login failed");
btnOk.Enabled = btnTest.Enabled = true;
return;
}
btnOk.Enabled = btnTest.Enabled = true;
@@ -68,15 +72,35 @@ namespace AyaNova.PlugIn.V8
lblPreRelease.Text = util.PRE_RELEASE_VERSION_STRING;
#if (DEBUG)
edServerUrl.Text = "192.168.1.56:7575";
edServerUrl.Text = "http://192.168.1.56:7575";
edUserName.Text = "superuser";
edPassword.Text = "l3tm3in";
#endif
}
private void label2_Click(object sender, EventArgs e)
{
private bool ValidateAndCleanServerAddress()
{
var serverUrl=edServerUrl.Text;
Uri u;
try
{
u = new Uri(serverUrl);
var scheme = u.Scheme;
var host = u.Host;
var port = u.Port;
edServerUrl.Text= scheme + "://" + host + ":" + port + "/" + util.API_BASE_ROUTE;
}
catch (Exception ex)
{
MessageBox.Show("Server address not valid\n" + ex.Message);
return false;
}
//ok, it's some kind of url, now format it for api access
return true;
}