LSP - push page - stop all manual pushes
This commit is contained in:
parent
b7a69c800a
commit
d696082eb3
2 changed files with 50 additions and 4 deletions
|
@ -117,8 +117,9 @@ h=["Preview","Embed urls","Meta information"];k=h[0];for(q in h)r=$("<a>").addCl
|
|||
mist.send(function(){b.remove()},{push_auto_remove:{stream:a[1],target:a[2]}}):mist.send(function(){function c(){setTimeout(function(){mist.send(function(d){var f=false;if("push_list"in d&&d.push_list&&d.push_list.length){var f=true,e;for(e in d.push_list)if(d.push_list[e][0]==a[0]){f=false;break}}else f=true;f?b.remove():c()},{push_list:1})},1E3)}c()},{push_stop:[a[0]]})}})))}y.html("");var c=a.push_settings;c||(c={});y.append(UI.buildUI([{type:"help",help:"You can push streams to files or other servers, allowing them to broadcast your stream as well."},
|
||||
$("<h3>").text("Settings"),{label:"Delay before retry",unit:"s",type:"int",min:0,help:"How long the delay should be before MistServer retries an automatic push.<br>If set to 0, it does not retry.","default":0,pointer:{main:c,index:"wait"}},{label:"Maximum retries",unit:"/s",type:"int",min:0,help:"The maximum amount of retries per second (for all automatic pushes).<br>If set to 0, there is no limit.","default":0,pointer:{main:c,index:"maxspeed"}},{type:"buttons",buttons:[{type:"save",label:"Save",
|
||||
"function":function(){mist.send(function(){UI.navto("Push")},{push_settings:c})}}]}]));var d=$("<table>").append($("<tr>").append($("<th>").text("Stream")).append($("<th>").text("Target")).append($("<th>"))),e=d.clone();if("push_list"in a)for(var f in a.push_list)d.append(b(a.push_list[f],"Manual"));if("push_auto_list"in a)for(f in a.push_auto_list)e.append(b([-1,a.push_auto_list[f][0],a.push_auto_list[f][1]],"Automatic"));y.append($("<h3>").text("Automatic pushes")).append($("<button>").text("Add an automatic push").click(function(){UI.navto("Start Push",
|
||||
"auto")}));e.find("tr").length==1?y.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):y.append(e);y.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));d.find("tr").length==1?y.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em")):y.append(d)},{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in
|
||||
mist.data)){b.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push")},{capabilities:1});break}var t,O=function(){var a=[],d;for(d in mist.data.capabilities.connectors){var f=mist.data.capabilities.connectors[d];"push_urls"in f&&(a=a.concat(f.push_urls))}c=="auto"&&b.find("h2").text("Add automatic push");var e={};b.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
|
||||
"auto")}));e.find("tr").length==1?y.append($("<div>").text("No automatic pushes have been configured.").addClass("text").css("margin-top","0.5em")):y.append(e);y.append($("<h3>").text("Pushes")).append($("<button>").text("Start a push").click(function(){UI.navto("Start Push")}));d.find("tr").length==1?y.append($("<div>").text("No pushes are active.").addClass("text").css("margin-top","0.5em")):y.append($("<button>").text("Stop all pushes").click(function(){var b=[],c;for(c in a.push_list)b.push(a.push_list[c][0]);
|
||||
if(b.length!=0&&confirm("Are you sure you want to stop all pushes?")){mist.send(function(){function a(){setTimeout(function(){mist.send(function(c){var d=false;if("push_list"in c&&c.push_list&&c.push_list.length){var d=true,f;for(f in c.push_list)if(b.indexOf(c.push_list[f][0])==-1){d=false;break}}else d=true;d?UI.navto("Push"):a()},{push_list:1})},1E3)}a()},{push_stop:b});d.find("tr:not(:first-child)").html($("<td colspan=99>").append($("<span>").addClass("red").text("Stopping..")));$(this).remove()}})).append(d)},
|
||||
{push_settings:1,push_list:1,push_auto_list:1});break;case "Start Push":if(!("capabilities"in mist.data)){b.append("Loading Mist capabilities..");mist.send(function(){UI.navto("Start Push")},{capabilities:1});break}var t,O=function(){var a=[],d;for(d in mist.data.capabilities.connectors){var f=mist.data.capabilities.connectors[d];"push_urls"in f&&(a=a.concat(f.push_urls))}c=="auto"&&b.find("h2").text("Add automatic push");var e={};b.append(UI.buildUI([{label:"Stream name",type:"str",help:"This may either be a full stream name, a partial wildcard stream name, or a full wildcard stream name.<br>For example, given the stream <i>a</i> you can use:<ul><li><i>a</i>: the stream configured as <i>a</i></li><li><i>a+</i>: all streams configured as <i>a</i> with a wildcard behind it, but not <i>a</i> itself</li><li><i>a+b</i>: only the version of stream <i>a</i> that has wildcard <i>b</i></li></ul>",
|
||||
pointer:{main:e,index:"stream"},validate:["required",function(a){a=a.split("+");a=a[0];return a in mist.data.streams?false:{msg:"'"+a+"' is not a stream name.",classes:["red"]}}],datalist:t},{label:"Target",type:"str",help:"Where the stream will be pushed to.<br>Valid formats:<ul><li>"+a.join("</li><li>")+"</li></ul>",pointer:{main:e,index:"target"},validate:["required",function(b){for(var c in a)if(mist.inputMatch(a[c],b))return false;return{msg:"Does not match a valid target.<br>Valid formats:<ul><li>"+
|
||||
a.join("</li><li>")+"</li></ul>",classes:["red"]}}]},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("Push")}},{type:"save",label:"Save","function":function(){var a={};a[c=="auto"?"push_auto_add":"push_start"]=e;mist.send(function(){UI.navto("Push")},a)}}]}]))};mist.data.LTS?mist.send(function(a){(t=a.active_streams)||(t=[]);var a=[],b;for(b in t)t[b].indexOf("+")!=-1&&a.push(t[b].replace(/\+.*/,"")+"+");t=t.concat(a);var c=0,d=0;for(b in mist.data.streams){t.push(b);
|
||||
if(mist.inputMatch(mist.data.capabilities.inputs.Folder.source_match,mist.data.streams[b].source)){t.push(b+"+");mist.send(function(a,b){var f=b.stream,e;for(e in a.browse.files)for(var g in mist.data.capabilities.inputs)g.indexOf("Buffer")>=0||g.indexOf("Folder")>=0||mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[e])&&t.push(f+"+"+a.browse.files[e]);d++;if(c==d){t=t.filter(function(a,b,c){return c.lastIndexOf(a)===b}).sort();O()}},{browse:mist.data.streams[b].source},
|
||||
|
@ -142,7 +143,7 @@ false);b.closest("label").hide()}a.children('option[value="'+a.val()+'"]:disable
|
|||
"function":function(){$s=A.find(".graph_datatype");switch($(this).getval()){case "coords":$s.children("option").prop("disabled",true).filter('[value="coords"]').prop("disabled",false);break;case "time":$s.children("option").prop("disabled",false).filter('[value="coords"]').prop("disabled",true)}if(!$s.val()||$s.children('option[value="'+$s.val()+'"]:disabled').length){$s.val($s.children("option:enabled").first().val());$s.trigger("change")}}},{label:"Data type",type:"select",select:[["clients","Connections"],
|
||||
["upbps","Bandwidth (up)"],["downbps","Bandwidth (down)"],["cpuload","CPU use"],["memload","Memory load"],["coords","Client location"]],pointer:{main:o,index:"datatype"},classes:["graph_datatype"],"function":function(){$s=A.find(".graph_origin");switch($(this).getval()){case "cpuload":case "memload":$s.find("input[type=radio]").not('[value="total"]').prop("disabled",true);$s.find('input[type=radio][value="total"]').prop("checked",true);break;default:$s.find("input[type=radio]").prop("disabled",false)}}},
|
||||
{label:"Data origin",type:"radioselect",radioselect:[["total","All"],["stream","The stream:",H],["protocol","The protocol:",Q]],pointer:{main:o,index:"origin"},value:["total"],classes:["graph_origin"]},{type:"buttons",buttons:[{label:"Add data set",type:"save","function":function(){var a;if(o.graph=="new"){a=UI.plot.addGraph(o,c);u[a.id]=a;A.find("select.graph_ids").append($("<option>").text(a.id)).val(a.id).trigger("change")}else a=u[o.graph];var b=UI.plot.datatype.getOptions({datatype:o.datatype,
|
||||
origin:o.origin});a.datasets.push(b);UI.plot.save(a);UI.plot.go(u)}}]}]));var c=$("<div>").addClass("graph_container");b.append(c);var d=A.find("select.graph_ids");for(a in u){var e=UI.plot.addGraph(u[a],c);d.append($("<option>").text(e.id)).val(e.id);var f=[],g;for(g in u[a].datasets){var h=UI.plot.datatype.getOptions({datatype:u[a].datasets[g].datatype,origin:u[a].datasets[g].origin});f.push(h)}e.datasets=f;u[e.id]=e}d.trigger("change");UI.plot.go(u);UI.interval.set(function(){UI.plot.go(u)},1E4)},
|
||||
origin:o.origin});a.datasets.push(b);UI.plot.save(a);UI.plot.go(u)}}]}]));var c=$("<div>").addClass("graph_container");b.append(c);var d=A.find("select.graph_ids");for(a in u){var f=UI.plot.addGraph(u[a],c);d.append($("<option>").text(f.id)).val(f.id);var e=[],g;for(g in u[a].datasets){var h=UI.plot.datatype.getOptions({datatype:u[a].datasets[g].datatype,origin:u[a].datasets[g].origin});e.push(h)}f.datasets=e;u[f.id]=f}d.trigger("change");UI.plot.go(u);UI.interval.set(function(){UI.plot.go(u)},1E4)},
|
||||
{active_streams:!0,capabilities:!0});break;case "Server Stats":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a)},{capabilities:!0});b.append("Loading..");break}var R=$("<table>"),S=$("<table>"),h={vheader:"CPUs",labels:["Model","Processor speed","Amount of cores","Amount of threads"],content:[]};for(q in mist.data.capabilities.cpu)r=mist.data.capabilities.cpu[q],h.content.push({header:"CPU #"+(Number(q)+1),body:[r.model,UI.format.addUnit(UI.format.number(r.mhz),"MHz"),
|
||||
r.cores,r.threads]});var h=UI.buildVheaderTable(h),aa=function(){var a=mist.data.capabilities.mem,b=mist.data.capabilities.load,a={vheader:"Memory",labels:["Used","Cached","Available","Total"],content:[{header:"Physical memory",body:[UI.format.bytes(a.used*1048576)+" ("+UI.format.addUnit(b.memory,"%")+")",UI.format.bytes(a.cached*1048576),UI.format.bytes(a.free*1048576),UI.format.bytes(a.total*1048576)]},{header:"Swap memory",body:[UI.format.bytes((a.swaptotal-a.swapfree)*1048576),UI.format.addUnit("",
|
||||
"N/A"),UI.format.bytes(a.swapfree*1048576),UI.format.bytes(a.swaptotal*1048576)]}]},a=UI.buildVheaderTable(a);R.replaceWith(a);R=a;b={vheader:"Load average",labels:["CPU use","1 minute","5 minutes","15 minutes"],content:[{header:" ",body:[UI.format.addUnit(UI.format.number(mist.data.capabilities.cpu_use/10),"%"),UI.format.number(b.one/100),UI.format.number(b.five/100),UI.format.number(b.fifteen/100)]}]};b=UI.buildVheaderTable(b);S.replaceWith(b);S=b};aa();b.append(UI.buildUI([{type:"help",help:"You can find general server statistics here. Note that memory and CPU usage is for your entire machine, not just MistServer."}])).append($("<table>").css("width",
|
||||
|
|
47
lsp/mist.js
47
lsp/mist.js
|
@ -3363,7 +3363,52 @@ var UI = {
|
|||
);
|
||||
}
|
||||
else {
|
||||
$c.append($push);
|
||||
$c.append(
|
||||
$('<button>').text('Stop all pushes').click(function(){
|
||||
var push_list = [];
|
||||
for (var i in d.push_list) {
|
||||
push_list.push(d.push_list[i][0]);
|
||||
}
|
||||
if (push_list.length == 0) { return; }
|
||||
if (confirm('Are you sure you want to stop all pushes?')) {
|
||||
mist.send(function(d){
|
||||
function checkgone() {
|
||||
setTimeout(function(){
|
||||
mist.send(function(d){
|
||||
var gone = false;
|
||||
if (('push_list' in d) && (d.push_list) && (d.push_list.length)) {
|
||||
gone = true;
|
||||
for (var i in d.push_list) {
|
||||
if (push_list.indexOf(d.push_list[i][0]) == -1) {
|
||||
gone = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
gone = true;
|
||||
}
|
||||
if (gone) {
|
||||
UI.navto('Push');
|
||||
}
|
||||
else {
|
||||
checkgone();
|
||||
}
|
||||
},{push_list:1});
|
||||
},1e3);
|
||||
}
|
||||
checkgone();
|
||||
},{push_stop:push_list});
|
||||
$push.find('tr:not(:first-child)').html(
|
||||
$('<td colspan=99>').append(
|
||||
$('<span>').addClass('red').text('Stopping..')
|
||||
)
|
||||
);
|
||||
$(this).remove();
|
||||
}
|
||||
|
||||
})
|
||||
).append($push);
|
||||
}
|
||||
|
||||
},{push_settings:1,push_list:1,push_auto_list:1});
|
||||
|
|
Loading…
Add table
Reference in a new issue