diff --git a/lsp/minified.js b/lsp/minified.js index 804fd180..b35d8beb 100644 --- a/lsp/minified.js +++ b/lsp/minified.js @@ -69,16 +69,16 @@ e.push("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[d.getMonth() "years, ")).append(UI.format.addUnit(b.week,"wks"));break;case "week":c.append(UI.format.addUnit(b.week,"wks, ")).append(UI.format.addUnit(b.day,"days"));break;case "day":c.append(UI.format.addUnit(b.day,"days, ")).append(UI.format.addUnit(b.hr,"hrs"));break;default:c.append([("0"+b.hr).slice(-2),("0"+b.min).slice(-2),("0"+b.sec).slice(-2)+(b.ms?"."+b.ms:"")].join(":"))}return c[0].innerHTML},number:function(a){if(isNaN(Number(a))||0==a)return a;var c=Math.pow(10,3-Math.floor(Math.log(a)/Math.LN10)- 1),a=Math.round(a*c)/c;if(1E4");if("undefined"==typeof a.online)return c.text("Unknown, checking.."),"undefined"!=typeof a.error&&c.text(a.error),c;switch(a.online){case -1:c.text("Enabling");break;case 0:c.text("Unavailable").addClass("red");break;case 1:c.text("Active").addClass("green");break;case 2:c.text("Standby").addClass("orange"); break;default:c.text(a.online)}"error"in a&&c.text(a.error);return c},capital:function(a){return a.charAt(0).toUpperCase()+a.substring(1)},addUnit:function(a,c){var d=$("").html(a);d.append($("").addClass("unit").html(c));return d[0].innerHTML},bytes:function(a,c){var d="bytes KiB MiB GiB TiB PiB".split(" ");if(0==a)unit=d[0];else{var b=Math.floor(Math.log(Math.abs(a))/Math.log(1024));0>b?unit=d[0]:(a/=Math.pow(1024,b),unit=d[b])}return UI.format.addUnit(UI.format.number(a),unit+(c?"/s": -""))}},navto:function(a,c){var d=location.hash,b=d.split("@");b[0]=[mist.user.name,mist.user.host].join("&");b[1]=[a,c].join("&");"undefined"!=typeof screenlog&&screenlog.navto(b[1]);location.hash=b.join("@");location.hash==d&&$(window).trigger("hashchange")},showTab:function(a,c){var d=UI.elements.main;if(mist.user.loggedin&&!("ui_settings"in mist.data))d.html("Loading.."),mist.send(function(){UI.showTab(a,c)},{ui_settings:!0});else{var b=UI.elements.menu.removeClass("hide").find('.plain:contains("'+ -a+'")').closest(".button");0").text(a));switch(a){case "Login":if(mist.user.loggedin){UI.navto("Overview");return}UI.elements.menu.addClass("hide");UI.elements.connection.status.text("Disconnected").removeClass("green").addClass("red"); -d.append(UI.buildUI([{type:"help",help:"Please provide your account details.
You were asked to set these when MistController was started for the first time. If you did not yet set any account details, log in with your desired credentials to create a new account."},{label:"Host",help:"Url location of the MistServer API. Generally located at http://MistServerIP:4242/api","default":"http://localhost:4242/api",pointer:{main:mist.user,index:"host"}},{label:"Username",help:"Please enter your username here.", -validate:["required"],pointer:{main:mist.user,index:"name"}},{label:"Password",type:"password",help:"Please enter your password here.",validate:["required"],pointer:{main:mist.user,index:"rawpassword"}},{type:"buttons",buttons:[{label:"Login",type:"save","function":function(){mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword;mist.send(function(){UI.navto("Overview")})}}]}]));break;case "Create a new account":UI.elements.menu.addClass("hide");d.append($("

").text("No account has been created yet in the MistServer at ").append($("").text(mist.user.host)).append(".")); -d.append(UI.buildUI([{type:"buttons",buttons:[{label:"Select other host",type:"cancel",css:{"float":"left"},"function":function(){UI.navto("Login")}}]},{type:"custom",custom:$("
")},{label:"Desired username",type:"str",validate:["required"],help:"Enter your desired username. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"name"}},{label:"Desired password",type:"password",validate:["required",function(a,c){$(".match_password").not($(c)).trigger("change"); -return false}],help:"Enter your desired password. In the future, you will need this to access the Management Interface.",pointer:{main:mist.user,index:"rawpassword"},classes:["match_password"]},{label:"Repeat password",type:"password",validate:["required",function(a,c){return a!=$(".match_password").not($(c)).val()?{msg:'The fields "Desired password" and "Repeat password" do not match.',classes:["red"]}:false}],help:"Repeat your desired password.",classes:["match_password"]},{type:"buttons",buttons:[{type:"save", -label:"Create new account","function":function(){mist.send(function(){UI.navto("Account created")},{authorize:{new_username:mist.user.name,new_password:mist.user.rawpassword}});mist.user.password=MD5(mist.user.rawpassword);delete mist.user.rawpassword}}]}]));break;case "Account created":UI.elements.menu.addClass("hide");d.append($("

").text("Your account has been created succesfully.")).append(UI.buildUI([{type:"text",text:"Would you like to enable all (currently) available protocols with their default settings?"}, -{type:"buttons",buttons:[{label:"Enable protocols",type:"save","function":function(){if(mist.data.config.protocols)d.append("Unable to enable all protocols as protocol settings already exist.
");else{d.append("Retrieving available protocols..
");mist.send(function(a){var c=[],b;for(b in a.capabilities.connectors)if(a.capabilities.connectors[b].required)d.append('Could not enable protocol "'+b+'" because it has required settings.
');else{c.push({connector:b});d.append('Enabled protocol "'+ -b+'".
')}d.append("Saving protocol settings..
");mist.send(function(){d.append("Protocols enabled. Redirecting..");setTimeout(function(){UI.navto("Overview")},5E3)},{config:{protocols:c}})},{capabilities:true})}}},{label:"Skip",type:"cancel","function":function(){UI.navto("Overview")}}]}]));break;case "Overview":if("undefined"==typeof mist.data.bandwidth){mist.send(function(){UI.navto(a)},{bandwidth:!0});d.append("Loading..");return}var g=$("").text("Loading.."),q=$(""),o=$("").addClass("logs"), -l=$(""),u=$(""),f=$("").text("Unknown"),j=$(""),i=$("");e={serverid:mist.data.config.serverid,debug:mist.data.config.debug,accesslog:mist.data.config.accesslog,prometheus:mist.data.config.prometheus};var k={};"bandwidth"in mist.data&&(k=mist.data.bandwidth,null==k&&(k={}),k.limit||(k.limit=""));var I=$("").html($("

").text("This tab does not exist."))}d.find(".field").filter(function(){var a=$(this).getval(); -return a==""||a==null?true:false}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api"; +return a==""||a==null?true:false}).each(function(){var a=[];$(this).is("input, select, textarea")?a.push($(this)):a=$(this).find("input, select, textarea");if(a.length){$(a[0]).focus();return false}})}};"origin"in location||(location.origin=location.protocol+"//");var host;host="file://"==location.origin?"http://localhost:4242/api":location.origin+location.pathname.replace(/\/+$/,"")+"/api"; var mist={data:{},user:{name:"",password:"",host:host},send:function(a,c,d){var c=c||{},d=d||{},d=$.extend(true,{timeOut:3E4,sendData:c},d),b={authorize:{password:mist.user.authstring?MD5(mist.user.password+mist.user.authstring):"",username:mist.user.name}};$.extend(true,b,c);log("Send",$.extend(true,{},c));var e={url:mist.user.host,type:"POST",data:{command:JSON.stringify(b)},dataType:"jsonp",crossDomain:true,timeout:d.timeout*1E3,async:true,error:function(b,e){delete mist.user.loggedin;if(!d.hide){switch(e){case "timeout":e= $("").text("The connection timed out. ");break;case "abort":e=$("").text("The connection was aborted. ");break;default:e=$("").text(e+". ").css("text-transform","capitalize")}$("#message").addClass("red").text("An error occurred while attempting to communicate with MistServer:").append($("
")).append($("").text(e)).append($("").text("Send server request again").click(function(){mist.send(a,c,d)}))}UI.navto("Login")},success:function(e){log("Receive",$.extend(true,{},e),"as reply to", d.sendData);delete mist.user.loggedin;switch(e.authorize.status){case "OK":if("streams"in e)if(e.streams)if("incomplete list"in e.streams){delete e.streams["incomplete list"];$.extend(mist.data.streams,e.streams)}else mist.data.streams=e.streams;else mist.data.streams={};var g=$.extend({},e),h=["config","capabilities","ui_settings","LTS","active_streams","browse","log","totals","bandwidth"],o;for(o in g)h.indexOf(o)==-1&&delete g[o];if("bandwidth"in b&&!("bandwidth"in e))g.bandwidth=null;$.extend(mist.data, diff --git a/lsp/mist.js b/lsp/mist.js index 95b99396..790ddd39 100644 --- a/lsp/mist.js +++ b/lsp/mist.js @@ -1884,12 +1884,18 @@ var UI = { showTab: function(tab,other) { var $main = UI.elements.main; - if ((mist.user.loggedin) && (!('ui_settings' in mist.data))) { - $main.html('Loading..'); - mist.send(function(){ - UI.showTab(tab,other); - },{ui_settings: true}); - return; + if (mist.user.loggedin) { + if (!('ui_settings' in mist.data)) { + $main.html('Loading..'); + mist.send(function(){ + UI.showTab(tab,other); + },{ui_settings: true}); + return; + } + + if (mist.data.config.serverid) { + document.title = mist.data.config.serverid+" - MistServer MI"; + } } var $currbut = UI.elements.menu.removeClass('hide').find('.plain:contains("'+tab+'")').closest('.button'); @@ -1925,6 +1931,7 @@ var UI = { UI.navto('Overview'); return; } + document.title = "MistServer MI"; UI.elements.menu.addClass('hide'); UI.elements.connection.status.text('Disconnected').removeClass('green').addClass('red'); $main.append(UI.buildUI([