Add projectUpdate Alert

This commit is contained in:
Konstantinos Triantafyllou 2023-07-20 11:49:04 +03:00
parent d3775ba01f
commit 03fcd9b8ce
3 changed files with 53 additions and 3 deletions

View File

@ -24,6 +24,24 @@
</div> </div>
</ng-container> </ng-container>
</div> </div>
<div *ngIf="projectUpdate && !isFrontPage" class="project-update">
<div *ngIf="projectUpdate === 'danger'" class="uk-alert uk-alert-danger" uk-alert>
<a class="uk-alert-close" uk-close></a>
<div class="uk-text-bold uk-text-small">Projects Status: Urgent Update Needed</div>
<div class="uk-margin-xsmall-top uk-text-xsmall">
The latest-starting project in your portfolio in the OpenAIRE Graph began more than a year ago. Please urgently follow these instructions
<a href="https://www.openaire.eu/funders-how-to-join-guide" class="custom-external" target="_blank">here</a> to update your project list.
</div>
</div>
<div *ngIf="projectUpdate === 'warning'" class="uk-alert uk-alert-warning" uk-alert>
<a class="uk-alert-close" uk-close></a>
<div class="uk-text-bold uk-text-small">Projects Status: Update Needed</div>
<div class="uk-margin-xsmall-top uk-text-xsmall">
The latest-starting project in your portfolio in the OpenAIRE Graph began 6 to 12 months ago. To maintain current project data, please follow the instructions
<a href="https://www.openaire.eu/funders-how-to-join-guide" class="custom-external" target="_blank">here</a>.
</div>
</div>
</div>
<div *ngIf="isHidden" class="private-data uk-light dark"> <div *ngIf="isHidden" class="private-data uk-light dark">
<div class="uk-section uk-section-small uk-container uk-container-small uk-text-center"> <div class="uk-section uk-section-small uk-container uk-container-small uk-text-center">
<img src="assets/common-assets/logo-services/monitor/inverted.svg" style="height: 80px;"> <img src="assets/common-assets/logo-services/monitor/inverted.svg" style="height: 80px;">

View File

@ -0,0 +1,12 @@
@import (reference) "~src/assets/openaire-theme/less/_import-variables";
.project-update {
z-index: @global-z-index;
position: fixed;
bottom: 0;
left: 50%;
right: 50%;
transform: translate(-50%, 0);
width: 500px;
max-width: 60%;
}

View File

@ -30,7 +30,8 @@ import {
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: './app.component.html' templateUrl: './app.component.html',
styleUrls: ['app.component.less']
}) })
export class AppComponent implements OnInit, OnDestroy { export class AppComponent implements OnInit, OnDestroy {
properties: EnvProperties = properties; properties: EnvProperties = properties;
@ -62,7 +63,6 @@ export class AppComponent implements OnInit, OnDestroy {
badge: true, badge: true,
menuPosition: "center" menuPosition: "center"
}; };
userMenuItems: MenuItem[] = []; userMenuItems: MenuItem[] = [];
adminMenuItems: MenuItem[] = []; adminMenuItems: MenuItem[] = [];
stakeholder: Stakeholder = null; stakeholder: Stakeholder = null;
@ -71,6 +71,7 @@ export class AppComponent implements OnInit, OnDestroy {
loading: boolean = true; loading: boolean = true;
paramsResolved: boolean = false; paramsResolved: boolean = false;
innerWidth; innerWidth;
projectUpdate: 'danger' | 'warning';
paramsSubscription: Subscription; paramsSubscription: Subscription;
private subscriptions: any[] = []; private subscriptions: any[] = [];
@ -189,6 +190,9 @@ export class AppComponent implements OnInit, OnDestroy {
} }
} }
}); });
this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
this.setProjectUpdate(stakeholder);
}))
})); }));
} }
@ -236,6 +240,22 @@ export class AppComponent implements OnInit, OnDestroy {
})); }));
} }
public setProjectUpdate(stakeholder: Stakeholder) {
if(stakeholder?.projectUpdateDate) {
let today = new Date();
let date = new Date(stakeholder.projectUpdateDate);
let months = (today.getFullYear() - date.getFullYear())*12 + (today.getMonth() - date.getMonth());
console.log(months)
if(months > 12) {
this.projectUpdate = 'danger';
} else if (months > 6 && months < 12) {
this.projectUpdate = 'warning';
} else {
this.projectUpdate = null;
}
}
}
public ngOnDestroy() { public ngOnDestroy() {
if(this.paramsSubscription) { if(this.paramsSubscription) {
this.paramsSubscription.unsubscribe(); this.paramsSubscription.unsubscribe();