-
-
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.
* Layers now working * Fan Speed now working * AppComponent config needs to be public
- Loading branch information
1 parent
737f5d1
commit 393a482
Showing
10 changed files
with
127 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { DisplayLayerProgressService } from './display-layer-progress.service'; | ||
|
||
describe('DisplayLayerProgressService', () => { | ||
beforeEach(() => TestBed.configureTestingModule({})); | ||
|
||
it('should be created', () => { | ||
const service: DisplayLayerProgressService = TestBed.get(DisplayLayerProgressService); | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
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,49 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable, Observer, timer } from 'rxjs'; | ||
import { HttpHeaders, HttpErrorResponse, HttpClient } from '@angular/common/http'; | ||
import { ConfigService } from './config/config.service'; | ||
import { share } from 'rxjs/operators'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class DisplayLayerProgressService { | ||
|
||
observable: Observable<Object> | ||
|
||
constructor(private _configService: ConfigService, private _http: HttpClient) { | ||
this.observable = Observable.create((observer: Observer<any>) => { | ||
timer(750, this._configService.config.octoprint.apiInterval).subscribe(_ => { | ||
if (this._configService.config) { | ||
const httpHeaders = { | ||
headers: new HttpHeaders({ | ||
'x-api-key': this._configService.config.octoprint.accessToken | ||
}) | ||
} | ||
this._http.get(this._configService.config.octoprint.url + "plugin/DisplayLayerProgress", httpHeaders).subscribe( | ||
(data: JSON) => { | ||
observer.next({ | ||
current: data["layer"]["current"] === "-" ? 0 : data["layer"]["current"], | ||
total: data["layer"]["total"] === "-" ? 0 : data["layer"]["total"], | ||
fanSpeed: data["fanSpeed"] === "-" ? 0 : data["fanSpeed"] | ||
}) | ||
}, (error: HttpErrorResponse) => { | ||
console.error("Can't retrieve layerProgress! " + error.message) | ||
}) | ||
} | ||
}) | ||
}).pipe(share()) | ||
} | ||
|
||
|
||
public getObservable(): Observable<Object> { | ||
return this.observable | ||
} | ||
|
||
} | ||
|
||
export interface DisplayLayerProgressAPI { | ||
current: number; | ||
total: number; | ||
fanSpeed: 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
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