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">
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<Import Project="../InnovEnergy.App.props" />
<ItemGroup>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,6 @@
using System.Web;
using HandlebarsDotNet;
using InnovEnergy.App.RemoteSupportConsole;
using InnovEnergy.App.VrmGrabber.Database;
using InnovEnergy.Lib.Victron.VictronVRM;
using Microsoft.AspNetCore.Mvc;
@ -11,7 +13,8 @@ public record Install(
String Ip,
UInt64 Vrm,
String Identifier,
String Serial
String Serial,
String EscapedName
);
[Controller]
@ -64,23 +67,17 @@ td {
String partialSource =
@"<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>{{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);
var template = Handlebars.Compile(source);
var insts = instList.Select(i =>
{
try
{
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));
}
return new Install(i.Name, Ip(i), i.IdSite, i.Identifier, Serial(i), HttpUtility.UrlEncode(i.Name));
});
@ -100,7 +97,8 @@ td {
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)

View File

@ -1,4 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
<Import Project="../InnovEnergy.App.props" />
<ItemGroup>
@ -28,20 +31,9 @@
<ItemGroup>
<ProjectReference Include="../../Lib/Utils/Utils.csproj" />
<ProjectReference Include="..\..\Lib\Victron\VictronVRM\VictronVRM.csproj" />
<ProjectReference Include="..\RemoteSupportConsole\RemoteSupportConsole.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Resources/s3cmd.py">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Update="Resources\urlAndKey.json">
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="wwwroot\index.html" />
</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}.Release|Any CPU.ActiveCfg = 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.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
GlobalSection(NestedProjects) = preSolution
{CF4834CB-91B7-4172-AC13-ECDA8613CD17} = {145597B4-3E30-45E6-9F72-4DD43194539A}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
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 UInt32? TryGetUInt32(this JsonNode n, String propName) => n.TryGet<UInt32>(propName);

View File

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

View File

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

View File

@ -16,7 +16,7 @@ public readonly partial record struct Installation(VrmAccount VrmAccount, JsonNo
public String Name => Json.GetString("name");
public String Notes => Json.GetString("notes");
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?
// public String Name
// {

View File

@ -5,6 +5,11 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup>
<Configurations>Debug;Release;Release-Server</Configurations>
<Platforms>AnyCPU;linux-arm</Platforms>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../../Utils/Utils.csproj" />

View File

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