mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Instance names can now be renamed on the WebUI (incl. inst 0)
Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
parent
a080c7151d
commit
3dee474356
@ -196,6 +196,10 @@ table label{margin:0}
|
|||||||
background-color:#d1322e;
|
background-color:#d1322e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal-icon-edit{
|
||||||
|
background-color:#3579b6;
|
||||||
|
}
|
||||||
|
|
||||||
.overlay {
|
.overlay {
|
||||||
background-image: url('/img/hyperion/hyperionwhitelogo.png');
|
background-image: url('/img/hyperion/hyperionwhitelogo.png');
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
"general_btn_stop" : "Stop",
|
"general_btn_stop" : "Stop",
|
||||||
"general_btn_continue": "Fortfahren",
|
"general_btn_continue": "Fortfahren",
|
||||||
"general_btn_delete" : "Löschen",
|
"general_btn_delete" : "Löschen",
|
||||||
|
"general_btn_rename" : "Umbenennen",
|
||||||
"general_btn_save": "Speichern",
|
"general_btn_save": "Speichern",
|
||||||
"general_btn_saverestart": "Speichern und neustarten",
|
"general_btn_saverestart": "Speichern und neustarten",
|
||||||
"general_btn_saveandreload": "Speichern und neu laden",
|
"general_btn_saveandreload": "Speichern und neu laden",
|
||||||
@ -103,6 +104,15 @@
|
|||||||
"conf_general_impexp_l2": "Exportiere eine Konfiguration, indem du auf \"Exportieren\" klickst. Dein Browser startet einen Download.",
|
"conf_general_impexp_l2": "Exportiere eine Konfiguration, indem du auf \"Exportieren\" klickst. Dein Browser startet einen Download.",
|
||||||
"conf_general_impexp_impbtn": "Importieren",
|
"conf_general_impexp_impbtn": "Importieren",
|
||||||
"conf_general_impexp_expbtn": "Exportieren",
|
"conf_general_impexp_expbtn": "Exportieren",
|
||||||
|
"conf_general_inst_title" : "LED Hardware Instanzverwaltung",
|
||||||
|
"conf_general_inst_desc" : "Verwende mehrere LED Hardware gleichzeitig. Jede Instanz läuft unabhängig voneinander, wodurch unterschiedliche LED-Layouts und Kalibrierungseinstellungen möglich sind. Laufende Instanzen sind in der oberen Symbolleiste verfügbar.",
|
||||||
|
"conf_general_inst_namehead" : "Instanzname",
|
||||||
|
"conf_general_inst_actionhead" : "Aktionen",
|
||||||
|
"conf_general_inst_name_title" : "Neuer Instanzname",
|
||||||
|
"conf_general_createInst_btn" : "Instanz erstellen",
|
||||||
|
"conf_general_inst_renreq_t" : "Gib in das untere Feld deinen neuen Instanznamen ein.",
|
||||||
|
"conf_general_inst_delreq_h" : "LED Hardware Instanz löschen",
|
||||||
|
"conf_general_inst_delreq_t" : "Bist du Dir sicher, das du die Instanz \"$1\" löschen möchtest? Alle Einstellungen zu dieser Instanz gehen verloren.",
|
||||||
"conf_helptable_option": "Option",
|
"conf_helptable_option": "Option",
|
||||||
"conf_helptable_expl": "Erklärung",
|
"conf_helptable_expl": "Erklärung",
|
||||||
"conf_effect_path_intro": "Hier kannst du Ordner angeben, die beim Laden von Effekten berücksichtig werden sollen. Zusätzlich können Effekte anhand ihres Namens deaktiviert werden um sie aus Listen zu löschen.",
|
"conf_effect_path_intro": "Hier kannst du Ordner angeben, die beim Laden von Effekten berücksichtig werden sollen. Zusätzlich können Effekte anhand ihres Namens deaktiviert werden um sie aus Listen zu löschen.",
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
"general_btn_stop" : "Stop",
|
"general_btn_stop" : "Stop",
|
||||||
"general_btn_cancel" : "Cancel",
|
"general_btn_cancel" : "Cancel",
|
||||||
"general_btn_delete" : "Delete",
|
"general_btn_delete" : "Delete",
|
||||||
|
"general_btn_rename" : "Rename",
|
||||||
"general_btn_continue" : "Continue",
|
"general_btn_continue" : "Continue",
|
||||||
"general_btn_save" : "Save",
|
"general_btn_save" : "Save",
|
||||||
"general_btn_saveandreload" : "Save and reload",
|
"general_btn_saveandreload" : "Save and reload",
|
||||||
@ -108,6 +109,7 @@
|
|||||||
"conf_general_inst_actionhead" : "Action",
|
"conf_general_inst_actionhead" : "Action",
|
||||||
"conf_general_inst_name_title" : "New Instance name",
|
"conf_general_inst_name_title" : "New Instance name",
|
||||||
"conf_general_createInst_btn" : "Create Instance",
|
"conf_general_createInst_btn" : "Create Instance",
|
||||||
|
"conf_general_inst_renreq_t" : "Enter a new name for your instance in the field below.",
|
||||||
"conf_general_inst_delreq_h" : "Delete LED Hardware instance",
|
"conf_general_inst_delreq_h" : "Delete LED Hardware instance",
|
||||||
"conf_general_inst_delreq_t" : "Are you sure that you want to delete instance \"$1\"? All settings will be deleted too.",
|
"conf_general_inst_delreq_t" : "Are you sure that you want to delete instance \"$1\"? All settings will be deleted too.",
|
||||||
"conf_helptable_option" : "Option",
|
"conf_helptable_option" : "Option",
|
||||||
|
@ -25,9 +25,21 @@ $(document).ready( function() {
|
|||||||
requestWriteConfig(conf_editor.getValue());
|
requestWriteConfig(conf_editor.getValue());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Instance handling
|
// Instance handling
|
||||||
|
function handleInstanceRename(e)
|
||||||
|
{
|
||||||
|
var inst = e.currentTarget.id.split("_")[1];
|
||||||
|
showInfoDialog('renInst', $.i18n('conf_general_inst_renreq_t'), getInstanceNameByIndex(inst));
|
||||||
|
|
||||||
|
$("#id_btn_ok").off().on('click', function(){
|
||||||
|
requestInstanceRename(inst, $('#renInst_name').val())
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#renInst_name').off().on('input',function(e) {
|
||||||
|
(e.currentTarget.value.length >= 5 && e.currentTarget.value != getInstanceNameByIndex(inst)) ? $('#id_btn_ok').attr('disabled', false) : $('#id_btn_ok').attr('disabled', true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function handleInstanceStartStop(e)
|
function handleInstanceStartStop(e)
|
||||||
{
|
{
|
||||||
var inst = e.currentTarget.id.split("_")[1];
|
var inst = e.currentTarget.id.split("_")[1];
|
||||||
@ -38,7 +50,7 @@ $(document).ready( function() {
|
|||||||
function handleInstanceDelete(e)
|
function handleInstanceDelete(e)
|
||||||
{
|
{
|
||||||
var inst = e.currentTarget.id.split("_")[1];
|
var inst = e.currentTarget.id.split("_")[1];
|
||||||
showInfoDialog('delplug',$.i18n('conf_general_inst_delreq_h'),$.i18n('conf_general_inst_delreq_t',getInstanceNameByIndex(inst)));
|
showInfoDialog('delInst',$.i18n('conf_general_inst_delreq_h'),$.i18n('conf_general_inst_delreq_t',getInstanceNameByIndex(inst)));
|
||||||
$("#id_btn_yes").off().on('click', function(){
|
$("#id_btn_yes").off().on('click', function(){
|
||||||
requestInstanceDelete(inst)
|
requestInstanceDelete(inst)
|
||||||
});
|
});
|
||||||
@ -51,29 +63,35 @@ $(document).ready( function() {
|
|||||||
for(var key in inst)
|
for(var key in inst)
|
||||||
{
|
{
|
||||||
var startBtnColor = inst[key].running ? "success" : "danger";
|
var startBtnColor = inst[key].running ? "success" : "danger";
|
||||||
|
var startBtnIcon = inst[key].running ? "stop" : "play";
|
||||||
var startBtnText = inst[key].running ? $.i18n('general_btn_stop') : $.i18n('general_btn_start');
|
var startBtnText = inst[key].running ? $.i18n('general_btn_stop') : $.i18n('general_btn_start');
|
||||||
var startBtn = "-"
|
var renameBtn = '<button id="instren_'+inst[key].instance+'" type="button" class="btn btn-primary"><i class="fa fa-pencil"> '+$.i18n('general_btn_rename')+'</i></button>';
|
||||||
var delBtn = "-";
|
var startBtn = ""
|
||||||
|
var delBtn = "";
|
||||||
if(inst[key].instance > 0)
|
if(inst[key].instance > 0)
|
||||||
{
|
{
|
||||||
delBtn = '<button id="instdel_'+inst[key].instance+'" type="button" class="btn btn-danger">'+$.i18n('general_btn_delete')+'</button>';
|
delBtn = '<button id="instdel_'+inst[key].instance+'" type="button" class="btn btn-warning"><i class="fa fa-remove"> '+$.i18n('general_btn_delete')+'</i></button>';
|
||||||
startBtn = '<button id="inst_'+inst[key].instance+'" type="button" class="btn btn-'+startBtnColor+'">'+startBtnText+'</button>';
|
startBtn = '<button id="inst_'+inst[key].instance+'" type="button" class="btn btn-'+startBtnColor+'"><i class="fa fa-'+startBtnIcon+'"> '+startBtnText+'</i></button>';
|
||||||
}
|
}
|
||||||
$('.itbody').append(createTableRow([inst[key].friendly_name, startBtn, delBtn], false, true));
|
$('.itbody').append(createTableRow([inst[key].friendly_name, renameBtn, startBtn, delBtn], false, true));
|
||||||
|
$('#instren_'+inst[key].instance).off().on('click', handleInstanceRename);
|
||||||
$('#inst_'+inst[key].instance).off().on('click', handleInstanceStartStop);
|
$('#inst_'+inst[key].instance).off().on('click', handleInstanceStartStop);
|
||||||
$('#instdel_'+inst[key].instance).off().on('click', handleInstanceDelete);
|
$('#instdel_'+inst[key].instance).off().on('click', handleInstanceDelete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createTable('ithead', 'itbody', 'itable');
|
createTable('ithead', 'itbody', 'itable');
|
||||||
$('.ithead').html(createTableRow([$.i18n('conf_general_inst_namehead'), $.i18n('conf_general_inst_actionhead'), $.i18n('general_btn_delete')], true, true));
|
$('.ithead').html(createTableRow([$.i18n('conf_general_inst_namehead'), "", $.i18n('conf_general_inst_actionhead'), ""], true, true));
|
||||||
buildInstanceList();
|
buildInstanceList();
|
||||||
|
|
||||||
$('#inst_name').off().on('input',function(e) {
|
$('#inst_name').off().on('input',function(e) {
|
||||||
(e.currentTarget.value.length >= 5) ? $('#btn_create_inst').attr('disabled', false) : $('#btn_create_inst').attr('disabled', true);
|
(e.currentTarget.value.length >= 5) ? $('#btn_create_inst').attr('disabled', false) : $('#btn_create_inst').attr('disabled', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#btn_create_inst').off().on('click',function(e) {
|
$('#btn_create_inst').off().on('click',function(e) {
|
||||||
requestInstanceCreate($('#inst_name').val());
|
requestInstanceCreate($('#inst_name').val());
|
||||||
|
$('#inst_name').val("");
|
||||||
|
$('#btn_create_inst').attr('disabled', true)
|
||||||
});
|
});
|
||||||
|
|
||||||
$(hyperion).off("instance-updated").on("instance-updated", function(event) {
|
$(hyperion).off("instance-updated").on("instance-updated", function(event) {
|
||||||
|
@ -190,6 +190,11 @@ function requestTokenDelete(id)
|
|||||||
sendToHyperion("authorize","deleteToken",'"id":"'+id+'"');
|
sendToHyperion("authorize","deleteToken",'"id":"'+id+'"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function requestInstanceRename(inst, name)
|
||||||
|
{
|
||||||
|
sendToHyperion("instance", "saveName",'"instance": '+inst+', "name": "'+name+'"');
|
||||||
|
}
|
||||||
|
|
||||||
function requestInstanceStartStop(inst, start)
|
function requestInstanceStartStop(inst, start)
|
||||||
{
|
{
|
||||||
if(start)
|
if(start)
|
||||||
|
@ -214,53 +214,69 @@ function setClassByBool(obj,enable,class1,class2)
|
|||||||
|
|
||||||
function showInfoDialog(type,header,message)
|
function showInfoDialog(type,header,message)
|
||||||
{
|
{
|
||||||
if (type=="success"){
|
if (type=="success")
|
||||||
|
{
|
||||||
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-check modal-icon-check">');
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-check modal-icon-check">');
|
||||||
if(header == "")
|
if(header == "")
|
||||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_success_title')+'</h4>');
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_success_title')+'</h4>');
|
||||||
$('#id_footer').html('<button type="button" class="btn btn-success" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
$('#id_footer').html('<button type="button" class="btn btn-success" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
||||||
}
|
}
|
||||||
else if (type=="warning"){
|
else if (type=="warning")
|
||||||
|
{
|
||||||
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
|
||||||
if(header == "")
|
if(header == "")
|
||||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_warning_title')+'</h4>');
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_warning_title')+'</h4>');
|
||||||
$('#id_footer').html('<button type="button" class="btn btn-warning" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
$('#id_footer').html('<button type="button" class="btn btn-warning" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
||||||
}
|
}
|
||||||
else if (type=="error"){
|
else if (type=="error")
|
||||||
|
{
|
||||||
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-error">');
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-error">');
|
||||||
if(header == "")
|
if(header == "")
|
||||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_error_title')+'</h4>');
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_error_title')+'</h4>');
|
||||||
$('#id_footer').html('<button type="button" class="btn btn-danger" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
$('#id_footer').html('<button type="button" class="btn btn-danger" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
||||||
}
|
}
|
||||||
else if (type == "select"){
|
else if (type == "select")
|
||||||
|
{
|
||||||
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||||
$('#id_footer').html('<button type="button" id="id_btn_saveset" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_saveandreload')+'</button>');
|
$('#id_footer').html('<button type="button" id="id_btn_saveset" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_saveandreload')+'</button>');
|
||||||
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
||||||
}
|
}
|
||||||
else if (type == "iswitch"){
|
else if (type == "iswitch")
|
||||||
|
{
|
||||||
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||||
$('#id_footer').html('<button type="button" id="id_btn_saveset" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-fw fa-exchange"></i>'+$.i18n('general_btn_iswitch')+'</button>');
|
$('#id_footer').html('<button type="button" id="id_btn_saveset" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-fw fa-exchange"></i>'+$.i18n('general_btn_iswitch')+'</button>');
|
||||||
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
||||||
}
|
}
|
||||||
else if (type == "uilock"){
|
else if (type == "uilock")
|
||||||
|
{
|
||||||
$('#id_body').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
$('#id_body').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||||
$('#id_footer').html('<b>'+$.i18n('InfoDialog_nowrite_foottext')+'</b>');
|
$('#id_footer').html('<b>'+$.i18n('InfoDialog_nowrite_foottext')+'</b>');
|
||||||
}
|
}
|
||||||
else if (type == "import"){
|
else if (type == "import")
|
||||||
|
{
|
||||||
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
|
||||||
$('#id_footer').html('<button type="button" id="id_btn_import" class="btn btn-warning" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_saverestart')+'</button>');
|
$('#id_footer').html('<button type="button" id="id_btn_import" class="btn btn-warning" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_saverestart')+'</button>');
|
||||||
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
||||||
}
|
}
|
||||||
else if (type == "delplug"){
|
else if (type == "delInst")
|
||||||
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
|
{
|
||||||
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-remove modal-icon-warning">');
|
||||||
$('#id_footer').html('<button type="button" id="id_btn_yes" class="btn btn-warning" data-dismiss="modal"><i class="fa fa-fw fa-trash"></i>'+$.i18n('general_btn_yes')+'</button>');
|
$('#id_footer').html('<button type="button" id="id_btn_yes" class="btn btn-warning" data-dismiss="modal"><i class="fa fa-fw fa-trash"></i>'+$.i18n('general_btn_yes')+'</button>');
|
||||||
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
||||||
}
|
}
|
||||||
|
else if (type == "renInst")
|
||||||
|
{
|
||||||
|
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-pencil modal-icon-edit"><br>');
|
||||||
|
$('#id_body').append('<h4>'+header+'</h4>');
|
||||||
|
$('#id_body').append('<input class="form-control" id="renInst_name" type="text" value="'+message+'">');
|
||||||
|
$('#id_footer').html('<button type="button" id="id_btn_ok" class="btn btn-success" data-dismiss="modal" disabled><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_ok')+'</button>');
|
||||||
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
|
||||||
|
}
|
||||||
else if (type == "checklist")
|
else if (type == "checklist")
|
||||||
{
|
{
|
||||||
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
|
||||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_checklist_title')+'</h4>');
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_checklist_title')+'</h4>');
|
||||||
$('#id_body').append(message);
|
$('#id_body').append(header);
|
||||||
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
$('#id_footer').html('<button type="button" class="btn btn-primary" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
|
||||||
}
|
}
|
||||||
else if (type == "newToken")
|
else if (type == "newToken")
|
||||||
@ -275,8 +291,11 @@ function showInfoDialog(type,header,message)
|
|||||||
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal" id="tok_deny_acc">'+$.i18n('general_btn_denyAccess')+'</button>');
|
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal" id="tok_deny_acc">'+$.i18n('general_btn_denyAccess')+'</button>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+header+'</h4>');
|
if(type != "renInst")
|
||||||
$('#id_body').append(message);
|
{
|
||||||
|
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+header+'</h4>');
|
||||||
|
$('#id_body').append(message);
|
||||||
|
}
|
||||||
|
|
||||||
if(type == "select" || type == "iswitch")
|
if(type == "select" || type == "iswitch")
|
||||||
$('#id_body').append('<select id="id_select" class="form-control" style="margin-top:10px;width:auto;"></select>');
|
$('#id_body').append('<select id="id_select" class="form-control" style="margin-top:10px;width:auto;"></select>');
|
||||||
@ -669,8 +688,8 @@ function createHelpTable(list, phead){
|
|||||||
// break one iteration (in the loop), if the schema has the entry hidden=true
|
// break one iteration (in the loop), if the schema has the entry hidden=true
|
||||||
if ("options" in list[key] && "hidden" in list[key].options && (list[key].options.hidden))
|
if ("options" in list[key] && "hidden" in list[key].options && (list[key].options.hidden))
|
||||||
continue;
|
continue;
|
||||||
if ("access" in list[key] && ((list[key].access == "advanced" && storedAccess == "default") || (list[key].access == "expert" && storedAccess != "expert")))
|
if ("access" in list[key] && ((list[key].access == "advanced" && storedAccess == "default") || (list[key].access == "expert" && storedAccess != "expert")))
|
||||||
continue;
|
continue;
|
||||||
var text = list[key].title.replace('title', 'expl');
|
var text = list[key].title.replace('title', 'expl');
|
||||||
tbody.appendChild(createTableRow([$.i18n(list[key].title), $.i18n(text)], false, false));
|
tbody.appendChild(createTableRow([$.i18n(list[key].title), $.i18n(text)], false, false));
|
||||||
|
|
||||||
@ -682,8 +701,8 @@ function createHelpTable(list, phead){
|
|||||||
// break one iteration (in the loop), if the schema has the entry hidden=true
|
// break one iteration (in the loop), if the schema has the entry hidden=true
|
||||||
if ("options" in ilist[ikey] && "hidden" in ilist[ikey].options && (ilist[ikey].options.hidden))
|
if ("options" in ilist[ikey] && "hidden" in ilist[ikey].options && (ilist[ikey].options.hidden))
|
||||||
continue;
|
continue;
|
||||||
if ("access" in ilist[ikey] && ((ilist[ikey].access == "advanced" && storedAccess == "default") || (ilist[ikey].access == "expert" && storedAccess != "expert")))
|
if ("access" in ilist[ikey] && ((ilist[ikey].access == "advanced" && storedAccess == "default") || (ilist[ikey].access == "expert" && storedAccess != "expert")))
|
||||||
continue;
|
continue;
|
||||||
var itext = ilist[ikey].title.replace('title', 'expl');
|
var itext = ilist[ikey].title.replace('title', 'expl');
|
||||||
tbody.appendChild(createTableRow([$.i18n(ilist[ikey].title), $.i18n(itext)], false, false));
|
tbody.appendChild(createTableRow([$.i18n(ilist[ikey].title), $.i18n(itext)], false, false));
|
||||||
}
|
}
|
||||||
|
@ -80,10 +80,10 @@ typedef struct {
|
|||||||
#define STATIC_ASSERT(condition, message) \
|
#define STATIC_ASSERT(condition, message) \
|
||||||
_Static_assert(condition, message)
|
_Static_assert(condition, message)
|
||||||
#else
|
#else
|
||||||
#define STATIC_ASSERT(condition, message) // FIXME
|
#define STATIC_ASSERT(condition, message)
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define STATIC_ASSERT(condition, message) // FIXME
|
#define STATIC_ASSERT(condition, message)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC_ASSERT(sizeof(PacketHeader) == 8, "PacketHeader has invalid size");
|
STATIC_ASSERT(sizeof(PacketHeader) == 8, "PacketHeader has invalid size");
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
setTable("instances");
|
setTable("instances");
|
||||||
createTable(QStringList()<<"instance INTEGER"<<"friendly_name TEXT"<<"enabled INTEGER DEFAULT 0"<<"last_use TEXT");
|
createTable(QStringList()<<"instance INTEGER"<<"friendly_name TEXT"<<"enabled INTEGER DEFAULT 0"<<"last_use TEXT");
|
||||||
|
|
||||||
// create the first Hyperion instance index 0
|
// start/create the first Hyperion instance index 0
|
||||||
createInstance();
|
createInstance();
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -93,14 +93,21 @@ public:
|
|||||||
///
|
///
|
||||||
inline bool saveName(const quint8& inst, const QString& name)
|
inline bool saveName(const quint8& inst, const QString& name)
|
||||||
{
|
{
|
||||||
if(instanceExist(inst))
|
VectorPair fcond;
|
||||||
{
|
fcond.append(CPair("friendly_name",name));
|
||||||
VectorPair cond;
|
|
||||||
cond.append(CPair("instance",inst));
|
|
||||||
QVariantMap data;
|
|
||||||
data["friendly_name"] = name;
|
|
||||||
|
|
||||||
return updateRecord(cond, data);
|
// check duplicate
|
||||||
|
if(!recordExists(fcond))
|
||||||
|
{
|
||||||
|
if(instanceExist(inst))
|
||||||
|
{
|
||||||
|
VectorPair cond;
|
||||||
|
cond.append(CPair("instance",inst));
|
||||||
|
QVariantMap data;
|
||||||
|
data["friendly_name"] = name;
|
||||||
|
|
||||||
|
return updateRecord(cond, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -207,13 +214,18 @@ private:
|
|||||||
///
|
///
|
||||||
inline void createInstance()
|
inline void createInstance()
|
||||||
{
|
{
|
||||||
QVariantMap data;
|
if(instanceExist(0))
|
||||||
data["friendly_name"] = "First LED Hardware instance";
|
|
||||||
VectorPair cond;
|
|
||||||
cond.append(CPair("instance", 0));
|
|
||||||
if(createRecord(cond, data))
|
|
||||||
setEnable(0, true);
|
setEnable(0, true);
|
||||||
else
|
else
|
||||||
throw std::runtime_error("Failed to create Hyperion root instance in db! This should never be the case...");
|
{
|
||||||
|
QVariantMap data;
|
||||||
|
data["friendly_name"] = "First LED Hardware instance";
|
||||||
|
VectorPair cond;
|
||||||
|
cond.append(CPair("instance", 0));
|
||||||
|
if(createRecord(cond, data))
|
||||||
|
setEnable(0, true);
|
||||||
|
else
|
||||||
|
throw std::runtime_error("Failed to create Hyperion root instance in db! This should never be the case...");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1298,9 +1298,16 @@ void JsonAPI::handleInstanceCommand(const QJsonObject & message, const QString &
|
|||||||
|
|
||||||
if(subc == "saveName")
|
if(subc == "saveName")
|
||||||
{
|
{
|
||||||
// silent fail
|
if(_userAuthorized)
|
||||||
_instanceManager->saveName(inst,name);
|
{
|
||||||
sendSuccessReply(command+"-"+subc, tan);
|
// silent fail
|
||||||
|
if(_instanceManager->saveName(inst,name))
|
||||||
|
sendSuccessReply(command+"-"+subc, tan);
|
||||||
|
else
|
||||||
|
sendErrorReply(QString("The instance name '%1' is already in use").arg(name), command+"-"+subc, tan);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sendErrorReply("No Authorization",command+"-"+subc, tan);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user