98_weekprofile: new attribute 'widgetEditOnNewPage'

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@10352 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
risiko79
2016-01-03 19:17:01 +00:00
parent a3085333bf
commit 277e91e64c
3 changed files with 81 additions and 25 deletions

View File

@@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- feature: 98_weekprofile: new attribute 'widgetEditOnNewPage' to edit
weekprofile on new web page
- change: 89_HEATRONIC: new feature: set heating mode, set temperature - change: 89_HEATRONIC: new feature: set heating mode, set temperature
new reading ch_code new reading ch_code
- bugfix: FB_CALLMONITOR: empty phonebooks will be recognized correctly, - bugfix: FB_CALLMONITOR: empty phonebooks will be recognized correctly,

View File

@@ -310,7 +310,7 @@ sub weekprofile_Initialize($)
$hash->{StateFn} = "weekprofile_State"; $hash->{StateFn} = "weekprofile_State";
$hash->{NotifyFn} = "weekprofile_Notify"; $hash->{NotifyFn} = "weekprofile_Notify";
$hash->{AttrFn} = "weekprofile_Attr"; $hash->{AttrFn} = "weekprofile_Attr";
$hash->{AttrList} = "widgetWeekdays configFile ".$readingFnAttributes; $hash->{AttrList} = "widgetWeekdays widgetEditOnNewPage:0,1 configFile ".$readingFnAttributes;
$hash->{FW_summaryFn} = "weekprofile_SummaryFn"; $hash->{FW_summaryFn} = "weekprofile_SummaryFn";
@@ -659,11 +659,13 @@ sub weekprofile_SummaryFn()
my $html; my $html;
my $iconName = AttrVal($d, "icon", "edit_settings"); my $iconName = AttrVal($d, "icon", "edit_settings");
my $icon = FW_iconName($iconName) ? FW_makeImage($iconName,$iconName,"icon") : ""; my $editNewpage = AttrVal($d, "widgetEditOnNewPage", 0);
$icon = "<a name=\"$d.edit\" onclick=\"weekprofile_DoEditWeek('$d')\" href=\"javascript:void(0)\">$icon</a>";
my $lnk = AttrVal($d, "alias", $d); my $editIcon = FW_iconName($iconName) ? FW_makeImage($iconName,$iconName,"icon") : "";
$lnk = "<a name=\"$d.detail\" href=\"$FW_ME$FW_subdir?detail=$d\">$lnk</a>" if($show_links); $editIcon = "<a name=\"$d.edit\" onclick=\"weekprofile_DoEditWeek('$d','$editNewpage')\" href=\"javascript:void(0)\">$editIcon</a>";
my $lnkDetails = AttrVal($d, "alias", $d);
$lnkDetails = "<a name=\"$d.detail\" href=\"$FW_ME$FW_subdir?detail=$d\">$lnkDetails</a>" if($show_links);
my $args = "weekprofile"; my $args = "weekprofile";
my $curr = undef; my $curr = undef;
@@ -673,7 +675,7 @@ sub weekprofile_SummaryFn()
$html .= "<tr><td>"; $html .= "<tr><td>";
$html .= "<div class=\"devType\" id=\"weekprofile.$d.header\">"; $html .= "<div class=\"devType\" id=\"weekprofile.$d.header\">";
$html .= "<div class=\"devType\" id=\"weekprofile.menu.base\">"; $html .= "<div class=\"devType\" id=\"weekprofile.menu.base\">";
$html .= $icon."&nbsp;".$lnk; $html .= $editIcon."&nbsp;".$lnkDetails;
$html .= "</di></div></td></tr>"; $html .= "</di></div></td></tr>";
$html .= "<tr><td>"; $html .= "<tr><td>";
$html .= "<div class=\"fhemWidget\" informId=\"$d\" cmd=\"\" arg=\"$args\" current=\"$curr\" dev=\"$d\">"; # div tag to support inform updates $html .= "<div class=\"fhemWidget\" informId=\"$d\" cmd=\"\" arg=\"$args\" current=\"$curr\" dev=\"$d\">"; # div tag to support inform updates
@@ -682,6 +684,30 @@ sub weekprofile_SummaryFn()
$html .= "</table>"; $html .= "</table>";
return $html; return $html;
} }
##############################################
sub weekprofile_editOnNewpage(@)
{
my ($device, $prf,$backurl) = @_;
my $hash = $defs{$device};
$backurl="?" if(!defined($backurl));
my $args = "weekprofile,EDIT,$backurl";
my $html;
$html .= "<html>";
$html .= "<table>";
$html .= "<tr><td>";
$html .= "<div class=\"devType\" id=\"weekprofile.$device.header\">";
$html .= "<div class=\"devType\" id=\"weekprofile.menu.base\">";
$html .= "</di></div></td></tr>";
$html .= "<tr><td>";
$html .= "<div class=\"fhemWidget\" informId=\"$device\" cmd=\"\" arg=\"$args\" current=\"$prf\" dev=\"$device\">"; # div tag to support inform updates
$html .= "</div>";
$html .= "</td></tr>";
$html .= "</table>";
$html .= "</html>";
return $html;
}
1; 1;
=pod =pod
@@ -764,6 +790,9 @@ sub weekprofile_SummaryFn()
Liste von Wochentagen getrennt durch ',' welche im Widget angzeigt werden. Liste von Wochentagen getrennt durch ',' welche im Widget angzeigt werden.
Beginnend bei Montag. z.B. Beginnend bei Montag. z.B.
<code>attr name widgetWeekdays Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag</code> <code>attr name widgetWeekdays Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag</code>
</li>
<li>widgetEditOnNewPage<br>
Wenn gesetzt ('1'), dann wird die Bearbeitung auf einer separaten\neuen Webseite gestartet.
</li> </li>
<li>configFile<br> <li>configFile<br>
Pfad und Dateiname wo die Profile gespeichert werden sollen. Pfad und Dateiname wo die Profile gespeichert werden sollen.

