Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show favorite list on startpage dropdown menu sorted by name #665

Merged
merged 2 commits into from Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,10 @@
--- occu/WebUI/www/rega/pages/startpage.htm.orig
+++ occu/WebUI/www/rega/pages/startpage.htm
@@ -50,6 +50,7 @@
{
Write( '<option>${noFav}</option>' );
}
+ oFavoriteList.SortByName();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anstatt das SortBaName() bei jedem Aufruf von startpage.htm aufzurufen sollte es IMHO effektiver/ressourcenschonender sein das SortByName besser in den Routinen aufzurufen nach de Editieren des Namens bzw. anlegen eines neuen Favoriten.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Da sehe ich leider nicht so recht durch.
Da werden die IDs umgeshiftet; der zuletzt editierte wandert nach ganz unten, nachdem vorher auch eine Kopie angelegt wurde.
Müsste wohl irgendwo hier passieren: /www/rega/esp/favorites.fn#L233
Ich schaue es mir die Tage noch mal an 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fazit nach einer Stunde intensiver Beschäftigung mit der SaveFavoriteList Methode:
Ich blick da absolut nicht durch 😣
Es mangelt schon am Verständnis undokumentierten verwendeten internen Methoden:

      integer iOrigID = oCopy.EnCopyID();
      object oOrig = dom.GetObject( iOrigID );
      if( oOrig )
      {
        oCopy.EnumCopyTo( oOrig.ID() );
        dom.DeleteObject( oCopy.ID() );
        oOrig.EnCopyID( ID_ERROR );
      }

Aber auch mit viel Debug-Output bekomme ich es nicht auf die Reihe, an irgendeiner Stelle die Sortierung einzubauen. 😞

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also ich hab vorerst auch kapituliert. An den Stellen werden anscheinend Objekte hin/her-kopiert um irgendwie eine neue Favoritenliste zu erzeugen falls Objekte entfernt werden. Da schein deine ursprüngliche Änderung mit einfach SortByName() doch die effektivere zu sein.

