added Grafana

This commit is contained in:
Kim 2023-05-11 10:20:47 +02:00
parent 70a4a1bfb8
commit fa9d06192d
33 changed files with 134 additions and 31 deletions

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.App.props" /> <Import Project="../InnovEnergy.App.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.App.props" /> <Import Project="../InnovEnergy.App.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.App.props" /> <Import Project="../InnovEnergy.App.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.App.props" /> <Import Project="../InnovEnergy.App.props" />
<ItemGroup> <ItemGroup>

View File

@ -4,7 +4,7 @@
<PropertyGroup Condition=" '$(Configuration)' != 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' != 'Debug' ">
<!-- https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-7-0 --> <!-- https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-7-0 -->
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained> <SelfContained>true</SelfContained>
<PublishTrimmed>true</PublishTrimmed> <PublishTrimmed>true</PublishTrimmed>
<DebuggerSupport>false</DebuggerSupport> <DebuggerSupport>false</DebuggerSupport>

View File

@ -21,6 +21,8 @@
<PropertyGroup> <PropertyGroup>
<PublishTrimmed>false</PublishTrimmed> <PublishTrimmed>false</PublishTrimmed>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.App.props" /> <Import Project="../InnovEnergy.App.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.App.props" /> <Import Project="../InnovEnergy.App.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,6 @@
using System.Web;
using HandlebarsDotNet; using HandlebarsDotNet;
using InnovEnergy.App.RemoteSupportConsole;
using InnovEnergy.App.VrmGrabber.Database; using InnovEnergy.App.VrmGrabber.Database;
using InnovEnergy.Lib.Victron.VictronVRM; using InnovEnergy.Lib.Victron.VictronVRM;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -11,7 +13,8 @@ public record Install(
String Ip, String Ip,
UInt64 Vrm, UInt64 Vrm,
String Identifier, String Identifier,
String Serial String Serial,
String EscapedName
); );
[Controller] [Controller]
@ -64,23 +67,17 @@ td {
String partialSource = String partialSource =
@"<tr><td>{{Name}}</td> @"<tr><td>{{Name}}</td>
<td><a target='_blank' href=https://{{Ip}}>{{Ip}}</a></td> <td><a target='_blank' href=http://{{Ip}}>{{Ip}}</a></td>
<td><a target='_blank' href=https://vrm.victronenergy.com/installation/{{Vrm}}/dashboard>VRM</a></td> <td><a target='_blank' href=https://vrm.victronenergy.com/installation/{{Vrm}}/dashboard>VRM</a></td>
<td>{{Identifier}}</td> <td>{{Identifier}}</td>
<td>{{Serial}}</td></tr>"; <td>{{Serial}}</td>
<td><a target='_blank' href='https://salidomo.innovenergy.ch/d/ENkNRQXmk/installation?refresh=5s&orgId=1&var-Installation={{EscapedName}}&kiosk=tv'>Grafana</a></td></tr>";
Handlebars.RegisterTemplate("installations", partialSource); Handlebars.RegisterTemplate("installations", partialSource);
var template = Handlebars.Compile(source); var template = Handlebars.Compile(source);
var insts = instList.Select(i => var insts = instList.Select(i =>
{ {
try return new Install(i.Name, Ip(i), i.IdSite, i.Identifier, Serial(i), HttpUtility.UrlEncode(i.Name));
{
return new Install(i.Name, Ip(i), i.IdSite, i.Identifier, Serial(i));
}
catch (Exception)
{
return new Install(i.Name, Ip(i), i.IdSite, "0", Serial(i));
}
}); });
@ -100,7 +97,8 @@ td {
private String Ip(Installation installation) private String Ip(Installation installation)
{ {
return Db.InstallationsAndDetails[installation].RemoteSupportIp() ?? "Unknown";
return VpnInfo.LookUpIp(installation.Identifier, Serial(installation)).Result ?? "Unknown";
} }
private String Serial(Installation installation) private String Serial(Installation installation)

View File

@ -1,4 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
<Import Project="../InnovEnergy.App.props" /> <Import Project="../InnovEnergy.App.props" />
<ItemGroup> <ItemGroup>
@ -28,18 +31,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="../../Lib/Utils/Utils.csproj" /> <ProjectReference Include="../../Lib/Utils/Utils.csproj" />
<ProjectReference Include="..\..\Lib\Victron\VictronVRM\VictronVRM.csproj" /> <ProjectReference Include="..\..\Lib\Victron\VictronVRM\VictronVRM.csproj" />
</ItemGroup> <ProjectReference Include="..\RemoteSupportConsole\RemoteSupportConsole.csproj" />
<ItemGroup>
<None Update="Resources/s3cmd.py">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Update="Resources\urlAndKey.json">
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -186,10 +186,10 @@ Global
{B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Debug|Any CPU.Build.0 = Debug|Any CPU {B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Release|Any CPU.ActiveCfg = Release|Any CPU {B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Release|Any CPU.Build.0 = Release|Any CPU {B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Release|Any CPU.Build.0 = Release|Any CPU
{4F9BB20B-8030-48AB-A37B-23796459D516}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4F9BB20B-8030-48AB-A37B-23796459D516}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F9BB20B-8030-48AB-A37B-23796459D516}.Release|Any CPU.ActiveCfg = Release|Any CPU {4F9BB20B-8030-48AB-A37B-23796459D516}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F9BB20B-8030-48AB-A37B-23796459D516}.Release|Any CPU.Build.0 = Release|Any CPU {4F9BB20B-8030-48AB-A37B-23796459D516}.Release|Any CPU.Build.0 = Release|Any CPU
{4F9BB20B-8030-48AB-A37B-23796459D516}.Debug|Any CPU.ActiveCfg = Release-Server|linux-arm
{4F9BB20B-8030-48AB-A37B-23796459D516}.Debug|Any CPU.Build.0 = Release-Server|linux-arm
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{CF4834CB-91B7-4172-AC13-ECDA8613CD17} = {145597B4-3E30-45E6-9F72-4DD43194539A} {CF4834CB-91B7-4172-AC13-ECDA8613CD17} = {145597B4-3E30-45E6-9F72-4DD43194539A}

View File

@ -1,5 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.Lib.props" /> <Import Project="../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../../InnovEnergy.Lib.props" /> <Import Project="../../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../../InnovEnergy.Lib.props" /> <Import Project="../../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../../InnovEnergy.Lib.props" /> <Import Project="../../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../../InnovEnergy.Lib.props" /> <Import Project="../../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../../../InnovEnergy.Lib.props" /> <Import Project="../../../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\Protocols\Modbus\Modbus.csproj" /> <ProjectReference Include="..\..\..\Protocols\Modbus\Modbus.csproj" />

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../../../InnovEnergy.Lib.props" /> <Import Project="../../../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../../../InnovEnergy.Lib.props" /> <Import Project="../../../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../../../InnovEnergy.Lib.props" /> <Import Project="../../../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -4,6 +4,8 @@
<PropertyGroup> <PropertyGroup>
<Description>DBus Library</Description> <Description>DBus Library</Description>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../../InnovEnergy.Lib.props" /> <Import Project="../../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.Lib.props" /> <Import Project="../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.Lib.props" /> <Import Project="../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,3 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.Lib.props" /> <Import Project="../InnovEnergy.Lib.props" />
</Project> </Project>

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.Lib.props" /> <Import Project="../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Nodes; using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
namespace InnovEnergy.Lib.Utils; namespace InnovEnergy.Lib.Utils;
@ -38,7 +39,19 @@ public static class JsonNodeAccessors
} }
} }
public static String? TryGetString(this JsonNode n, String propName) => n.TryGet<String>(propName); public static String? TryGetString(this JsonNode n, String propName)
{
try
{
return n.TryGet<String>(propName);
}
catch (Exception e)
{
Console.WriteLine(e);
return n.TryGet<UInt64>(propName).ToString();
}
}
public static Boolean? TryGetBoolean(this JsonNode n, String propName) => n.TryGet<Boolean>(propName); public static Boolean? TryGetBoolean(this JsonNode n, String propName) => n.TryGet<Boolean>(propName);
public static UInt32? TryGetUInt32(this JsonNode n, String propName) => n.TryGet<UInt32>(propName); public static UInt32? TryGetUInt32(this JsonNode n, String propName) => n.TryGet<UInt32>(propName);

