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

Commit c50971c

Browse files
committed
Merge pull request #285 from GoogleCloudPlatform/dev-joemu-fix-copydash
Fix issues in Dashboard Admin toolbar for selected widgets.
2 parents c8f66a5 + 5a071da commit c50971c

5 files changed

Lines changed: 24 additions & 15 deletions

File tree

client/components/dashboard/dashboard-directive_test.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,25 @@ describe('dashboardDirective', function() {
3030
beforeEach(module('explorer'));
3131
beforeEach(module('p3rf.perfkit.explorer.templates'));
3232

33-
beforeEach(inject(function(_$rootScope_, _$compile_, _$httpBackend_,
34-
dashboardService, explorerService, chartTypeMockData) {
33+
beforeEach(inject(function(_$httpBackend_, _chartTypeMockData_) {
34+
chartTypeMockData = _chartTypeMockData_;
35+
$httpBackend = _$httpBackend_;
36+
37+
$httpBackend.whenGET(
38+
'/static/components/widget/data_viz/gviz/gviz-charts.json')
39+
.respond(200, chartTypeMockData);
40+
}));
41+
42+
beforeEach(inject(function(_$rootScope_, _$compile_,
43+
dashboardService, explorerService, chartWrapperService) {
3544
$rootScope = _$rootScope_;
3645
scope = _$rootScope_.$new();
3746
$compile = _$compile_;
38-
$httpBackend = _$httpBackend_;
3947

4048
dashboardSvc = dashboardService;
4149
explorerSvc = explorerService;
50+
51+
$httpBackend.flush();
4252
}));
4353

4454
describe('compilation', function() {
@@ -56,10 +66,6 @@ describe('dashboardDirective', function() {
5666
var mockEvent;
5767

5868
beforeEach(inject(function() {
59-
$httpBackend.whenGET(
60-
/\/static\/components\/widget\/data_viz\/gviz\/gviz-charts\.json/)
61-
.respond(chartTypeMockData);
62-
6369
explorerSvc.newDashboard();
6470
scope.$digest();
6571

client/components/dashboard_admin_page/dashboard-admin-page-controller.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ DashboardAdminPageCtrl.prototype.verifySelection = function() {
156156
if (!goog.isDefAndNotNull(selection)) {
157157
throw 'verifySelection() failed: No dashboard selected.';
158158
}
159-
160-
if (!goog.isNull(selection)) {
161-
throw 'verifySelection() failed: Dashboard not saved.';
162-
}
163159

164160
return selection;
165161
};

client/components/dashboard_admin_page/dashboard-admin-page-service.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ DashboardAdminPageService.prototype.addDashboard = function(dashboardJson) {
119119
dashboard.modified_date = new Date(dashboardJson.modified_date);
120120
}
121121

122-
console.log(dashboard);
123122
this.dashboards.push(dashboard);
124123
};
125124

client/components/widget/widget-service.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ explorer.components.widget.WidgetService = class {
103103
isCopyableAsImage(widget) {
104104
if (widget.model.type === this.widgetFactorySvc.widgetTypes.CHART) {
105105
let chartType = this.chartWrapperSvc.allChartsIndex[widget.model.chart.chartType];
106-
goog.asserts.assert(goog.isDefAndNotNull(chartType));
106+
goog.asserts.assert(
107+
goog.isDefAndNotNull(chartType),
108+
'Chart Type not valid: %s',
109+
[widget.model.chart.chartType]);
107110

108111
if (chartType.canScreenshot === true) {
109112
return true;

client/components/widget/widget-toolbar-directive_test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ goog.require('p3rf.perfkit.explorer.components.widget.WidgetToolbarDirective');
2323
goog.require('p3rf.perfkit.explorer.models.ChartWidgetConfig');
2424

2525
describe('WidgetToolbarDirective', function() {
26-
var scope, $compile, $timeout, uiConfig;
26+
var scope, $compile, $timeout, $httpBackend, uiConfig;
2727
var containerService, dashboardService, explorerService;
2828

2929
const explorer = p3rf.perfkit.explorer;
@@ -33,10 +33,11 @@ describe('WidgetToolbarDirective', function() {
3333
beforeEach(module('p3rf.perfkit.explorer.templates'));
3434

3535
beforeEach(inject(function(
36-
_$rootScope_, _$compile_, _$timeout_,
36+
_$rootScope_, _$compile_, _$timeout_, _$httpBackend_,
3737
_dashboardService_, _containerService_, _explorerService_) {
3838
scope = _$rootScope_.$new();
3939
$compile = _$compile_;
40+
$httpBackend = _$httpBackend_;
4041
$timeout = _$timeout_;
4142

4243
containerService = _containerService_;
@@ -45,6 +46,10 @@ describe('WidgetToolbarDirective', function() {
4546

4647
explorerService.newDashboard();
4748

49+
$httpBackend.expectGET(
50+
'/static/components/widget/data_viz/gviz/gviz-charts.json')
51+
.respond(200);
52+
4853
scope.$digest();
4954
}));
5055

0 commit comments

Comments
 (0)