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

Commit

Permalink
Merge pull request #285 from GoogleCloudPlatform/dev-joemu-fix-copydash
Browse files Browse the repository at this point in the history
Fix issues in Dashboard Admin toolbar for selected widgets.
  • Loading branch information
jmuharsky committed Jun 2, 2016
2 parents c8f66a5 + 5a071da commit c50971c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
20 changes: 13 additions & 7 deletions client/components/dashboard/dashboard-directive_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,25 @@ describe('dashboardDirective', function() {
beforeEach(module('explorer'));
beforeEach(module('p3rf.perfkit.explorer.templates'));

beforeEach(inject(function(_$rootScope_, _$compile_, _$httpBackend_,
dashboardService, explorerService, chartTypeMockData) {
beforeEach(inject(function(_$httpBackend_, _chartTypeMockData_) {
chartTypeMockData = _chartTypeMockData_;
$httpBackend = _$httpBackend_;

$httpBackend.whenGET(
'/static/components/widget/data_viz/gviz/gviz-charts.json')
.respond(200, chartTypeMockData);
}));

beforeEach(inject(function(_$rootScope_, _$compile_,
dashboardService, explorerService, chartWrapperService) {
$rootScope = _$rootScope_;
scope = _$rootScope_.$new();
$compile = _$compile_;
$httpBackend = _$httpBackend_;

dashboardSvc = dashboardService;
explorerSvc = explorerService;

$httpBackend.flush();
}));

describe('compilation', function() {
Expand All @@ -56,10 +66,6 @@ describe('dashboardDirective', function() {
var mockEvent;

beforeEach(inject(function() {
$httpBackend.whenGET(
/\/static\/components\/widget\/data_viz\/gviz\/gviz-charts\.json/)
.respond(chartTypeMockData);

explorerSvc.newDashboard();
scope.$digest();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ DashboardAdminPageCtrl.prototype.verifySelection = function() {
if (!goog.isDefAndNotNull(selection)) {
throw 'verifySelection() failed: No dashboard selected.';
}

if (!goog.isNull(selection)) {
throw 'verifySelection() failed: Dashboard not saved.';
}

return selection;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ DashboardAdminPageService.prototype.addDashboard = function(dashboardJson) {
dashboard.modified_date = new Date(dashboardJson.modified_date);
}

console.log(dashboard);
this.dashboards.push(dashboard);
};

Expand Down
5 changes: 4 additions & 1 deletion client/components/widget/widget-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ explorer.components.widget.WidgetService = class {
isCopyableAsImage(widget) {
if (widget.model.type === this.widgetFactorySvc.widgetTypes.CHART) {
let chartType = this.chartWrapperSvc.allChartsIndex[widget.model.chart.chartType];
goog.asserts.assert(goog.isDefAndNotNull(chartType));
goog.asserts.assert(
goog.isDefAndNotNull(chartType),
'Chart Type not valid: %s',
[widget.model.chart.chartType]);

if (chartType.canScreenshot === true) {
return true;
Expand Down
9 changes: 7 additions & 2 deletions client/components/widget/widget-toolbar-directive_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ goog.require('p3rf.perfkit.explorer.components.widget.WidgetToolbarDirective');
goog.require('p3rf.perfkit.explorer.models.ChartWidgetConfig');

describe('WidgetToolbarDirective', function() {
var scope, $compile, $timeout, uiConfig;
var scope, $compile, $timeout, $httpBackend, uiConfig;
var containerService, dashboardService, explorerService;

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

beforeEach(inject(function(
_$rootScope_, _$compile_, _$timeout_,
_$rootScope_, _$compile_, _$timeout_, _$httpBackend_,
_dashboardService_, _containerService_, _explorerService_) {
scope = _$rootScope_.$new();
$compile = _$compile_;
$httpBackend = _$httpBackend_;
$timeout = _$timeout_;

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

explorerService.newDashboard();

$httpBackend.expectGET(
'/static/components/widget/data_viz/gviz/gviz-charts.json')
.respond(200);

scope.$digest();
}));

Expand Down

0 comments on commit c50971c

Please sign in to comment.