View File

@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.Lib.props" /> <Import Project="../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -1,5 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../../InnovEnergy.Lib.props" /> <Import Project="../../InnovEnergy.Lib.props" />
<ItemGroup> <ItemGroup>

View File

@ -16,7 +16,7 @@ public readonly partial record struct Installation(VrmAccount VrmAccount, JsonNo
public String Name => Json.GetString("name"); public String Name => Json.GetString("name");
public String Notes => Json.GetString("notes"); public String Notes => Json.GetString("notes");
public String PhoneNumber => Json.GetString("phonenumber"); public String PhoneNumber => Json.GetString("phonenumber");
public String Identifier => Json.GetString("identifier"); public String Identifier => Json.TryGetString("identifier");
// TODO: alternative way to handle settings? make them writeable here and have an UpdateInstallation function? // TODO: alternative way to handle settings? make them writeable here and have an UpdateInstallation function?
// public String Name // public String Name
// { // {

View File

@ -6,6 +6,11 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="../../Utils/Utils.csproj" /> <ProjectReference Include="../../Utils/Utils.csproj" />
<ProjectReference Include="../../Time/Time.csproj" /> <ProjectReference Include="../../Time/Time.csproj" />

View File

@ -3,7 +3,8 @@
<Import Project="../InnovEnergy.Lib.props" /> <Import Project="../InnovEnergy.Lib.props" />
<PropertyGroup> <PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>