'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Licensed Materials - Property of IBM * IBM Business Analytics (C) Copyright IBM Corp. 2019 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['../../../lib/@waca/dashboard-common/dist/core/APIFactory', './DashboardPreferencesAPI'], function (APIFactory, DashboardPreferencesAPI) { var DashboardPreferences = function () { function DashboardPreferences() { _classCallCheck(this, DashboardPreferences); this._api = APIFactory.createAPI(this, [DashboardPreferencesAPI]); this._preferences = {}; } DashboardPreferences.prototype.initialize = function initialize() { try { var storageValue = window.localStorage.getItem('dashboardPreferences'); if (storageValue !== null) { try { this._preferences = JSON.parse(storageValue); } catch (err) { this._preferences = {}; } } return Promise.resolve(); } catch (err) { return Promise.reject(err); } }; DashboardPreferences.prototype.getAPI = function getAPI() { return this._api; }; DashboardPreferences.prototype.getPreference = function getPreference(name) { return this._preferences[name]; }; DashboardPreferences.prototype.setPreference = function setPreference(name, value) { this._preferences[name] = value; }; DashboardPreferences.prototype.savePreferences = function savePreferences() { var response = Promise.resolve(); try { window.localStorage.setItem('dashboardPreferences', JSON.stringify(this._preferences)); } catch (err) { response = Promise.reject(err); } return response; }; return DashboardPreferences; }(); return DashboardPreferences; }); //# sourceMappingURL=DashboardPreferences.js.map