Fullscreen & edit state persisted to url is nearing completion, refactored fullscreen state management to a special dashboardViewState object, Issue #672

This commit is contained in:
Torkel Ödegaard
2014-08-13 10:07:32 +02:00
parent ec99096d52
commit fc686ca618
11 changed files with 75 additions and 26 deletions

View File

@@ -78,5 +78,35 @@ define([
});
describe('when updating view state', function() {
var viewState, location;
beforeEach(module('grafana.services'));
beforeEach(inject(function(dashboardSrv, $location) {
viewState = dashboardSrv.createViewState();
location = $location;
}));
describe('to fullscreen true and edit true', function() {
it('should update querystring and view state', function() {
var updateState = { fullscreen: true, edit: true, panelId: 1 };
viewState.update(updateState);
expect(location.search()).to.eql(updateState);
expect(viewState).to.eql(updateState);
});
});
describe('to fullscreen false', function() {
it('should remove params from query string', function() {
viewState.update({fullscreen: true, panelId: 1, edit: true});
viewState.update({fullscreen: false});
expect(location.search()).to.eql({});
expect(viewState).to.eql({});
});
});
});
});

View File

@@ -26,6 +26,7 @@ define([
self.scope.panel = {};
self.scope.row = { panels:[] };
self.scope.filter = new FilterSrvStub();
self.scope.dashboardViewState = { update: function() {} };
$rootScope.colors = [];
for (var i = 0; i < 50; i++) { $rootScope.colors.push('#' + i); }