[Library | Trunk]: Metrics: Fix a bug with iframe width.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58719 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2020-05-19 14:12:10 +00:00
parent d1521f8802
commit 0fff8485a9
2 changed files with 11 additions and 10 deletions

View File

@ -10,7 +10,7 @@
margin-top: 20px; margin-top: 20px;
margin-left: 20px; margin-left: 20px;
width: 350px; width: 350px;
z-index: 1; z-index: 3;
} }
.metrics .widget:after { .metrics .widget:after {

View File

@ -1,4 +1,4 @@
import {Component, Input, Output, EventEmitter} from '@angular/core'; import {Component, Input, Output, EventEmitter, ChangeDetectorRef} from '@angular/core';
import {Metrics} from '../../../utils/entities/metrics'; import {Metrics} from '../../../utils/entities/metrics';
import {MetricsService} from '../../../services/metrics.service'; import {MetricsService} from '../../../services/metrics.service';
import {ErrorCodes} from '../../../utils/properties/errorCodes'; import {ErrorCodes} from '../../../utils/properties/errorCodes';
@ -43,16 +43,16 @@ import {animate, state, style, transition, trigger} from "@angular/animations";
<div *ngIf="(metrics.totalViews > 0 && viewsFrameUrl) || (metrics.totalDownloads > 0 && downloadsFrameUrl)" <div *ngIf="(metrics.totalViews > 0 && viewsFrameUrl) || (metrics.totalDownloads > 0 && downloadsFrameUrl)"
[@charts]="state.toString()" [@charts]="state.toString()"
class="charts uk-visible-toggle" tabindex="-1" uk-slider> class="charts uk-visible-toggle" tabindex="-1" uk-slider>
<ul class="uk-slider-items uk-child-width-1-1 uk-grid"> <ul class="uk-slider-items uk-child-width-1-1">
<li> <li #element>
<i-frame *ngIf="metrics.totalViews > 0 && viewsFrameUrl" <i-frame *ngIf="metrics.totalViews > 0 && viewsFrameUrl"
[width]="325" [height]="200" [width]="element.offsetWidth" [height]="200"
[url]=viewsFrameUrl> [url]=viewsFrameUrl>
</i-frame> </i-frame>
</li> </li>
<li> <li #element>
<i-frame *ngIf="metrics.totalDownloads > 0 && downloadsFrameUrl" <i-frame *ngIf="metrics.totalDownloads > 0 && downloadsFrameUrl"
[width]="325" [height]="200" [width]="element.offsetWidth" [height]="200"
[url]=downloadsFrameUrl> [url]=downloadsFrameUrl>
</i-frame> </i-frame>
</li> </li>
@ -168,7 +168,7 @@ export class MetricsComponent {
public status: number; public status: number;
public state: number = -1; public state: number = -1;
constructor(private _metricsService: MetricsService) { constructor(private metricsService: MetricsService, private cdr: ChangeDetectorRef) {
} }
ngOnInit() { ngOnInit() {
@ -186,9 +186,10 @@ export class MetricsComponent {
} }
private getMetrics() { private getMetrics() {
this.sub = this._metricsService.getMetrics(this.id, this.entityType, this.properties).subscribe( this.sub = this.metricsService.getMetrics(this.id, this.entityType, this.properties).subscribe(
data => { data => {
this.metrics = data; this.metrics = data;
this.cdr.detectChanges();
this.status = this.errorCodes.DONE; this.status = this.errorCodes.DONE;
this.metricsResults.emit({ this.metricsResults.emit({
totalViews: this.metrics.totalViews, totalViews: this.metrics.totalViews,
@ -197,7 +198,6 @@ export class MetricsComponent {
}); });
}, },
err => { err => {
console.log(err);
if (err.status == '404') { if (err.status == '404') {
this.status = this.errorCodes.NOT_FOUND; this.status = this.errorCodes.NOT_FOUND;
} else if (err.status == '500') { } else if (err.status == '500') {
@ -247,6 +247,7 @@ export class MetricsComponent {
}, 300)); }, 300));
}, 100)); }, 100));
} }
this.cdr.detectChanges();
} }
public getKeys(map) { public getKeys(map) {