Skip to content

Commit 72a7cf7

Browse files
authored
feat: libre hardware monitor beta support (#13)
* feat: screenshots updated * feat: libre hardware monitor beta support * fix: sensor name correction
1 parent 39bc023 commit 72a7cf7

File tree

4 files changed

+181
-47
lines changed

4 files changed

+181
-47
lines changed

app/models/api/deviceInfo.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export enum IAPISensorType {
22
Voltage = 'Voltage',
3-
Clock = 'Vlock',
3+
Clock = 'Clock',
44
Load = 'Load',
55
Temperature = 'Temperature',
66
Fan = 'Fan',
@@ -9,19 +9,23 @@ export enum IAPISensorType {
99
Level = 'Level',
1010
Power = 'Power',
1111
Throughput = 'Throughput',
12+
Current = 'Current',
13+
Capacity = 'Capacity',
1214
}
1315

1416
export enum IAPIHardwareType {
1517
CPU = 'CPU',
1618
GpuNvidia = 'GpuNvidia',
1719
GpuAti = 'GpuAti',
20+
GpuIntel = 'GpuIntel',
1821
HDD = 'HDD',
1922
Heatmaster = 'Heatmaster',
2023
Mainboard = 'Mainboard',
2124
Chipset = 'Chipset',
2225
TBalancer = 'TBalancer',
2326
RAM = 'RAM',
2427
NIC = 'NIC',
28+
Battery = 'Battery',
2529
}
2630

2731
export enum IAPISystemType {

app/models/mapper/cardValueViewModel.ts

Lines changed: 127 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
IDeviceSensorData,
1010
IDeviceChipset,
1111
IDeviceNIC,
12+
IDeviceGpuintel,
13+
IDeviceBattery,
14+
IDeviceGpunvidia,
1215
} from 'app/models/models/deviceInfo';
1316
import { IAPIHardwareType, IAPISensorType, IAPISystemType } from 'app/models/api/deviceInfo';
1417

@@ -36,25 +39,25 @@ export const convertToViewModel = (device: IDevice | null): ICardViewModel[] =>
3639
let voltages = getObjectFromType(chipsetInfo.chipset, IAPISensorType.Voltage) as IDeviceChipset[];
3740
let voltagesVMs = voltages.map(voltageInfo => {
3841
let voltagesVM = convertArrayToVM(voltageInfo.voltage!);
39-
return { id: voltageInfo.id, values: voltagesVM, title: IAPISensorType.Voltage, sections: null };
42+
return { id: voltageInfo.id, values: voltagesVM, title: voltageInfo.text, sections: null };
4043
});
4144
//Temperatures
4245
let temperatures = getObjectFromType(chipsetInfo.chipset, IAPISensorType.Temperature) as IDeviceChipset[];
4346
let temperaturesVMs = temperatures.map(temperatureInfo => {
4447
let temperaturesVM = convertArrayToVM(temperatureInfo.temperature!);
45-
return { id: temperatureInfo.id, values: temperaturesVM, title: IAPISensorType.Temperature, sections: null };
48+
return { id: temperatureInfo.id, values: temperaturesVM, title: temperatureInfo.text, sections: null };
4649
});
4750
//Fans
4851
let fans = getObjectFromType(chipsetInfo.chipset, IAPISensorType.Fan) as IDeviceChipset[];
4952
let fansVMs = fans.map(fanInfo => {
5053
let fansVM = convertArrayToVM(fanInfo.fan!);
51-
return { id: fanInfo.id, values: fansVM, title: IAPISensorType.Fan, sections: null };
54+
return { id: fanInfo.id, values: fansVM, title: fanInfo.text, sections: null };
5255
});
5356
//Controls
5457
let controls = getObjectFromType(chipsetInfo.chipset, IAPISensorType.Control) as IDeviceChipset[];
5558
let controlsVMs = controls.map(controlInfo => {
5659
let controlsVM = convertArrayToVM(controlInfo.control!);
57-
return { id: controlInfo.id, values: controlsVM, title: IAPISensorType.Control, sections: null };
60+
return { id: controlInfo.id, values: controlsVM, title: controlInfo.text, sections: null };
5861
});
5962
return {
6063
id: chipsetInfo.id,
@@ -78,34 +81,40 @@ export const convertToViewModel = (device: IDevice | null): ICardViewModel[] =>
7881
if (!cpuInfo.cpu) {
7982
return null;
8083
}
81-
//VLocks
82-
let vlocks = getObjectFromType(cpuInfo.cpu, IAPISensorType.Clock) as IDeviceCPU[];
83-
let vlocksVMs = vlocks.map(vlockInfo => {
84-
let vlocksVM = convertArrayToVM(vlockInfo.vlock!);
85-
return { id: vlockInfo.id, values: vlocksVM, title: IAPISensorType.Clock, sections: null };
84+
//Voltages
85+
let voltages = getObjectFromType(cpuInfo.cpu, IAPISensorType.Voltage) as IDeviceChipset[];
86+
let voltagesVMs = voltages.map(voltageInfo => {
87+
let voltagesVM = convertArrayToVM(voltageInfo.voltage!);
88+
return { id: voltageInfo.id, values: voltagesVM, title: voltageInfo.text, sections: null };
89+
});
90+
//Cocks
91+
let clocks = getObjectFromType(cpuInfo.cpu, IAPISensorType.Clock) as IDeviceCPU[];
92+
let clocksVMs = clocks.map(clockInfo => {
93+
let clocksVM = convertArrayToVM(clockInfo.clock!);
94+
return { id: clockInfo.id, values: clocksVM, title: clockInfo.text, sections: null };
8695
});
8796
//Temperatures
8897
let temperatures = getObjectFromType(cpuInfo.cpu, IAPISensorType.Temperature) as IDeviceCPU[];
8998
let temperaturesVMs = temperatures.map(temperatureInfo => {
9099
let controlsVMs = convertArrayToVM(temperatureInfo.temperature!);
91-
return { id: temperatureInfo.id, values: controlsVMs, title: IAPISensorType.Temperature, sections: null };
100+
return { id: temperatureInfo.id, values: controlsVMs, title: temperatureInfo.text, sections: null };
92101
});
93102
//Loads
94103
let loads = getObjectFromType(cpuInfo.cpu, IAPISensorType.Load) as IDeviceCPU[];
95104
let loadsVMs = loads.map(loadInfo => {
96105
let controlsVMs = convertArrayToVM(loadInfo.load!);
97-
return { id: loadInfo.id, values: controlsVMs, title: IAPISensorType.Load, sections: null };
106+
return { id: loadInfo.id, values: controlsVMs, title: loadInfo.text, sections: null };
98107
});
99108
//Powers
100109
let powers = getObjectFromType(cpuInfo.cpu, IAPISensorType.Power) as IDeviceCPU[];
101110
let powersVMs = powers.map(power => {
102111
let powerVMs = convertArrayToVM(power.power!);
103-
return { id: power.id, values: powerVMs, title: IAPISensorType.Power, sections: null };
112+
return { id: power.id, values: powerVMs, title: power.text, sections: null };
104113
});
105114
return {
106115
id: cpuInfo.id,
107116
title: `${IAPIHardwareType.CPU} - ${cpuInfo.text}`,
108-
sections: [...vlocksVMs, ...powersVMs, ...temperaturesVMs, ...loadsVMs],
117+
sections: [...voltagesVMs, ...clocksVMs, ...powersVMs, ...temperaturesVMs, ...loadsVMs],
109118
values: null,
110119
} as ICardViewModel;
111120
});
@@ -121,13 +130,13 @@ export const convertToViewModel = (device: IDevice | null): ICardViewModel[] =>
121130
let loads = getObjectFromType(ramInfo.ram, IAPISensorType.Load) as IDeviceRAM[];
122131
let loadsVMs = loads.map(load => {
123132
let loadVMs = convertArrayToVM(load.load!);
124-
return { id: load.id, values: loadVMs, title: IAPISensorType.Load, sections: null };
133+
return { id: load.id, values: loadVMs, title: load.text, sections: null };
125134
});
126135
//Data
127136
let powers = getObjectFromType(ramInfo.ram, IAPISensorType.Power) as IDeviceRAM[];
128137
let powersVMs = powers.map(power => {
129138
let powerVMs = convertArrayToVM(power.power!);
130-
return { id: power.id, values: powerVMs, title: IAPISensorType.Power, sections: null };
139+
return { id: power.id, values: powerVMs, title: power.text, sections: null };
131140
});
132141
return {
133142
id: ramInfo.id,
@@ -148,43 +157,43 @@ export const convertToViewModel = (device: IDevice | null): ICardViewModel[] =>
148157
let voltages = getObjectFromType(gpuAtiInfo.gpuati, IAPISensorType.Voltage) as IDeviceGpuati[];
149158
let voltagesVMs = voltages.map(voltage => {
150159
let controlsVM = convertArrayToVM(voltage.voltage!);
151-
return { id: voltage.id, values: controlsVM, title: IAPISensorType.Voltage, sections: null };
160+
return { id: voltage.id, values: controlsVM, title: voltage.text, sections: null };
152161
});
153162
//Clocks
154163
let clocks = getObjectFromType(gpuAtiInfo.gpuati, IAPISensorType.Clock) as IDeviceGpuati[];
155164
let clocksVMs = clocks.map(clock => {
156-
let controlsVM = convertArrayToVM(clock.vlock!);
157-
return { id: clock.id, values: controlsVM, title: IAPISensorType.Clock, sections: null };
165+
let controlsVM = convertArrayToVM(clock.clock!);
166+
return { id: clock.id, values: controlsVM, title: clock.text, sections: null };
158167
});
159168
//Temperatures
160169
let temperatures = getObjectFromType(gpuAtiInfo.gpuati, IAPISensorType.Temperature) as IDeviceGpuati[];
161170
let temperaturesVMs = temperatures.map(temperature => {
162171
let temperaturesVM = convertArrayToVM(temperature.temperature!);
163-
return { id: temperature.id, values: temperaturesVM, title: IAPISensorType.Temperature, sections: null };
172+
return { id: temperature.id, values: temperaturesVM, title: temperature.text, sections: null };
164173
});
165174
//Load
166175
let loads = getObjectFromType(gpuAtiInfo.gpuati, IAPISensorType.Load) as IDeviceGpuati[];
167176
let loadsVMs = loads.map(load => {
168177
let loadsVM = convertArrayToVM(load.load!);
169-
return { id: load.id, values: loadsVM, title: IAPISensorType.Load, sections: null };
178+
return { id: load.id, values: loadsVM, title: load.text, sections: null };
170179
});
171180
//Fan
172181
let fans = getObjectFromType(gpuAtiInfo.gpuati, IAPISensorType.Fan) as IDeviceGpuati[];
173182
let fansVMs = fans.map(fan => {
174183
let fansVM = convertArrayToVM(fan.fan!);
175-
return { id: fan.id, values: fansVM, title: IAPISensorType.Fan, sections: null };
184+
return { id: fan.id, values: fansVM, title: fan.text, sections: null };
176185
});
177186
//Controls
178187
let controls = getObjectFromType(gpuAtiInfo.gpuati, IAPISensorType.Control) as IDeviceGpuati[];
179188
let controlsVMs = controls.map(control => {
180189
let controlsVM = convertArrayToVM(control.control!);
181-
return { id: control.id, values: controlsVM, title: IAPISensorType.Control, sections: null };
190+
return { id: control.id, values: controlsVM, title: control.text, sections: null };
182191
});
183192
//Power
184193
let powers = getObjectFromType(gpuAtiInfo.gpuati, IAPISensorType.Power) as IDeviceGpuati[];
185194
let powersVMs = powers.map(power => {
186195
let powersVM = convertArrayToVM(power.power!);
187-
return { id: power.id, values: powersVM, title: IAPISensorType.Power, sections: null };
196+
return { id: power.id, values: powersVM, title: power.text, sections: null };
188197
});
189198
return {
190199
id: gpuAtiInfo.id,
@@ -210,46 +219,46 @@ export const convertToViewModel = (device: IDevice | null): ICardViewModel[] =>
210219
return null;
211220
}
212221
//Voltages
213-
let voltages = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Voltage) as IDeviceGpuati[];
222+
let voltages = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Voltage) as IDeviceGpunvidia[];
214223
let voltagesVMs = voltages.map(voltage => {
215224
let controlsVM = convertArrayToVM(voltage.voltage!);
216-
return { id: voltage.id, values: controlsVM, title: IAPISensorType.Voltage, sections: null };
225+
return { id: voltage.id, values: controlsVM, title: voltage.text, sections: null };
217226
});
218227
//Clocks
219-
let clocks = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Clock) as IDeviceGpuati[];
228+
let clocks = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Clock) as IDeviceGpunvidia[];
220229
let clocksVMs = clocks.map(clock => {
221-
let controlsVM = convertArrayToVM(clock.vlock!);
222-
return { id: clock.id, values: controlsVM, title: IAPISensorType.Clock, sections: null };
230+
let controlsVM = convertArrayToVM(clock.clock!);
231+
return { id: clock.id, values: controlsVM, title: clock.text, sections: null };
223232
});
224233
//Temperatures
225-
let temperatures = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Temperature) as IDeviceGpuati[];
234+
let temperatures = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Temperature) as IDeviceGpunvidia[];
226235
let temperaturesVMs = temperatures.map(temperature => {
227236
let temperaturesVM = convertArrayToVM(temperature.temperature!);
228-
return { id: temperature.id, values: temperaturesVM, title: IAPISensorType.Temperature, sections: null };
237+
return { id: temperature.id, values: temperaturesVM, title: temperature.text, sections: null };
229238
});
230239
//Load
231-
let loads = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Load) as IDeviceGpuati[];
240+
let loads = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Load) as IDeviceGpunvidia[];
232241
let loadsVMs = loads.map(load => {
233242
let loadsVM = convertArrayToVM(load.load!);
234-
return { id: load.id, values: loadsVM, title: IAPISensorType.Load, sections: null };
243+
return { id: load.id, values: loadsVM, title: load.text, sections: null };
235244
});
236245
//Fan
237-
let fans = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Fan) as IDeviceGpuati[];
246+
let fans = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Fan) as IDeviceGpunvidia[];
238247
let fansVMs = fans.map(fan => {
239248
let fansVM = convertArrayToVM(fan.fan!);
240-
return { id: fan.id, values: fansVM, title: IAPISensorType.Fan, sections: null };
249+
return { id: fan.id, values: fansVM, title: fan.text, sections: null };
241250
});
242251
//Controls
243-
let controls = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Control) as IDeviceGpuati[];
252+
let controls = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Control) as IDeviceGpunvidia[];
244253
let controlsVMs = controls.map(control => {
245254
let controlsVM = convertArrayToVM(control.control!);
246-
return { id: control.id, values: controlsVM, title: IAPISensorType.Control, sections: null };
255+
return { id: control.id, values: controlsVM, title: control.text, sections: null };
247256
});
248257
//Power
249-
let powers = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Power) as IDeviceGpuati[];
258+
let powers = getObjectFromType(gpuNvidiaInfo.gpunvidia, IAPISensorType.Power) as IDeviceGpunvidia[];
250259
let powersVMs = powers.map(power => {
251260
let powersVM = convertArrayToVM(power.power!);
252-
return { id: power.id, values: powersVM, title: IAPISensorType.Power, sections: null };
261+
return { id: power.id, values: powersVM, title: power.text, sections: null };
253262
});
254263
return {
255264
id: gpuNvidiaInfo.id,
@@ -268,6 +277,34 @@ export const convertToViewModel = (device: IDevice | null): ICardViewModel[] =>
268277
});
269278
let gpuNvidiaSectionViewModelsMapped = gpuNvidiaSectionViewModels.filter(v => v).map(v => v!);
270279

