1- import { Component , HostListener , Renderer2 , ViewChild } from '@angular/core' ;
1+ import { Component , ElementRef , HostListener , Renderer2 , ViewChild } from '@angular/core' ;
22import { DomSanitizer } from '@angular/platform-browser' ;
33import { Subject } from 'rxjs' ;
44import { Observable } from 'rxjs/internal/Observable' ;
@@ -10,7 +10,6 @@ import { marked } from 'marked';
1010import { NzNotificationService } from 'ng-zorro-antd/notification' ;
1111import { AngularGridInstance , Column , GridOption } from 'angular-slickgrid' ;
1212import { ExcelExportService } from '@slickgrid-universal/excel-export' ;
13-
1413interface trace {
1514 x :Array < any > ,
1615 y :Array < any > ,
@@ -80,6 +79,7 @@ export class AppComponent {
8079 dataset : any [ ] = [ ] ;
8180 hide_sidebar :boolean = true
8281 wide_mode = false
82+ current_page = 'main'
8383 breakpoints = {
8484 sm : 576 ,
8585 columns : 640 ,
@@ -97,8 +97,10 @@ export class AppComponent {
9797 config : { editable :true , responsive : true }
9898} ;
9999 angularGrid : AngularGridInstance ;
100-
101- constructor ( private api :ApiService , public sanitizer : DomSanitizer , public renderer : Renderer2 , public notification :NzNotificationService ) {
100+ @ViewChild ( 'scrollableDiv' ) scrollableDiv : ElementRef ;
101+ constructor ( private api :ApiService ,
102+ public sanitizer : DomSanitizer ,
103+ public renderer : Renderer2 , public notification :NzNotificationService ) {
102104 console . log ( window . location . protocol )
103105 let host = window . location . hostname
104106 let port
@@ -180,6 +182,10 @@ export class AppComponent {
180182
181183 update_app ( res :any ) {
182184 console . log ( res )
185+ if ( this . current_page != res [ 'current_page' ] ) {
186+ this . scrollToTop ( )
187+ this . current_page = res [ 'current_page' ]
188+ }
183189 let all_elements = [ ]
184190 let all_pages = [ 'main_page' ] . concat ( res [ 'pages' ] )
185191 console . log ( all_pages )
@@ -599,7 +605,11 @@ is_menu_open(item, value){
599605 return item . children . some ( item => item . title === value )
600606}
601607
602-
608+ scrollToTop ( ) {
609+ console . log ( 'scrolling to top' )
610+ const scrollableElement = this . scrollableDiv . nativeElement ;
611+ scrollableElement . scrollTop = 0 ;
612+ }
603613
604614}
605615
0 commit comments