UNPKG

my-test123

Version:
82 lines 3.84 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 { UserService } from 'ngx-login-client'; import { Store } from '@ngrx/store'; import { Actions, Effect } from '@ngrx/effects'; import { Injectable } from '@angular/core'; import * as CollaboratorActions from './../actions/collaborator.actions'; import { Observable } from 'rxjs'; import { Notifications, NotificationType } from "ngx-base"; import { CollaboratorService as CollabService } from './../services/collaborator.service'; import { UserMapper } from './../models/user'; var CollaboratorEffects = /** @class */ (function () { function CollaboratorEffects(actions$, collaboratorService, userService, notifications, store) { var _this = this; this.actions$ = actions$; this.collaboratorService = collaboratorService; this.userService = userService; this.notifications = notifications; this.store = store; this.getCollaborators$ = this.actions$ .ofType(CollaboratorActions.GET) .withLatestFrom(this.store.select('listPage').select('space')) .switchMap(function (_a) { var action = _a[0], space = _a[1]; return _this.collaboratorService.getCollaborators2(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); }); }) .mergeMap(function (collaborators) { // resolving loggedin user return _this.userService.loggedInUser .map(function (user) { if (user) { collaborators.map(function (c) { c.currentUser = c.id === user.id; return c; }); } return new CollaboratorActions.GetSuccess(collaborators); }); }) .catch(function (e) { try { _this.notifications.message({ message: "Problem in fetching collaborators", type: NotificationType.DANGER }); } catch (e) { console.log('Problem in fetching collaborators'); } return Observable.of(new CollaboratorActions.GetError()); }); }); } CollaboratorEffects.decorators = [ { type: Injectable }, ]; /** @nocollapse */ CollaboratorEffects.ctorParameters = function () { return [ { type: Actions, }, { type: CollabService, }, { type: UserService, }, { type: Notifications, }, { type: Store, }, ]; }; __decorate([ Effect(), __metadata("design:type", Observable) ], CollaboratorEffects.prototype, "getCollaborators$", void 0); return CollaboratorEffects; }()); export { CollaboratorEffects }; //# sourceMappingURL=collaborator.effects.js.map