telebit.js/lib/admin/js/app.js

76 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-10-16 02:37:07 +00:00
;(function () {
'use strict';
console.log("hello");
var Vue = window.Vue;
var api = {};
api.config = function apiConfig() {
return window.fetch("/api/config", { method: "GET" }).then(function (resp) {
return resp.json().then(function (json) {
appData.config = json;
return json;
});
});
};
api.status = function apiStatus() {
return window.fetch("/api/status", { method: "GET" }).then(function (resp) {
return resp.json().then(function (json) {
appData.status = json;
return json;
});
});
};
2018-10-18 07:11:37 +00:00
// TODO test for internet connectivity (and telebit connectivity)
var DEFAULT_RELAY = 'telebit.cloud';
var BETA_RELAY = 'telebit.ppl.family';
2018-10-16 02:37:07 +00:00
var appData = {
config: null
, status: null
2018-10-18 07:11:37 +00:00
, init: {
teletos: true
, letos: true
, notifications: "important"
, relay: DEFAULT_RELAY
}
2018-10-16 02:37:07 +00:00
, http: null
, tcp: null
, ssh: null
2018-10-18 07:11:37 +00:00
, views: {
section: {
create: true
}
}
2018-10-16 02:37:07 +00:00
};
var appMethods = {
initialize: function () {
console.log("call initialize");
2018-10-18 07:11:37 +00:00
if (!appData.init.relay) {
appData.init.relay = DEFAULT_RELAY;
}
if (DEFAULT_RELAY !== appData.init.relay) {
window.alert("TODO: Custom Relay Not Implemented Yet");
}
}
, defaultRelay: function () {
appData.init.relay = DEFAULT_RELAY;
}
, betaRelay: function () {
appData.init.relay = BETA_RELAY;
2018-10-16 02:37:07 +00:00
}
};
new Vue({
el: ".v-app"
, data: appData
, methods: appMethods
});
api.config();
api.status();
window.api = api;
}());