connect/src/app/utils/subscribe/subscribe.component.ts

263 lines
10 KiB
TypeScript
Raw Normal View History

import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {AlertModal} from '../../openaireLibrary/utils/modal/alert';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
import {EmailService} from "../../openaireLibrary/utils/email/email.service";
import {Session, User} from '../../openaireLibrary/login/utils/helper.class';
import {Email} from "../../openaireLibrary/utils/email/email";
import {Composer} from "../../openaireLibrary/utils/email/composer";
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {UserManagementService} from "../../openaireLibrary/services/user-management.service";
import {Subscriber, Subscription} from "rxjs";
import {properties} from "../../../environments/environment";
import {UserRegistryService} from "../../openaireLibrary/services/user-registry.service";
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
declare var UIkit: any;
@Component({
selector: 'subscribe',
template: `
<span *ngIf="subscribed != null && !showNumbers && showTemplate">
<div *ngIf="!subscribed && showLoginAlert" class="uk-alert-warning uk-animation-slide-bottom" uk-alert="">
<a class="uk-alert-close" uk-close></a>
<p>Please login first to subscribe</p>
</div>
<button *ngIf="loading" id="subscribe" class="uk-button portal-button uk-button-small uk-width-1-1">
<span class="uk-icon"><loading [top_margin]="false" [size]="'small'" [color]="null"></loading></span>
</button>
<button *ngIf="!subscribed && !loading" id="subscribe" class="uk-button portal-button uk-button-small uk-width-1-1"
[Trunk | Connect]: 1. app-routing.module.ts: Add route '/subjects'. 2. app.component.ts: Group subscribe and invite buttons under id="subscribeAndInviteBtn" (keep distance between them alwayes the same) | uncomment menu item 'Subjects' in About. 3. app.module.ts: import 'SubscribeService' (singleton service to update everywhere subscriber status). 4. libUser.module.ts & subscribe.module.ts: remove import of 'SubscribeService' (singleton service to update everywhere subscriber status). 5. community.component.html: a. Improve some checks b. In main tabs of the page (class main-tabs) add class 'uk-text-truncate' and remove class 'uk-width-3-4' (each tab has max-width) c. Add icon in 'Analytics' tab d. [Bug fix] In description, fix overflow and max height of box 6. community.component.ts: Add field '@ViewChild(SubscribeComponent) subscribeComponent: SubscribeComponent' to add some checks in html. 7. curators.component.html: Remove div with class 'image-front-topbar' | Update css for title | Add <breadcrumbs> | Add user icon for each curator. 8. curators.component.ts: Initialize breadcrumb | [Bug fix] In methods 'getPageContents()' and 'getDivContents()' use communityId (instead of 'connect'). 9. curators.module.ts & organizationsPage.module.ts & inviteBasic.module.ts: import 'BreadcrumbsModule'. 10. organizationsPage.component.ts: Update css for title | Add <breadcrumbs> | Initialize breadcrumb. 11. subjects.component.ts, subjects.module.ts, subjects-routing.module.ts: Add page for Subjects. 12. invite.component.html: Add <breadcrumbs> in longView | Add icon in button 'Invite users'. 13. invite.component.ts: Initialize breadcrumb. 14. subscribe.component.ts: a. Add icon in button "Subscribe"/ "Subscribed" b. Add class 'uk-display-inline-block' in showNumbers (members) c. Initialize and get subscriber status with new methods of service (initIsSubscribedToCommunity() & isSubscribed - BehaviorSubject instead of isSubscribedToCommunity()) 15. connect-custom.css: Group css for #subscribeBtn, #inviteBtn into #subscribeAndInviteBtn | Add css for class 'user-circle-background' (background of user icon in curators). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58574 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-28 13:07:36 +02:00
(click)="subscribe()">
<span class="uk-icon uk-flex uk-flex-middle">
<svg height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"></path>
<path
d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"></path>
[Trunk | Connect]: 1. app-routing.module.ts: Add route '/subjects'. 2. app.component.ts: Group subscribe and invite buttons under id="subscribeAndInviteBtn" (keep distance between them alwayes the same) | uncomment menu item 'Subjects' in About. 3. app.module.ts: import 'SubscribeService' (singleton service to update everywhere subscriber status). 4. libUser.module.ts & subscribe.module.ts: remove import of 'SubscribeService' (singleton service to update everywhere subscriber status). 5. community.component.html: a. Improve some checks b. In main tabs of the page (class main-tabs) add class 'uk-text-truncate' and remove class 'uk-width-3-4' (each tab has max-width) c. Add icon in 'Analytics' tab d. [Bug fix] In description, fix overflow and max height of box 6. community.component.ts: Add field '@ViewChild(SubscribeComponent) subscribeComponent: SubscribeComponent' to add some checks in html. 7. curators.component.html: Remove div with class 'image-front-topbar' | Update css for title | Add <breadcrumbs> | Add user icon for each curator. 8. curators.component.ts: Initialize breadcrumb | [Bug fix] In methods 'getPageContents()' and 'getDivContents()' use communityId (instead of 'connect'). 9. curators.module.ts & organizationsPage.module.ts & inviteBasic.module.ts: import 'BreadcrumbsModule'. 10. organizationsPage.component.ts: Update css for title | Add <breadcrumbs> | Initialize breadcrumb. 11. subjects.component.ts, subjects.module.ts, subjects-routing.module.ts: Add page for Subjects. 12. invite.component.html: Add <breadcrumbs> in longView | Add icon in button 'Invite users'. 13. invite.component.ts: Initialize breadcrumb. 14. subscribe.component.ts: a. Add icon in button "Subscribe"/ "Subscribed" b. Add class 'uk-display-inline-block' in showNumbers (members) c. Initialize and get subscriber status with new methods of service (initIsSubscribedToCommunity() & isSubscribed - BehaviorSubject instead of isSubscribedToCommunity()) 15. connect-custom.css: Group css for #subscribeBtn, #inviteBtn into #subscribeAndInviteBtn | Add css for class 'user-circle-background' (background of user icon in curators). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58574 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-28 13:07:36 +02:00
</svg>
<span class="space">Subscribe</span>
[Trunk | Connect]: 1. app-routing.module.ts: Add route '/subjects'. 2. app.component.ts: Group subscribe and invite buttons under id="subscribeAndInviteBtn" (keep distance between them alwayes the same) | uncomment menu item 'Subjects' in About. 3. app.module.ts: import 'SubscribeService' (singleton service to update everywhere subscriber status). 4. libUser.module.ts & subscribe.module.ts: remove import of 'SubscribeService' (singleton service to update everywhere subscriber status). 5. community.component.html: a. Improve some checks b. In main tabs of the page (class main-tabs) add class 'uk-text-truncate' and remove class 'uk-width-3-4' (each tab has max-width) c. Add icon in 'Analytics' tab d. [Bug fix] In description, fix overflow and max height of box 6. community.component.ts: Add field '@ViewChild(SubscribeComponent) subscribeComponent: SubscribeComponent' to add some checks in html. 7. curators.component.html: Remove div with class 'image-front-topbar' | Update css for title | Add <breadcrumbs> | Add user icon for each curator. 8. curators.component.ts: Initialize breadcrumb | [Bug fix] In methods 'getPageContents()' and 'getDivContents()' use communityId (instead of 'connect'). 9. curators.module.ts & organizationsPage.module.ts & inviteBasic.module.ts: import 'BreadcrumbsModule'. 10. organizationsPage.component.ts: Update css for title | Add <breadcrumbs> | Initialize breadcrumb. 11. subjects.component.ts, subjects.module.ts, subjects-routing.module.ts: Add page for Subjects. 12. invite.component.html: Add <breadcrumbs> in longView | Add icon in button 'Invite users'. 13. invite.component.ts: Initialize breadcrumb. 14. subscribe.component.ts: a. Add icon in button "Subscribe"/ "Subscribed" b. Add class 'uk-display-inline-block' in showNumbers (members) c. Initialize and get subscriber status with new methods of service (initIsSubscribedToCommunity() & isSubscribed - BehaviorSubject instead of isSubscribedToCommunity()) 15. connect-custom.css: Group css for #subscribeBtn, #inviteBtn into #subscribeAndInviteBtn | Add css for class 'user-circle-background' (background of user icon in curators). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58574 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-28 13:07:36 +02:00
</span>
</button>
<button *ngIf="subscribed && !loading" id="subscribe" class="subscribed-button uk-button uk-button-small uk-width-1-1"
(click)="confirmOpen()" [disabled]="isManager" [attr.uk-tooltip]="isManager?'You cannot unsubscribe because you are a manager':null">
[Trunk | Connect]: 1. app-routing.module.ts: Add route '/subjects'. 2. app.component.ts: Group subscribe and invite buttons under id="subscribeAndInviteBtn" (keep distance between them alwayes the same) | uncomment menu item 'Subjects' in About. 3. app.module.ts: import 'SubscribeService' (singleton service to update everywhere subscriber status). 4. libUser.module.ts & subscribe.module.ts: remove import of 'SubscribeService' (singleton service to update everywhere subscriber status). 5. community.component.html: a. Improve some checks b. In main tabs of the page (class main-tabs) add class 'uk-text-truncate' and remove class 'uk-width-3-4' (each tab has max-width) c. Add icon in 'Analytics' tab d. [Bug fix] In description, fix overflow and max height of box 6. community.component.ts: Add field '@ViewChild(SubscribeComponent) subscribeComponent: SubscribeComponent' to add some checks in html. 7. curators.component.html: Remove div with class 'image-front-topbar' | Update css for title | Add <breadcrumbs> | Add user icon for each curator. 8. curators.component.ts: Initialize breadcrumb | [Bug fix] In methods 'getPageContents()' and 'getDivContents()' use communityId (instead of 'connect'). 9. curators.module.ts & organizationsPage.module.ts & inviteBasic.module.ts: import 'BreadcrumbsModule'. 10. organizationsPage.component.ts: Update css for title | Add <breadcrumbs> | Initialize breadcrumb. 11. subjects.component.ts, subjects.module.ts, subjects-routing.module.ts: Add page for Subjects. 12. invite.component.html: Add <breadcrumbs> in longView | Add icon in button 'Invite users'. 13. invite.component.ts: Initialize breadcrumb. 14. subscribe.component.ts: a. Add icon in button "Subscribe"/ "Subscribed" b. Add class 'uk-display-inline-block' in showNumbers (members) c. Initialize and get subscriber status with new methods of service (initIsSubscribedToCommunity() & isSubscribed - BehaviorSubject instead of isSubscribedToCommunity()) 15. connect-custom.css: Group css for #subscribeBtn, #inviteBtn into #subscribeAndInviteBtn | Add css for class 'user-circle-background' (background of user icon in curators). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58574 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-28 13:07:36 +02:00
<span class="uk-icon uk-flex uk-flex-middle">
<svg height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"></path>
<path
d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"></path>
[Trunk | Connect]: 1. app-routing.module.ts: Add route '/subjects'. 2. app.component.ts: Group subscribe and invite buttons under id="subscribeAndInviteBtn" (keep distance between them alwayes the same) | uncomment menu item 'Subjects' in About. 3. app.module.ts: import 'SubscribeService' (singleton service to update everywhere subscriber status). 4. libUser.module.ts & subscribe.module.ts: remove import of 'SubscribeService' (singleton service to update everywhere subscriber status). 5. community.component.html: a. Improve some checks b. In main tabs of the page (class main-tabs) add class 'uk-text-truncate' and remove class 'uk-width-3-4' (each tab has max-width) c. Add icon in 'Analytics' tab d. [Bug fix] In description, fix overflow and max height of box 6. community.component.ts: Add field '@ViewChild(SubscribeComponent) subscribeComponent: SubscribeComponent' to add some checks in html. 7. curators.component.html: Remove div with class 'image-front-topbar' | Update css for title | Add <breadcrumbs> | Add user icon for each curator. 8. curators.component.ts: Initialize breadcrumb | [Bug fix] In methods 'getPageContents()' and 'getDivContents()' use communityId (instead of 'connect'). 9. curators.module.ts & organizationsPage.module.ts & inviteBasic.module.ts: import 'BreadcrumbsModule'. 10. organizationsPage.component.ts: Update css for title | Add <breadcrumbs> | Initialize breadcrumb. 11. subjects.component.ts, subjects.module.ts, subjects-routing.module.ts: Add page for Subjects. 12. invite.component.html: Add <breadcrumbs> in longView | Add icon in button 'Invite users'. 13. invite.component.ts: Initialize breadcrumb. 14. subscribe.component.ts: a. Add icon in button "Subscribe"/ "Subscribed" b. Add class 'uk-display-inline-block' in showNumbers (members) c. Initialize and get subscriber status with new methods of service (initIsSubscribedToCommunity() & isSubscribed - BehaviorSubject instead of isSubscribedToCommunity()) 15. connect-custom.css: Group css for #subscribeBtn, #inviteBtn into #subscribeAndInviteBtn | Add css for class 'user-circle-background' (background of user icon in curators). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58574 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-28 13:07:36 +02:00
</svg>
<span class="space">Subscribed</span>
[Trunk | Connect]: 1. app-routing.module.ts: Add route '/subjects'. 2. app.component.ts: Group subscribe and invite buttons under id="subscribeAndInviteBtn" (keep distance between them alwayes the same) | uncomment menu item 'Subjects' in About. 3. app.module.ts: import 'SubscribeService' (singleton service to update everywhere subscriber status). 4. libUser.module.ts & subscribe.module.ts: remove import of 'SubscribeService' (singleton service to update everywhere subscriber status). 5. community.component.html: a. Improve some checks b. In main tabs of the page (class main-tabs) add class 'uk-text-truncate' and remove class 'uk-width-3-4' (each tab has max-width) c. Add icon in 'Analytics' tab d. [Bug fix] In description, fix overflow and max height of box 6. community.component.ts: Add field '@ViewChild(SubscribeComponent) subscribeComponent: SubscribeComponent' to add some checks in html. 7. curators.component.html: Remove div with class 'image-front-topbar' | Update css for title | Add <breadcrumbs> | Add user icon for each curator. 8. curators.component.ts: Initialize breadcrumb | [Bug fix] In methods 'getPageContents()' and 'getDivContents()' use communityId (instead of 'connect'). 9. curators.module.ts & organizationsPage.module.ts & inviteBasic.module.ts: import 'BreadcrumbsModule'. 10. organizationsPage.component.ts: Update css for title | Add <breadcrumbs> | Initialize breadcrumb. 11. subjects.component.ts, subjects.module.ts, subjects-routing.module.ts: Add page for Subjects. 12. invite.component.html: Add <breadcrumbs> in longView | Add icon in button 'Invite users'. 13. invite.component.ts: Initialize breadcrumb. 14. subscribe.component.ts: a. Add icon in button "Subscribe"/ "Subscribed" b. Add class 'uk-display-inline-block' in showNumbers (members) c. Initialize and get subscriber status with new methods of service (initIsSubscribedToCommunity() & isSubscribed - BehaviorSubject instead of isSubscribedToCommunity()) 15. connect-custom.css: Group css for #subscribeBtn, #inviteBtn into #subscribeAndInviteBtn | Add css for class 'user-circle-background' (background of user icon in curators). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58574 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-28 13:07:36 +02:00
</span>
</button>
</span>
<span *ngIf="showNumbers && members > 0 && showTemplate" class="uk-display-inline-block">
<span class="lowOpacityColor uk-text-muted">Members: </span> {{members}}
</span>
<modal-alert (alertOutput)="confirmClose($event)">
</modal-alert>
`
})
export class SubscribeComponent {
// @Input() showSubscribe:boolean = true;
@Input() showNumbers: boolean;
@Input() communityId: string;
@Input() showTemplate: boolean = true;
@Output() subscribeEvent = new EventEmitter();
public community = null;
public emailToInformManagers: Email;
loading: boolean = false;
subscribed: boolean = null;
properties: EnvProperties = properties;
members: number = 0;
@Output() countSubscribersEvent = new EventEmitter();
showLoginAlert: Boolean = false;
@ViewChild(AlertModal, { static: true }) alert;
private user: User;
subs: Subscription[] = [];
constructor(private route: ActivatedRoute,
private _emailService: EmailService,
private _communityService: CommunityService,
private router: Router,
private subscribeService: SubscribeService,
private userManagementService: UserManagementService,
private userRegistryService: UserRegistryService) {
}
public ngOnInit() {
this.subs.push(this.subscribeService.getLoading().subscribe(loading => {
this.loading = loading;
}));
this.subs.push(this.subscribeService.getMembers().subscribe(members => {
this.members = members;
this.countSubscribersEvent.emit({
value: this.members
});
}));
if (!this.showNumbers) {
this.subs.push(this.userManagementService.getUserInfo().subscribe(
user => {
this.user = user;
this.init();
}
));
} else {
this.init();
}
}
public ngOnDestroy() {
for (let sub of this.subs) {
if (sub instanceof Subscriber) {
sub.unsubscribe();
}
}
this.subscribeService.setLoading(false);
}
[Trunk | Connect]: 1. app-routing.module.ts: Add route '/subjects'. 2. app.component.ts: Group subscribe and invite buttons under id="subscribeAndInviteBtn" (keep distance between them alwayes the same) | uncomment menu item 'Subjects' in About. 3. app.module.ts: import 'SubscribeService' (singleton service to update everywhere subscriber status). 4. libUser.module.ts & subscribe.module.ts: remove import of 'SubscribeService' (singleton service to update everywhere subscriber status). 5. community.component.html: a. Improve some checks b. In main tabs of the page (class main-tabs) add class 'uk-text-truncate' and remove class 'uk-width-3-4' (each tab has max-width) c. Add icon in 'Analytics' tab d. [Bug fix] In description, fix overflow and max height of box 6. community.component.ts: Add field '@ViewChild(SubscribeComponent) subscribeComponent: SubscribeComponent' to add some checks in html. 7. curators.component.html: Remove div with class 'image-front-topbar' | Update css for title | Add <breadcrumbs> | Add user icon for each curator. 8. curators.component.ts: Initialize breadcrumb | [Bug fix] In methods 'getPageContents()' and 'getDivContents()' use communityId (instead of 'connect'). 9. curators.module.ts & organizationsPage.module.ts & inviteBasic.module.ts: import 'BreadcrumbsModule'. 10. organizationsPage.component.ts: Update css for title | Add <breadcrumbs> | Initialize breadcrumb. 11. subjects.component.ts, subjects.module.ts, subjects-routing.module.ts: Add page for Subjects. 12. invite.component.html: Add <breadcrumbs> in longView | Add icon in button 'Invite users'. 13. invite.component.ts: Initialize breadcrumb. 14. subscribe.component.ts: a. Add icon in button "Subscribe"/ "Subscribed" b. Add class 'uk-display-inline-block' in showNumbers (members) c. Initialize and get subscriber status with new methods of service (initIsSubscribedToCommunity() & isSubscribed - BehaviorSubject instead of isSubscribedToCommunity()) 15. connect-custom.css: Group css for #subscribeBtn, #inviteBtn into #subscribeAndInviteBtn | Add css for class 'user-circle-background' (background of user icon in curators). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58574 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-28 13:07:36 +02:00
private isSubscribed() {
this.subscribed = Session.isSubscribedTo('community', this.communityId, this.user);
[Trunk | Connect]: 1. app-routing.module.ts: Add route '/subjects'. 2. app.component.ts: Group subscribe and invite buttons under id="subscribeAndInviteBtn" (keep distance between them alwayes the same) | uncomment menu item 'Subjects' in About. 3. app.module.ts: import 'SubscribeService' (singleton service to update everywhere subscriber status). 4. libUser.module.ts & subscribe.module.ts: remove import of 'SubscribeService' (singleton service to update everywhere subscriber status). 5. community.component.html: a. Improve some checks b. In main tabs of the page (class main-tabs) add class 'uk-text-truncate' and remove class 'uk-width-3-4' (each tab has max-width) c. Add icon in 'Analytics' tab d. [Bug fix] In description, fix overflow and max height of box 6. community.component.ts: Add field '@ViewChild(SubscribeComponent) subscribeComponent: SubscribeComponent' to add some checks in html. 7. curators.component.html: Remove div with class 'image-front-topbar' | Update css for title | Add <breadcrumbs> | Add user icon for each curator. 8. curators.component.ts: Initialize breadcrumb | [Bug fix] In methods 'getPageContents()' and 'getDivContents()' use communityId (instead of 'connect'). 9. curators.module.ts & organizationsPage.module.ts & inviteBasic.module.ts: import 'BreadcrumbsModule'. 10. organizationsPage.component.ts: Update css for title | Add <breadcrumbs> | Initialize breadcrumb. 11. subjects.component.ts, subjects.module.ts, subjects-routing.module.ts: Add page for Subjects. 12. invite.component.html: Add <breadcrumbs> in longView | Add icon in button 'Invite users'. 13. invite.component.ts: Initialize breadcrumb. 14. subscribe.component.ts: a. Add icon in button "Subscribe"/ "Subscribed" b. Add class 'uk-display-inline-block' in showNumbers (members) c. Initialize and get subscriber status with new methods of service (initIsSubscribedToCommunity() & isSubscribed - BehaviorSubject instead of isSubscribedToCommunity()) 15. connect-custom.css: Group css for #subscribeBtn, #inviteBtn into #subscribeAndInviteBtn | Add css for class 'user-circle-background' (background of user icon in curators). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58574 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-28 13:07:36 +02:00
}
private get isManager() {
return Session.isManager('community', this.communityId, this.user);
}
private init() {
if (!this.showNumbers) {
let email = (this.user) ? this.user.email : null;
if (email == null) {
this.subscribed = false;
} else {
if (this.communityId) {
[Trunk | Connect]: 1. app-routing.module.ts: Add route '/subjects'. 2. app.component.ts: Group subscribe and invite buttons under id="subscribeAndInviteBtn" (keep distance between them alwayes the same) | uncomment menu item 'Subjects' in About. 3. app.module.ts: import 'SubscribeService' (singleton service to update everywhere subscriber status). 4. libUser.module.ts & subscribe.module.ts: remove import of 'SubscribeService' (singleton service to update everywhere subscriber status). 5. community.component.html: a. Improve some checks b. In main tabs of the page (class main-tabs) add class 'uk-text-truncate' and remove class 'uk-width-3-4' (each tab has max-width) c. Add icon in 'Analytics' tab d. [Bug fix] In description, fix overflow and max height of box 6. community.component.ts: Add field '@ViewChild(SubscribeComponent) subscribeComponent: SubscribeComponent' to add some checks in html. 7. curators.component.html: Remove div with class 'image-front-topbar' | Update css for title | Add <breadcrumbs> | Add user icon for each curator. 8. curators.component.ts: Initialize breadcrumb | [Bug fix] In methods 'getPageContents()' and 'getDivContents()' use communityId (instead of 'connect'). 9. curators.module.ts & organizationsPage.module.ts & inviteBasic.module.ts: import 'BreadcrumbsModule'. 10. organizationsPage.component.ts: Update css for title | Add <breadcrumbs> | Initialize breadcrumb. 11. subjects.component.ts, subjects.module.ts, subjects-routing.module.ts: Add page for Subjects. 12. invite.component.html: Add <breadcrumbs> in longView | Add icon in button 'Invite users'. 13. invite.component.ts: Initialize breadcrumb. 14. subscribe.component.ts: a. Add icon in button "Subscribe"/ "Subscribed" b. Add class 'uk-display-inline-block' in showNumbers (members) c. Initialize and get subscriber status with new methods of service (initIsSubscribedToCommunity() & isSubscribed - BehaviorSubject instead of isSubscribedToCommunity()) 15. connect-custom.css: Group css for #subscribeBtn, #inviteBtn into #subscribeAndInviteBtn | Add css for class 'user-circle-background' (background of user icon in curators). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58574 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-28 13:07:36 +02:00
this.isSubscribed();
}
}
} else {
if (this.communityId) {
this.subscribeService.setLoading(true);
this.subs.push(this.userRegistryService.getMembersCount('community', this.communityId).subscribe(res => {
this.subscribeService.setMembers((res && res.response) ? res.response : 0);
this.subscribeService.setLoading(false);
},
error => {
this.handleError("Error getting community subscribers for community with id: " + this.communityId, error);
}));
}
}
if (this.communityId) {
this.emailToInformManagers = {body: "", subject: "", recipients: []};
this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
community => {
this.community = community;
},
error => {
//console.log('System error retrieving community profile', error)
this.handleError("Error getting community with id: " + this.communityId, error);
}
));
}
}
private successfulSubscribe() {
if (!this.subscribed) {
this.subscribed = true;
this.subscribeEvent.emit({
value: "ok"
});
this.subs.push(this._emailService.notifyManagers(this.communityId, 'subscriber',
Composer.composeEmailToInformManagers(this.community.title, this.communityId, this.user.fullname)).subscribe(
res => {
//console.log("The email has been sent successfully!")
},
error => {
//console.log(error)
this.handleError("Error notifying managers about new subscribers for community with id: " + this.communityId, error);
}
));
}
}
subscribe() {
if (!this.user) {
this.subscribed = false;
// this.showLoginAlert = true;
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.ACTION_REQUIRES_LOGIN,
"redirectUrl": this.router.url
}
});
} else {
this.subscribeService.setLoading(true);
this.showLoginAlert = false;
this.subs.push(this.userRegistryService.subscribeTo('community', this.communityId).subscribe(res => {
this.userManagementService.updateUserInfo();
this.subscribeService.setMembers(this.members + 1);
this.subscribeService.setLoading(false);
this.successfulSubscribe();
}, error => {
this.subscribeService.setLoading(false);
UIkit.notification({
message: '<strong>An error occurred. Please try again!<strong>',
status: 'warning',
timeout: 3000,
pos: 'top-center'
});
//console.log(error)
this.handleError("Error subscribing email: " + this.user.email + " from community with id: " + this.communityId, error);
}));
}
}
unsubscribe() {
var email = (this.user) ? this.user.email : null;
if (email == null) {
this.subscribed = false;
} else {
this.subscribeService.setLoading(true);
this.subs.push(this.userRegistryService.unsubscribeFrom('community', this.communityId).subscribe(res => {
this.userManagementService.updateUserInfo();
this.subscribeService.setMembers(this.members - 1);
this.subscribeService.setLoading(false);
this.subscribed = false;
}, error => {
this.subscribeService.setLoading(false);
UIkit.notification({
message: '<strong>An error occurred. Please try again!<strong>',
status: 'warning',
timeout: 3000,
pos: 'top-center'
});
//console.log(error)
this.handleError("Error unsubscribing email: " + email + " from community with id: " + this.communityId, error);
}));
}
}
confirmOpen() {
this.alert.cancelButton = true;
this.alert.okButton = true;
[Trunk | Connect]: Connect redesing 1. app.component.ts: <subscribe> and <invite> components added (floating buttons on the right side of each page for communities). 2. community.component.html: 3. community.component.ts: a. 'projectsCalculated' and 'contentProvidersCalculated' fields added, to calculate tootlip after both requests complete b. added methods for building tootips c. 'activeTab' set to 'summary'. 4. affiliations.component.html: minor phrasing changes (e.g. title). 5. curators.component.html: shortview changed. 6. results.component.ts: Title changed | 'View all' moved to the bottom. 7. customization.component.ts: Changed '--portal-main-color' from '#4C9CD5' to '#4687E6' | Changed '--portal-dark-color' from '#24857F' to '#2D72D6'. 8. invite.component.html: shortview changed. 9. invite.component.ts: 'properties' field as input (get it is called from app.component). 10. invite.module.ts & inviteBasic.module.ts: InviteBasicModule created to declare InviteComponent without routing and login guard | InviteModule imports InviteBasicModule and adds routing and login guar$ 11. subscribe.component.ts: Changes for subscribe button and members | 'properties' field as input (get it is called from app.component). 12. connect-custom.css: css for subscribe and invite buttons and for tooltip with 'community-page-tooltip' class. 13. customization.css: class 'communityBackground' added and css for 'subtitle' class inside 'communityBackground'. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58549 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-24 18:38:35 +02:00
//this.alert.alertTitle = "Unsubscribe community ";
//this.alert.message = "Do you want to proceed? ";
this.alert.message = "You are subscribed to the Community Gateway. Do you want to unsubscribe?";
this.alert.okButtonText = "UNSUBSCRIBE";
this.alert.cancelButtonText = "CANCEL";
this.alert.open();
}
confirmClose(data) {
this.unsubscribe();
}
private handleError(message: string, error) {
console.error("Subscribe (component): " + message, error);
}
}