280+
//CARD
281+
let computerGpusIntel = getObjectFromType(computers, IAPIHardwareType.GpuIntel) as IDeviceComputer[];
282+
283+
let gpuIntelSectionViewModels = computerGpusIntel.map(gpuIntelInfo => {
284+
if (!gpuIntelInfo.gpuintel) {
285+
return null;
286+
}
287+
//Power
288+
let powers = getObjectFromType(gpuIntelInfo.gpuintel, IAPISensorType.Power) as IDeviceGpuintel[];
289+
let powersVMs = powers.map(power => {
290+
let powersVM = convertArrayToVM(power.power!);
291+
return { id: power.id, values: powersVM, title: power.text, sections: null };
292+
});
293+
//Load
294+
let loads = getObjectFromType(gpuIntelInfo.gpuintel, IAPISensorType.Load) as IDeviceGpuintel[];
295+
let loadsVMs = loads.map(load => {
296+
let loadsVM = convertArrayToVM(load.load!);
297+
return { id: load.id, values: loadsVM, title: load.text, sections: null };
298+
});
299+
return {
300+
id: gpuIntelInfo.id,
301+
title: `${IAPIHardwareType.GpuIntel} - ${gpuIntelInfo.text}`,
302+
sections: [...loadsVMs, ...powersVMs],
303+
values: null,
304+
} as ICardViewModel;
305+
});
306+
let gpuIntelSectionViewModelsMapped = gpuIntelSectionViewModels.filter(v => v).map(v => v!);
307+
271308
//HDD
272309
let computerHdds = getObjectFromType(computers, IAPIHardwareType.HDD) as IDeviceComputer[];
273310
let computerHddViewModels = computerHdds.map(hddInfo => {
@@ -295,13 +332,13 @@ export const convertToViewModel = (device: IDevice | null): ICardViewModel[] =>
295332
let powers = getObjectFromType(hddInfo.hdd, IAPISensorType.Power) as IDeviceHDD[];
296333
let powersVMs = powers.map(power => {
297334
let powersVM = convertArrayToVM(power.power!);
298-
return { id: power.id, values: powersVM, title: IAPISensorType.Power, sections: null };
335+
return { id: power.id, values: powersVM, title: power.text, sections: null };
299336
});
300337
//Throughput
301338
let throughputs = getObjectFromType(hddInfo.hdd, IAPISensorType.Throughput) as IDeviceHDD[];
302339
let throughputsVMs = throughputs.map(throughput => {
303340
let throughputsVM = convertArrayToVM(throughput.throughput!);
304-
return { id: throughput.id, values: throughputsVM, title: IAPISensorType.Throughput, sections: null };
341+
return { id: throughput.id, values: throughputsVM, title: throughput.text, sections: null };
305342
});
306343
return {
307344
id: hddInfo.id,
@@ -322,19 +359,19 @@ export const convertToViewModel = (device: IDevice | null): ICardViewModel[] =>
322359
let loads = getObjectFromType(nicInfo.nic, IAPISensorType.Load) as IDeviceNIC[];
323360
let loadsVMs = loads.map(load => {
324361
let loadsVM = convertArrayToVM(load.load!);
325-
return { id: load.id, values: loadsVM, title: IAPISensorType.Load, sections: null };
362+
return { id: load.id, values: loadsVM, title: load.text, sections: null };
326363
});
327364
//Data
328365
let powers = getObjectFromType(nicInfo.nic, IAPISensorType.Power) as IDeviceNIC[];
329366
let powersVMs = powers.map(power => {
330367
let powerVMs = convertArrayToVM(power.power!);
331-
return { id: power.id, values: powerVMs, title: IAPISensorType.Power, sections: null };
368+
return { id: power.id, values: powerVMs, title: power.text, sections: null };
332369
});
333370
//Throughput
334371
let throughputs = getObjectFromType(nicInfo.nic, IAPISensorType.Throughput) as IDeviceNIC[];
335372
let throughputsVMs = throughputs.map(throughput => {
336373
let throughputsVM = convertArrayToVM(throughput.throughput!);
337-
return { id: throughput.id, values: throughputsVM, title: IAPISensorType.Throughput, sections: null };
374+
return { id: throughput.id, values: throughputsVM, title: throughput.text, sections: null };
338375
});
339376
return {
340377
id: nicInfo.id,
@@ -345,14 +382,61 @@ export const convertToViewModel = (device: IDevice | null): ICardViewModel[] =>
345382
});
346383
let computerNicViewModelsMapped = computerNicViewModels.filter(v => v).map(v => v!);
347384

385+
//BATTERY
386+
let computerBatteries = getObjectFromType(computers, IAPIHardwareType.Battery) as IDeviceComputer[];
387+
let batterySectionViewModels = computerBatteries.map(batteryInfo => {
388+
if (!batteryInfo.battery) {
389+
return null;
390+
}
391+
//Voltages
392+
let voltages = getObjectFromType(batteryInfo.battery, IAPISensorType.Voltage) as IDeviceBattery[];
393+
let voltagesVMs = voltages.map(voltage => {
394+
let controlsVM = convertArrayToVM(voltage.voltage!);
395+
return { id: voltage.id, values: controlsVM, title: voltage.text, sections: null };
396+
});
397+
//Currents
398+
let currents = getObjectFromType(batteryInfo.battery, IAPISensorType.Clock) as IDeviceBattery[];
399+
let currentsVMs = currents.map(current => {
400+
let controlsVM = convertArrayToVM(current.current!);
401+
return { id: current.id, values: controlsVM, title: current.text, sections: null };
402+
});
403+
//Power
404+
let powers = getObjectFromType(batteryInfo.battery, IAPISensorType.Power) as IDeviceBattery[];
405+
let powersVMs = powers.map(power => {
406+
let powersVM = convertArrayToVM(power.power!);
407+
return { id: power.id, values: powersVM, title: power.text, sections: null };
408+
});
409+
//Level
410+
let levels = getObjectFromType(batteryInfo.battery, IAPISensorType.Level) as IDeviceBattery[];
411+
let levelsVMs = levels.map(level => {
412+
let levelsVM = convertArrayToVM(level.level!);
413+
return { id: level.id, values: levelsVM, title: level.text, sections: null };
414+
});
415+
//Capacities
416+
let capacities = getObjectFromType(batteryInfo.battery, IAPISensorType.Capacity) as IDeviceBattery[];
417+
let capacitiesVMs = capacities.map(capacity => {
418+
let capacitiesVM = convertArrayToVM(capacity.capacity!);
419+
return { id: capacity.id, values: capacitiesVM, title: capacity.text, sections: null };
420+
});
421+
return {
422+
id: batteryInfo.id,
423+
title: `${IAPIHardwareType.Battery} - ${batteryInfo.text}`,
424+
sections: [...voltagesVMs, ...currentsVMs, ...powersVMs, ...levelsVMs, ...capacitiesVMs],
425+
values: null,
426+
} as ICardViewModel;
427+
});
428+
let batterySectionViewModelsMapped = batterySectionViewModels.filter(v => v).map(v => v!);
429+
348430
return [
349431
...mainboardSectionViewModelsMapped,
350432
...computerCpusViewModelsMapped,
351433
...ramSectionViewModelsMapped,
434+
...gpuIntelSectionViewModelsMapped,
352435
...gpuAtiSectionViewModelsMapped,
353436
...gpuNvidiaSectionViewModelsMapped,
354437
...computerHddViewModelsMapped,
355438
...computerNicViewModelsMapped,
439+
...batterySectionViewModelsMapped,
356440
];
357441
};
358442

0 commit comments

Comments
 (0)