-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
244 additions
and
17 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
// Power BI API references | ||
import powerbiVisualsApi from 'powerbi-visuals-api'; | ||
import powerbi = powerbiVisualsApi; | ||
import IVisualHost = powerbi.extensibility.visual.IVisualHost; | ||
import ILocalizationManager = powerbi.extensibility.ILocalizationManager; | ||
|
||
// External dependencies | ||
import * as d3 from 'd3'; | ||
|
||
// Internal dependencies | ||
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 { | ||
|
||
// Specifies that the landing page is currently on. | ||
landingPageEnabled: boolean = false; | ||
// Specifies that the landing page has been removed since being displayed. | ||
landingPageRemoved: boolean = false; | ||
// Element to bind the landing page to. | ||
private element: d3.Selection<any, any, any, any>; | ||
// Handle localisation of visual text. | ||
private localisationManager: ILocalizationManager; | ||
|
||
/** | ||
* @param element - main visual element | ||
* @param localisationManager - Power BI localisation manager instance | ||
*/ | ||
constructor( | ||
element: d3.Selection<any, any, any, any>, | ||
localisationManager: ILocalizationManager | ||
) { | ||
this.element = element; | ||
this.localisationManager = localisationManager; | ||
} | ||
|
||
/** | ||
* Handles the display or removal of the landing page elements | ||
* @param options - visual update options | ||
* @param host - Power BI visual host services | ||
*/ | ||
handleLandingPage(viewModelIsValid: boolean, host: IVisualHost) { | ||
|
||
// Conditions for showing landing page | ||
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; | ||
} | ||
|
||
/** | ||
* Renders the landing page content | ||
* | ||
* @param host - Power BI visual host services | ||
*/ | ||
render(host: IVisualHost) { | ||
|
||
// Top-level elements | ||
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); | ||
|
||
// Add title | ||
heading | ||
.append('h5') | ||
.text(VisualConstants.pbiviz.visual.displayName); | ||
|
||
// Add version number | ||
version | ||
.text(VisualConstants.pbiviz.visual.version); | ||
|
||
// Help box content | ||
|
||
// Button / remote link | ||
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.pbiviz.visual.supportUrl)) | ||
.text('?'); | ||
|
||
// Overview | ||
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()); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,53 @@ | ||
@import (less) "node_modules/overlayscrollbars/css/OverLayScrollbars.min.css"; | ||
@import (less) "node_modules/w3-css/w3.css"; | ||
|
||
#htmlViewer { | ||
width: 100vw; | ||
height: 100vh; | ||
overflow: auto; | ||
} | ||
|
||
.w3-theme-l5 {color:#000 !important; background-color:#fcfcfc !important} | ||
.w3-theme-l4 {color:#000 !important; background-color:#f6f6f6 !important} | ||
.w3-theme-l3 {color:#000 !important; background-color:#eceded !important} | ||
.w3-theme-l2 {color:#000 !important; background-color:#e3e4e4 !important} | ||
.w3-theme-l1 {color:#000 !important; background-color:#d9dbdb !important} | ||
.w3-theme-d1 {color:#000 !important; background-color:#babdbe !important} | ||
.w3-theme-d2 {color:#000 !important; background-color:#a5a8aa !important} | ||
.w3-theme-d3 {color:#fff !important; background-color:#8f9396 !important} | ||
.w3-theme-d4 {color:#fff !important; background-color:#7a7f81 !important} | ||
.w3-theme-d5 {color:#fff !important; background-color:#656a6c !important} | ||
|
||
.w3-theme-light {color:#000 !important; background-color:#fcfcfc !important} | ||
.w3-theme-dark {color:#fff !important; background-color:#656a6c !important} | ||
.w3-theme-action {color:#fff !important; background-color:#656a6c !important} | ||
|
||
.w3-theme {color:#000 !important; background-color:#d0d2d3 !important} | ||
.w3-text-theme {color:#d0d2d3 !important} | ||
.w3-border-theme {border-color:#d0d2d3 !important} | ||
|
||
.w3-hover-theme:hover {color:#000 !important; background-color:#d0d2d3 !important} | ||
.w3-hover-text-theme:hover {color:#d0d2d3 !important} | ||
.w3-hover-border-theme:hover {border-color:#d0d2d3 !important} | ||
|
||
.html-display-landing-page { | ||
width: 100vw; | ||
height: 100vh; | ||
overflow: auto; | ||
} | ||
|
||
.html-display-watermark { | ||
background-image: url("data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNTEyIDUxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgb3ZlcmZsb3c9ImhpZGRlbiI+PHBhdGggZD0iTTcxIDQ2MCAzMCAwIDQ4MSAwIDQ0MCA0NjAgMjU1IDUxMiIgZmlsbD0iI0UzNEYyNiIvPjxwYXRoIGQ9Ik0yNTYgNDcyIDQwNSA0MzEgNDQwIDM3IDI1NiAzNyIgZmlsbD0iI0VGNjUyQSIvPjxwYXRoIGQ9Ik0yNTYgMjA4IDE4MSAyMDggMTc2IDE1MCAyNTYgMTUwIDI1NiA5NCAyNTUgOTQgMTE0IDk0IDExNSAxMDkgMTI5IDI2NSAyNTYgMjY1Wk0yNTYgMzU1IDI1NSAzNTUgMTkyIDMzOCAxODggMjkzIDE1OCAyOTMgMTMyIDI5MyAxMzkgMzgyIDI1NSA0MTQgMjU2IDQxNFoiIGZpbGw9IiNFQkVCRUIiLz48cGF0aCBkPSJNMjU1IDIwOCAyNTUgMjY1IDMyNSAyNjUgMzE4IDMzOCAyNTUgMzU1IDI1NSA0MTQgMzcxIDM4MiAzNzIgMzcyIDM4NSAyMjMgMzg3IDIwOCAzNzEgMjA4Wk0yNTUgOTQgMjU1IDEyOSAyNTUgMTUwIDI1NSAxNTAgMzkyIDE1MCAzOTIgMTUwIDM5MiAxNTAgMzkzIDEzOCAzOTYgMTA5IDM5NyA5NFoiIGZpbGw9IiNGRkZGRkYiLz48L3N2Zz4="); | ||
background-repeat: no-repeat; | ||
background-position: center; | ||
background-size: auto 85%; | ||
} | ||
|
||
.html-display-minimised { | ||
width: 100vw; | ||
height: 100vh; | ||
} | ||
|
||
.html-display-help { | ||
height: 60%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters