mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
parent
df8e56ddf8
commit
ad9b2ab617
@ -16,5 +16,5 @@ define([
|
|||||||
'./graphiteImportCtrl',
|
'./graphiteImportCtrl',
|
||||||
'./dynamicDashboardSrv',
|
'./dynamicDashboardSrv',
|
||||||
'./importCtrl',
|
'./importCtrl',
|
||||||
'./impressionStore',
|
'./impression_store',
|
||||||
], function () {});
|
], function () {});
|
||||||
|
@ -5,7 +5,7 @@ define([
|
|||||||
'jquery',
|
'jquery',
|
||||||
'app/core/utils/kbn',
|
'app/core/utils/kbn',
|
||||||
'app/core/utils/datemath',
|
'app/core/utils/datemath',
|
||||||
'./impressionStore',
|
'./impression_store',
|
||||||
],
|
],
|
||||||
function (angular, moment, _, $, kbn, dateMath, impressionStore) {
|
function (angular, moment, _, $, kbn, dateMath, impressionStore) {
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -41,7 +41,7 @@ function (angular, moment, _, $, kbn, dateMath, impressionStore) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
promise.then(function(result) {
|
promise.then(function(result) {
|
||||||
impressionStore.impressions.addDashboardImpression(slug);
|
impressionStore.impressions.addDashboardImpression(result);
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@ import _ from 'lodash';
|
|||||||
export class ImpressionsStore {
|
export class ImpressionsStore {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
addDashboardImpression(slug) {
|
addDashboardImpression(impression) {
|
||||||
|
console.log(impression);
|
||||||
var impressions = [];
|
var impressions = [];
|
||||||
if (store.exists("dashboard_impressions")) {
|
if (store.exists("dashboard_impressions")) {
|
||||||
impressions = JSON.parse(store.get("dashboard_impressions"));
|
impressions = JSON.parse(store.get("dashboard_impressions"));
|
||||||
@ -15,12 +16,14 @@ export class ImpressionsStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var exists = impressions.indexOf(slug);
|
impressions = impressions.filter((imp) => {
|
||||||
if (exists >= 0) {
|
return impression.meta.slug !== imp.slug;
|
||||||
impressions.splice(exists, 1);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
impressions.unshift(slug);
|
impressions.unshift({
|
||||||
|
title: impression.dashboard.title,
|
||||||
|
slug: impression.meta.slug
|
||||||
|
});
|
||||||
|
|
||||||
if (impressions.length > 20) {
|
if (impressions.length > 20) {
|
||||||
impressions.shift();
|
impressions.shift();
|
@ -3,7 +3,7 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import {PanelCtrl} from 'app/plugins/sdk';
|
import {PanelCtrl} from 'app/plugins/sdk';
|
||||||
import {impressions} from 'app/features/dashboard/impressionStore';
|
import {impressions} from 'app/features/dashboard/impression_store';
|
||||||
|
|
||||||
// Set and populate defaults
|
// Set and populate defaults
|
||||||
var panelDefaults = {
|
var panelDefaults = {
|
||||||
@ -45,8 +45,8 @@ class DashListCtrl extends PanelCtrl {
|
|||||||
if (this.panel.mode === 'last viewed') {
|
if (this.panel.mode === 'last viewed') {
|
||||||
var dashListNames = _.first(impressions.getDashboardOpened(), this.panel.limit).map((dashboard) => {
|
var dashListNames = _.first(impressions.getDashboardOpened(), this.panel.limit).map((dashboard) => {
|
||||||
return {
|
return {
|
||||||
title: dashboard,
|
title: dashboard.title,
|
||||||
uri: 'db/' + dashboard
|
uri: 'db/' + dashboard.slug
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user