@@ -51,6 +51,7 @@ const ChartWidgetConfig = explorer.models.ChartWidgetConfig;
5151const ConfigService = explorer . components . config . ConfigService ;
5252const ContainerWidgetConfig = explorer . components . container . ContainerWidgetConfig ;
5353const DashboardInstance = explorer . components . dashboard . DashboardInstance ;
54+ const DashboardModel = explorer . components . dashboard . DashboardModel ;
5455const DashboardParam = explorer . components . dashboard . DashboardParam ;
5556const DashboardDataService = explorer . components . dashboard . DashboardDataService ;
5657const ExplorerStateService = explorer . components . explorer . ExplorerStateService ;
@@ -156,7 +157,7 @@ explorer.components.dashboard.DashboardService = function(arrayUtilService,
156157 ] ;
157158
158159 Object . defineProperty ( this , 'current' , {
159- /** @export {function(): explorer.components.dashboard.DashboardModel } */
160+ /** @export {function(): explorer.components.dashboard.DashboardInstance } */
160161 get : function ( ) {
161162 return explorerStateService . selectedDashboard ;
162163 }
@@ -308,16 +309,16 @@ DashboardService.prototype.saveDashboardCopy = function() {
308309 * Set the current dashboard and the set the widgets array to reference the
309310 * dashboard's widgets.
310311 *
311- * @param {!DashboardInstance } dashboardConfig
312+ * @param {!DashboardInstance } dashboard
312313 * @export
313314 */
314- DashboardService . prototype . setDashboard = function ( dashboardConfig ) {
315- this . explorerStateService_ . selectedDashboard = dashboardConfig ;
316- if ( dashboardConfig ) {
315+ DashboardService . prototype . setDashboard = function ( dashboard ) {
316+ this . explorerStateService_ . selectedDashboard = dashboard ;
317+ if ( dashboard ) {
317318 this . explorerStateService_ . widgets . clear ( ) ;
318319 this . explorerStateService_ . containers . clear ( ) ;
319320
320- for ( let container of dashboardConfig . model . children ) {
321+ for ( let container of dashboard . model . children ) {
321322 this . explorerStateService_ . containers . all [ container . model . id ] = container ;
322323 if ( container . model . id ===
323324 this . explorerStateService_ . containers . selectedId ) {
@@ -416,17 +417,17 @@ DashboardService.prototype.selectWidget = function(
416417 }
417418 }
418419
419- if ( widget ) {
420+ if ( goog . isDefAndNotNull ( widget ) ) {
420421 this . sidebarTabService_ . resolveSelectedTabForWidget ( ) ;
421422
422423 this . timeout_ ( ( ) => {
423- this . scrollWidgetIntoView ( widget ) ;
424+ this . scrollWidgetIntoView ( /** @type { !WidgetConfig } */ ( widget ) ) ;
424425 } ) ;
425- } else if ( container ) {
426+ } else if ( goog . isDefAndNotNull ( container ) ) {
426427 this . sidebarTabService_ . resolveSelectedTabForContainer ( ) ;
427428
428429 this . timeout_ ( ( ) => {
429- this . scrollContainerIntoView ( container ) ;
430+ this . scrollContainerIntoView ( /** @type { !ContainerWidgetConfig } */ ( container ) ) ;
430431 } ) ;
431432 } else {
432433 this . timeout_ ( ( ) => {
@@ -535,7 +536,7 @@ DashboardService.prototype.selectContainer = function(
535536
536537/**
537538 * Rewrites the current widget's query based on the config.
538- * @param {!Widget } widget The widget to rewrite the query against.
539+ * @param {!WidgetConfig } widget The widget to rewrite the query against.
539540 * @param {boolean= } replaceParams If true, parameters (%%NAME%%) will be
540541 * replaced with the current param value (from the dashboard or url).
541542 * Defaults to false.
@@ -547,45 +548,47 @@ DashboardService.prototype.rewriteQuery = function(widget, replaceParams) {
547548
548549 let widgetConfig = widget . model . datasource . config ;
549550
550- let project_name = this . arrayUtilService_ . getFirst ( [
551+ let project_name = ( this . arrayUtilService_ . getFirst ( [
551552 widgetConfig . results . project_id ,
552553 this . current . model . project_id ,
553- this . config . default_project ] , false ) ;
554- if ( project_name === null ) {
555- this . errorService_ . addError ( ErrorTypes . DANGER , 'Project name not found.' ) ;
554+ this . config . default_project ] , false ) ) ;
555+ if ( goog . isNull ( project_name ) ) {
556+ throw 'Project name not found.' ;
556557 }
557558
558- let dataset_name = this . arrayUtilService_ . getFirst ( [
559+ let dataset_name = ( this . arrayUtilService_ . getFirst ( [
559560 widgetConfig . results . dataset_name ,
560561 this . current . model . dataset_name ,
561- this . config . default_dataset ] , false ) ;
562- if ( project_name === null ) {
563- this . errorService_ . addError ( ErrorTypes . DANGER , 'Dataset name not found.' ) ;
562+ this . config . default_dataset ] , false ) ) ;
563+ if ( goog . isNull ( dataset_name ) ) {
564+ throw 'Dataset name not found.' ;
564565 }
565566
566- let table_name = this . arrayUtilService_ . getFirst ( [
567+ let table_name = ( this . arrayUtilService_ . getFirst ( [
567568 widgetConfig . results . table_name ,
568569 this . current . model . table_name ,
569- this . config . default_table ] , false ) ;
570- if ( project_name === null ) {
571- this . errorService_ . addError ( ErrorTypes . DANGER , 'Table name not found.' ) ;
570+ this . config . default_table ] , false ) ) ;
571+ if ( goog . isNull ( table_name ) ) {
572+ throw 'Table name not found.' ;
572573 }
573574
574- let table_partition = this . arrayUtilService_ . getFirst ( [
575+ let table_partition = ( this . arrayUtilService_ . getFirst ( [
575576 widgetConfig . results . table_partition ,
576577 this . current . model . table_partition ,
577- this . DEFAULT_TABLE_PARTITION ] , false ) ;
578- if ( project_name === null ) {
579- this . errorService_ . addError ( ErrorTypes . DANGER ,
580- 'Table partition not found.' ) ;
578+ this . DEFAULT_TABLE_PARTITION ] , false ) ) ;
579+ if ( goog . isNull ( table_partition ) ) {
580+ throw 'Table partition not found.' ;
581581 }
582582
583583 this . initializeParams_ ( ) ;
584584 let params = replaceParams ? this . params : null ;
585585
586586 return this . queryBuilderService_ . getSql (
587587 widget . model . datasource . config ,
588- project_name , dataset_name , table_name , table_partition , params ) ;
588+ /** @type {string } */ ( project_name ) ,
589+ /** @type {string } */ ( dataset_name ) ,
590+ /** @type {string } */ ( table_name ) ,
591+ /** @type {!QueryTablePartitioning } */ ( table_partition ) , params ) ;
589592} ;
590593
591594/**
0 commit comments