1- import { Component , Inject , OnDestroy , OnInit } from '@angular/core' ;
1+ import { Component , Inject , OnDestroy , OnInit , PLATFORM_ID } from '@angular/core' ;
22
33import { BehaviorSubject , Subscription } from 'rxjs' ;
44import { TranslateService } from '@ngx-translate/core' ;
@@ -13,6 +13,7 @@ import { ItemDataService } from '../../../../../core/data/item-data.service';
1313import { CrisLayoutBox , MetricsBoxConfiguration , } from '../../../../../core/layout/models/box.model' ;
1414import { Item } from '../../../../../core/shared/item.model' ;
1515import { CrisLayoutMetricRow } from '../../../../../core/layout/models/tab.model' ;
16+ import { isPlatformBrowser } from '@angular/common' ;
1617
1718/**
1819 * This component renders the metadata boxes of items
@@ -54,25 +55,28 @@ export class CrisLayoutMetricsBoxComponent extends CrisLayoutBoxModelComponent i
5455 protected itemService : ItemDataService ,
5556 protected translateService : TranslateService ,
5657 @Inject ( 'boxProvider' ) public boxProvider : CrisLayoutBox ,
57- @Inject ( 'itemProvider' ) public itemProvider : Item
58+ @Inject ( 'itemProvider' ) public itemProvider : Item ,
59+ @Inject ( PLATFORM_ID ) protected platformId : Object
5860 ) {
5961 super ( translateService , boxProvider , itemProvider ) ;
6062 }
6163
6264 ngOnInit ( ) {
6365 super . ngOnInit ( ) ;
6466
65- this . metricsBoxConfiguration = this . box . configuration as MetricsBoxConfiguration ;
66- this . subs . push (
67- this . itemService . getMetrics ( this . item . uuid ) . pipe ( getFirstSucceededRemoteDataPayload ( ) )
68- . subscribe ( ( result ) => {
69- const matchingMetrics = this . metricsComponentService . getMatchingMetrics (
70- result . page ,
71- this . metricsBoxConfiguration . maxColumns ,
72- this . metricsBoxConfiguration . metrics
73- ) ;
74- this . metricRows . next ( matchingMetrics ) ;
75- } ) ) ;
67+ if ( isPlatformBrowser ( this . platformId ) ) {
68+ this . metricsBoxConfiguration = this . box . configuration as MetricsBoxConfiguration ;
69+ this . subs . push (
70+ this . itemService . getMetrics ( this . item . uuid ) . pipe ( getFirstSucceededRemoteDataPayload ( ) )
71+ . subscribe ( ( result ) => {
72+ const matchingMetrics = this . metricsComponentService . getMatchingMetrics (
73+ result . page ,
74+ this . metricsBoxConfiguration . maxColumns ,
75+ this . metricsBoxConfiguration . metrics
76+ ) ;
77+ this . metricRows . next ( matchingMetrics ) ;
78+ } ) ) ;
79+ }
7680 }
7781
7882 /**
0 commit comments