Files
redash/client/app/lib/localOptions.js
Arik Fraimovich bac90db3ee Autocomplete toggle improvements (#3091)
* Autocomplete toggle improvements:

* Refactor to its own component.
* Show state in tooltip (enabled/disabled).
* Disable the toggle if autocomplete is not possible (no schema/too many tokens).

* Remove unsued code.

* Custom icons font (currently has only two icons).

Generated with Icomoon. If we extend its use, we should probably automate this and move to its own package.

* Don't disable live autocomplete for data sources without schema.

It can still be useful to autocomplete from local keywords.

* Differentiate between autocomplete toggle states with an icon.

Also added explicit message for the disabled state.

* Remember thes state of autocomplete.

* Only auto register init functions.
2018-11-20 18:45:33 +02:00

20 lines
401 B
JavaScript

const PREFIX = 'localOptions:';
function get(key, defaultValue = undefined) {
const fullKey = PREFIX + key;
if (fullKey in window.localStorage) {
return JSON.parse(window.localStorage.getItem(fullKey));
}
return defaultValue;
}
function set(key, value) {
const fullKey = PREFIX + key;
window.localStorage.setItem(fullKey, JSON.stringify(value));
}
export default {
get,
set,
};