string s;
foreach(s,oFavoriteList.EnumIDs())
{
@@ -0,0 +1,293 @@
<%
system.SetSessionVar("sessionTAB", "startpage");
%>

<script type="text/javascript">

<%
var id = "";
var userId = system.GetSessionVar("sessionUserID");
var oFavorites = dom.GetObject(ID_FAVORITES);
var bFavoritesAvailable = false;
var oFavoriteIds = "";

if (oFavorites)
{
var oFavoriteList = oFavorites.Get("_USER" # userId);

if ((oFavoriteList) && (0 < oFavoriteList.Count()))
{
bFavoritesAvailable = true;
sFavoriteIds = oFavoriteList.EnumIDs();
}
}

%>



</script>

<div id="startpage" class="CLASS01800">

<!-- Linke Seite: Favoriten -->
<div id="contentLeft" class="CLASS01802">

<div class="CLASS01801">

<!-- Favoritenliste -->
<div id="favSelector" class="CLASS01803" style="display:none">&nbsp;
<select class="SelectBox j_translate" onchange="WebUI.enter(StartPage, this.value);">
<%
string id = "";
object oFavorites = dom.GetObject( ID_FAVORITES );
if( oFavorites )
{
object oFavoriteList = oFavorites.Get( "_USER"#system.GetSessionVar("sessionUserID") );
if( oFavoriteList )
{
if( oFavoriteList.Count() == 0 )
{
Write( '<option>${noFav}</option>' );
}
oFavoriteList.SortByName();
string s;
foreach(s,oFavoriteList.EnumIDs())
{
object oFavorite = dom.GetObject(s);
if( oFavorite )
{
if( !id.Length() )
{
if( system.IsVar("fid") )
{
id = system.GetVar("fid");
system.SetSessionVar("sessionFAV",system.GetVar("fid"));
}
else
{
if( system.IsSessionVar("sessionFAV") )
{
id = system.GetSessionVar("sessionFAV");
object oTmpTest = dom.GetObject( id );
if( !oTmpTest ) { id = oFavorite.ID(); }
}
else
{
id = oFavorite.ID();
}
}
}
string sSelected = "";
if( id == oFavorite.ID() ) { sSelected = "selected";}
Write( '<option '#sSelected#' value="'#oFavorite.ID()#'">' );
Write( oFavorite.Name() );
Write( '</option>' );
}
}
}
}
%>
</select>&nbsp;
</div>

<!-- Favoriten -->
<div id="loadingGif"><img style="margin: 30px;" src="/ise/img/loading.gif" /></div>
<div id="favView" class="CLASS01804" style="display:none">
<div align="center">
<table id="tblfav" cellpadding="0" cellspacing="0" class="CLASS01805">
<tr>
<%
string sid;
integer i = 0;
object objX = dom.GetObject( system.GetVar("id") );
if( objX )
{
if( objX.TypeName() == "FAVORITE" )
{
foreach( sid, objX.EnumIDs() )
{
object oEntry = dom.GetObject( sid );
if( oEntry )
{
Write('<td>');
Write('<table cellpadding="0" cellspacing="0" class="CLASS01806">');
Write('<tr>');
Write('<td class="CLASS01807">'#dom.GetObject(sid).Name()#'</td>');
Write('</tr>');
Write('<tr>');
Write('<td id="dpc'#oEntry.ID()#'" class="CLASS01812">');
integer cId = oEntry.ID();
integer iStatusOnly = 0;
boolean bInStatusList = false;
boolean bHasFullAccess = (oEntry.UserAccessRights(iulOtherThanAdmin) == iarFullAccess);
string s;
foreach(s,objX.FavControlIDs().EnumIDs() )
{
if( s == oEntry.ID().ToString() )
{
bInStatusList = true;
}
}
boolean bBoolVar = false;
if ( oEntry.IsTypeOf( OT_ALARMDP ) ) { bBoolVar = true;}
if ( oEntry.IsTypeOf( OT_VARDP ) && (oEntry.ValueSubType() == istBool) ) { bBoolVar = true; }
if (bInStatusList || bBoolVar || (!bHasFullAccess)) {
iStatusOnly = 1;
}
Call("/esp/datapointconfigurator.fn::dcCreate()");
Write('</td>');
Write('</tr>');
Write('</table>');
Write('</br>');
Write('</td>');
Write('</tr><tr>');
i = i + 1;
}
}
}
}
else
{
Write("<td>Kann Favoriten nicht öffnen!</td>");
}
%>
</tr>
</table>
</div>
</div>

</div>

</div>

<!-- Rechte Seite: Anlern-Button, SystemInformationen -->
<div id="contentRight" class="CLASS01809" style="overflow:auto;">

<table id="tblRightContent" width="100%">
<tr valign="top" class="CLASS01810">
<td>
<table id="tblStartpageInfo" width="100%" class="CLASS01811 startPageInfo hidden">

<tr>
<th style="width:40%"></th>
<th style="width:60%"></th>
</tr>

<tr>
<!-- Uhrzeit -->
<td>${time}:</td>
<td><span id="maintime"><% Write(system.Date("%H:%M")); %></span><!-- Uhr--></td>
</tr>
<tr>
<!--Datum -->
<td>${date}:</td>
<td><span id="maindate"><% Write(system.Date("%d.%m.%Y")); %></span></td>
</tr>

<tr>
<!-- Sonnenaufgang -->
<td>${sunrise}:</td>
<td id="sunrise"><% Write(system.SunriseTime("%H:%M")); %><!-- Uhr --></td>
</tr>

<tr>
<!-- Sonnenuntergang -->
<td>${sunset}:</td>
<td id="sunset"><% Write(system.SunsetTime("%H:%M")); %><!-- Uhr--></td>
</tr>

<tr>
<td>${currentFirmwareVersion}</td>
<td id="currentFirmware">${lblCurrentFirmwareVersionNotKnown}</td>
</tr>

<tr id="updateRow" style="display:none;">
<!-- CCU2-Update -->
<td>${update}</td>
<!-- Firmware ist verf&uuml;gbar -->
<td colspan="3" id="updateCol">${newFirmwareAvailable}</td>
</tr>

<!-- Device-Firmware -->
<tr id="devFwAvailable" class="hidden">
<td>${deviceUpdate}</td>
<td class="firmwareAvailable">${lblNewDeviceFirmwareAvailable}&nbsp;<span id="devFwAvailableCounter"></span></td>
</tr>

<%
object oUser = dom.GetObject( system.GetSessionVar('sessionUserID') );
if (oUser.UserPwd() == "")
{
Write("<tr>");

Write("<td>${login}:</td>");

Write("<td colspan='3' class='attention'>${noPasswd}</td>");
Write("</tr>");
}

if (oUser) {
string tmp;
foreach ( tmp, oUser.UserSharedObjects().EnumIDs()) {
object oDP = dom.GetObject(tmp);
Write("<tr>");
Write("<td>"#oDP.Name()#":</td>");
Write("<td colspan='3' id='SYSVAR_" # tmp # "' >");
string sSysVarVal = "";
object cObjTmp = oDP;
integer iVT = oDP.ValueType();
integer iST = oDP.ValueSubType();
boolean bLogic = ( (iVT==ivtBinary) && (iST==istBool) );
boolean bList = ( (iVT==ivtInteger) && (iST==istEnum) );
boolean bNumber = ( (iVT==ivtFloat) && (iST==istGeneric) );
boolean bAlarm = ( (iVT==ivtBinary) && (iST==istAlarm) );
boolean bString = ( (iVT==ivtString) && (iST==istChar8859));
Call( "/esp/system.fn::getSysVarValAsString()" );
Write( sSysVarVal );
Write("</td>");
Write("</tr>");
}
}
%>

<tr id="partingLine1" class="hidden"><td colspan="2" style="height: 50px"><hr></td></tr>

<!-- DutyCycle -->
<tr name="trDutyCycle" style="visibility: hidden"><td></td><td><div id="dutyCycleVal" style="width:75%; text-align:center"></div></td></tr>
<tr name="trDutyCycle" style="visibility: hidden">
<td>${lblDutyCycle}</td>
<td> <div id="dutyCycleProgress" align="right"><div id="dutyCycleProgressBar"></div></div> </td>
</tr>

</table>
</td>
</tr>
</table>

<div id="forceUpdate" style="display:none; margine-top:50px; padding:10px;" >
<div style="background-color:#BCC7CB; padding:5px; border:solid 1px;">${forcedUpdateHint}</div>
<div style="text-align: center; margin-top: 50px;"><a href="/licenseinfo.htm" target="_blank">${lblLicenseInformation}</a></div>
<div class="StdTableBtn CLASS21701" style="width:50%; margin:25%; margin-top: 50px;" onclick="showMaintenanceCP();">${forcedUpdateBtn}</div>
</div>
</div>
</div>

<script type="text/javascript">
WebUI.resize();
StartPage.showUpdate();
if (forceUpdate) {
StartPage.showCurrentFirmware();
jQuery("#forceUpdate").show();
} else {
jQuery("#favSelector").show();
jQuery("#favView").show();
StartPage.showUpdate();
StartPage.showCurrentFirmware();
StartPage.showAllDeviceFirmware();
jQuery("#forceUpdate").remove();
}
translatePage();
jQuery("#loadingGif").hide();
jQuery("#tblStartpageInfo").show();
</script>