feat(dashlist): stores recently visited dashboards per orgid
This commit is contained in:
@@ -2,14 +2,16 @@
|
||||
|
||||
import store from 'app/core/store';
|
||||
import _ from 'lodash';
|
||||
import config from 'app/core/config';
|
||||
|
||||
export class ImpressionsStore {
|
||||
constructor() {}
|
||||
|
||||
addDashboardImpression(dashboardId) {
|
||||
var impressionsKey = this.impressionKey(config);
|
||||
var impressions = [];
|
||||
if (store.exists("dashboard_impressions")) {
|
||||
impressions = JSON.parse(store.get("dashboard_impressions"));
|
||||
if (store.exists(impressionsKey)) {
|
||||
impressions = JSON.parse(store.get(impressionsKey));
|
||||
if (!_.isArray(impressions)) {
|
||||
impressions = [];
|
||||
}
|
||||
@@ -24,11 +26,11 @@ export class ImpressionsStore {
|
||||
if (impressions.length > 50) {
|
||||
impressions.pop();
|
||||
}
|
||||
store.set("dashboard_impressions", JSON.stringify(impressions));
|
||||
store.set(impressionsKey, JSON.stringify(impressions));
|
||||
}
|
||||
|
||||
getDashboardOpened() {
|
||||
var impressions = store.get("dashboard_impressions") || "[]";
|
||||
var impressions = store.get(this.impressionKey(config)) || "[]";
|
||||
|
||||
impressions = JSON.parse(impressions);
|
||||
|
||||
@@ -38,6 +40,10 @@ export class ImpressionsStore {
|
||||
|
||||
return impressions;
|
||||
}
|
||||
|
||||
impressionKey(config) {
|
||||
return "dashboard_impressions-" + config.bootData.user.orgId;
|
||||
}
|
||||
}
|
||||
|
||||
var impressions = new ImpressionsStore();
|
||||
|
||||
Reference in New Issue
Block a user