Make dashboard titles customizable
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		@@ -110,6 +110,18 @@ pub struct AppConfig {
 | 
				
			|||||||
    #[arg(short('f'), long, env, default_value_t = 5)]
 | 
					    #[arg(short('f'), long, env, default_value_t = 5)]
 | 
				
			||||||
    pub energy_fetch_interval: u64,
 | 
					    pub energy_fetch_interval: u64,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Custom current consumption title in dashboard
 | 
				
			||||||
 | 
					    #[arg(long, env)]
 | 
				
			||||||
 | 
					    pub dashboard_custom_current_consumption_title: Option<String>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Custom relays consumption title in dashboard
 | 
				
			||||||
 | 
					    #[arg(long, env)]
 | 
				
			||||||
 | 
					    pub dashboard_custom_relays_consumption_title: Option<String>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Custom cached consumption title in dashboard
 | 
				
			||||||
 | 
					    #[arg(long, env)]
 | 
				
			||||||
 | 
					    pub dashboard_custom_cached_consumption_title: Option<String>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Consumption backend provider
 | 
					    /// Consumption backend provider
 | 
				
			||||||
    #[clap(subcommand)]
 | 
					    #[clap(subcommand)]
 | 
				
			||||||
    pub consumption_backend: Option<ConsumptionBackend>,
 | 
					    pub consumption_backend: Option<ConsumptionBackend>,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,9 @@ struct ServerConfig {
 | 
				
			|||||||
    constraints: StaticConstraints,
 | 
					    constraints: StaticConstraints,
 | 
				
			||||||
    unsecure_origin: String,
 | 
					    unsecure_origin: String,
 | 
				
			||||||
    backend_version: &'static str,
 | 
					    backend_version: &'static str,
 | 
				
			||||||
 | 
					    dashboard_custom_current_consumption_title: Option<&'static str>,
 | 
				
			||||||
 | 
					    dashboard_custom_relays_consumption_title: Option<&'static str>,
 | 
				
			||||||
 | 
					    dashboard_custom_cached_consumption_title: Option<&'static str>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Default for ServerConfig {
 | 
					impl Default for ServerConfig {
 | 
				
			||||||
@@ -23,6 +26,15 @@ impl Default for ServerConfig {
 | 
				
			|||||||
            constraints: Default::default(),
 | 
					            constraints: Default::default(),
 | 
				
			||||||
            unsecure_origin: AppConfig::get().unsecure_origin(),
 | 
					            unsecure_origin: AppConfig::get().unsecure_origin(),
 | 
				
			||||||
            backend_version: env!("CARGO_PKG_VERSION"),
 | 
					            backend_version: env!("CARGO_PKG_VERSION"),
 | 
				
			||||||
 | 
					            dashboard_custom_current_consumption_title: AppConfig::get()
 | 
				
			||||||
 | 
					                .dashboard_custom_current_consumption_title
 | 
				
			||||||
 | 
					                .as_deref(),
 | 
				
			||||||
 | 
					            dashboard_custom_relays_consumption_title: AppConfig::get()
 | 
				
			||||||
 | 
					                .dashboard_custom_relays_consumption_title
 | 
				
			||||||
 | 
					                .as_deref(),
 | 
				
			||||||
 | 
					            dashboard_custom_cached_consumption_title: AppConfig::get()
 | 
				
			||||||
 | 
					                .dashboard_custom_cached_consumption_title
 | 
				
			||||||
 | 
					                .as_deref(),
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,9 @@ export interface ServerConfig {
 | 
				
			|||||||
  constraints: ServerConstraint;
 | 
					  constraints: ServerConstraint;
 | 
				
			||||||
  unsecure_origin: string;
 | 
					  unsecure_origin: string;
 | 
				
			||||||
  backend_version: string;
 | 
					  backend_version: string;
 | 
				
			||||||
 | 
					  dashboard_custom_current_consumption_title?: string;
 | 
				
			||||||
 | 
					  dashboard_custom_relays_consumption_title?: string;
 | 
				
			||||||
 | 
					  dashboard_custom_cached_consumption_title?: string;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface ServerConstraint {
 | 
					export interface ServerConstraint {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ import React from "react";
 | 
				
			|||||||
import { EnergyApi } from "../../api/EnergyApi";
 | 
					import { EnergyApi } from "../../api/EnergyApi";
 | 
				
			||||||
import { useSnackbar } from "../../hooks/context_providers/SnackbarProvider";
 | 
					import { useSnackbar } from "../../hooks/context_providers/SnackbarProvider";
 | 
				
			||||||
import StatCard from "../../widgets/StatCard";
 | 
					import StatCard from "../../widgets/StatCard";
 | 
				
			||||||
 | 
					import { ServerApi } from "../../api/ServerApi";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function CachedConsumptionWidget(): React.ReactElement {
 | 
					export function CachedConsumptionWidget(): React.ReactElement {
 | 
				
			||||||
  const snackbar = useSnackbar();
 | 
					  const snackbar = useSnackbar();
 | 
				
			||||||
@@ -26,6 +27,12 @@ export function CachedConsumptionWidget(): React.ReactElement {
 | 
				
			|||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <StatCard title="Cached consumption" value={val?.toString() ?? "Loading"} />
 | 
					    <StatCard
 | 
				
			||||||
 | 
					      title={
 | 
				
			||||||
 | 
					        ServerApi.Config.dashboard_custom_cached_consumption_title ??
 | 
				
			||||||
 | 
					        "Cached consumption"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      value={val?.toString() ?? "Loading"}
 | 
				
			||||||
 | 
					    />
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ import React from "react";
 | 
				
			|||||||
import { EnergyApi } from "../../api/EnergyApi";
 | 
					import { EnergyApi } from "../../api/EnergyApi";
 | 
				
			||||||
import { useSnackbar } from "../../hooks/context_providers/SnackbarProvider";
 | 
					import { useSnackbar } from "../../hooks/context_providers/SnackbarProvider";
 | 
				
			||||||
import StatCard from "../../widgets/StatCard";
 | 
					import StatCard from "../../widgets/StatCard";
 | 
				
			||||||
 | 
					import { ServerApi } from "../../api/ServerApi";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function CurrConsumptionWidget(): React.ReactElement {
 | 
					export function CurrConsumptionWidget(): React.ReactElement {
 | 
				
			||||||
  const snackbar = useSnackbar();
 | 
					  const snackbar = useSnackbar();
 | 
				
			||||||
@@ -29,7 +30,10 @@ export function CurrConsumptionWidget(): React.ReactElement {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <StatCard
 | 
					    <StatCard
 | 
				
			||||||
      title="Current consumption"
 | 
					      title={
 | 
				
			||||||
 | 
					        ServerApi.Config.dashboard_custom_current_consumption_title ??
 | 
				
			||||||
 | 
					        "Current consumption"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      data={history ?? []}
 | 
					      data={history ?? []}
 | 
				
			||||||
      interval="Last day"
 | 
					      interval="Last day"
 | 
				
			||||||
      value={val?.toString() ?? "Loading"}
 | 
					      value={val?.toString() ?? "Loading"}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ import React from "react";
 | 
				
			|||||||
import { EnergyApi } from "../../api/EnergyApi";
 | 
					import { EnergyApi } from "../../api/EnergyApi";
 | 
				
			||||||
import { useSnackbar } from "../../hooks/context_providers/SnackbarProvider";
 | 
					import { useSnackbar } from "../../hooks/context_providers/SnackbarProvider";
 | 
				
			||||||
import StatCard from "../../widgets/StatCard";
 | 
					import StatCard from "../../widgets/StatCard";
 | 
				
			||||||
 | 
					import { ServerApi } from "../../api/ServerApi";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function RelayConsumptionWidget(): React.ReactElement {
 | 
					export function RelayConsumptionWidget(): React.ReactElement {
 | 
				
			||||||
  const snackbar = useSnackbar();
 | 
					  const snackbar = useSnackbar();
 | 
				
			||||||
@@ -29,7 +30,10 @@ export function RelayConsumptionWidget(): React.ReactElement {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <StatCard
 | 
					    <StatCard
 | 
				
			||||||
      title="Relays consumption"
 | 
					      title={
 | 
				
			||||||
 | 
					        ServerApi.Config.dashboard_custom_relays_consumption_title ??
 | 
				
			||||||
 | 
					        "Relays consumption"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      data={history ?? []}
 | 
					      data={history ?? []}
 | 
				
			||||||
      interval="Last day"
 | 
					      interval="Last day"
 | 
				
			||||||
      value={val?.toString() ?? "Loading"}
 | 
					      value={val?.toString() ?? "Loading"}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user