-
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Spool Manager (#2147)
* Spool Manager Working * add beta to spool manager
- Loading branch information
1 parent
e762285
commit c7c6a0c
Showing
18 changed files
with
220 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
export interface SpoolManagerSpoolList { | ||
allSpools: Array<SpoolManagerSpool>; | ||
selectedSpools: Array<SpoolManagerSpool>; | ||
catalogs: SpoolManagerCatalogs; | ||
templateSpool: SpoolManagerSpool; | ||
totalItemCount: string; | ||
} | ||
|
||
interface SpoolManagerCatalogs { | ||
labels: Array<string>; | ||
materials: Array<string>; | ||
vendors: Array<string>; | ||
} | ||
|
||
export interface SpoolManagerSelectionPut { | ||
databaseId: number; | ||
toolIndex: number; | ||
} | ||
|
||
export interface SpoolManagerSpool { | ||
bedTemperature: number; | ||
code: unknown; | ||
color: string; | ||
colorName: string; | ||
cost: number; | ||
costUnit: string; | ||
created: string; | ||
databaseId: number; | ||
density: number; | ||
diameter: number; | ||
diameterTolerance: number; | ||
displayName: string; | ||
enclosureTemperature: number; | ||
firstUse: string; | ||
flowRateCompensation: number; | ||
isActive: boolean; | ||
isTemplate: boolean; | ||
labels: string; | ||
lastUse: string; | ||
material: string; | ||
materialCharacteristic: unknown; | ||
noteDeltaFormat: string; | ||
noteHtml: string; | ||
noteText: string; | ||
offsetBedTemperature: number; | ||
offsetEnclosureTemperature: number; | ||
offsetTemperature: number; | ||
originator: unknown; | ||
purchasedFrom: string; | ||
purchasedOn: string; | ||
remainingLength: string; | ||
remainingLengthPercentage: string; | ||
remainingPercentage: string; | ||
remainingWeight: string; | ||
spoolWeight: string; | ||
temperature: number; | ||
totalLength: number; | ||
totalWeight: number; | ||
updated: string; | ||
usedLength: number; | ||
usedLengthPercentage: string; | ||
usedPercentage: string; | ||
usedWeight: string; | ||
vendor: string; | ||
version: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/app/services/filament/spool-manager.octoprint.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
import { ConfigService } from '../../config/config.service'; | ||
import { FilamentSpool } from '../../model'; | ||
import { SpoolManagerSelectionPut, SpoolManagerSpool, SpoolManagerSpoolList } from '../../model/octoprint'; | ||
import { FilamentPluginService } from './filament-plugin.service'; | ||
|
||
@Injectable() | ||
export class SpoolManagerOctoprintService implements FilamentPluginService { | ||
public constructor(private configService: ConfigService, private http: HttpClient) {} | ||
|
||
public getSpools(): Observable<Array<FilamentSpool>> { | ||
return this.callSpoolManagerAPI('hideInactiveSpools', 0, 3000, 'lastUse', 'desc').pipe( | ||
map((spools: SpoolManagerSpoolList): Array<FilamentSpool> => { | ||
return spools.allSpools.map((spool: SpoolManagerSpool): FilamentSpool => { | ||
return this.convertFilamentManagerSpool(spool); | ||
}); | ||
}), | ||
); | ||
} | ||
|
||
public getCurrentSpool(): Observable<FilamentSpool> { | ||
return this.callSpoolManagerAPI('hideInactiveSpools', 0, 3000, 'lastUse', 'desc').pipe( | ||
map((spools: SpoolManagerSpoolList): FilamentSpool => { | ||
if (spools.selectedSpools.length > 0) { | ||
return this.convertFilamentManagerSpool(spools.selectedSpools[0]); | ||
} else { | ||
return null; | ||
} | ||
}), | ||
); | ||
} | ||
|
||
private callSpoolManagerAPI( | ||
filterName: string, | ||
from: number, | ||
to: number, | ||
sortColumn: string, | ||
sortOrder: string, | ||
): Observable<SpoolManagerSpoolList> { | ||
return this.http.get<SpoolManagerSpoolList>( | ||
this.configService.getApiURL('plugin/SpoolManager/loadSpoolsByQuery', false), | ||
{ | ||
...this.configService.getHTTPHeaders(), | ||
params: { | ||
filterName, | ||
from, | ||
to, | ||
sortColumn, | ||
sortOrder, | ||
}, | ||
}, | ||
); | ||
} | ||
|
||
private convertFilamentManagerSpool(spool: SpoolManagerSpool): FilamentSpool { | ||
return { | ||
color: spool.color ?? '#f5f6fa', | ||
density: spool.density, | ||
diameter: spool.diameter, | ||
displayName: `${spool.vendor} - ${spool.displayName}`, | ||
id: spool.databaseId, | ||
material: spool.material, | ||
name: spool.displayName, | ||
temperatureOffset: spool.offsetTemperature ?? 0, | ||
used: Number(spool.usedWeight), | ||
vendor: spool.vendor, | ||
weight: spool.totalWeight, | ||
}; | ||
} | ||
|
||
public setSpool(spool: FilamentSpool): Observable<void> { | ||
const setSpoolBody: SpoolManagerSelectionPut = { | ||
databaseId: spool.id, | ||
toolIndex: 0, | ||
}; | ||
|
||
return this.http.put<void>( | ||
this.configService.getApiURL('plugin/SpoolManager/selectSpool', false), | ||
setSpoolBody, | ||
this.configService.getHTTPHeaders(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters