Add new methods in role-users and subscribers.

deprecated-master
parent 9d65eaab72
commit aae1a2a0d0

@ -38,9 +38,8 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
@Input()
public inviteDisableMessage: string;
public user: User = null;
public active: any[];
public active: any[] = [];
public showActive: any[] = [];
public managers: any[];
public pending: any[];
public showPending: any[] = [];
public showCurrent: boolean = true;
@ -114,24 +113,11 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
updateLists() {
this.loadActive = true;
this.loadPending = true;
this.subs.push(this.userRegistryService.getActiveEmail(this.type, this.id, this.role).subscribe(users => {
if (this.role === 'member') {
this.subs.push(this.userRegistryService.getActiveEmail(this.type, this.id, 'manager').subscribe(managers => {
this.managers = managers;
this.active = users;
this.active.forEach(user => {
user['isManager'] = this.managers.find(manager => manager.email === user.email);
});
this.filterActiveBySearch(this.filterForm.value.active);
this.loadActive = false;
this.exists = true;
}))
} else {
this.active = users;
this.filterActiveBySearch(this.filterForm.value.active);
this.loadActive = false;
this.exists = true;
}
this.subs.push(this.userRegistryService.getActive(this.type, this.id, this.role).subscribe(users => {
this.active = users;
this.filterActiveBySearch(this.filterForm.value.active);
this.loadActive = false;
this.exists = true;
}, error => {
this.active = [];
this.showActive = [];
@ -191,11 +177,12 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.createRoleModal.okButtonLeft = false;
this.createRoleModal.okButtonText = 'Create';
this.roleFb = this.fb.group({
name: this.fb.control(Role.mapType(this.type, (this.role === 'manager')) + '.' + this.id, Validators.required),
description: this.fb.control('', Validators.required)
name: this.fb.control(Role.mapType(this.type) + '.' + this.id, Validators.required),
description: this.fb.control(Role.mapType(this.type) + ' ' + this.id, Validators.required)
});
setTimeout(() => {
this.roleFb.get('name').disable();
this.roleFb.get('description').disable();
}, 0);
this.createRoleModal.open();
}
@ -204,7 +191,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.loadActive = true;
this.subs.push(this.userRegistryService.remove(this.type, this.id, this.selectedUser, this.role).subscribe(() => {
this.active = this.active.filter(user => user.email != this.selectedUser);
if(this.currentActivePage.length === 0) {
if (this.currentActivePage.length === 0) {
this.activePage = 1;
}
this.filterActiveBySearch(this.filterForm.value.active);
@ -230,7 +217,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.subs.push(this.userRegistryService.cancelInvitation(this.type, this.id, this.selectedUser, this.role).subscribe(() => {
this.pending = this.pending.filter(user => user != this.selectedUser);
this.filterPendingBySearch(this.filterForm.value.pending);
if(this.currentPendingPage.length === 0) {
if (this.currentPendingPage.length === 0) {
this.pendingPage = 1;
}
UIkit.notification(StringUtils.capitalize(this.role) + ' invitation to ' + this.selectedUser + ' has been <b>canceled</b>', {
@ -260,7 +247,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.subs.push(this.userRegistryService.invite(this.type, this.id, details, this.role).subscribe(invitation => {
if (!this.pending.includes(this.invited.value)) {
this.pending.push(this.invited.value);
this.pendingPage = Math.ceil(this.pending.length/this.pageSize);
this.pendingPage = Math.ceil(this.pending.length / this.pageSize);
this.filterPendingBySearch(this.filterForm.value.pending);
}
if (this.notificationFn) {
@ -298,7 +285,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.loadActive = true;
this.loadPending = true;
this.roleFb.get('name').enable();
this.userRegistryService.createRole(this.type, this.id, this.roleFb.value).subscribe(() => {
this.userRegistryService.createRole(this.type, this.id).subscribe(() => {
UIkit.notification('Group has been <b> successfully created</b>', {
status: 'success',
timeout: 6000,

@ -40,7 +40,6 @@ export class SubscribersComponent implements OnInit, OnDestroy, OnChanges {
@Input()
public inviteDisableMessage: string;
public user: User = null;
public managers: any[];
public subscribers: any[];
public showSubscribers: any[];
public subs: any[] = [];
@ -104,14 +103,8 @@ export class SubscribersComponent implements OnInit, OnDestroy, OnChanges {
updateList() {
this.loading = true;
let data = zip(this.userRegistryService.getActiveEmail(this.type, this.id, 'manager'),
this.userRegistryService.getActiveEmail(this.type, this.id, 'member'));
this.subs.push(data.subscribe(users => {
this.managers = users[0];
this.subscribers = users[1];
this.subscribers.forEach(subscriber => {
subscriber['isManager'] = this.managers.find(manager => manager.email === subscriber.email);
});
this.subs.push( this.userRegistryService.getActive(this.type, this.id, 'member').subscribe(users => {
this.subscribers = users;
this.filterBySearch(this.filterForm.value.keyword);
this.loading = false;
this.exists = true;
@ -147,10 +140,11 @@ export class SubscribersComponent implements OnInit, OnDestroy, OnChanges {
this.createRoleModal.okButtonText = 'create';
this.roleFb = this.fb.group({
name: this.fb.control(Role.mapType(this.type) + '.' + this.id, Validators.required),
description: this.fb.control('', Validators.required)
description: this.fb.control(Role.mapType(this.type) + ' ' + this.id, Validators.required)
});
setTimeout(() => {
this.roleFb.get('name').disable();
this.roleFb.get('description').disable();
}, 0);
this.createRoleModal.open();
}
@ -182,8 +176,7 @@ export class SubscribersComponent implements OnInit, OnDestroy, OnChanges {
createGroup() {
this.loading = true;
this.roleFb.get('name').enable();
this.userRegistryService.createRole(this.type, this.id, this.roleFb.value).subscribe(() => {
this.userRegistryService.createRole(this.type, this.id).subscribe(() => {
UIkit.notification('Group has been <b> successfully created</b>', {
status: 'success',
timeout: 6000,

@ -32,7 +32,7 @@ export class ErrorInterceptorService implements HttpInterceptor {
}
isService(req: HttpRequest<any>, service: string | string[]):boolean {
if(isArray(service)) {
if(Array.isArray(service)) {
return !!service.find(element => req.url.indexOf(element) !== -1);
} else {
return req.url.indexOf(service) !== -1;

@ -28,6 +28,10 @@ export class StakeholderService {
constructor(private http: HttpClient, private route: ActivatedRoute) {
this.stakeholderSubject = new BehaviorSubject<Stakeholder>(null);
/* let source = new EventSource(properties.monitorServiceAPIURL + "/stakeholder/events", {withCredentials: true});
source.addEventListener('message', message => {
console.log(message.data);
});*/
}
ngOnDestroy() {

@ -1,5 +1,5 @@
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {Observable} from 'rxjs';
import {properties} from '../../../environments/environment';
import {CustomOptions} from './servicesUtils/customOptions.class';
@ -13,8 +13,8 @@ export class UserRegistryService {
constructor(private http: HttpClient) {
}
public createRole(type: string, id: string, role): Observable<any[]> {
return this.http.post<any>(properties.registryUrl + 'createRole', role,
public createRole(type: string, id: string): Observable<any[]> {
return this.http.post<any>(properties.registryUrl + 'create/' + encodeURIComponent(type) + '/' + encodeURIComponent(id), null,
CustomOptions.registryOptions()).pipe(map((response: any) => response.response));
}
@ -56,14 +56,15 @@ export class UserRegistryService {
return this.http.delete<any>(properties.registryUrl + 'verification/' + encodeURIComponent(id), CustomOptions.registryOptions());
}
public getActiveEmail(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {
return this.http.get<any>(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + "/" + role + 's/email',
CustomOptions.registryOptions()).pipe(map((response:any) => response.response));
}
public getActiveNames(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {
return this.http.get<any>(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + "/" + role + 's/',
CustomOptions.registryOptions()).pipe(map((response:any) => response.response));
public getActive(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {
return this.http.get<any>(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + "/" + role + 's',
CustomOptions.registryOptions()).pipe(map((response:any) => response.response), map(users => {
if(users.length > 0 && !users[0].email) {
return [];
} else {
return users;
}
}));
}
public getPending(type: string, id: string, role: "member" | "manager" = "manager"): Observable<any[]> {

Loading…
Cancel
Save