LSP: stop changing the api guys

This commit is contained in:
Cat 2023-03-09 17:02:08 +01:00
parent 472ab810a5
commit 44c879286a
2 changed files with 14 additions and 9 deletions

View file

@ -116,12 +116,12 @@ for(var c in a.variable_list){var d=a.variable_list[c];b.append($("<tr>").addCla
{type:"int",step:1E-8,label:"Server longitude",pointer:{main:ea.location,index:"lon"},help:"This setting is only useful when MistServer is combined with a load balancer. When this is set, the balancer can send users to a server close to them."},{type:"str",label:"Server location name",pointer:{main:ea.location,index:"name"},help:"This setting is only useful when MistServer is combined with a load balancer. This will be displayed as the server's location."},{type:"buttons",buttons:[{type:"save",label:"Save",
"function":function(a){$(a).text("Saving..");var a={config:ea},b={};b.limit=E.limit?Ga.val()*E.limit:0;b.exceptions=E.exceptions;if(b.exceptions===null)b.exceptions=[];a.bandwidth=b;mist.send(function(){UI.navto("Overview")},a)}}]}]));var na=$("<div>").html("Loading..");c.append(UI.buildUI([$("<h3>").text("External writers"),{type:"help",help:"When pushing a stream to a target unsupported by MistServer like S3 storage, an external writer can be provided which handles writing the media data to the target location. The writer will receive data over stdin and MistServer will print any info written to stdout and stderr as log messages."},
$("<div>").addClass("button_container").css("text-align","right").html($("<button>").text("New external writer").click(function(){UI.navto("Edit external writer","")})),na]));mist.send(function(a){if(a.external_writer_list){var b=$("<tbody>");na.html($("<table>").html($("<thead>").html($("<tr>").append($("<th>").text("Name")).append($("<th>").text("Command line")).append($("<th>").text("URI protocols handled")).append($("<th>")))).append(b));for(var c in a.external_writer_list){var d=a.external_writer_list[c];
b.append($("<tr>").addClass("uploader").attr("data-name",c).html($("<td>").text(d[0])).append($("<td>").html($("<code>").html(d[1]))).append($("<td>").text(d[2]?d[2].join(", "):"none").addClass("desc")).append($("<td>").html($("<button>").text("Edit").click(function(){var a=$(this).closest("tr").attr("data-name");UI.navto("Edit external writer",a)})).append($("<button>").text("Remove").click(function(){var a=$(this).closest("tr").attr("data-name");confirm("Are you sure you want to remove the Uploader '"+
a+"'?")&&mist.send(function(){UI.showTab("General")},{external_writer_remove:a})}))))}}else na.html("None configured.")},{external_writer_list:!0});break;case "Edit external writer":var z=!1;""!=b&&(z=!0);var Ia=function(){z?c.html($("<h2>").text("Edit external writer '"+b+"'")):c.html($("<h2>").text("New external writer"));var a={};if(mist.data.external_writer_list&&b in mist.data.external_writer_list){var d=mist.data.external_writer_list[b];a.name=d[0];a.cmdline=d[1];a.protocols=d[2]}c.append(UI.buildUI([{type:"str",
b.append($("<tr>").addClass("uploader").attr("data-name",c).html($("<td>").text(d[0])).append($("<td>").html($("<code>").html(d[1]))).append($("<td>").text(d[2]?d[2].join(", "):"none").addClass("desc")).append($("<td>").html($("<button>").text("Edit").click(function(){var a=$(this).closest("tr").attr("data-name");UI.navto("Edit external writer",a)})).append($("<button>").text("Remove").click(function(){var b=$(this).closest("tr").attr("data-name"),b=a.external_writer_list[b][0];confirm("Are you sure you want to remove the Uploader '"+
b+"'?")&&mist.send(function(){UI.showTab("General")},{external_writer_remove:b})}))))}}else na.html("None configured.")},{external_writer_list:!0});break;case "Edit external writer":var z=!1;""!=b&&(z=!0);var Ia=function(){z?c.html($("<h2>").text("Edit external writer '"+b+"'")):c.html($("<h2>").text("New external writer"));var a={};if(mist.data.external_writer_list&&b in mist.data.external_writer_list){var d=mist.data.external_writer_list[b];a.name=d[0];a.cmdline=d[1];a.protocols=d[2]}c.append(UI.buildUI([{type:"str",
label:"Human readable name",help:"A human readable name for the external writer.",validate:["required"],pointer:{main:a,index:"name"}},{type:"str",label:"Command line",help:"Command line for a local command (with optional arguments) which will write media data to the target.",validate:["required"],pointer:{main:a,index:"cmdline"}},{type:"inputlist",label:"URI protocols handled",help:"URI protocols which the external writer will be handling.",validate:["required",function(a){for(var b in a){var c=
a[b];if(c.match(/^([a-z\d\+\-\.])+?$/)===null)return{classes:["red"],msg:"There was a problem with the protocol URI '"+$("<div>").text(c).html()+"':<br>A protocol URI may only contain lower case letters, digits, and the following special characters . + and -"}}}],input:{type:"str",unit:"://"},pointer:{main:a,index:"protocols"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={external_writer_add:a};
if(a.name!=b)c.external_writer_remove=b;mist.send(function(){UI.navto("General")},c)}}]}]))};"external_writer_list"in mist.data?Ia():mist.send(function(){Ia()},{external_writer_list:!0});break;case "Edit variable":z=!1;""!=b&&(z=!0);var Fa=function(a,d){z?c.html($("<h2>").text('Edit Variable "$'+b+'"')):c.html($("<h2>").text("New Variable"));var f=$("<div>");c.append(UI.buildUI([{type:"str",maxlength:31,label:"Variable name",prefix:"$",help:"What should the variable be called? A dollar sign will automatically be prepended.",
pointer:{main:a,index:"name"},validate:["required",function(a){if(a.length&&a[0]=="$")return{msg:"The dollar sign will automatically be prepended. You don't need to type it here.",classes:["red"]};if(a.indexOf("{")!==-1||a.indexOf("}")!==-1||a.indexOf("$")!==-1)return{msg:'The following symbols are not permitted: "$ { }".',classes:["red"]}}]},{type:"select",label:"Type",help:"What kind of variable is this? It can either be a static value that you can enter below, or a dynamic one that is returned by a command.",
a[b];if(c.match(/^([a-z\d\+\-\.])+?$/)===null)return{classes:["red"],msg:"There was a problem with the protocol URI '"+$("<div>").text(c).html()+"':<br>A protocol URI may only contain lower case letters, digits, and the following special characters . + and -"}}}],input:{type:"str",unit:"://"},pointer:{main:a,index:"protocols"}},{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={external_writer_add:a},
d=null;b!=""&&b in mist.data.external_writer_list&&(d=mist.data.external_writer_list[b][0]);if(d!==null&&a.name!=d)c.external_writer_remove=d;mist.send(function(){UI.navto("General")},c)}}]}]))};"external_writer_list"in mist.data?Ia():mist.send(function(){Ia()},{external_writer_list:!0});break;case "Edit variable":z=!1;""!=b&&(z=!0);var Fa=function(a,d){z?c.html($("<h2>").text('Edit Variable "$'+b+'"')):c.html($("<h2>").text("New Variable"));var f=$("<div>");c.append(UI.buildUI([{type:"str",maxlength:31,
label:"Variable name",prefix:"$",help:"What should the variable be called? A dollar sign will automatically be prepended.",pointer:{main:a,index:"name"},validate:["required",function(a){if(a.length&&a[0]=="$")return{msg:"The dollar sign will automatically be prepended. You don't need to type it here.",classes:["red"]};if(a.indexOf("{")!==-1||a.indexOf("}")!==-1||a.indexOf("$")!==-1)return{msg:'The following symbols are not permitted: "$ { }".',classes:["red"]}}]},{type:"select",label:"Type",help:"What kind of variable is this? It can either be a static value that you can enter below, or a dynamic one that is returned by a command.",
select:[["value","Static value"],["command","Dynamic through command"]],value:"value",pointer:{main:d,index:"type"},"function":function(){var a=[$("Invalid variable type")];switch($(this).val()){case "value":a=[{type:"str",label:"Value",pointer:{main:d,index:"value"},help:"The static value that this variable should be replaced with. There is a character limit of 63 characters.",validate:["required"]}];break;case "command":a=[{type:"str",label:"Command",help:"The command that should be executed to retrieve the value for this variable.<br>For example:<br><code>/usr/bin/date +%A</code><br>There is a character limit of 511 characters.",
validate:["required"],pointer:{main:d,index:"target"}},{type:"int",min:0,max:4294967295,"default":0,label:"Checking interval",unit:"s",help:"At what interval, in seconds, MistServer should execute the command and update the value.<br>To execute the command once when MistServer starts up (and then never update), set the interval to 0.",pointer:{main:d,index:"interval"}},{type:"int",min:0,max:4294967295,"default":1,label:"Wait time",unit:"s",help:"Specifies the maximum time, in seconds, MistServer should wait for data when executing the variable target. If set to 0 this variable takes on the same value as the interval.<br>MistServer only updates one variable at a time, so setting this value too high can block other variables from updating.",
pointer:{main:d,index:"waitTime"}}]}f.html(UI.buildUI(a))}},f,{type:"buttons",buttons:[{type:"cancel",label:"Cancel","function":function(){UI.navto("General")}},{type:"save",label:"Save","function":function(){var c={variable_add:a};switch(d.type){case "value":a.value=d.value;break;case "command":a.target=d.target;a.interval=d.interval;a.waitTime=d.waitTime}if(a.name!=b)c.variable_remove=b;mist.send(function(){UI.navto("General")},c)}}]}]))};c.html("Loading..");z?mist.send(function(a){if(b in a.variable_list){a=

View file

@ -3219,10 +3219,11 @@ var UI = {
).append(
$("<button>").text("Remove").click(function(){
var i = $(this).closest("tr").attr("data-name");
if (confirm("Are you sure you want to remove the Uploader '"+i+"'?")) {
var name = d.external_writer_list[i][0];
if (confirm("Are you sure you want to remove the Uploader '"+name+"'?")) {
mist.send(function(){
UI.showTab("General");
},{external_writer_remove:i});
},{external_writer_remove:name});
}
})
)
@ -3311,9 +3312,13 @@ var UI = {
label: 'Save',
'function': function(){
var o = {external_writer_add:saveas};
var prev_name = null;
if ((other != "") && (other in mist.data.external_writer_list)) {
prev_name = mist.data.external_writer_list[other][0];
}
if (saveas.name != other) {
o.external_writer_remove = other;
if ((prev_name !== null) && (saveas.name != prev_name)) {
o.external_writer_remove = prev_name;
}
mist.send(function(){
UI.navto('General');