diff --git a/dashboard/users/role-users/role-users.component.ts b/dashboard/users/role-users/role-users.component.ts
index 3096cc6f..13236706 100644
--- a/dashboard/users/role-users/role-users.component.ts
+++ b/dashboard/users/role-users/role-users.component.ts
@@ -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 canceled', {
@@ -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 successfully created', {
status: 'success',
timeout: 6000,
diff --git a/dashboard/users/subscribers/subscribers.component.ts b/dashboard/users/subscribers/subscribers.component.ts
index 10dddaa6..bd9fee67 100644
--- a/dashboard/users/subscribers/subscribers.component.ts
+++ b/dashboard/users/subscribers/subscribers.component.ts
@@ -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 successfully created', {
status: 'success',
timeout: 6000,
diff --git a/error-interceptor.service.ts b/error-interceptor.service.ts
index f90e2908..d56c557d 100644
--- a/error-interceptor.service.ts
+++ b/error-interceptor.service.ts
@@ -32,7 +32,7 @@ export class ErrorInterceptorService implements HttpInterceptor {
}
isService(req: HttpRequest, 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;
diff --git a/monitor/services/stakeholder.service.ts b/monitor/services/stakeholder.service.ts
index 6dfcf654..2618e425 100644
--- a/monitor/services/stakeholder.service.ts
+++ b/monitor/services/stakeholder.service.ts
@@ -28,6 +28,10 @@ export class StakeholderService {
constructor(private http: HttpClient, private route: ActivatedRoute) {
this.stakeholderSubject = new BehaviorSubject(null);
+/* let source = new EventSource(properties.monitorServiceAPIURL + "/stakeholder/events", {withCredentials: true});
+ source.addEventListener('message', message => {
+ console.log(message.data);
+ });*/
}
ngOnDestroy() {
diff --git a/services/user-registry.service.ts b/services/user-registry.service.ts
index 016c2ed8..f3d2dcc8 100644
--- a/services/user-registry.service.ts
+++ b/services/user-registry.service.ts
@@ -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 {
- return this.http.post(properties.registryUrl + 'createRole', role,
+ public createRole(type: string, id: string): Observable {
+ return this.http.post(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(properties.registryUrl + 'verification/' + encodeURIComponent(id), CustomOptions.registryOptions());
}
- public getActiveEmail(type: string, id: string, role: "member" | "manager" = "manager"): Observable {
- return this.http.get(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 {
- return this.http.get(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 {
+ return this.http.get(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 {