Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Commit

Permalink
host web gui on rest port
Browse files Browse the repository at this point in the history
  • Loading branch information
vuapo-eth committed Jan 8, 2019
1 parent 3cce627 commit ebd00ab
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 32 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/iota/ixi/ChatIxi.java
Expand Up @@ -104,6 +104,8 @@ public ChatIxi(String ictName, String username, String password) {

public void init() {

staticFiles.externalLocation("web/");

before((Filter) (request, response) -> {
String queryPassword = request.queryParams("password");

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/iota/ixi/Main.java
Expand Up @@ -13,6 +13,6 @@ public static void main(String[] args) {
properties.ixiEnabled = true;
new Ict(properties);

new ChatIxi(properties.name, "anonymous", "");
new ChatIxi(properties.name, "anonymous", "x");
}
}
4 changes: 0 additions & 4 deletions web/index.html
Expand Up @@ -61,10 +61,6 @@ <h1>Settings</h1>
<tr>
<th>Content</th>
</tr>
<tr>
<td>chat.ixi API</td>
<td><input id="settings_api" type="url" placeholder="http://localhost:4567" /></td>
</tr>
<tr>
<td>API password</td>
<td><input id="settings_password" type="password" placeholder="password" /></td>
Expand Down
32 changes: 5 additions & 27 deletions web/main.js
Expand Up @@ -15,6 +15,7 @@ var REST_URL_ADD_CONTACT;
var REST_URL_REMOVE_CONTACT;
var REST_URL_GET_ONLINE_USERS;
var REST_URL_INIT;
set_rest_urls();

const icons = {};
const audio = new Audio('sound.ogg');
Expand All @@ -25,7 +26,6 @@ setInterval(submit_life_sign, 10000);

function reset_settings() {
settings = {
"api": "http://localhost:4567/",
"hide_strangers": "off",
"bg_brightness": 30,
"bg_saturation": 30,
Expand All @@ -43,13 +43,12 @@ function load_settings() {
}
});

settings['api'] = correct_api(settings['api']);
settings['history_size'] = parseInt(settings['history_size']);
set_rest_urls();
//set_rest_urls();
}

function set_rest_urls() {
REST_URL = settings['api'];
REST_URL = window.location.protocol + "//" + window.location.host + "/";
REST_URL_GET = REST_URL+"getMessage/";
REST_URL_SUBMIT = REST_URL+"submitMessage/";
REST_URL_ADD_CHANNEL = REST_URL+"addChannel/";
Expand Down Expand Up @@ -356,8 +355,8 @@ function init() {
},
error: function (err) {
$('#loading_page').addClass("hidden");
const msg = "Could not connect to <code>" + settings['api'] + "</code><br/><br/>"+JSON.stringify(err) + "</b><br/><br/><hr/>Required format: <code>http://{IP}:4567</code>/, e.g. <code>http://localhost:4567/</code>";
swal("Failed to connecto to API", msg, "warning").then(ask_for_api_and_connect);
const msg = "Could not connect to <code>" + REST_URL + "</code><br/><br/>"+JSON.stringify(err) + "</b><br/><br/>Maybe you got the password wrong? Let's try again.";
swal("Failed to connecto to API", msg, "warning").then(ask_for_password_and_connect);
}
});
}
Expand All @@ -381,16 +380,6 @@ function read_message() {
});
}

function ask_for_api_and_connect() {
swal({
title: 'Enter chat.ixi API',
input: 'text',
}).then(function (text) {
settings['api'] = correct_api(text.value);
set_rest_urls();
ask_for_password_and_connect();
})
}

function ask_for_password_and_connect() {
swal({
Expand All @@ -404,17 +393,6 @@ function ask_for_password_and_connect() {
}


function correct_api(api) {
if(!api.match(/[:][0-9]{1,5}[/]?$/g))
api += ":4567/";
if(!api.endsWith("/"))
api += "/";
if(!api.startsWith("http"))
api = "http://" + api;
return api;

}

function submit_life_sign() {

if(REST_URL === undefined)
Expand Down

0 comments on commit ebd00ab

Please sign in to comment.