2019-07-14 22:43:22 +02:00
|
|
|
var instNameInit = false
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(document).ready(function () {
|
2016-12-21 18:24:03 +01:00
|
|
|
|
2020-04-05 20:08:56 +02:00
|
|
|
var darkModeOverwrite = getStorage("darkModeOverwrite", true);
|
|
|
|
|
|
|
|
if(darkModeOverwrite == "false" || darkModeOverwrite == null)
|
|
|
|
{
|
|
|
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
|
|
handleDarkMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
|
|
|
|
setStorage("darkMode", "off", false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(getStorage("darkMode", false) == "on")
|
|
|
|
{
|
|
|
|
handleDarkMode();
|
|
|
|
}
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
loadContentTo("#container_connection_lost", "connection_lost");
|
|
|
|
loadContentTo("#container_restart", "restart");
|
2016-09-06 10:14:54 +02:00
|
|
|
initWebSocket();
|
2016-09-07 20:10:37 +02:00
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-serverinfo", function (event) {
|
2019-06-05 18:19:08 +02:00
|
|
|
window.serverInfo = event.response.info;
|
2019-01-01 19:47:07 +01:00
|
|
|
// comps
|
2020-05-29 11:28:35 +02:00
|
|
|
window.comps = event.response.info.components
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).trigger("ready");
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
window.comps.forEach(function (obj) {
|
|
|
|
if (obj.name == "ALL") {
|
|
|
|
if (obj.enabled)
|
2019-01-01 19:47:07 +01:00
|
|
|
$("#hyperion_disabled_notify").fadeOut("fast");
|
|
|
|
else
|
|
|
|
$("#hyperion_disabled_notify").fadeIn("fast");
|
|
|
|
}
|
|
|
|
});
|
2016-09-14 13:51:28 +02:00
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
// determine button visibility
|
|
|
|
var running = window.serverInfo.instance.filter(entry => entry.running);
|
2020-03-26 17:59:41 +01:00
|
|
|
if (running.length > 1)
|
2019-07-14 22:43:22 +02:00
|
|
|
$('#btn_hypinstanceswitch').toggle(true)
|
2018-12-27 23:11:32 +01:00
|
|
|
else
|
2019-07-14 22:43:22 +02:00
|
|
|
$('#btn_hypinstanceswitch').toggle(false)
|
|
|
|
// update listing at button
|
|
|
|
updateHyperionInstanceListing()
|
2020-03-26 17:59:41 +01:00
|
|
|
if (!instNameInit) {
|
2019-07-14 22:43:22 +02:00
|
|
|
window.currentHyperionInstanceName = getInstanceNameByIndex(0);
|
|
|
|
instNameInit = true;
|
|
|
|
}
|
2016-11-26 22:46:16 +01:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
updateSessions();
|
2016-09-06 10:14:54 +02:00
|
|
|
}); // end cmd-serverinfo
|
|
|
|
|
2020-05-30 16:40:51 +02:00
|
|
|
// Update language selection
|
2020-05-29 14:28:15 +02:00
|
|
|
$("#language-select").on('changed.bs.select',function (e, clickedIndex, isSelected, previousValue){
|
|
|
|
var newLang = availLang[clickedIndex-1];
|
2020-05-29 11:28:35 +02:00
|
|
|
if (newLang !== storedLang)
|
|
|
|
{
|
|
|
|
setStorage("langcode", newLang);
|
2020-05-29 14:28:15 +02:00
|
|
|
reload();
|
2020-05-29 11:28:35 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-05-29 14:28:15 +02:00
|
|
|
$("#language-select").selectpicker(
|
|
|
|
{
|
2020-05-30 16:40:51 +02:00
|
|
|
container: 'body'
|
2020-05-29 14:28:15 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$(".bootstrap-select").click(function () {
|
|
|
|
$(this).addClass("open");
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).click(function(){
|
|
|
|
$(".bootstrap-select").removeClass("open");
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".bootstrap-select").click(function(e){
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
2020-05-30 16:40:51 +02:00
|
|
|
|
|
|
|
//End language selection
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-sessions-update", function (event) {
|
2019-06-05 18:19:08 +02:00
|
|
|
window.serverInfo.sessions = event.response.data;
|
2018-12-27 23:11:32 +01:00
|
|
|
updateSessions();
|
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-authorize-tokenRequest cmd-authorize-getPendingTokenRequests", function (event) {
|
|
|
|
var val = event.response.info;
|
|
|
|
if (Array.isArray(event.response.info)) {
|
|
|
|
if (event.response.info.length == 0) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
val = event.response.info[0]
|
|
|
|
if (val.comment == '')
|
|
|
|
$('#modal_dialog').modal('hide');
|
|
|
|
}
|
|
|
|
|
|
|
|
showInfoDialog("grantToken", $.i18n('conf_network_tok_grantT'), $.i18n('conf_network_tok_grantMsg') + '<br><span style="font-weight:bold">App: ' + val.comment + '</span><br><span style="font-weight:bold">Code: ' + val.id + '</span>')
|
|
|
|
$("#tok_grant_acc").off().on('click', function () {
|
|
|
|
tokenList.push(val)
|
|
|
|
// forward event, in case we need to rebuild the list now
|
|
|
|
$(window.hyperion).trigger({ type: "build-token-list" });
|
|
|
|
requestHandleTokenRequest(val.id, true)
|
|
|
|
});
|
|
|
|
$("#tok_deny_acc").off().on('click', function () {
|
|
|
|
requestHandleTokenRequest(val.id, false)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$(window.hyperion).one("cmd-authorize-getTokenList", function (event) {
|
2019-07-12 16:54:26 +02:00
|
|
|
tokenList = event.response.info;
|
|
|
|
requestServerInfo();
|
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-sysinfo", function (event) {
|
2017-03-18 00:05:04 +01:00
|
|
|
requestServerInfo();
|
2019-06-05 18:19:08 +02:00
|
|
|
window.sysInfo = event.response.info;
|
2017-04-07 21:33:40 +02:00
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
window.currentVersion = window.sysInfo.hyperion.version;
|
2019-07-08 15:04:38 +02:00
|
|
|
window.currentChannel = window.sysInfo.hyperion.channel;
|
2017-03-04 22:17:42 +01:00
|
|
|
});
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).one("cmd-config-getschema", function (event) {
|
2019-06-05 18:19:08 +02:00
|
|
|
window.serverSchema = event.response.info;
|
2016-10-10 23:15:50 +02:00
|
|
|
requestServerConfig();
|
2020-03-26 17:59:41 +01:00
|
|
|
requestTokenInfo();
|
|
|
|
requestGetPendingTokenRequests();
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
window.schema = window.serverSchema.properties;
|
2016-10-10 23:15:50 +02:00
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-config-getconfig", function (event) {
|
2019-06-05 18:19:08 +02:00
|
|
|
window.serverConfig = event.response.info;
|
2017-03-18 00:05:04 +01:00
|
|
|
requestSysInfo();
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
window.showOptHelp = window.serverConfig.general.showOptHelp;
|
2016-09-10 19:08:08 +02:00
|
|
|
});
|
2019-09-17 21:33:46 +02:00
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-config-setconfig", function (event) {
|
|
|
|
if (event.response.success === true) {
|
2019-09-17 21:33:46 +02:00
|
|
|
showNotification('success', $.i18n('dashboard_alert_message_confsave_success'), $.i18n('dashboard_alert_message_confsave_success_t'))
|
2020-03-26 17:59:41 +01:00
|
|
|
}
|
|
|
|
});
|
2016-09-10 19:08:08 +02:00
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-authorize-login", function (event) {
|
2019-09-17 21:33:46 +02:00
|
|
|
$("#main-nav").removeAttr('style')
|
|
|
|
$("#top-navbar").removeAttr('style')
|
|
|
|
|
2020-06-26 18:16:59 +02:00
|
|
|
if (window.defaultPasswordIsSet === true && getStorage("suppressDefaultPwWarning") !== "true" )
|
|
|
|
{
|
|
|
|
var supprPwWarnCheckbox = '<div class="text-right">'+$.i18n('dashboard_message_do_not_show_again')
|
|
|
|
+ ' <input id="chk_suppressDefaultPw" type="checkbox" onChange="suppressDefaultPwWarning()"> </div>'
|
|
|
|
showNotification('warning', $.i18n('dashboard_message_default_password'), $.i18n('dashboard_message_default_password_t'), '<a style="cursor:pointer" onClick="changePassword()">'
|
|
|
|
+ $.i18n('InfoDialog_changePassword_title') + '</a>' + supprPwWarnCheckbox)
|
|
|
|
}
|
2019-09-17 21:33:46 +02:00
|
|
|
else
|
|
|
|
//if logged on and pw != default show option to lock ui
|
|
|
|
$("#btn_lock_ui").removeAttr('style')
|
|
|
|
|
|
|
|
|
|
|
|
if (event.response.hasOwnProperty('info'))
|
|
|
|
setStorage("loginToken", event.response.info.token, true);
|
|
|
|
|
2019-07-12 16:54:26 +02:00
|
|
|
requestServerConfigSchema();
|
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-authorize-newPassword", function (event) {
|
|
|
|
if (event.response.success === true) {
|
|
|
|
showInfoDialog("success", $.i18n('InfoDialog_changePassword_success'));
|
2019-09-17 21:33:46 +02:00
|
|
|
// not necessarily true, but better than nothing
|
|
|
|
window.defaultPasswordIsSet = false;
|
|
|
|
}
|
2020-03-26 17:59:41 +01:00
|
|
|
});
|
2019-09-17 21:33:46 +02:00
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-authorize-newPasswordRequired", function (event) {
|
2019-09-17 21:33:46 +02:00
|
|
|
var loginToken = getStorage("loginToken", true)
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
if (event.response.info.newPasswordRequired == true) {
|
2019-09-17 21:33:46 +02:00
|
|
|
window.defaultPasswordIsSet = true;
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
if (loginToken)
|
2019-09-17 21:33:46 +02:00
|
|
|
requestTokenAuthorization(loginToken)
|
|
|
|
else
|
|
|
|
requestAuthorization('hyperion');
|
|
|
|
}
|
2020-03-26 17:59:41 +01:00
|
|
|
else {
|
2019-09-17 21:33:46 +02:00
|
|
|
$("#main-nav").attr('style', 'display:none')
|
|
|
|
$("#top-navbar").attr('style', 'display:none')
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
if (loginToken)
|
2019-09-17 21:33:46 +02:00
|
|
|
requestTokenAuthorization(loginToken)
|
|
|
|
else
|
|
|
|
loadContentTo("#page-content", "login")
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-authorize-adminRequired", function (event) {
|
2019-09-17 21:33:46 +02:00
|
|
|
//Check if a admin login is required.
|
|
|
|
//If yes: check if default pw is set. If no: go ahead to get server config and render page
|
|
|
|
if (event.response.info.adminRequired === true)
|
|
|
|
requestRequiresDefaultPasswortChange();
|
|
|
|
else
|
|
|
|
requestServerConfigSchema();
|
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("error", function (event) {
|
2019-09-17 21:33:46 +02:00
|
|
|
//If we are getting an error "No Authorization" back with a set loginToken we will forward to new Login (Token is expired.
|
|
|
|
//e.g.: hyperiond was started new in the meantime)
|
2020-03-26 17:59:41 +01:00
|
|
|
if (event.reason == "No Authorization" && getStorage("loginToken", true)) {
|
2019-09-17 21:33:46 +02:00
|
|
|
removeStorage("loginToken", true);
|
|
|
|
requestRequiresAdminAuth();
|
|
|
|
}
|
2020-03-26 17:59:41 +01:00
|
|
|
else {
|
|
|
|
showInfoDialog("error", "Error", event.reason);
|
2019-09-17 21:33:46 +02:00
|
|
|
}
|
2016-09-06 10:14:54 +02:00
|
|
|
});
|
2016-09-10 19:08:08 +02:00
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("open", function (event) {
|
2019-09-17 21:33:46 +02:00
|
|
|
requestRequiresAdminAuth();
|
2016-09-10 19:08:08 +02:00
|
|
|
});
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).one("ready", function (event) {
|
2017-02-08 14:36:28 +01:00
|
|
|
loadContent();
|
|
|
|
});
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-adjustment-update", function (event) {
|
2019-06-05 18:19:08 +02:00
|
|
|
window.serverInfo.adjustment = event.response.data
|
2018-12-27 23:11:32 +01:00
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-videomode-update", function (event) {
|
2019-06-05 18:19:08 +02:00
|
|
|
window.serverInfo.videomode = event.response.data.videomode
|
2018-12-27 23:11:32 +01:00
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-components-update", function (event) {
|
2018-12-27 23:11:32 +01:00
|
|
|
let obj = event.response.data
|
|
|
|
|
|
|
|
// notfication in index
|
2020-03-26 17:59:41 +01:00
|
|
|
if (obj.name == "ALL") {
|
|
|
|
if (obj.enabled)
|
2018-12-27 23:11:32 +01:00
|
|
|
$("#hyperion_disabled_notify").fadeOut("fast");
|
|
|
|
else
|
|
|
|
$("#hyperion_disabled_notify").fadeIn("fast");
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
window.comps.forEach((entry, index) => {
|
2020-03-26 17:59:41 +01:00
|
|
|
if (entry.name === obj.name) {
|
2019-06-05 18:19:08 +02:00
|
|
|
window.comps[index] = obj;
|
2018-12-27 23:11:32 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
// notify the update
|
2020-05-12 19:56:06 +02:00
|
|
|
$(window.hyperion).trigger("components-updated", event.response.data);
|
2018-12-27 23:11:32 +01:00
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-instance-update", function (event) {
|
2019-07-14 22:43:22 +02:00
|
|
|
window.serverInfo.instance = event.response.data
|
|
|
|
var avail = event.response.data;
|
|
|
|
// notify the update
|
|
|
|
$(window.hyperion).trigger("instance-updated");
|
|
|
|
|
|
|
|
// if our current instance is no longer available we are at instance 0 again.
|
|
|
|
var isInData = false;
|
2020-03-26 17:59:41 +01:00
|
|
|
for (var key in avail) {
|
|
|
|
if (avail[key].instance == currentHyperionInstance && avail[key].running) {
|
2019-07-14 22:43:22 +02:00
|
|
|
isInData = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
if (!isInData) {
|
2019-09-07 01:17:26 +02:00
|
|
|
//Delete Storage information about the last used but now stopped instance
|
|
|
|
if (getStorage('lastSelectedInstance', false))
|
|
|
|
removeStorage('lastSelectedInstance', false)
|
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
currentHyperionInstance = 0;
|
|
|
|
currentHyperionInstanceName = getInstanceNameByIndex(0);
|
|
|
|
requestServerConfig();
|
2020-03-26 17:59:41 +01:00
|
|
|
setTimeout(requestServerInfo, 100)
|
|
|
|
setTimeout(requestTokenInfo, 200)
|
|
|
|
setTimeout(loadContent, 300, undefined, true)
|
2019-07-14 22:43:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// determine button visibility
|
|
|
|
var running = serverInfo.instance.filter(entry => entry.running);
|
2020-03-26 17:59:41 +01:00
|
|
|
if (running.length > 1)
|
2019-07-14 22:43:22 +02:00
|
|
|
$('#btn_hypinstanceswitch').toggle(true)
|
|
|
|
else
|
|
|
|
$('#btn_hypinstanceswitch').toggle(false)
|
|
|
|
|
|
|
|
// update listing for button
|
|
|
|
updateHyperionInstanceListing()
|
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-instance-switchTo", function (event) {
|
2019-07-14 22:43:22 +02:00
|
|
|
requestServerConfig();
|
2020-03-26 17:59:41 +01:00
|
|
|
setTimeout(requestServerInfo, 200)
|
|
|
|
setTimeout(requestTokenInfo, 400)
|
|
|
|
setTimeout(loadContent, 400, undefined, true)
|
2019-07-14 22:43:22 +02:00
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(window.hyperion).on("cmd-effects-update", function (event) {
|
2019-06-05 18:19:08 +02:00
|
|
|
window.serverInfo.effects = event.response.data.effects
|
2018-12-27 23:11:32 +01:00
|
|
|
});
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(".mnava").bind('click.menu', function (e) {
|
2017-02-08 14:36:28 +01:00
|
|
|
loadContent(e);
|
2017-02-28 17:53:41 +01:00
|
|
|
window.scrollTo(0, 0);
|
2017-02-08 14:36:28 +01:00
|
|
|
});
|
|
|
|
|
2016-09-06 10:14:54 +02:00
|
|
|
});
|
|
|
|
|
2020-06-26 18:16:59 +02:00
|
|
|
function suppressDefaultPwWarning(){
|
|
|
|
|
|
|
|
if (document.getElementById('chk_suppressDefaultPw').checked)
|
|
|
|
setStorage("suppressDefaultPwWarning", "true");
|
|
|
|
else
|
|
|
|
setStorage("suppressDefaultPwWarning", "false");
|
|
|
|
}
|
|
|
|
|
2020-03-26 17:59:41 +01:00
|
|
|
$(function () {
|
2016-09-06 10:14:54 +02:00
|
|
|
var sidebar = $('#side-menu'); // cache sidebar to a variable for performance
|
2020-03-26 17:59:41 +01:00
|
|
|
sidebar.delegate('a.inactive', 'click', function () {
|
2016-09-06 10:14:54 +02:00
|
|
|
sidebar.find('.active').toggleClass('active inactive');
|
|
|
|
$(this).toggleClass('active inactive');
|
|
|
|
});
|
|
|
|
});
|
2019-09-17 21:33:46 +02:00
|
|
|
|
|
|
|
// hotfix body padding when bs modals overlap
|
|
|
|
$(document.body).on('hide.bs.modal,hidden.bs.modal', function () {
|
2020-03-26 17:59:41 +01:00
|
|
|
$('body').css('padding-right', '0');
|
2019-09-17 21:33:46 +02:00
|
|
|
});
|
2020-04-05 20:08:56 +02:00
|
|
|
|
|
|
|
//Dark Mode
|
|
|
|
$("#btn_darkmode").off().on("click",function(e){
|
|
|
|
|
|
|
|
if(getStorage("darkMode", false) != "on")
|
|
|
|
{
|
|
|
|
handleDarkMode();
|
|
|
|
setStorage("darkModeOverwrite", true, true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
setStorage("darkMode", "off", false);
|
|
|
|
setStorage("darkModeOverwrite", true, true);
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
|
2020-05-12 19:56:06 +02:00
|
|
|
});
|