2019-07-14 22:43:22 +02:00
|
|
|
var instNameInit = false
|
|
|
|
|
2016-09-06 10:14:54 +02:00
|
|
|
$(document).ready( function() {
|
2016-12-21 18:24:03 +01:00
|
|
|
|
2016-09-06 10:14:54 +02:00
|
|
|
loadContentTo("#container_connection_lost","connection_lost");
|
2017-01-17 21:53:35 +01:00
|
|
|
loadContentTo("#container_restart","restart");
|
2016-09-06 10:14:54 +02:00
|
|
|
initWebSocket();
|
2016-09-07 20:10:37 +02:00
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).on("cmd-serverinfo",function(event){
|
|
|
|
window.serverInfo = event.response.info;
|
2019-01-01 19:47:07 +01:00
|
|
|
// comps
|
2019-06-05 18:19:08 +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
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
window.comps.forEach( function(obj) {
|
2019-01-01 19:47:07 +01:00
|
|
|
if (obj.name == "ALL")
|
|
|
|
{
|
|
|
|
if(obj.enabled)
|
|
|
|
$("#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);
|
|
|
|
if(running.length > 1)
|
|
|
|
$('#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()
|
|
|
|
if(!instNameInit)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).on("cmd-sessions-update", function(event) {
|
|
|
|
window.serverInfo.sessions = event.response.data;
|
2018-12-27 23:11:32 +01:00
|
|
|
updateSessions();
|
|
|
|
});
|
|
|
|
|
2019-07-12 16:54:26 +02:00
|
|
|
$(window.hyperion).one("cmd-authorize-getTokenList", function(event) {
|
|
|
|
tokenList = event.response.info;
|
|
|
|
requestServerInfo();
|
|
|
|
});
|
|
|
|
|
2019-06-05 18:19:08 +02: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
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).one("cmd-config-getschema", function(event) {
|
|
|
|
window.serverSchema = event.response.info;
|
2016-10-10 23:15:50 +02:00
|
|
|
requestServerConfig();
|
2019-07-12 16:54:26 +02:00
|
|
|
requestTokenInfo();
|
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
|
|
|
});
|
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).on("cmd-config-getconfig", function(event) {
|
|
|
|
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
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).on("cmd-config-setconfig", function(event) {
|
2019-02-07 00:59:52 +01:00
|
|
|
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'))
|
2019-02-07 00:59:52 +01:00
|
|
|
}
|
|
|
|
});
|
2016-09-10 19:08:08 +02:00
|
|
|
|
2020-02-16 13:55:38 +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')
|
|
|
|
|
|
|
|
if(window.defaultPasswordIsSet === true)
|
|
|
|
showNotification('warning', $.i18n('dashboard_message_default_password'), $.i18n('dashboard_message_default_password_t'), '<a style="cursor:pointer" onClick="changePassword()"> '+$.i18n('InfoDialog_changePassword_title')+'</a>')
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
|
2019-09-17 21:33:46 +02:00
|
|
|
$(window.hyperion).on("cmd-authorize-newPassword", function(event) {
|
|
|
|
if (event.response.success === true){
|
|
|
|
showInfoDialog("success",$.i18n('InfoDialog_changePassword_success'));
|
|
|
|
// not necessarily true, but better than nothing
|
|
|
|
window.defaultPasswordIsSet = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-02-16 13:55:38 +01:00
|
|
|
$(window.hyperion).on("cmd-authorize-newPasswordRequired", function(event) {
|
2019-09-17 21:33:46 +02:00
|
|
|
var loginToken = getStorage("loginToken", true)
|
|
|
|
|
|
|
|
if (event.response.info.newPasswordRequired == true)
|
|
|
|
{
|
|
|
|
window.defaultPasswordIsSet = true;
|
|
|
|
|
|
|
|
if(loginToken)
|
|
|
|
requestTokenAuthorization(loginToken)
|
|
|
|
else
|
|
|
|
requestAuthorization('hyperion');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#main-nav").attr('style', 'display:none')
|
|
|
|
$("#top-navbar").attr('style', 'display:none')
|
|
|
|
|
|
|
|
if(loginToken)
|
|
|
|
requestTokenAuthorization(loginToken)
|
|
|
|
else
|
|
|
|
loadContentTo("#page-content", "login")
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-02-16 13:55:38 +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();
|
|
|
|
});
|
|
|
|
|
2019-06-05 18:19:08 +02: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)
|
|
|
|
if (event.reason == "No Authorization" && getStorage("loginToken", true))
|
|
|
|
{
|
|
|
|
removeStorage("loginToken", true);
|
|
|
|
requestRequiresAdminAuth();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
showInfoDialog("error","Error", event.reason);
|
|
|
|
}
|
2016-09-06 10:14:54 +02:00
|
|
|
});
|
2016-09-10 19:08:08 +02:00
|
|
|
|
2019-06-05 18:19:08 +02: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
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).one("ready", function(event) {
|
2017-02-08 14:36:28 +01:00
|
|
|
loadContent();
|
|
|
|
});
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).on("cmd-adjustment-update", function(event) {
|
|
|
|
window.serverInfo.adjustment = event.response.data
|
2018-12-27 23:11:32 +01:00
|
|
|
});
|
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).on("cmd-videomode-update", function(event) {
|
|
|
|
window.serverInfo.videomode = event.response.data.videomode
|
2018-12-27 23:11:32 +01:00
|
|
|
});
|
|
|
|
|
2019-06-05 18:19:08 +02: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
|
|
|
|
if (obj.name == "ALL")
|
|
|
|
{
|
2019-01-01 19:47:07 +01:00
|
|
|
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) => {
|
2018-12-27 23:11:32 +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
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).trigger("components-updated");
|
2018-12-27 23:11:32 +01:00
|
|
|
});
|
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
$(window.hyperion).on("cmd-instance-update", function(event) {
|
|
|
|
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;
|
|
|
|
for(var key in avail)
|
|
|
|
{
|
|
|
|
if(avail[key].instance == currentHyperionInstance && avail[key].running)
|
|
|
|
{
|
|
|
|
isInData = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
setTimeout(requestServerInfo,100)
|
|
|
|
setTimeout(requestTokenInfo,200)
|
|
|
|
setTimeout(loadContent,300, undefined, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
// determine button visibility
|
|
|
|
var running = serverInfo.instance.filter(entry => entry.running);
|
|
|
|
if(running.length > 1)
|
|
|
|
$('#btn_hypinstanceswitch').toggle(true)
|
|
|
|
else
|
|
|
|
$('#btn_hypinstanceswitch').toggle(false)
|
|
|
|
|
|
|
|
// update listing for button
|
|
|
|
updateHyperionInstanceListing()
|
|
|
|
});
|
|
|
|
|
|
|
|
$(window.hyperion).on("cmd-instance-switchTo", function(event){
|
|
|
|
requestServerConfig();
|
|
|
|
setTimeout(requestServerInfo,200)
|
|
|
|
setTimeout(requestTokenInfo,400)
|
|
|
|
setTimeout(loadContent,400, undefined, true)
|
|
|
|
});
|
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).on("cmd-effects-update", function(event){
|
|
|
|
window.serverInfo.effects = event.response.data.effects
|
2018-12-27 23:11:32 +01:00
|
|
|
});
|
|
|
|
|
2017-02-28 17:53: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
|
|
|
});
|
|
|
|
|
|
|
|
$(function(){
|
|
|
|
var sidebar = $('#side-menu'); // cache sidebar to a variable for performance
|
|
|
|
sidebar.delegate('a.inactive','click',function(){
|
|
|
|
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 () {
|
|
|
|
$('body').css('padding-right','0');
|
|
|
|
});
|