UNPKG

fabric8-planner

Version:
60 lines 3.31 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Injectable } from '@angular/core'; import { Actions, Effect } from '@ngrx/effects'; import { Observable } from 'rxjs'; import { catchError, map, switchMap } from 'rxjs/operators'; import { normalizeArray } from '../models/common.model'; import { SpaceQuery } from '../models/space'; import * as CollaboratorActions from './../actions/collaborator.actions'; import * as UserActions from './../actions/user.actions'; import { UserMapper } from './../models/user'; import { CollaboratorService as CollabService } from './../services/collaborator.service'; import { ErrorHandler, filterTypeWithSpace } from './work-item-utils'; var CollaboratorEffects = /** @class */ (function () { function CollaboratorEffects(actions$, collaboratorService, spaceQuery, errHandler) { var _this = this; this.actions$ = actions$; this.collaboratorService = collaboratorService; this.spaceQuery = spaceQuery; this.errHandler = errHandler; this.getCollaborators$ = this.actions$ .pipe(filterTypeWithSpace(CollaboratorActions.GET, this.spaceQuery.getCurrentSpace), switchMap(function (_a) { var action = _a[0], space = _a[1]; return _this.collaboratorService.getCollaborators(space.links.self + '/collaborators?page[offset]=0&page[limit]=1000'); }), map(function (collaborators) { var collabM = new UserMapper(); return collaborators.map(function (c) { return collabM.toUIModel(c); }). sort(function (c1, c2) { return (c1.name > c2.name ? 1 : 0); }); }), switchMap(function (collaborators) { return [ new CollaboratorActions.GetSuccess(collaborators.map(function (c) { return c.id; })), new UserActions.Set(normalizeArray(collaborators)) ]; }), catchError(function (err) { return _this.errHandler.handleError(err, 'Problem in fetching collaborators', new CollaboratorActions.GetError()); })); } CollaboratorEffects.decorators = [ { type: Injectable }, ]; /** @nocollapse */ CollaboratorEffects.ctorParameters = function () { return [ { type: Actions, }, { type: CollabService, }, { type: SpaceQuery, }, { type: ErrorHandler, }, ]; }; __decorate([ Effect(), __metadata("design:type", Observable) ], CollaboratorEffects.prototype, "getCollaborators$", void 0); return CollaboratorEffects; }()); export { CollaboratorEffects }; //# sourceMappingURL=collaborator.effects.js.map