View File

@@ -39,15 +39,24 @@ function FW_weekprofileInputDialog(title,inp,parent, callback)
}); });
} }
function weekprofile_DoEditWeek(devName) function weekprofile_DoEditWeek(devName,newPage)
{ {
var widget = $('div[informid="'+devName+'"]').get(0); var widget = $('div[informid="'+devName+'"]').get(0);
if (newPage == 1) {
var url = location.href;
var pos = url.indexOf('?');
if (pos >=0)
url = url.substr(pos);
else
url='';
window.location.assign(FW_root+'?cmd={weekprofile_editOnNewpage("'+widget.DEVICE+'","'+widget.CURPRF+'","'+url+'");;}');
} else {
widget.MODE = 'EDIT'; widget.MODE = 'EDIT';
$(widget.MENU.BASE).hide(); $(widget.MENU.BASE).hide();
widget.setValueFn("REUSEPRF"); widget.setValueFn("REUSEPRF");
} }
}
function FW_weekprofilePRFChached(devName,select) function FW_weekprofilePRFChached(devName,select)
{ {
@@ -357,15 +366,24 @@ function FW_weekprofilePrepAndSendProf(devName)
widget.PROFILE[day] = prf[day]; widget.PROFILE[day] = prf[day];
} }
} }
FW_weekprofileBack(widget);
}
function FW_weekprofileBack(widget)
{
if (widget.SHOWURL){
window.location.assign(FW_root+widget.SHOWURL);
}
else {
widget.MODE = "SHOW"; widget.MODE = "SHOW";
widget.setValueFn("REUSEPRF"); widget.setValueFn("REUSEPRF");
} }
}
function FW_weekprofileEditAbort(devName) function FW_weekprofileEditAbort(devName)
{ {
var widget = $('div[informid="'+devName+'"]').get(0); var widget = $('div[informid="'+devName+'"]').get(0);
widget.MODE = "SHOW"; FW_weekprofileBack(widget);
widget.setValueFn("REUSEPRF");
} }
function FW_weekprofileSetValue(devName,data) function FW_weekprofileSetValue(devName,data)
@@ -383,7 +401,7 @@ function FW_weekprofileSetValue(devName,data)
} }
widget.PROFILE = prf; widget.PROFILE = prf;
if (widget.MODE == 'SHOW' || widget.MODE == 'CREATE') if (widget.MODE == 'SHOW')
{ {
FW_weekprofileShow(widget); FW_weekprofileShow(widget);
} }
@@ -416,14 +434,15 @@ function FW_weekprofileGetValues(devName,what,data)
function function
FW_weekprofileCreate(elName, devName, vArr, currVal, set, params, cmd) FW_weekprofileCreate(elName, devName, vArr, currVal, set, params, cmd)
{ {
// called from FW_replaceWidget fhemweb.js
if( 0 ) { if( 0 ) {
console.log( "elName: "+elName ); console.log( "elName: "+elName );
console.log( "devName: "+devName ); console.log( "devName: "+devName ); // attr dev
console.log( "vArr: "+vArr ); console.log( "vArr: "+vArr ); // attr arg split ','
console.log( "currVal: "+currVal ); console.log( "currVal: "+currVal ); // attr current
console.log( "set: "+set ); console.log( "set: "+set ); // attr cmd split ' ' first entry
console.log( "params: "+params ); console.log( "params: "+params ); // attr cmd list split ' ' without first entry
console.log( "cmd: "+cmd ); console.log( "cmd: "+cmd ); // function for ToDo
} }
if(!vArr.length || vArr[0] != "weekprofile") if(!vArr.length || vArr[0] != "weekprofile")
@@ -451,7 +470,13 @@ FW_weekprofileCreate(elName, devName, vArr, currVal, set, params, cmd)
} }
$(widget.HEADER).append(prfCnt); $(widget.HEADER).append(prfCnt);
widget.MODE = 'CREATE'; widget.SHOWURL = null;
widget.MODE = 'SHOW';
if (vArr.length > 1) {
widget.MODE = vArr[1];
if (vArr.length > 2)
widget.SHOWURL = vArr[2];
}
widget.DEVICE = devName; widget.DEVICE = devName;
widget.WEEKDAYS = shortDays.slice(); widget.WEEKDAYS = shortDays.slice();
widget.CURPRF = currVal; widget.CURPRF = currVal;