Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 6213997

Browse files
committed
Merge pull request #262 from GoogleCloudPlatform/joemu-dev-fix-warnings
Fix Closure Compiler Warnings
2 parents 9c1c49d + e3a3be6 commit 6213997

52 files changed

Lines changed: 399 additions & 347 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/components/config/config-service_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ describe('configService', function() {
192192
provided_other_project = 'PROVIDED_OTHER_PROJECT';
193193

194194
provided_object = {
195-
'other_property': provided_other_value,
196195
'default_project': provided_other_project
197196
};
198197

@@ -206,7 +205,6 @@ describe('configService', function() {
206205
};
207206

208207
expected_data = {
209-
'other_property': provided_other_value,
210208
'default_project': provided_default_project,
211209
'default_dataset': provided_default_dataset,
212210
'default_table': provided_default_table,
@@ -219,7 +217,9 @@ describe('configService', function() {
219217
};
220218

221219
svc.populate(provided_data);
222-
expect(svc.toJSON(provided_object)).toEqual(expected_data);
220+
var actualData = svc.toJSON(provided_object);
221+
222+
expect(actualData).toEqual(expected_data);
223223
});
224224
});
225225

client/components/dashboard/dashboard-data-service.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ DashboardDataService.prototype.update = function(dashboardConfig) {
195195
/**
196196
* Deletes the given dashboard on the server based on its id.
197197
*
198-
* @param {!number} dashboard_id
198+
* @param {string} dashboard_id
199199
* @return {!angular.$q.Promise}
200200
*/
201201
DashboardDataService.prototype.delete = function(dashboard_id) {
@@ -206,53 +206,64 @@ DashboardDataService.prototype.delete = function(dashboard_id) {
206206
/**
207207
* Creates a copy of the dashboard, with an optional new name.
208208
*
209-
* @param {!number} dashboard_id
209+
* @param {?string} dashboardId
210210
* @param {?string=} opt_title The name of the new dashboard. If omitted,
211211
* will have the same name as the original.
212212
* @return {!angular.$q.Promise}
213213
*/
214-
DashboardDataService.prototype.copy = function(dashboard_id, opt_title) {
214+
DashboardDataService.prototype.copy = function(dashboardId, opt_title) {
215+
if (!dashboardId) {
216+
throw 'DashboadDataService.copy() failed: Dashboard id is required.';
217+
}
218+
215219
return this.post(
216-
'/dashboard/copy', {id: dashboard_id, title: opt_title}, null);
220+
'/dashboard/copy', {id: dashboardId, title: opt_title}, null);
217221
};
218222

219223

220224
/**
221225
* Changes the name of a dashboard.
222226
*
223-
* @param {!number} dashboard_id
224-
* @param {!string} title The title of the new dashboard. If omitted, will
225-
* have the same title as the original.
227+
* @param {?string} dashboardId
228+
* @param {string} title The title of the new dashboard.
226229
* @return {!angular.$q.Promise}
227230
*/
228-
DashboardDataService.prototype.rename = function(dashboard_id, title) {
231+
DashboardDataService.prototype.rename = function(dashboardId, title) {
232+
if (!dashboardId) {
233+
throw 'DashboadDataService.rename() failed: Dashboard id is required.';
234+
}
235+
229236
return this.post(
230-
'/dashboard/rename', {id: dashboard_id, title: title}, null);
237+
'/dashboard/rename', {id: dashboardId, title: title}, null);
231238
};
232239

233240

234241
/**
235242
* Transfers a dashboard to a new owner, based on the provided email address.
236243
*
237-
* @param {!number} dashboard_id
238-
* @param {!string} new_owner_email The email address of the new owner. If
244+
* @param {?string} dashboardId
245+
* @param {string} newOwnerEmail The email address of the new owner. If
239246
* the email address cannot be resolved, no change will take place.
240247
* @return {!angular.$q.Promise}
241248
*/
242249
DashboardDataService.prototype.editOwner = function(
243-
dashboard_id, new_owner_email) {
250+
dashboardId, newOwnerEmail) {
251+
if (!dashboardId) {
252+
throw 'DashboadDataService.editOwner() failed: Dashboard id is required.';
253+
}
254+
244255
return this.post(
245256
'/dashboard/edit-owner',
246-
{id: dashboard_id, email: new_owner_email}, null);
257+
{id: dashboardId, email: newOwnerEmail}, null);
247258
};
248259

249260

250261
/**
251262
* Returns a list of dashboards.
252263
*
253-
* @param {boolean=} opt_mine If true, limits the list to items owned by the
264+
* @param {?boolean=} opt_mine If true, limits the list to items owned by the
254265
* current user. This setting is not useful is opt_owner is specified.
255-
* @param {string=} opt_owner If provided, limits the list to dashboards owned
266+
* @param {?string=} opt_owner If provided, limits the list to dashboards owned
256267
* by the provided email address.
257268
*
258269
* @return {!angular.$q.Promise}

client/components/dashboard/dashboard-directive.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@
2020

2121
goog.provide('p3rf.perfkit.explorer.components.dashboard.DashboardDirective');
2222

23+
goog.require('p3rf.perfkit.explorer.components.container.ContainerWidgetConfig');
2324
goog.require('p3rf.perfkit.explorer.components.dashboard.DashboardService');
2425
goog.require('p3rf.perfkit.explorer.models.ChartType');
26+
goog.require('p3rf.perfkit.explorer.models.WidgetConfig');
2527

2628

2729
goog.scope(function() {
2830
const explorer = p3rf.perfkit.explorer;
2931
const ChartType = explorer.models.ChartType;
32+
const ContainerWidgetConfig = explorer.components.container.ContainerWidgetConfig;
33+
const WidgetConfig = explorer.models.WidgetConfig;
3034

3135

3236
/**
@@ -112,7 +116,7 @@ explorer.components.dashboard.DashboardDirective = function() {
112116
/**
113117
* Returns true if the widget should scroll its overflow, otherwise stretch.
114118
* @param {!WidgetConfig} widget
115-
* @param {!ContainerConfig} container
119+
* @param {!ContainerWidgetConfig} container
116120
*/
117121
$scope.isWidgetScrollable = function(widget, container) {
118122
// TODO: Replace with data-driven constraints for visualizations that support scrolling.
@@ -132,7 +136,13 @@ explorer.components.dashboard.DashboardDirective = function() {
132136
}
133137
}
134138

135-
/** @export {number} */
139+
/**
140+
* Returns the effective width of a widget within a container.
141+
* @param {!WidgetConfig} widget
142+
* @param {!ContainerWidgetConfig} container
143+
* @return {number}
144+
* @export
145+
*/
136146
$scope.getWidgetFlexWidth = function(widget, container) {
137147
let widgetSpan = widget.model.layout.columnspan;
138148
let totalSpan = container.model.container.columns;

client/components/dashboard/dashboard-service.js

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const ChartWidgetConfig = explorer.models.ChartWidgetConfig;
5151
const ConfigService = explorer.components.config.ConfigService;
5252
const ContainerWidgetConfig = explorer.components.container.ContainerWidgetConfig;
5353
const DashboardInstance = explorer.components.dashboard.DashboardInstance;
54+
const DashboardModel = explorer.components.dashboard.DashboardModel;
5455
const DashboardParam = explorer.components.dashboard.DashboardParam;
5556
const DashboardDataService = explorer.components.dashboard.DashboardDataService;
5657
const 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
/**

client/components/dashboard/dashboard-version-model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const DashboardModel = explorer.components.dashboard.DashboardModel;
5050
explorer.components.dashboard.DashboardVersionModel = function(
5151
opt_version, opt_verify, opt_update) {
5252
/**
53-
* @type {?string}
53+
* @type {string}
5454
* @export
5555
*/
5656
this.version = opt_version || '';

client/components/dashboard/dashboard-version-service.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ explorer.components.dashboard.DashboardVersionService = function($filter) {
8787

8888
/**
8989
* The version to target for updates. By default, this is the most recent version.
90-
* @type {?DashboardVersionModel}
90+
* @type {!DashboardVersionModel}
9191
* @export
9292
*/
9393
this.currentVersion = this.versions[0];
@@ -112,15 +112,15 @@ DashboardVersionService.prototype.verifyAndUpdateModel = function(dashboard) {
112112
// If the version is not current, run the update script to bring the version
113113
// current.
114114
if (version == this.currentVersion) {
115-
if (!goog.isDef(dashboard.version)) {
116-
dashboard.version = version.version;
117-
}
115+
dashboard.version = version.version;
118116
} else {
119117
let dashboard_version_index = this.versions.indexOf(version);
118+
120119
let current_version_index = this.versions.indexOf(this.currentVersion);
121120

122121
for (let i = dashboard_version_index - 1; i >= current_version_index; --i) {
123122
let update_version = this.versions[i];
123+
124124
update_version.update(dashboard);
125125
dashboard.version = update_version.version;
126126
}

client/components/dashboard/dashboard-version-service_test.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,10 @@ describe('dashboardVersionService', function() {
101101
expect(svc.currentVersion).not.toBeNull();
102102
});
103103

104-
it('should update the email, config, custom_query and querystring.',
104+
it('should update the email, config and custom_query.',
105105
function() {
106106
providedDatasource = {
107-
'query': 'TEST_QUERY',
108-
'querystring': 'product_name=SAMPLE_PRODUCT'};
107+
'query': 'TEST_QUERY'};
109108

110109
providedDashboard = {
111110
'owner': 'TEST_OWNER',
@@ -123,7 +122,6 @@ describe('dashboardVersionService', function() {
123122

124123
expectedOwner = 'TEST_OWNER';
125124
expectedConfig = new QueryConfigModel();
126-
expectedConfig.filters.product_name = 'SAMPLE_PRODUCT';
127125

128126
svc.verifyAndUpdateModel(providedDashboard);
129127

@@ -137,8 +135,7 @@ describe('dashboardVersionService', function() {
137135

138136
it('should add a custom_query flag when no query is present.',
139137
function() {
140-
providedDatasource = {
141-
'querystring': 'product_name=SAMPLE_PRODUCT'};
138+
providedDatasource = {};
142139

143140
providedDashboard = {
144141
'owner': 'TEST_OWNER',
@@ -156,7 +153,6 @@ describe('dashboardVersionService', function() {
156153

157154
expectedOwner = 'TEST_OWNER';
158155
expectedConfig = new QueryConfigModel();
159-
expectedConfig.filters.product_name = 'SAMPLE_PRODUCT';
160156

161157
svc.verifyAndUpdateModel(providedDashboard);
162158

client/components/dashboard/versions/dashboard-schema_02.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ goog.scope(function() {
6565
if (!widget.datasource.config) {
6666
widget.datasource.config = new QueryConfigModel();
6767
}
68-
69-
// If a querystring is present, apply it to the config object.
70-
if (widget.datasource.querystring) {
71-
QueryConfigModel.applyQueryString(
72-
widget.datasource.config,
73-
widget.datasource.querystring);
74-
delete widget.datasource.querystring;
75-
}
7668
});
7769
};
7870
});

0 commit comments

Comments
 (0)