[Monitor Dashboard]: Add home page. Fix a bug when edit indicator and filter is on

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@57719 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Konstantinos Triantafyllou 2019-11-27 15:52:59 +00:00
parent e8e95da10f
commit 706b2532f7
5 changed files with 25 additions and 20 deletions

View File

@ -23,6 +23,11 @@ const routes: Routes = [
resolve: {envSpecific: EnvironmentSpecificResolver},
data: {hasSidebar: false}
},
{
path: 'admin',
loadChildren: './home/home.module#HomeModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'admin/:stakeholder',
loadChildren: './stakeholder/stakeholder.module#StakeholderModule',

View File

@ -29,19 +29,19 @@ export class StakeholderService {
}
getAllStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
return this.http.get<Stakeholder[]>(url + '/stakeholder/all' + (type)?('?type=' + type):'').pipe(map(stakeholders => {
return this.http.get<Stakeholder[]>(url + '/stakeholder/all' + ((type)?('?type=' + type):'')).pipe(map(stakeholders => {
return this.formalize(stakeholders);
}));
}
getStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
return this.http.get<Stakeholder[]>(url + '/stakeholder' + (type)?('?type=' + type):'').pipe(map(stakeholders => {
return this.http.get<Stakeholder[]>(url + '/stakeholder' + ((type)?('?type=' + type):'')).pipe(map(stakeholders => {
return this.formalize(stakeholders);
}));
}
getDefaultStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
return this.http.get<Stakeholder[]>(url + '/stakeholder/default' + (type)?('?type=' + type):'').pipe(map(stakeholders => {
return this.http.get<Stakeholder[]>(url + '/stakeholder/default' + ((type)?('?type=' + type):'')).pipe(map(stakeholders => {
return this.formalize(stakeholders);
}));
}

View File

@ -54,7 +54,7 @@
<div [class.uk-child-width-1-3@m]="grid"
[class.uk-child-width-1-2@s]="grid"
[class.uk-child-width-1-1]="!grid"
[class.list]="!grid" id="number"
[class.max-width-large]="!grid" id="number"
class="uk-grid-match uk-grid-small"
uk-sortable uk-grid>
<ng-template ngFor [ngForOf]="displayNumbers" let-indicator let-i="index">
@ -76,8 +76,8 @@
<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>
<li><a (click)="editIndicatorOpen(indicator._id)">Edit</a></li>
<li><a (click)="deleteIndicatorOpen(indicator._id, 'number')">Delete</a></li>
</ul>
</div>
</div>
@ -108,7 +108,7 @@
<div [class.uk-child-width-1-3@m]="grid"
[class.uk-child-width-1-2@s]="grid"
[class.uk-child-width-1-1]="!grid"
[class.list]="!grid" id="chart"
[class.max-width-large]="!grid" id="chart"
class="uk-grid-match uk-grid-small uk-grid"
uk-sortable uk-grid>
<ng-template ngFor [ngForOf]="displayCharts" let-indicator let-i="index">
@ -143,8 +143,8 @@
<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)">Delete</a></li>
<li><a (click)="editIndicatorOpen(indicator._id)">Edit</a></li>
<li><a (click)="deleteIndicatorOpen(indicator._id)">Delete</a></li>
</ul>
</div>
</div>

View File

@ -97,7 +97,9 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
ngOnChanges(changes: SimpleChanges): void {
if (this.canEdit) {
this.buildFilters();
if(changes.topicIndex || changes.categoryIndex || changes.subcategoryIndex) {
this.buildFilters();
}
this.filterCharts();
this.filterNumbers();
}
@ -157,7 +159,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
}
onPrivacyChange(value) {
console.log(value);
this.displayCharts = this.filterPrivacy(this.charts, value);
this.displayNumbers = this.filterPrivacy(this.numbers, value);
}
@ -308,10 +309,10 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.editIndicatorOpen();
}
public editIndicatorOpen(index: number = -1) {
this.index = index;
public editIndicatorOpen(id = null) {
this.index = this.charts.findIndex(value => value._id === id);
if (this.index !== -1) {
this.indicator = HelperFunctions.copy(this.charts[index]);
this.indicator = HelperFunctions.copy(this.charts[this.index]);
}
let indicatorPaths = this.fb.array([]);
this.indicator.indicatorPaths.forEach(indicatorPath => {
@ -346,7 +347,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
indicatorPaths: indicatorPaths,
width: this.fb.control(this.indicator.width, Validators.required),
});
if(index === -1) {
if(this.index === -1) {
this.editIndicatorModal.okButtonText = 'Save';
this.editIndicatorModal.stayOpen = false;
} else {
@ -414,12 +415,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.indicatorPaths.at(index).markAsPristine({onlySelf: true});
}
deleteIndicatorOpen(index: number, type: string = 'chart') {
this.index = index;
deleteIndicatorOpen(id: string, type: string = 'chart') {
if(type === 'chart') {
this.indicator = this.charts[index];
this.indicator = this.charts.find(value => value._id == id);
} else {
this.indicator = this.numbers[index];
this.indicator = this.numbers.find(value => value._id == id);
}
this.deleteIndicatorModal.alertTitle = 'Delete ' + this.indicator.name;
this.deleteIndicatorModal.cancelButtonText = 'No';

View File

@ -99,7 +99,7 @@ body.dashboard {
float: none;
}
.dashboard .list {
.dashboard .max-width-large {
max-width: 1220px;
}