import powerbiVisualsApi from 'powerbi-visuals-api' ; import powerbi = powerbiVisualsApi ; import IVisualHost = powerbi . extensibility . visual . IVisualHost ; import ILocalizationManager = powerbi . extensibility . ILocalizationManager ; import * as d3 from 'd3' ; import { VisualConstants } from './VisualConstants' ; import { DomainUtils } from './DomainUtils' ; /**
 * Manages the handling and placement of the visual landing page if no data is present.
 */ export default class LandingPageHandler { landingPageEnabled : boolean = false ; landingPageRemoved : boolean = false ; private element : d3 . Selection < any , any , any , any > ; private localisationManager : ILocalizationManager ; param element param localisationManager constructor ( element , localisationManager ) { this . element = element ; this . localisationManager = localisationManager ; } param options param host handleLandingPage ( viewModelIsValid , host ) { if ( ! viewModelIsValid ) { if ( ! this . landingPageEnabled ) { this . landingPageEnabled = true ; this . render ( host ) ; } } else { this . clear ( ) ; } } /**
     * Clears down the landing page of elements
     */ clear ( ) { this . element . selectAll ( '*' ) . remove ( ) ; if ( this . landingPageEnabled && ! this . landingPageRemoved ) { this . landingPageRemoved = true ; } this . landingPageEnabled = false ; } param host render ( host ) { let container = this . element . append ( 'div' ) . classed ( `${ VisualConstants . dom . landingPageClassPrefix }-landing-page` , true ) . classed ( 'w3-card-4' , true ) ; let heading = container . append ( 'div' ) . classed ( 'w3-container' , true ) . classed ( 'w3-theme' , true ) ; let version = container . append ( 'div' ) . classed ( 'w3-container' , true ) . classed ( 'w3-theme-l3' , true ) . classed ( 'w3-small' , true ) ; let helpBox = container . append ( 'div' ) . classed ( 'w3-container' , true ) . classed ( 'w3-theme-l5' , true ) . classed ( `${ VisualConstants . dom . landingPageClassPrefix }-watermark` , true ) . classed ( `${ VisualConstants . dom . landingPageClassPrefix }-help` , true ) ; heading . append ( 'h5' ) . text ( VisualConstants . visual . displayName ) ; version . text ( VisualConstants . visual . version ) ; helpBox . append ( 'button' ) . classed ( 'w3-button' , true ) . classed ( 'w3-theme-action' , true ) . classed ( 'w3-circle' , true ) . style ( 'position' , 'fixed' ) . style ( 'top' , '24px' ) . style ( 'right' , '12px' ) . on ( 'click' , ( ) => host . launchUrl ( VisualConstants . visual . supportUrl ) ) . text ( '?' ) ; helpBox . append ( 'p' ) . classed ( 'w3-small' , true ) . text ( this . localisationManager . getDisplayName ( 'Landing_Page_Overview_1' ) ) ; helpBox . append ( 'p' ) . classed ( 'w3-small' , true ) . text ( this . localisationManager . getDisplayName ( 'Landing_Page_Overview_2' ) ) ; helpBox . append ( 'p' ) . classed ( 'w3-small' , true ) . text ( this . localisationManager . getDisplayName ( 'Landing_Page_Overview_3' ) ) ; helpBox . append ( 'p' ) . classed ( 'w3-small' , true ) . text ( this . localisationManager . getDisplayName ( 'Landing_Page_Overview_4' ) ) ; DomainUtils . resolveScrollableContent ( container . node ( ) ) ; } }