invite.component: scroll into view when invitation button is clicked |

when invitation request completes, fill and show which mails sent successfully and which not | 
		  show proper success/failure messages in short view too.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@54677 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-02-01 11:02:09 +00:00
parent 3694a03e01
commit 273aec27e0
3 changed files with 31 additions and 7 deletions

View File

@ -9,7 +9,8 @@
<errorMessages [status]="[status]" [type]="'community'"></errorMessages>
</div>
<div *ngIf="missingCommunityId" class="uk-alert uk-alert-warning" role="alert">{{missingCommunityId}}</div>
<div *ngIf="successfulSentMessage" class="uk-alert uk-alert-success" role="alert">{{successfulSentMessage}}</div>
<div *ngIf="successfulSentMessage" class="uk-alert uk-alert-success" role="alert">{{successfulSentMessage}} {{successfulSentRecipients}}</div>
<div *ngIf="failureSentMessage" class="uk-alert uk-alert-warning" role="alert">{{failureSentMessage}} {{failureSentRecipients}}</div>
<div *ngIf="inviteErrorMessage" class="uk-alert uk-alert-warning" role="alert">{{inviteErrorMessage}}</div>
<div *ngIf="communityId != null && status == errorCodes.DONE">
<table class="uk-table uk-align-center">
@ -161,9 +162,17 @@
Invite users</div>
<div class="uk-form uk-margin-small" id="toggle-usage" hidden="hidden">
<div class="uk-margin-top">
<errorMessages [status]="[status]" [type]="'community'"></errorMessages>
</div>
<div *ngIf="missingCommunityId" class="uk-width-large uk-text-warning uk-text-small uk-margin-top" role="alert">{{missingCommunityId}}</div>
<div *ngIf="successfulSentMessage" class="uk-width-large uk-text-success uk-text-small uk-margin-top" role="alert">{{successfulSentMessage}} {{successfulSentRecipients}}</div>
<div *ngIf="failureSentMessage" class="uk-width-large uk-text-warning uk-text-small uk-margin-top" role="alert">{{failureSentMessage}} {{failureSentRecipients}}</div>
<div *ngIf="inviteErrorMessage" class="uk-width-large uk-text-warning uk-text-small uk-margin-top" role="alert">{{inviteErrorMessage}}</div>
<div *ngIf="recipients && !areValid" class="uk-width-large uk-text-danger uk-text-small uk-margin-top">Please add valid email/s.</div>
<div *ngIf="isEmpty(recipients) && showAddRecipientMessage" class="uk-width-large uk-text-danger uk-text-small uk-margin-top">Please add a recipient.</div>
<input placeholder="Type e-mails" type="text"
<input (click)="resetMessages(); areValid=true" placeholder="Type e-mails" type="text"
class="form-control uk-input uk-form-small uk-form" [(ngModel)] = "recipients" id="recipients"
required >
<div class="uk-width-medium uk-text-muted uk-text-small">separate with commas</div>

View File

@ -32,6 +32,9 @@ export class InviteComponent implements OnInit {
//public showLoading: boolean = true;
public errorMessage: string = '';
public successfulSentMessage: string = '';
public successfulSentRecipients: string[] = [];
public failureSentMessage: string = '';
public failureSentRecipients: string[] = [];
public inviteErrorMessage: string = '';
public missingCommunityId: string = '';
public showAddRecipientMessage: boolean = false;
@ -112,8 +115,10 @@ export class InviteComponent implements OnInit {
public invite() {
this.successfulSentMessage = "";
this.failureSentMessage = "";
this.inviteErrorMessage = "";
this.status = this.errorCodes.LOADING;
this.scroll();
if (!this.isEmpty(this.recipients) && this.body.fromName != "") {
if (this.validateEmails()) {
this.composeEmail();
@ -123,11 +128,22 @@ export class InviteComponent implements OnInit {
res => {
console.log("The email has been sent successfully!");
this.status = this.errorCodes.DONE;
console.log("Emails Sent: "+res);
if(res > 1) {
console.log("Emails Sent: ",res);
/*if(res == 0) {
} else if(res > 1) {
this.successfulSentMessage = res + " emails sent successfully!";
} else {
this.successfulSentMessage = res + " email sent successfully!";
}*/
if(res['success']) {
this.successfulSentMessage = "Email sent successfully to: ";
this.successfulSentRecipients = res['success'];
}
if(res['failure']) {
this.failureSentMessage = "There was an error sending email to: ";
this.failureSentRecipients = res['failure'];
}
this.body = Composer.initializeInvitationsBody(this.communityId, this.community.title, this.fullname);
@ -142,12 +158,10 @@ export class InviteComponent implements OnInit {
);
} else {
this.email.recipients = [];
this.scroll();
this.status = this.errorCodes.DONE;
}
} else {
this.showAddRecipientMessage = true;
this.scroll();
this.status = this.errorCodes.DONE;
}
}
@ -162,6 +176,7 @@ export class InviteComponent implements OnInit {
public resetMessages() {
this.errorMessage = "";
this.successfulSentMessage = "";
this.failureSentMessage = "";
this.inviteErrorMessage = "";
}

View File

@ -51,7 +51,7 @@
"cacheUrl" :"http://scoobydoo.di.uoa.gr:3000/get?url=",
"adminToolsAPIURL" :"http://scoobydoo.di.uoa.gr:8080/uoa-admin-tools",
"adminToolsAPIURL" :"http://duffy.di.uoa.gr:8080/uoa-admin-tools",
"adminToolsCommunity" :"openaire",
"datasourcesAPI": "https://beta.services.openaire.eu/openaire/ds/search/",