fix(energiediagramm): Symcon-8-Darstellung korrigieren
This commit is contained in:
@@ -24,14 +24,21 @@ zusaetzlich ein frei waehlbarer inklusiver Datumsbereich und die Navigation
|
|||||||
durch abgeschlossene Zeitraeume zur Verfuegung.
|
durch abgeschlossene Zeitraeume zur Verfuegung.
|
||||||
|
|
||||||
Die Farben fuer Eigenverbrauchsquote und Autarkiegrad werden mit den beiden
|
Die Farben fuer Eigenverbrauchsquote und Autarkiegrad werden mit den beiden
|
||||||
Farbauswahlen in der Instanzkonfiguration festgelegt.
|
Farbauswahlen in der Instanzkonfiguration festgelegt. Das Modul verarbeitet
|
||||||
|
sowohl aktuelle Hex-Farbwerte als auch die von IP-Symcon 8.0 gespeicherten
|
||||||
|
dezimalen Farbwerte.
|
||||||
|
|
||||||
## Darstellung
|
## Darstellung
|
||||||
|
|
||||||
Die Kachel und ihre vergroesserte Ansicht erhalten beim Aufbau sofort einen
|
Der Inhalt beginnt unterhalb des von Symcon eingeblendeten Kachelkopfs, damit
|
||||||
vollstaendigen Datenstand. Beim Oeffnen und beim erneuten Sichtbarwerden wird
|
Zeitraum und Datum vollstaendig bedienbar bleiben. Beim Oeffnen und beim erneuten
|
||||||
die Darstellung aktualisiert. Das Diagrammraster wechselt bei geringer Breite
|
Sichtbarwerden wird die Darstellung aktualisiert. Das Diagrammraster wechselt
|
||||||
automatisch von zwei Spalten auf eine Spalte.
|
bei geringer Breite automatisch von zwei Spalten auf eine Spalte.
|
||||||
|
|
||||||
|
IP-Symcon 8.x unterstuetzt HTML-SDK-Darstellungen nur in der normalen Kachel.
|
||||||
|
Der vom Client angebotene Vergroesserungsdialog kann deshalb leer bleiben.
|
||||||
|
Ab IP-Symcon 9.0 aktiviert das Modul automatisch den zusaetzlichen
|
||||||
|
HTML-SDK-Vollbildmodus.
|
||||||
|
|
||||||
## Berechnung
|
## Berechnung
|
||||||
|
|
||||||
|
|||||||
@@ -118,9 +118,19 @@ final class EnergyChartCalculator
|
|||||||
|
|
||||||
public static function normalizeColor(string $color, string $fallback): string
|
public static function normalizeColor(string $color, string $fallback): string
|
||||||
{
|
{
|
||||||
return preg_match('/^#[0-9A-Fa-f]{6}$/', $color) === 1
|
$color = trim($color);
|
||||||
? strtoupper($color)
|
if (preg_match('/^#[0-9A-Fa-f]{6}$/', $color) === 1) {
|
||||||
: strtoupper($fallback);
|
return strtoupper($color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('/^[0-9]+$/', $color) === 1) {
|
||||||
|
$legacyColor = (int) $color;
|
||||||
|
if ($legacyColor >= 0 && $legacyColor <= 0xFFFFFF) {
|
||||||
|
return sprintf('#%06X', $legacyColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return strtoupper($fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function date(string $date): DateTimeImmutable
|
private static function date(string $date): DateTimeImmutable
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 14px;
|
padding: 58px 14px 14px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
|
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
@@ -234,7 +234,7 @@
|
|||||||
|
|
||||||
@media (max-width: 560px) {
|
@media (max-width: 560px) {
|
||||||
#energy-app {
|
#energy-app {
|
||||||
padding: 10px;
|
padding: 58px 10px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toolbar,
|
.toolbar,
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ class Energiediagramm extends IPSModule
|
|||||||
$this->RegisterAttributeString(self::ATTR_CUSTOM_START, $today);
|
$this->RegisterAttributeString(self::ATTR_CUSTOM_START, $today);
|
||||||
$this->RegisterAttributeString(self::ATTR_CUSTOM_END, $today);
|
$this->RegisterAttributeString(self::ATTR_CUSTOM_END, $today);
|
||||||
|
|
||||||
$this->SetVisualizationType(1);
|
$visualizationType = version_compare(IPS_GetKernelVersion(), '9.0', '>=')
|
||||||
|
? 2
|
||||||
|
: 1;
|
||||||
|
$this->SetVisualizationType($visualizationType);
|
||||||
$this->RegisterTimer(
|
$this->RegisterTimer(
|
||||||
'Refresh',
|
'Refresh',
|
||||||
0,
|
0,
|
||||||
|
|||||||
@@ -49,11 +49,13 @@ final class EnergiediagrammModulstrukturTest extends TestCase
|
|||||||
self::assertStringContainsString('__ENELIX_INITIAL_STATE__', $html);
|
self::assertStringContainsString('__ENELIX_INITIAL_STATE__', $html);
|
||||||
self::assertStringContainsString('ResizeObserver', $html);
|
self::assertStringContainsString('ResizeObserver', $html);
|
||||||
self::assertStringContainsString('grid-template-columns: minmax(0, 1fr)', $html);
|
self::assertStringContainsString('grid-template-columns: minmax(0, 1fr)', $html);
|
||||||
|
self::assertStringContainsString('padding: 58px 14px 14px', $html);
|
||||||
|
self::assertStringContainsString('padding: 58px 10px 10px', $html);
|
||||||
self::assertStringContainsString('SetCustomRange', $html);
|
self::assertStringContainsString('SetCustomRange', $html);
|
||||||
self::assertStringNotContainsString("addEventListener('load'", $html);
|
self::assertStringNotContainsString("addEventListener('load'", $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testModuleEmbedsInitialPayloadForTileAndPopup(): void
|
public function testModuleEmbedsInitialPayloadAndEnablesSupportedVisualization(): void
|
||||||
{
|
{
|
||||||
$module = file_get_contents(__DIR__ . '/../Energiediagramm/module.php');
|
$module = file_get_contents(__DIR__ . '/../Energiediagramm/module.php');
|
||||||
self::assertNotFalse($module);
|
self::assertNotFalse($module);
|
||||||
@@ -61,7 +63,11 @@ final class EnergiediagrammModulstrukturTest extends TestCase
|
|||||||
"str_replace('__ENELIX_INITIAL_STATE__'",
|
"str_replace('__ENELIX_INITIAL_STATE__'",
|
||||||
$module
|
$module
|
||||||
);
|
);
|
||||||
self::assertStringContainsString('GetVisualizationPopup', $module);
|
self::assertStringContainsString(
|
||||||
|
"version_compare(IPS_GetKernelVersion(), '9.0', '>=')",
|
||||||
|
$module
|
||||||
|
);
|
||||||
|
self::assertStringContainsString('SetVisualizationType($visualizationType)', $module);
|
||||||
self::assertStringContainsString('Standardzeitraum', $module);
|
self::assertStringContainsString('Standardzeitraum', $module);
|
||||||
self::assertStringContainsString('CustomStart', $module);
|
self::assertStringContainsString('CustomStart', $module);
|
||||||
self::assertStringContainsString('CustomEnd', $module);
|
self::assertStringContainsString('CustomEnd', $module);
|
||||||
|
|||||||
@@ -110,9 +110,21 @@ final class EnergiediagrammTest extends TestCase
|
|||||||
'#2F80ED',
|
'#2F80ED',
|
||||||
EnergyChartCalculator::normalizeColor('#2f80ed', '#000000')
|
EnergyChartCalculator::normalizeColor('#2f80ed', '#000000')
|
||||||
);
|
);
|
||||||
|
self::assertSame(
|
||||||
|
'#00FF4C',
|
||||||
|
EnergyChartCalculator::normalizeColor('65356', '#000000')
|
||||||
|
);
|
||||||
|
self::assertSame(
|
||||||
|
'#000000',
|
||||||
|
EnergyChartCalculator::normalizeColor('0', '#FFFFFF')
|
||||||
|
);
|
||||||
self::assertSame(
|
self::assertSame(
|
||||||
'#22A06B',
|
'#22A06B',
|
||||||
EnergyChartCalculator::normalizeColor('transparent', '#22a06b')
|
EnergyChartCalculator::normalizeColor('16777216', '#22a06b')
|
||||||
|
);
|
||||||
|
self::assertSame(
|
||||||
|
'#22A06B',
|
||||||
|
EnergyChartCalculator::normalizeColor('-1', '#22a06b')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user