import { Component , OnInit , Injector , TemplateRef } from '@angular/core' ; import { DashboardTabComponent } from '../dashboard-tab/dashboard-tab.component' ; import { FitToScreenEvent } from 'src/app/shared/events/fit-to-screen.event' ; import { FitToSelectionEvent } from 'src/app/shared/events/fit-to-selection.event' ; import { environment } from 'src/environments/environment' ; import { FitToSelectionTransmitterEvent } from 'src/app/shared/events/fit-to-selection-transmitter.event' ; import { DashboardSplitScreenEvent } from 'src/app/shared/events/dashboard-split-screen.event' ; import { ExportService } from '../dashboard.export' ; import { GlyphLayout } from '../../glyph/glyph.layout' ; import { GlobalDialogEvent , GlobalDialogPayload } from 'src/app/shared/events/global-dialog.event' ; import { AngularFileUploaderConfig } from 'angular-file-uploader' ; @ Component ( { selector : 'app-dashboard-functionbuttons' , templateUrl : './dashboard-functionbuttons.component.html' , styleUrls : [ './dashboard-functionbuttons.component.scss' ] } ) export class DashboardFunctionbuttonsComponent extends DashboardTabComponent implements OnInit { public backendUploadRoute = environment . backendAddress ; public afuConfig : AngularFileUploaderConfig = { multiple : false , formatsAllowed : '.csv' , maxSize : 5 , uploadAPI : { url : this . backendUploadRoute } , theme : 'dragNDrop' , hideProgressBar : true , hideResetBtn : true , hideSelectBtn : true } ; public resetUploadVar = false ; constructor ( injector ) { super ( injector ) ; } ngOnInit ( ) { } /**
     * Switch between splitscreen and single-view mode.
     */ public onScreenToggle ( ) { this . regionManager . regions [ 1 ] . display = this . regionManager . regions [ 1 ] . display === 'none' ? 'block' : 'none' ; this . regionManager . regions [ 0 ] . display = 'block' ; this . regionManager . regions [ 3 ] . display = 'none' ; this . configuration . splitScreenActive = this . regionManager . regions [ 1 ] . display === 'block' ; const width = window . innerWidth ; const height = window . innerHeight ; this . regionManager . updateRegions ( width , height ) ; if ( this . configuration . splitScreenActive ) { this . cursor . position . left -= width / 2 ; } else { this . cursor . position . left += width / 2 ; } this . cursor . splitActive = this . regionManager . regions [ 1 ] . display === 'block' ; this . cursor . boundaries . right = width / ( this . cursor . splitActive ? 2 : 1 ) ; this . eventAggregator . getEvent ( DashboardSplitScreenEvent ) . publish ( this . configuration . splitScreenActive ) ; } param { any } e public onForceLayoutToggle ( e ) { this . configuration . configurations [ 0 ] . useForceLayout = e . srcElement . checked ; this . configuration . configurations [ 1 ] . useForceLayout = e . srcElement . checked ; } param { any } e public onViewLayoutToggle ( e ) { this . configuration . configurations . forEach ( config => { config . useForceLayout = true ; config . currentLayout = config . currentLayout === GlyphLayout . Matrix ? GlyphLayout . Cluster : GlyphLayout . Matrix ; } ) ; } param { any } e public onAggregateItemsToggle ( e ) { this . configuration . configurations [ 0 ] . aggregateItems = e . srcElement . checked ; this . configuration . configurations [ 1 ] . aggregateItems = e . srcElement . checked ; this . onLayoutChange ( ) ; } public fitToSelection ( ) { this . eventAggregator . getEvent ( FitToSelectionTransmitterEvent ) . publish ( true ) ; } public fitToScreen ( ) { if ( this . configuration . configurations [ 0 ] . selectedDataSetInfo . name === '' ) { return ; } this . configuration . configurations [ 0 ] . currentLayout = GlyphLayout . Cluster ; this . configuration . configurations [ 0 ] . currentLevelOfDetail = 0 ; this . configuration . configurations [ 1 ] . currentLayout = GlyphLayout . Cluster ; this . configuration . configurations [ 1 ] . currentLevelOfDetail = 0 ; this . eventAggregator . getEvent ( FitToScreenEvent ) . publish ( true ) ; } public onExport ( ) { const idListFirst = [ ] ; let dataFirst ; this . configuration . configurations [ 0 ] . getData ( ) . subscribe ( message => { dataFirst = message ; } ) ; if ( dataFirst === null ) { return ; } const expFirst = new ExportService ( ) ; expFirst . exportData ( dataFirst , this . configuration . configurations [ 0 ] . filteredItemsIds , [ this . configuration . configurations [ 0 ] . selectedDataSetInfo . name , this . configuration . configurations [ 0 ] . selectedDataSetInfo . positionAlgorithm , this . configuration . configurations [ 0 ] . selectedDataSetInfo . version ] , this . configuration . configurations [ 0 ] . activeFeatures , ( this . configuration . configurations [ 0 ] . featureFilters . length == 0 ) ) ; } public openHelp ( ) { window . open ( 'https://visualengineers.github.io/glyphboard-doc/' , '_blank' ) ; } public openUploadDialog ( template ) { this . eventAggregator . getEvent ( GlobalDialogEvent ) . publish ( new GlobalDialogPayload ( { content : template , title : 'File Upload' , visible : true , } ) ) ; } public docUpload ( event ) { this . logger . log ( event ) ; this . resetUploadVar = true ; } }