[Monitor Dashboard]: Add home, missed on previous commit
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@57720 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
706b2532f7
commit
3062e0ecae
|
@ -0,0 +1,21 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {RouterModule} from '@angular/router';
|
||||
import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard';
|
||||
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
|
||||
import {HomeComponent} from "./home.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild([
|
||||
{
|
||||
path: '',
|
||||
component: HomeComponent,
|
||||
canActivate: [FreeGuard],
|
||||
canDeactivate: [PreviousRouteRecorder],
|
||||
data: {hasSidebar: false}
|
||||
}
|
||||
])
|
||||
]
|
||||
})
|
||||
export class HomeRoutingModule {
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
<div id="page_content">
|
||||
<div class="uk-padding-small md-bg-white" uk-grid>
|
||||
<div *ngIf="filters" class="uk-width-2-3@m uk-width-1-1 uk-child-width-1-3@m uk-child-width-1-1" uk-grid>
|
||||
<div>
|
||||
<div dashboard-input [formInput]="filters.get('privacy')"
|
||||
type="select" [options]="[all].concat(indicatorUtils.isPublic)"
|
||||
label="Privacy"></div>
|
||||
</div>
|
||||
<div>
|
||||
<div dashboard-input [formInput]="filters.get('status')"
|
||||
type="select" [options]="[all].concat(indicatorUtils.isActive)"
|
||||
label="Status"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-width-expand@m uk-width-1-1 uk-flex uk-flex-middle uk-flex-right">
|
||||
<div class="uk-inline uk-width-medium">
|
||||
<span class="uk-position-center-right"><i class="material-icons">search</i></span>
|
||||
<div dashboard-input [formInput]="filters.get('keyword')" label="Locate Stakeholder"></div>
|
||||
</div>
|
||||
<div [class.uk-active]="grid" class="uk-margin-small-left">
|
||||
<a [routerLink]="" class="uk-icon-button" (click)="changeGrid(true)"><i
|
||||
class="material-icons">view_module</i></a>
|
||||
</div>
|
||||
<div [class.uk-active]="!grid" class="uk-margin-small-left">
|
||||
<a [routerLink]="" class="uk-icon-button" (click)="changeGrid(false)"><i class="material-icons">list</i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="page_content_inner">
|
||||
<h4 class="uk-text-bold main">Default Profiles</h4>
|
||||
<div [class.uk-child-width-1-4@m]="grid"
|
||||
[class.uk-child-width-1-3@s]="grid"
|
||||
[class.uk-child-width-1-1]="!grid"
|
||||
[class.max-width-large]="!grid"
|
||||
class="uk-grid-match uk-grid-small"
|
||||
uk-grid>
|
||||
<loading *ngIf="loading" [loading]="loading"></loading>
|
||||
<ng-template ngFor [ngForOf]="displayDefaultStakeholders" let-stakeholder let-i="index">
|
||||
<div *ngIf="stakeholder">
|
||||
<div class="md-card">
|
||||
<div class="md-card-toolbar">
|
||||
<div class="md-card-toolbar-actions" [class.uk-flex-middle]="!grid" [class.uk-flex]="!grid">
|
||||
<span *ngIf="!grid" class="uk-margin-medium-right uk-flex uk-flex-middle">
|
||||
<i class="material-icons md-24 uk-margin-small-right">{{indicatorUtils.isPublicIcon.get(stakeholder.isPublic)}}</i>
|
||||
{{(stakeholder.isPublic) ? 'Public' : 'Private'}}
|
||||
</span>
|
||||
<span *ngIf="!grid" class="uk-margin-medium-right uk-flex uk-flex-middle">
|
||||
<i class="material-icons md-24 uk-margin-small-right"
|
||||
[class.md-color-green-300]="stakeholder.isActive">{{indicatorUtils.isActiveIcon}}</i>
|
||||
{{(stakeholder.isActive) ? 'Active' : 'Inactive'}}
|
||||
</span>
|
||||
<div class="md-card-dropdown uk-inline">
|
||||
<i class="md-icon material-icons">more_vert</i>
|
||||
<div uk-dropdown="mode: click; pos: bottom-right" class="uk-padding-remove-horizontal">
|
||||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<li><a (click)="editIndicatorOpen(i)">Edit</a></li>
|
||||
<li><a (click)="deleteIndicatorOpen(i, 'number')">Delete</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-card-toolbar-heading-text">{{stakeholder.index_name}}</div>
|
||||
</div>
|
||||
<div *ngIf="grid" class="md-card-content">
|
||||
<div class="uk-flex uk-flex-center" uk-grid>
|
||||
<div class="uk-width-1-2 uk-text-center">
|
||||
<i class="material-icons md-24">{{indicatorUtils.isPublicIcon.get(stakeholder.isPublic)}}</i>
|
||||
<div>{{(stakeholder.isPublic) ? 'Public' : 'Private'}}</div>
|
||||
</div>
|
||||
<div class="uk-width-1-2 uk-text-center">
|
||||
<i class="material-icons md-24"
|
||||
[class.md-color-green-300]="stakeholder.isActive">{{indicatorUtils.isActiveIcon}}</i>
|
||||
<div>{{(stakeholder.isActive) ? 'Active' : 'Inactive'}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
</div>
|
||||
<h4 class="uk-text-bold">Stakeholders</h4>
|
||||
<div [class.uk-child-width-1-4@m]="grid"
|
||||
[class.uk-child-width-1-3@s]="grid"
|
||||
[class.uk-child-width-1-1]="!grid"
|
||||
[class.max-width-large]="!grid"
|
||||
class="uk-grid-match uk-grid-small"
|
||||
uk-grid>
|
||||
<loading *ngIf="loading" [loading]="loading"></loading>
|
||||
<ng-template ngFor [ngForOf]="displayStakeholders" let-stakeholder let-i="index">
|
||||
<a *ngIf="stakeholder" [routerLink]="stakeholder.alias">
|
||||
<div class="md-card">
|
||||
<div class="md-card-toolbar">
|
||||
<div class="md-card-toolbar-actions" [class.uk-flex-middle]="!grid" [class.uk-flex]="!grid">
|
||||
<span *ngIf="!grid" class="uk-margin-medium-right uk-flex uk-flex-middle">
|
||||
<i class="material-icons md-24 uk-margin-small-right">{{indicatorUtils.isPublicIcon.get(stakeholder.isPublic)}}</i>
|
||||
{{(stakeholder.isPublic) ? 'Public' : 'Private'}}
|
||||
</span>
|
||||
<span *ngIf="!grid" class="uk-margin-medium-right uk-flex uk-flex-middle">
|
||||
<i class="material-icons md-24 uk-margin-small-right"
|
||||
[class.md-color-green-300]="stakeholder.isActive">{{indicatorUtils.isActiveIcon}}</i>
|
||||
{{(stakeholder.isActive) ? 'Active' : 'Inactive'}}
|
||||
</span>
|
||||
<div class="md-card-dropdown uk-inline">
|
||||
<i class="md-icon material-icons"
|
||||
(click)="$event.stopPropagation();$event.preventDefault()">more_vert</i>
|
||||
<div uk-dropdown="mode: click; pos: bottom-right" class="uk-padding-remove-horizontal">
|
||||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<li><a (click)="editStakeholder(i)">Edit</a></li>
|
||||
<li><a (click)="deleteStakeholder(i)">Delete</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-card-toolbar-heading-text">{{stakeholder.index_name}}</div>
|
||||
</div>
|
||||
<div *ngIf="grid" class="md-card-content">
|
||||
<div class="uk-flex uk-flex-center" uk-grid>
|
||||
<div class="uk-width-1-2 uk-text-center">
|
||||
<i class="material-icons md-24">{{indicatorUtils.isPublicIcon.get(stakeholder.isPublic)}}</i>
|
||||
<div>{{(stakeholder.isPublic) ? 'Public' : 'Private'}}</div>
|
||||
</div>
|
||||
<div class="uk-width-1-2 uk-text-center">
|
||||
<i class="material-icons md-24"
|
||||
[class.md-color-green-300]="stakeholder.isActive">{{indicatorUtils.isActiveIcon}}</i>
|
||||
<div>{{(stakeholder.isActive) ? 'Active' : 'Inactive'}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,145 @@
|
|||
import {Component, OnDestroy, OnInit} from "@angular/core";
|
||||
import {StakeholderService} from "../services/stakeholder.service";
|
||||
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
|
||||
import {EnvironmentSpecificService} from "../openaireLibrary/utils/properties/environment-specific.service";
|
||||
import {Stakeholder} from "../utils/entities/stakeholder";
|
||||
import {Subscriber, zip} from "rxjs";
|
||||
import {IndicatorUtils, Option} from "../utils/indicator-utils";
|
||||
import {FormBuilder, FormGroup} from "@angular/forms";
|
||||
|
||||
@Component({
|
||||
selector: 'home',
|
||||
templateUrl: "./home.component.html"
|
||||
})
|
||||
export class HomeComponent implements OnInit, OnDestroy {
|
||||
|
||||
public properties: EnvProperties;
|
||||
public loading: boolean = true;
|
||||
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
|
||||
public defaultStakeholders: Stakeholder[];
|
||||
public stakeholders: Stakeholder[];
|
||||
public stakeholder: FormGroup;
|
||||
/**
|
||||
* Filtered Stakeholders
|
||||
*/
|
||||
public displayDefaultStakeholders: Stakeholder[];
|
||||
public displayStakeholders: Stakeholder[];
|
||||
/**
|
||||
* Top filters
|
||||
*/
|
||||
public filters: FormGroup;
|
||||
public all: Option = {
|
||||
value: 'all',
|
||||
label: 'All'
|
||||
};
|
||||
|
||||
/**
|
||||
* Grid or List View
|
||||
*/
|
||||
public grid: boolean = true;
|
||||
private subscriptions: any[] = [];
|
||||
|
||||
constructor(private stakeholderService: StakeholderService,
|
||||
private propertiesService: EnvironmentSpecificService,
|
||||
private fb: FormBuilder) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.buildFilters();
|
||||
this.propertiesService.loadEnvironment()
|
||||
.then(properties => {
|
||||
this.properties = properties;
|
||||
let data = zip(
|
||||
this.stakeholderService.getDefaultStakeholders(this.properties.monitorServiceAPIURL),
|
||||
this.stakeholderService.getStakeholders(this.properties.monitorServiceAPIURL)
|
||||
);
|
||||
data.subscribe(res => {
|
||||
this.defaultStakeholders = res[0];
|
||||
this.stakeholders = res[1];
|
||||
this.displayDefaultStakeholders = res[0];
|
||||
this.displayStakeholders = res[1];
|
||||
this.loading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subscriptions.forEach(value => {
|
||||
if (value instanceof Subscriber) {
|
||||
value.unsubscribe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public changeGrid(value) {
|
||||
this.grid = value;
|
||||
}
|
||||
|
||||
private buildFilters() {
|
||||
this.filters = this.fb.group({
|
||||
privacy: this.fb.control('all'),
|
||||
status: this.fb.control('all'),
|
||||
keyword: this.fb.control('')
|
||||
});
|
||||
this.subscriptions.push(this.filters.get('privacy').valueChanges.subscribe(value => {
|
||||
this.onPrivacyChange(value);
|
||||
}));
|
||||
this.subscriptions.push(this.filters.get('status').valueChanges.subscribe(value => {
|
||||
this.onStatusChange(value);
|
||||
}));
|
||||
this.subscriptions.push(this.filters.get('keyword').valueChanges.subscribe(value => {
|
||||
this.onKeywordChange(value);
|
||||
}));
|
||||
}
|
||||
|
||||
onPrivacyChange(value) {
|
||||
this.displayDefaultStakeholders = this.filterPrivacy(this.defaultStakeholders, value);
|
||||
this.displayStakeholders = this.filterPrivacy(this.stakeholders, value);
|
||||
}
|
||||
|
||||
onStatusChange(value) {
|
||||
this.displayDefaultStakeholders = this.filterStatus(this.defaultStakeholders, value);
|
||||
this.displayStakeholders = this.filterStatus(this.stakeholders, value);
|
||||
}
|
||||
|
||||
onKeywordChange(value) {
|
||||
this.displayDefaultStakeholders = this.filterByKeyword(this.defaultStakeholders, value);
|
||||
this.displayStakeholders = this.filterByKeyword(this.stakeholders, value);
|
||||
}
|
||||
|
||||
|
||||
private filterPrivacy(stakeholders: Stakeholder[], value): Stakeholder[] {
|
||||
if (value === 'all') {
|
||||
return stakeholders;
|
||||
} else {
|
||||
return stakeholders.filter(stakeholder => stakeholder.isPublic === value);
|
||||
}
|
||||
}
|
||||
|
||||
private filterStatus(stakeholders: Stakeholder[], value): Stakeholder[] {
|
||||
if (value === 'all') {
|
||||
return stakeholders;
|
||||
} else {
|
||||
return stakeholders.filter(stakeholder => stakeholder.isActive === value);
|
||||
}
|
||||
}
|
||||
|
||||
private filterByKeyword(stakeholders: Stakeholder[], value): Stakeholder[] {
|
||||
if (value === null || value === '') {
|
||||
return stakeholders;
|
||||
} else {
|
||||
return stakeholders.filter(stakeholder => (
|
||||
stakeholder.index_id && stakeholder.index_id.toLowerCase().includes(value.toLowerCase())) ||
|
||||
stakeholder.index_shortName && stakeholder.index_shortName.toLowerCase().includes(value.toLowerCase()) ||
|
||||
stakeholder.index_name && stakeholder.index_name.toLowerCase().includes(value.toLowerCase())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public editStakeholder(index = -1) {
|
||||
/*let stakeholder = this.d
|
||||
this.fb.group({
|
||||
_id: this.fb.control()
|
||||
})*/
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
import {NgModule} from "@angular/core";
|
||||
import {HomeComponent} from "./home.component";
|
||||
import {HomeRoutingModule} from "./home-routing.module";
|
||||
import {FreeGuard} from "../openaireLibrary/login/freeGuard.guard";
|
||||
import {PreviousRouteRecorder} from "../openaireLibrary/utils/piwik/previousRouteRecorder.guard";
|
||||
import {CommonModule} from "@angular/common";
|
||||
import {RouterModule} from "@angular/router";
|
||||
import {InputModule} from "../library/sharedComponents/input/input.module";
|
||||
import {LoadingModule} from "../library/sharedComponents/loading/loading.module";
|
||||
|
||||
@NgModule({
|
||||
declarations: [HomeComponent],
|
||||
imports: [
|
||||
HomeRoutingModule,
|
||||
CommonModule,
|
||||
RouterModule,
|
||||
InputModule,
|
||||
LoadingModule
|
||||
],
|
||||
providers: [
|
||||
FreeGuard, PreviousRouteRecorder,
|
||||
],
|
||||
exports: [HomeComponent]
|
||||
})
|
||||
export class HomeModule {
|
||||
|
||||
}
|
Loading…
Reference in New Issue