UNPKG

my-test123

Version:
59 lines 2.14 kB
import { Injectable } from '@angular/core'; import 'rxjs/add/operator/toPromise'; import { Logger } from 'ngx-base'; import { HttpService } from './http-service'; import { Spaces } from 'ngx-fabric8-wit'; var LabelService = /** @class */ (function () { function LabelService(http, logger, spaces) { this.http = http; this.logger = logger; this.spaces = spaces; } LabelService.prototype.notifyError = function (message, httpError) { this.logger.log('ERROR [WorkItemService] ' + message + (httpError.message ? ' ' + httpError.message : '')); }; /** * getLabels - We call this service method to fetch all labels in currect space * @return Observable of LabelModel[] - Array of labels. * Url - http://localhost:8080/api/spaces/829d2039-3929-4e8e-865b-fd463b8b34f1/labels/ */ LabelService.prototype.getLabels = function () { var _this = this; return this.spaces.current .switchMap(function (currentSpace) { if (currentSpace) return _this.http.get(currentSpace.links.self + '/labels'); else return []; }).map(function (response) { return response.json().data; }); }; LabelService.prototype.getLabels2 = function (labelUrl) { return this.http.get(labelUrl) .map(function (response) { return response.json().data; }); }; LabelService.prototype.createLabel = function (label) { var _this = this; return this.spaces.current.switchMap(function (currentSpace) { return _this.http.post(currentSpace.links.self + '/labels', { data: label }); }) .map(function (response) { return response.json().data; }); }; LabelService.decorators = [ { type: Injectable }, ]; /** @nocollapse */ LabelService.ctorParameters = function () { return [ { type: HttpService, }, { type: Logger, }, { type: Spaces, }, ]; }; return LabelService; }()); export { LabelService }; //# sourceMappingURL=label.service.js.map