Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/src/__test__/store/modules/emhttp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ test('After init returns values from cfg file for all fields', { timeout: 30000
"fsUsed": null,
"id": "ST18000NM000J-2TV103_ZR585CPY",
"idx": 0,
"isSpinning": true,
"name": "parity",
"numErrors": 0,
"numReads": 0,
Expand All @@ -235,6 +236,7 @@ test('After init returns values from cfg file for all fields', { timeout: 30000
"fsUsed": 4116003021,
"id": "ST18000NM000J-2TV103_ZR5B1W9X",
"idx": 1,
"isSpinning": true,
"name": "disk1",
"numErrors": 0,
"numReads": 0,
Expand All @@ -259,6 +261,7 @@ test('After init returns values from cfg file for all fields', { timeout: 30000
"fsUsed": 11904860828,
"id": "WDC_WD120EDAZ-11F3RA0_5PJRD45C",
"idx": 2,
"isSpinning": true,
"name": "disk2",
"numErrors": 0,
"numReads": 0,
Expand All @@ -283,6 +286,7 @@ test('After init returns values from cfg file for all fields', { timeout: 30000
"fsUsed": 6478056481,
"id": "WDC_WD120EMAZ-11BLFA0_5PH8BTYD",
"idx": 3,
"isSpinning": true,
"name": "disk3",
"numErrors": 0,
"numReads": 0,
Expand All @@ -307,6 +311,7 @@ test('After init returns values from cfg file for all fields', { timeout: 30000
"fsUsed": 137273827,
"id": "Samsung_SSD_850_EVO_250GB_S2R5NX0H643734Z",
"idx": 30,
"isSpinning": true,
"name": "cache",
"numErrors": 0,
"numReads": 0,
Expand All @@ -331,6 +336,7 @@ test('After init returns values from cfg file for all fields', { timeout: 30000
"fsUsed": null,
"id": "KINGSTON_SA2000M8250G_50026B7282669D9E",
"idx": 31,
"isSpinning": true,
"name": "cache2",
"numErrors": 0,
"numReads": 0,
Expand All @@ -355,6 +361,7 @@ test('After init returns values from cfg file for all fields', { timeout: 30000
"fsUsed": 851325,
"id": "Cruzer",
"idx": 32,
"isSpinning": true,
"name": "flash",
"numErrors": 0,
"numReads": 0,
Expand Down
7 changes: 7 additions & 0 deletions api/src/__test__/store/state-parsers/slots.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test('Returns parsed state file', async () => {
"fsUsed": null,
"id": "ST18000NM000J-2TV103_ZR585CPY",
"idx": 0,
"isSpinning": true,
"name": "parity",
"numErrors": 0,
"numReads": 0,
Expand All @@ -52,6 +53,7 @@ test('Returns parsed state file', async () => {
"fsUsed": 4116003021,
"id": "ST18000NM000J-2TV103_ZR5B1W9X",
"idx": 1,
"isSpinning": true,
"name": "disk1",
"numErrors": 0,
"numReads": 0,
Expand All @@ -76,6 +78,7 @@ test('Returns parsed state file', async () => {
"fsUsed": 11904860828,
"id": "WDC_WD120EDAZ-11F3RA0_5PJRD45C",
"idx": 2,
"isSpinning": true,
"name": "disk2",
"numErrors": 0,
"numReads": 0,
Expand All @@ -100,6 +103,7 @@ test('Returns parsed state file', async () => {
"fsUsed": 6478056481,
"id": "WDC_WD120EMAZ-11BLFA0_5PH8BTYD",
"idx": 3,
"isSpinning": true,
"name": "disk3",
"numErrors": 0,
"numReads": 0,
Expand All @@ -124,6 +128,7 @@ test('Returns parsed state file', async () => {
"fsUsed": 137273827,
"id": "Samsung_SSD_850_EVO_250GB_S2R5NX0H643734Z",
"idx": 30,
"isSpinning": true,
"name": "cache",
"numErrors": 0,
"numReads": 0,
Expand All @@ -148,6 +153,7 @@ test('Returns parsed state file', async () => {
"fsUsed": null,
"id": "KINGSTON_SA2000M8250G_50026B7282669D9E",
"idx": 31,
"isSpinning": true,
"name": "cache2",
"numErrors": 0,
"numReads": 0,
Expand All @@ -172,6 +178,7 @@ test('Returns parsed state file', async () => {
"fsUsed": 851325,
"id": "Cruzer",
"idx": 32,
"isSpinning": true,
"name": "flash",
"numErrors": 0,
"numReads": 0,
Expand Down
2 changes: 2 additions & 0 deletions api/src/store/state-parsers/slots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type IniSlot = {
size: string;
sizeSb: string;
slots: string;
spundown: string;
status: SlotStatus;
temp: string;
type: SlotType;
Expand Down Expand Up @@ -82,6 +83,7 @@ export const parse: StateFileToIniParserMap['disks'] = (disksIni) =>
fsType: slot.fsType ?? null,
format: slot.format === '-' ? null : slot.format,
transport: slot.transport ?? null,
isSpinning: slot.spundown ? slot.spundown === '0' : null,
};
// @TODO Zod Parse This
return result;
Expand Down
3 changes: 3 additions & 0 deletions api/src/unraid-api/graph/resolvers/array/array.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ export class ArrayDisk extends Node {

@Field(() => ArrayDiskFsColor, { nullable: true })
color?: ArrayDiskFsColor | null;

@Field(() => Boolean, { nullable: true, description: 'Whether the disk is currently spinning' })
isSpinning?: boolean | null;
}

@ObjectType({
Expand Down
14 changes: 13 additions & 1 deletion api/src/unraid-api/graph/resolvers/disks/disks.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import { Field, ObjectType, registerEnumType } from '@nestjs/graphql';
import { Node } from '@unraid/shared/graphql.model.js';
import { PrefixedID } from '@unraid/shared/prefixed-id-scalar.js';
import { Type } from 'class-transformer';
import { IsArray, IsEnum, IsNumber, IsOptional, IsString, ValidateNested } from 'class-validator';
import {
IsArray,
IsBoolean,
IsEnum,
IsNumber,
IsOptional,
IsString,
ValidateNested,
} from 'class-validator';

export enum DiskFsType {
XFS = 'XFS',
Expand Down Expand Up @@ -136,4 +144,8 @@ export class Disk extends Node {
@ValidateNested({ each: true })
@Type(() => DiskPartition)
partitions!: DiskPartition[];

@Field(() => Boolean, { description: 'Whether the disk is spinning or not' })
@IsBoolean()
isSpinning!: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('DisksResolver', () => {
smartStatus: DiskSmartStatus.OK,
temperature: -1,
partitions: [],
isSpinning: false,
},
];
mockDisksService.getDisks.mockResolvedValue(mockResult);
Expand All @@ -92,6 +93,7 @@ describe('DisksResolver', () => {
const mockDisk: Disk = {
id: 'SERIAL123',
device: '/dev/sda',
isSpinning: false,
type: 'SSD',
name: 'Samsung SSD 860 EVO 1TB',
vendor: 'Samsung',
Expand Down
5 changes: 5 additions & 0 deletions api/src/unraid-api/graph/resolvers/disks/disks.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ export class DisksResolver {
public async temperature(@Parent() disk: Disk) {
return this.disksService.getTemperature(disk.device);
}

@ResolveField(() => Boolean)
public async isSpinning(@Parent() disk: Disk) {
return disk.isSpinning;
}
}
Loading
Loading