mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-27 02:01:40 +00:00
Does the following: - Adjusts the shade of red buttons and banners to increase readability and reduce eye strain   - Cleans up factory reset and camera deletion modals   - Removes matchCamerasOnlyByPath as it is no longer used and throws errors in the console  - Limits the criteria to flag a camera mismatch in Camera Matching to only what is necessary based on camera type and highlights differences in table properties (testing on this is appreciated)  - Only displays both saved vs. current info in camera matching if there is a difference between the two  - Some general code cleanup (reduced unnecessary padding/margin/row-col statements, style="display:flex;" -> class="d-flex", etc. - Moves Compact Mode button to the bottom away from all the menu items (cleaner imo, open to thoughts) - Establishes a general spacing format for cards and pages and applies this to existing cards and pages to create a consistent look and feel to the UI (e.g. keeping things in line and less erratic spacing/placement of UI elements)     - Delete protection for camera matching modules - Anti-backend-spam for activate/deactivate/delete modules to hopefully prevent any odd behavior from button spamming - Enforces a common camera stream size on camera matching view (NEEDS MORE TESTING)  https://private-user-images.githubusercontent.com/29715865/400783758-dc99c151-b8a7-4367-a173-74c2fc5b2666.mp4?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzYyNTc3NzEsIm5iZiI6MTczNjI1NzQ3MSwicGF0aCI6Ii8yOTcxNTg2NS80MDA3ODM3NTgtZGM5OWMxNTEtYjhhNy00MzY3LWExNzMtNzRjMmZjNWIyNjY2Lm1wND9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAxMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMTA3VDEzNDQzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMwOWM1MDc2ZTVlOWZhM2MxYjAwZjAyZTc2MTYyZTk1ZTVmOGFhZmVkMzlmODRlZTk1ODVlOTk2ZGQzZmM0Y2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ovtRnObwbkEfljr9d5fqaory0nH91LWJSSkmrUUe_4Y
132 lines
3.8 KiB
TypeScript
132 lines
3.8 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import type {
|
|
ConfigurableNetworkSettings,
|
|
GeneralSettings,
|
|
LightingSettings,
|
|
MetricData,
|
|
NetworkSettings
|
|
} from "@/types/SettingTypes";
|
|
import { NetworkConnectionType } from "@/types/SettingTypes";
|
|
import { useStateStore } from "@/stores/StateStore";
|
|
import axios from "axios";
|
|
import type { WebsocketSettingsUpdate } from "@/types/WebsocketDataTypes";
|
|
|
|
interface GeneralSettingsStore {
|
|
general: GeneralSettings;
|
|
network: NetworkSettings;
|
|
lighting: LightingSettings;
|
|
metrics: MetricData;
|
|
currentFieldLayout;
|
|
}
|
|
|
|
export const useSettingsStore = defineStore("settings", {
|
|
state: (): GeneralSettingsStore => ({
|
|
general: {
|
|
version: undefined,
|
|
gpuAcceleration: undefined,
|
|
hardwareModel: undefined,
|
|
hardwarePlatform: undefined,
|
|
mrCalWorking: true,
|
|
availableModels: {},
|
|
supportedBackends: []
|
|
},
|
|
network: {
|
|
ntServerAddress: "",
|
|
shouldManage: true,
|
|
canManage: true,
|
|
connectionType: NetworkConnectionType.DHCP,
|
|
staticIp: "",
|
|
hostname: "photonvision",
|
|
runNTServer: false,
|
|
shouldPublishProto: false,
|
|
networkInterfaceNames: [
|
|
{
|
|
connName: "Example Wired Connection",
|
|
devName: "eth0"
|
|
}
|
|
],
|
|
networkingDisabled: false
|
|
},
|
|
lighting: {
|
|
supported: true,
|
|
brightness: 0
|
|
},
|
|
metrics: {
|
|
cpuTemp: undefined,
|
|
cpuUtil: undefined,
|
|
cpuMem: undefined,
|
|
gpuMem: undefined,
|
|
ramUtil: undefined,
|
|
gpuMemUtil: undefined,
|
|
cpuThr: undefined,
|
|
cpuUptime: undefined,
|
|
diskUtilPct: undefined,
|
|
npuUsage: undefined,
|
|
ipAddress: undefined
|
|
},
|
|
currentFieldLayout: {
|
|
field: {
|
|
length: 16.4592,
|
|
width: 8.2296
|
|
},
|
|
tags: []
|
|
}
|
|
}),
|
|
getters: {
|
|
gpuAccelerationEnabled(): boolean {
|
|
return this.general.gpuAcceleration !== undefined;
|
|
},
|
|
networkInterfaceNames(): string[] {
|
|
return this.network.networkInterfaceNames.map((i) => i.devName);
|
|
}
|
|
},
|
|
actions: {
|
|
requestMetricsUpdate() {
|
|
return axios.post("/utils/publishMetrics");
|
|
},
|
|
updateMetricsFromWebsocket(data: Required<MetricData>) {
|
|
this.metrics = {
|
|
cpuTemp: data.cpuTemp || undefined,
|
|
cpuUtil: data.cpuUtil || undefined,
|
|
cpuMem: data.cpuMem || undefined,
|
|
gpuMem: data.gpuMem || undefined,
|
|
ramUtil: data.ramUtil || undefined,
|
|
gpuMemUtil: data.gpuMemUtil || undefined,
|
|
cpuThr: data.cpuThr || undefined,
|
|
cpuUptime: data.cpuUptime || undefined,
|
|
diskUtilPct: data.diskUtilPct || undefined,
|
|
npuUsage: data.npuUsage || undefined,
|
|
ipAddress: data.ipAddress || undefined
|
|
};
|
|
},
|
|
updateGeneralSettingsFromWebsocket(data: WebsocketSettingsUpdate) {
|
|
this.general = {
|
|
version: data.general.version || undefined,
|
|
hardwareModel: data.general.hardwareModel || undefined,
|
|
hardwarePlatform: data.general.hardwarePlatform || undefined,
|
|
gpuAcceleration: data.general.gpuAcceleration || undefined,
|
|
mrCalWorking: data.general.mrCalWorking,
|
|
availableModels: data.general.availableModels || undefined,
|
|
supportedBackends: data.general.supportedBackends || []
|
|
};
|
|
this.lighting = data.lighting;
|
|
this.network = data.networkSettings;
|
|
this.currentFieldLayout = data.atfl;
|
|
},
|
|
updateGeneralSettings(payload: Required<ConfigurableNetworkSettings>) {
|
|
return axios.post("/settings/general", payload);
|
|
},
|
|
/**
|
|
* Modify the brightness of the LEDs.
|
|
*
|
|
* @param brightness brightness to set [0, 100]
|
|
*/
|
|
changeLEDBrightness(brightness: number) {
|
|
const payload = {
|
|
enabledLEDPercentage: brightness
|
|
};
|
|
useStateStore().websocket?.send(payload, true);
|
|
}
|
|
}
|
|
});
|