-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from Jalle19/groups
Add a "Group" page
- Loading branch information
Showing
8 changed files
with
185 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
export enum SensorType { | ||
Iotawatt = 'iotawatt', | ||
Shelly = 'shelly', | ||
Virtual = 'virtual', | ||
Unmetered = 'unmetered', | ||
Dummy = 'dummy', | ||
} | ||
|
||
export interface PowerSensor { | ||
type: SensorType | ||
} | ||
|
||
export enum CircuitType { | ||
Main = 'main', | ||
Circuit = 'circuit', | ||
} | ||
|
||
export type Circuit = { | ||
name: string | ||
type: CircuitType // resolved during parsing | ||
parent?: Circuit // resolved to the circuit in question | ||
children: Circuit[] // resolved from parent | ||
phase?: string // resolved from parent | ||
hidden?: boolean // defaults to false | ||
sensor: PowerSensor | ||
group?: string | ||
} | ||
|
||
export type PowerSensorData = { | ||
timestamp: number | ||
circuit: Circuit | ||
// Mandatory data. Undefined means the data was not available. | ||
power?: number | ||
// Optional data, not all sensor types support them | ||
apparentPower?: number | ||
powerFactor?: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script lang="ts"> | ||
import { page } from '$app/stores' | ||
import { circuitSensorDataStore } from '$lib/stores' | ||
import Circuits from '../../Circuits.svelte' | ||
import { derived } from 'svelte/store' | ||
import type { PowerSensorData } from '$lib/types' | ||
// Create a derived store containing the sensor data for just the circuits belonging | ||
// to the current group | ||
const group = $page.params?.group | ||
let groupSensorData = derived(circuitSensorDataStore, (data) => { | ||
return data.filter((data: PowerSensorData) => data.circuit.group === group) | ||
}) | ||
</script> | ||
|
||
<div class="pure-u-1-1 l-box"> | ||
<h2>Group <i>{group}</i></h2> | ||
<Circuits sensorData="{$groupSensorData}" /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
:root { | ||
--background: #fff; | ||
--color: #222; | ||
--component-background: #e0e0e0; | ||
--highlight-color: #ff3d00; | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
:root { | ||
--background: #272727; | ||
--color: #aaa; | ||
--component-background: #3b3b3b; | ||
--highlight-color: #ff3d00; | ||
} | ||
|
||
nav { | ||
background-color: var(--component-background); | ||
} | ||
|
||
/* pure-table overrides */ | ||
.pure-table { | ||
border: 2px solid #424242; | ||
} | ||
|
||
.pure-table thead { | ||
background-color: var(--component-background); | ||
color: var(--color); | ||
} | ||
|
||
.pure-table th, | ||
.pure-table td { | ||
border: 0; | ||
} | ||
|
||
.pure-table-striped tr:nth-child(2n-1) td { | ||
background-color: #2e2e2e; | ||
} | ||
|
||
/* end pure-table overrides */ | ||
} | ||
|
||
body { | ||
background: var(--background); | ||
color: var(--color); | ||
} | ||
|
||
h1, | ||
h2, | ||
h3, | ||
h4, | ||
h5, | ||
h6 { | ||
margin-top: 0; | ||
padding-bottom: 0.2em; | ||
display: inline-block; | ||
border-bottom: 2px solid var(--highlight-color); | ||
} | ||
|
||
a { | ||
color: var(--color); | ||
text-decoration: none; | ||
padding-bottom: 0.2em; | ||
border-bottom: 2px solid var(--highlight-color); | ||
} | ||
|
||
.container { | ||
max-width: 1200px; | ||
margin: 0 auto; | ||
clear: both; | ||
} | ||
|
||
table { | ||
width: 100%; | ||
} | ||
|
||
.cell-right-align { | ||
text-align: right; | ||
} | ||
|
||
.pure-g > div { | ||
box-sizing: border-box; | ||
} | ||
|
||
.l-box { | ||
padding: 1em; | ||
} | ||
|
||
/* pure-menu tweaks */ | ||
.pure-menu-link { | ||
border-bottom: 2px solid var(--component-background); | ||
} | ||
|
||
.pure-menu-link:hover { | ||
border-bottom: 2px solid var(--highlight-color); | ||
background: inherit !important; | ||
} | ||
|
||
/* end pure-menu tweaks */ |