Implement iframe reload on deployment

This commit is contained in:
Kristóf Tóth
2018-05-17 15:58:08 +02:00
parent 4df50e165d
commit 454507615d
4 changed files with 24 additions and 10 deletions

View File

@ -10,6 +10,7 @@
<app-web *ngIf="!iframeUrl"></app-web>
<div *ngIf="iframeUrl" class="iframe-container">
<iframe class="iframe"
#webiframe
scrolling="yes"
frameborder="0"
[src]="iframeUrl | safe">

View File

@ -1,13 +1,12 @@
// Copyright (C) 2018 Avatao.com Innovative Learning Kft.
// All Rights Reserved. See LICENSE file for details.
import { Component, OnDestroy, OnInit, ChangeDetectorRef } from '@angular/core';
import { Component, OnDestroy, OnInit, ChangeDetectorRef, ElementRef, ViewChild } from '@angular/core';
import { DeploymentNotificationService } from '../services/deployment-notification.service';
import { Subscription } from 'rxjs/Subscription';
import { WebSocketService } from '../services/websocket.service';
import { LayoutCommand } from './layout-command';
import { config } from '../config';
import { SidebarComponent } from '../sidebar/sidebar.component';
@Component({
selector: 'app-dashboard',
@ -20,6 +19,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
layout: string = config.dashboard.currentLayout;
hide_messages: boolean = config.dashboard.hide_messages;
iframeUrl: string = config.dashboard.iframeUrl;
@ViewChild('webiframe') webiframe: ElementRef;
command_handlers = {'layout': this.layoutHandler.bind(this),
'reload_frontend': this.reloadFrontendHandlder.bind(this)};
@ -34,8 +34,12 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.changeDetectorRef.detectChanges();
});
this.deploymentNotificationSubscription = this.deploymentNotificationService.deploying.subscribe(
(deploying) => this.deploying = deploying
);
(deploying) => {
this.deploying = deploying;
if (!deploying) {
this.reloadIframe();
}
});
}
layoutHandler(data: LayoutCommand) {
@ -65,4 +69,10 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.deploymentNotificationSubscription.unsubscribe();
}
}
reloadIframe() {
setTimeout(() => {
this.webiframe.nativeElement.contentWindow.location.reload(true);
});
}
}