Commit ed1864e0 by bergquist

feat(dashlist): stores recently visited dashboards per orgid

parent 0998ce81
...@@ -2,14 +2,16 @@ ...@@ -2,14 +2,16 @@
import store from 'app/core/store'; import store from 'app/core/store';
import _ from 'lodash'; import _ from 'lodash';
import config from 'app/core/config';
export class ImpressionsStore { export class ImpressionsStore {
constructor() {} constructor() {}
addDashboardImpression(dashboardId) { addDashboardImpression(dashboardId) {
var impressionsKey = this.impressionKey(config);
var impressions = []; var impressions = [];
if (store.exists("dashboard_impressions")) { if (store.exists(impressionsKey)) {
impressions = JSON.parse(store.get("dashboard_impressions")); impressions = JSON.parse(store.get(impressionsKey));
if (!_.isArray(impressions)) { if (!_.isArray(impressions)) {
impressions = []; impressions = [];
} }
...@@ -24,11 +26,11 @@ export class ImpressionsStore { ...@@ -24,11 +26,11 @@ export class ImpressionsStore {
if (impressions.length > 50) { if (impressions.length > 50) {
impressions.pop(); impressions.pop();
} }
store.set("dashboard_impressions", JSON.stringify(impressions)); store.set(impressionsKey, JSON.stringify(impressions));
} }
getDashboardOpened() { getDashboardOpened() {
var impressions = store.get("dashboard_impressions") || "[]"; var impressions = store.get(this.impressionKey(config)) || "[]";
impressions = JSON.parse(impressions); impressions = JSON.parse(impressions);
...@@ -38,6 +40,10 @@ export class ImpressionsStore { ...@@ -38,6 +40,10 @@ export class ImpressionsStore {
return impressions; return impressions;
} }
impressionKey(config) {
return "dashboard_impressions-" + config.bootData.user.orgId;
}
} }
var impressions = new ImpressionsStore(); var impressions = new ImpressionsStore();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment