2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

YAF: path to background image is now configurable via the YAF interface (marcproe)

git-svn-id: https://svn.fhem.de/fhem/trunk@3900 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
marcproe 2013-09-12 20:34:49 +00:00
parent 1ba92b1941
commit 4efb260c8d
7 changed files with 45 additions and 14 deletions

View File

@ -1,4 +1,5 @@
- Added regex capability for generic widget onclick function
- path to background image is now configurable via the YAF interface (marcproe)
- Added regex capability for generic widget onclick function (marcproe)
- Added foundation for modify dialog and modify dialog for generic widget (marcproe)
- Added Conig Save button (marcproe)
- Added widget generic (marcproe)

View File

@ -301,7 +301,7 @@ sub YAF_Request ($@) {
#-- changes the name of a View
elsif ($function eq "editView") {
if ($_GET{"id"} && $_GET{"name"}) {
YAF_Print(YAF_editView($_GET{"id"}, $_GET{"name"}));
YAF_Print(YAF_editView($_GET{"id"}, $_GET{"name"}, $_GET{"image"}));
}
else {
YAF_Print("0");

View File

@ -31,6 +31,7 @@ my $yaf_version=0.41;
my %fhemwidgets;
my %fhemviews;
my %fhemviewbgs;
my $isInit = 0;
#######################################################################################
@ -45,11 +46,17 @@ my $isInit = 0;
sub YAF_FHEMConfig { #this is called via ajax when the page is loaded.
#get the views
my $views = AttrVal("yaf","views",undef);
my $backgrounds = AttrVal("yaf", "backgrounds", undef);
if(defined $views and $isInit == 0) {
foreach my $view (split (/;/,$views)) {
my @aview = split(/,/,$view);
$fhemviews{$aview[0]} = $aview[1];
}
foreach my $bg (split (/;/,$backgrounds)) {
my @abg = split(/,/,$bg);
$fhemviewbgs{$abg[0]} = $abg[3];
}
my $retAttr = "";
foreach my $viewId (keys %fhemviews) {
@ -89,6 +96,7 @@ sub YAF_getViews{
foreach my $view (keys %fhemviews){
$viewsArray[$index][0] = $view;
$viewsArray[$index][1] = $fhemviews{$view};
$viewsArray[$index][2] = $fhemviewbgs{$view};
$index++;
}
@ -159,26 +167,40 @@ sub YAF_getView{
sub YAF_editView{
my $viewId = $_[0];
my $viewName = $_[1];
my $viewImage = $_[2];
my %viewhash = ();
my %viewbghash = ();
#load current config
foreach my $views (split(/;/,AttrVal("yaf","views",undef))) {
my @view = split(/,/,$views);
$viewhash{$view[0]} = $view[1];
}
foreach my $bgs (split(/;/,AttrVal("yaf","backgrounds",undef))) {
my @bg = split(/,/,$bgs);
$viewbghash{$bg[0]} = $bg[3];
}
#set new config value
$viewhash{$viewId} = $viewName;
$viewbghash{$viewId} = $viewImage;
#create new config
my $newview = "";
foreach my $key (keys %viewhash) {
$newview .= $key . "," . $viewhash{$key} . ";;";
}
my $newbg = "";
foreach my $key (keys %viewbghash) {
$newbg .= $key . ",1,1," . $viewbghash{$key} . ";;";
}
#save new config
fhem ("attr yaf views $newview");
fhem ("attr yaf backgrounds $newbg");
return 1;
}

View File

@ -80,7 +80,7 @@ function load_views(callback) {
context: document.body,
success: function (jsondata) {
views = jQuery.parseJSON(jsondata);
//console.log(views);
console.log(views);
if (callback) {
callback();
}

View File

@ -99,7 +99,7 @@ function init_dialogs() {
type: "GET",
async: true,
url: "../../ajax/global/editView",
data: "id=" + edit_view_id + "&name=" + $("#dialog_editview_name").val(),
data: "id=" + edit_view_id + "&name=" + $("#dialog_editview_name").val() + "&image=" + $("#dialog_editview_image").val(),
context: document.body,
success: function (jsondata) {
load_views(show_views);
@ -116,7 +116,6 @@ function init_dialogs() {
}
});
$("#dialog_addwidget").dialog({
autoOpen: false,
resizable: true,
@ -315,7 +314,6 @@ function init_dialogs() {
}
});
$("#dialog_manageviews").dialog({
autoOpen: false,
resizable: true,
@ -330,7 +328,7 @@ function init_dialogs() {
open: function (event, ui) {
$("#dialog_manageviews-table").html("<colgroup><col class=\"col1\"><col class=\"col2\"><col class=\"col3\"></colgroup>");
$.each(views, function (index, view) {
$("#dialog_manageviews-table").append("<tr id=\"manageviews_tr_" + view[0] + "\"><td>" + view[1] + "</td><td><button id=\"button_edit_" + view[0] + "\" class=\"button_edit\">&nbsp;</button></td><td><button class=\"button_delete\" id=\"button_edit_" + view[0] + "\">&nbsp;</button></td></tr>");
$("#dialog_manageviews-table").append("<tr id=\"manageviews_tr_" + view[0] + "\"><td>" + view[1] + "&nbsp;&nbsp;&nbsp;<img width=\"40\" src=\"" + view[2] + "\" id=\"image_edit_" + view[0] + "\" /></td><td><button id=\"button_edit_" + view[0] + "\" class=\"button_edit\">&nbsp;</button></td><td><button class=\"button_delete\" id=\"button_edit_" + view[0] + "\">&nbsp;</button></td></tr>" );
});
$(".button_edit").button({
icons: {
@ -352,9 +350,18 @@ function init_dialogs() {
return false;
});
$(".button_edit").click(function (ui) {
edit_view_name = $(ui.currentTarget.parentNode.parentNode.firstChild).html();
edit_view_id = $(ui.currentTarget).attr("id").substr(12);
$.each(views, function (index, view) { //this is quite ineffective and should be redone
if(view[0] == edit_view_id) {
edit_view_name = view[1];
edit_view_image = view[2];
}
});
$("#dialog_editview_name").val(edit_view_name);
$("#dialog_editview_image").val(edit_view_image);
$("#dialog_editview").dialog("open");
return false;
});

View File

@ -140,7 +140,8 @@
<div id="dialog_editview" title="Sicht bearbeiten">
<div class="loading_animation" id="dialog_addview_loading"></div>
<p>Hier können Sie die bestehende Sicht ändern.</p>
<label>Name: </label><input id="dialog_editview_name" name="dialog_editview_name" value="" />
<label>Name: </label><input id="dialog_editview_name" name="dialog_editview_name" value="" /><br />
<label>Bild: </label><input id="dialog_editview_image" name="dialog_editview_image" value="" />
</div>
<div id="dialog_deleteview" title="Sicht löschen">

View File

@ -17,7 +17,7 @@ DIR FHEM/YAF/www/smoothness/images
DIR FHEM/YAF/www/img
DIR FHEM/YAF/www/js
DIR FHEM/YAF/xml
UPD 2013-08-14_21:30:00 12046 FHEM/01_YAF.pm
UPD 2013-09-12_22:30:00 12062 FHEM/01_YAF.pm
UPD 2013-05-15_20:00:00 6590 FHEM/YAF/widgets/fs20st/fs20st.pm
UPD 2013-08-14_21:30:00 7471 FHEM/YAF/widgets/fht80/fht80.pm
UPD 2013-07-31_15:30:00 6534 FHEM/YAF/widgets/fhttk/fhttk.pm
@ -27,9 +27,9 @@ UPD 2013-05-15_20:00:00 2608 FHEM/YAF/www/img/loading.gif
UPD 2013-05-15_20:00:00 766 FHEM/YAF/www/img/lamp_off.png
UPD 2013-05-15_20:00:00 19226 FHEM/YAF/www/img/background.png
UPD 2013-05-15_20:00:00 831 FHEM/YAF/www/img/lamp_on.png
UPD 2013-08-14_21:30:00 12312 FHEM/YAF/www/js/yaf-basics.js
UPD 2013-08-14_21:30:00 11737 FHEM/YAF/www/js/yaf-dialogs.js
UPD 2013-08-14_21:30:00 7489 FHEM/YAF/www/yaf.htm
UPD 2013-09-12_22:30:00 12310 FHEM/YAF/www/js/yaf-basics.js
UPD 2013-09-12_22:30:00 12076 FHEM/YAF/www/js/yaf-dialogs.js
UPD 2013-09-12_22:30:00 7594 FHEM/YAF/www/yaf.htm
UPD 2013-05-15_20:00:00 3433 FHEM/YAF/www/js/combobox.js
UPD 2013-05-15_20:00:00 4593 FHEM/YAF/www/js/jquery.ui.touch-punch.min.js
UPD 2013-05-15_20:00:00 237176 FHEM/YAF/www/js/jquery-ui-1.9.1.custom.min.js
@ -53,5 +53,5 @@ UPD 2013-05-15_20:00:00 101 FHEM/YAF/www/css/smoothness/images/ui-bg_highlight-s
UPD 2013-05-15_20:00:00 26086 FHEM/YAF/www/css/smoothness/jquery-ui-1.9.1.custom.min.css
UPD 2013-05-15_20:00:00 3641 FHEM/YAF/xml/xmlSchema.xsd
UPD 2013-05-15_20:00:00 1690 FHEM/YAF/xml/yafConfig.xml
UPD 2013-09-10_22:20:00 15962 FHEM/YAF/YAFConfig.pm
UPD 2013-09-12_22:30:00 16597 FHEM/YAF/YAFConfig.pm
UPD 2013-05-15_20:00:00 3439 FHEM/YAF/YAFWidgets.pm