Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View/edit modes for dashboard #10585

Merged
merged 17 commits into from
Mar 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ describe('dashboard panels', function () {
$route.current = {
locals: {
dash: dashboard
}
},
params: {}
};

$el = angular.element(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { DashboardState } from '../dashboard_state';

describe('DashboardState', function () {
let AppState;
let dashboardState;
let savedDashboard;
let SavedDashboard;
let timefilter;
let quickTimeRanges;

function initDashboardState() {
new DashboardState(savedDashboard, timefilter, true, quickTimeRanges, AppState);
dashboardState = new DashboardState(savedDashboard, AppState);
}

beforeEach(ngMock.module('kibana'));
Expand All @@ -23,72 +24,56 @@ describe('DashboardState', function () {
savedDashboard = new SavedDashboard();
}));

describe('timefilter', function () {

describe('when timeRestore is true', function () {
it('syncs quick time', function () {
savedDashboard.timeRestore = true;
savedDashboard.timeFrom = 'now/w';
savedDashboard.timeTo = 'now/w';

timefilter.time.from = '2015-09-19 06:31:44.000';
timefilter.time.to = '2015-09-29 06:31:44.000';
timefilter.time.mode = 'absolute';

initDashboardState();

expect(timefilter.time.mode).to.equal('quick');
expect(timefilter.time.to).to.equal('now/w');
expect(timefilter.time.from).to.equal('now/w');
});

it('syncs relative time', function () {
savedDashboard.timeRestore = true;
savedDashboard.timeFrom = 'now-13d';
savedDashboard.timeTo = 'now';
describe('syncTimefilterWithDashboard', function () {
it('syncs quick time', function () {
savedDashboard.timeRestore = true;
savedDashboard.timeFrom = 'now/w';
savedDashboard.timeTo = 'now/w';

timefilter.time.from = '2015-09-19 06:31:44.000';
timefilter.time.to = '2015-09-29 06:31:44.000';
timefilter.time.mode = 'absolute';
timefilter.time.from = '2015-09-19 06:31:44.000';
timefilter.time.to = '2015-09-29 06:31:44.000';
timefilter.time.mode = 'absolute';

initDashboardState();
initDashboardState();
dashboardState.syncTimefilterWithDashboard(timefilter, quickTimeRanges);

expect(timefilter.time.mode).to.equal('relative');
expect(timefilter.time.to).to.equal('now');
expect(timefilter.time.from).to.equal('now-13d');
});
expect(timefilter.time.mode).to.equal('quick');
expect(timefilter.time.to).to.equal('now/w');
expect(timefilter.time.from).to.equal('now/w');
});

it('syncs absolute time', function () {
savedDashboard.timeRestore = true;
savedDashboard.timeFrom = '2015-09-19 06:31:44.000';
savedDashboard.timeTo = '2015-09-29 06:31:44.000';
it('syncs relative time', function () {
savedDashboard.timeRestore = true;
savedDashboard.timeFrom = 'now-13d';
savedDashboard.timeTo = 'now';

timefilter.time.from = 'now/w';
timefilter.time.to = 'now/w';
timefilter.time.mode = 'quick';
timefilter.time.from = '2015-09-19 06:31:44.000';
timefilter.time.to = '2015-09-29 06:31:44.000';
timefilter.time.mode = 'absolute';

initDashboardState();
initDashboardState();
dashboardState.syncTimefilterWithDashboard(timefilter, quickTimeRanges);

expect(timefilter.time.mode).to.equal('absolute');
expect(timefilter.time.to).to.equal(savedDashboard.timeTo);
expect(timefilter.time.from).to.equal(savedDashboard.timeFrom);
});
expect(timefilter.time.mode).to.equal('relative');
expect(timefilter.time.to).to.equal('now');
expect(timefilter.time.from).to.equal('now-13d');
});

it('is not synced when timeRestore is false', function () {
savedDashboard.timeRestore = false;
savedDashboard.timeFrom = 'now/w';
savedDashboard.timeTo = 'now/w';
it('syncs absolute time', function () {
savedDashboard.timeRestore = true;
savedDashboard.timeFrom = '2015-09-19 06:31:44.000';
savedDashboard.timeTo = '2015-09-29 06:31:44.000';

timefilter.time.timeFrom = '2015-09-19 06:31:44.000';
timefilter.time.timeTo = '2015-09-29 06:31:44.000';
timefilter.time.mode = 'absolute';
timefilter.time.from = 'now/w';
timefilter.time.to = 'now/w';
timefilter.time.mode = 'quick';

initDashboardState();
dashboardState.syncTimefilterWithDashboard(timefilter, quickTimeRanges);

expect(timefilter.time.mode).to.equal('absolute');
expect(timefilter.time.timeFrom).to.equal('2015-09-19 06:31:44.000');
expect(timefilter.time.timeTo).to.equal('2015-09-29 06:31:44.000');
expect(timefilter.time.to).to.equal(savedDashboard.timeTo);
expect(timefilter.time.from).to.equal(savedDashboard.timeFrom);
});
});
});
11 changes: 10 additions & 1 deletion src/core_plugins/kibana/public/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
ng-model="model.query"
placeholder="Filter..."
aria-label="Filter input"
data-test-subj="dashboardQuery"
type="text"
class="kuiLocalSearchInput"
ng-class="{'kuiLocalSearchInput-isInvalid': queryInput.$invalid}"
Expand All @@ -41,6 +42,7 @@
type="submit"
aria-label="Filter Dashboards"
class="kuiLocalSearchButton"
data-test-subj="dashboardQueryFilterButton"
ng-disabled="queryInput.$invalid"
>
<span class="fa fa-search" aria-hidden="true"></span>
Expand All @@ -55,14 +57,20 @@
<!-- Filters. -->
<filter-bar state="state"></filter-bar>

<div ng-show="showEditHelpText()" class="text-center start-screen">
<div ng-show="getShouldShowEditHelp()" class="text-center start-screen">
<h2>This dashboard is empty. Let's fill it up!</h2>
<p>Click the <a class="btn btn-xs navbtn-inverse" ng-click="kbnTopNav.open('add'); toggleAddVisualization = !toggleAddVisualization" aria-label="Add visualization">Add</a> button in the menu bar above to add a visualization to the dashboard. <br/>If you haven't setup a visualization yet visit <a href="#/visualize" title="Visualize">"Visualize"</a> to create your first visualization.</p>
</div>

<div ng-show="getShouldShowViewHelp()" class="text-center start-screen">
<h2>This dashboard is empty. Let's fill it up!</h2>
<p>Click the <a class="btn btn-xs navbtn-inverse" ng-click="kbnTopNav.open('edit');" aria-label="Edit">Edit</a> button in the menu bar above to start working on your new dashboard.
</div>

<dashboard-grid
ng-show="!hasExpandedPanel()"
on-panel-removed="onPanelRemoved"
dashboard-view-mode="dashboardViewMode"
panels="panels"
get-vis-click-handler="getFilterBarClickHandler"
get-vis-brush-handler="getBrushEvent"
Expand All @@ -77,6 +85,7 @@ <h2>This dashboard is empty. Let's fill it up!</h2>
panel="expandedPanel"
is-full-screen-mode="!chrome.getVisible()"
is-expanded="true"
dashboard-view-mode="dashboardViewMode"
get-vis-click-handler="getFilterBarClickHandler"
get-vis-brush-handler="getBrushEvent"
save-state="saveState"
Expand Down
Loading