}
+export interface IXDSDeploy {
+ boardIP: string;
+ file: string;
+}
+
export interface IAgentStatus {
baseURL: string;
connected: boolean;
if (url) {
this._initURLs(url);
}
- //FIXME [XDS-Agent]: not implemented yet, set always as connected
- //this._status.connected = false;
- this._status.connected = true;
+ this._status.connected = false;
this._status.connectionRetry = 0;
this.connectionMaxRetry = retry || 3600; // 1 hour
}
public getVersion(): Observable<IXDSVersion> {
- /*FIXME [XDS-Agent]: Not implemented for now
return this._get('/version');
- */
- return Observable.of({
- version: "NOT_IMPLEMENTED",
- apiVersion: "NOT_IMPLEMENTED",
- gitTag: "NOT_IMPLEMENTED"
- });
+ }
+
+ public deploy(dpy: IXDSDeploy) {
+ return this._post('/deploy', dpy);
}
private _initURLs(url: string) {
options = options || {};
let headers = options.headers || new Headers();
// headers.append('Authorization', 'Basic ' + btoa('username:password'));
- headers.append('Access-Control-Allow-Origin', '*');
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json');
if (this.apikey !== "") {
return Observable.of(true);
}
- return this.http.get(this._status.baseURL, this._attachAuthHeaders())
+ return this.http.get(this.baseRestUrl + "/version", this._attachAuthHeaders())
.map((r) => this._status.connected = true)
.retryWhen((attempts) => {
this._status.connectionRetry = 0;
return this._checkAlive()
.flatMap(() => this.http.post(this.baseRestUrl + url, JSON.stringify(body), this._attachAuthHeaders()))
.map((res: Response) => res.json())
- .catch((error) => {
- return this._decodeError(error);
- });
+ .catch(this._decodeError);
}
private _delete(url: string): Observable<any> {
return this._checkAlive()
if (this._status) {
this._status.connected = false;
}
- if (typeof err === "object") {
+ if (err instanceof Response) {
+ const body = err.json() || 'Server error';
+ e = body.error || JSON.stringify(body);
+ if (!e || e === "") {
+ e = `${err.status} - ${err.statusText || 'Unknown error'}`;
+ }
+ } else if (typeof err === "object") {
if (err.statusText) {
e = err.statusText;
} else if (err.error) {
} else {
e = JSON.stringify(err);
}
- } else if (err instanceof Response) {
- const body = err.json() || 'Server error';
- const error = body.error || JSON.stringify(body);
- e = `${err.status} - ${err.statusText || ''} ${error}`;
} else {
e = err.message ? err.message : err.toString();
}