How to use the api/apiHelper.getFromTotalStorage function in api

To help you get started, we’ve selected a few api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudera / hue / desktop / core / src / desktop / js / ko / components / ko.contextSelector.js View on Github external
return;
        }

        // In some cases we could have a namespace or compute without the name attribute, or the name might have changed.
        if (self[type.name]() && !self[type.name]().name) {
          available.some(other => {
            if (other !== self[type.name]() && other.id === self[type.name]().id) {
              self[type.name](other);
              return true;
            }
          });
        }

        if (
          !self[type.name]() &&
          apiHelper.getFromTotalStorage('contextSelector', type.totalStorageId)
        ) {
          const lastSelected = apiHelper.getFromTotalStorage(
            'contextSelector',
            type.totalStorageId
          );
          const found = available.some(other => {
            if (other.id === lastSelected.id) {
              self[type.name](other);
              return true;
            }
          });

          // If we can't find the last selected cluster or compute we try to find by type
          if (
            !found &&
            lastSelected &&
github cloudera / hue / desktop / core / src / desktop / js / ko / bindings / ace / ko.aceEditor.js View on Github external
const aceWarningsSub = snippet.aceWarnings.subscribe(newWarnings => {
      processErrorsAndWarnings('warning', newWarnings);
    });

    const aceErrorsSub = snippet.aceErrors.subscribe(newErrors => {
      processErrorsAndWarnings('error', newErrors);
    });

    disposeFunctions.push(() => {
      errorsSub.dispose();
      aceWarningsSub.dispose();
      aceErrorsSub.dispose();
    });

    let darkThemeEnabled = apiHelper.getFromTotalStorage('ace', 'dark.theme.enabled', false);
    editor.setTheme(darkThemeEnabled ? 'ace/theme/hue_dark' : 'ace/theme/hue');

    const editorOptions = {
      enableSnippets: true,
      showGutter: false,
      showLineNumbers: false,
      showPrintMargin: false,
      scrollPastEnd: 0.1,
      minLines: 1,
      maxLines: 25
    };

    editor.enabledMenuOptions = {
      setShowInvisibles: true,
      setTabSize: true,
      setShowGutter: true
github cloudera / hue / desktop / core / src / desktop / js / ko / components / ko.performanceGraph.js View on Github external
})
              .attr('r', 4)
              .attr(
                'transform',
                'translate(' + mainXScale(dataPoint[0]) + ',' + options.y(dataPoint) + ')'
              );
          }
        }
      };
    };

    const graphs = [
      createLineGraph({
        id: 'queries',
        label: I18n('Queries'),
        enabled: apiHelper.getFromTotalStorage('warehouses', 'queriesGraphEnabled', true),
        color: '#A9DBF1',
        subLineColor: '#DCDCDC',
        area: true,
        subLine: true,
        tooltip: function(d) {
          return d[4] + (d[5] ? ' (' + d[5] + ' ' + I18n('queued') : '');
        },
        y: function(d) {
          return queryYScale(d[4]);
        },
        subY: function(d) {
          return subQueryYScale(d[4]);
        },
        stackedGraph: function() {
          return createLineGraph({
            id: 'query-count-queued',
github cloudera / hue / desktop / core / src / desktop / js / apps / notebook / editorViewModel.js View on Github external
self.assistAvailable = ko.observable(options.assistAvailable);

    self.assistWithoutStorage = ko.observable(false);

    self.isLeftPanelVisible = ko.observable(
      apiHelper.getFromTotalStorage('assist', 'assist_panel_visible', true)
    );
    self.isLeftPanelVisible.subscribe(val => {
      if (!self.assistWithoutStorage()) {
        apiHelper.setInTotalStorage('assist', 'assist_panel_visible', val);
      }
    });

    self.isRightPanelAvailable = ko.observable(options.assistAvailable && HAS_OPTIMIZER);
    self.isRightPanelVisible = ko.observable(
      apiHelper.getFromTotalStorage('assist', 'right_assist_panel_visible', true)
    );
    self.isRightPanelVisible.subscribe(val => {
      if (!self.assistWithoutStorage()) {
        apiHelper.setInTotalStorage('assist', 'right_assist_panel_visible', val);
      }
    });

    const withActiveSnippet = function(callback) {
      const notebook = self.selectedNotebook();
      let foundSnippet;
      if (notebook) {
        if (notebook.snippets().length === 1) {
          foundSnippet = notebook.snippets()[0];
        } else {
          notebook.snippets().every(snippet => {
            if (snippet.inFocus()) {
github cloudera / hue / desktop / core / src / desktop / js / apps / table_browser / metastoreNamespace.js View on Github external
const whenLoaded = clearCacheOnMissing => {
      if (!databaseName) {
        databaseName =
          apiHelper.getFromTotalStorage('editor', 'last.selected.database') ||
          apiHelper.getFromTotalStorage('metastore', 'last.selected.database') ||
          'default';
        clearCacheOnMissing = false;
      }
      if (this.database() && this.database().catalogEntry.name === databaseName) {
        if (callback) {
          callback();
        }
        return;
      }
      let foundDatabases = this.databases().filter(
        database => database.catalogEntry.name === databaseName
      );

      if (foundDatabases.length === 1) {
        this.setDatabase(foundDatabases[0], callback);
      } else if (clearCacheOnMissing) {
github cloudera / hue / desktop / core / src / desktop / js / ko / components / assist / ko.assistHBasePanel.js View on Github external
root.loadEntries(() => {
        const lastOpenendPath = apiHelper.getFromTotalStorage(
          'assist',
          'last.opened.hbase.entry',
          null
        );
        if (lastOpenendPath) {
          root.entries().every(entry => {
            if (entry.path === lastOpenendPath) {
              entry.open();
              return false;
            }
            return true;
          });
        }
      });
    };
github cloudera / hue / desktop / core / src / desktop / js / ko / components / contextPopover / ko.contextPopover.js View on Github external
constructor(params) {
    const self = this;
    self.disposals = [];

    self.left = ko.observable(0);
    self.top = ko.observable(0);

    const popoverSize = apiHelper.getFromTotalStorage('assist', 'popover.size', {
      width: 450,
      height: 400
    });

    self.width = ko.observable(popoverSize.width);
    self.height = ko.observable(popoverSize.height);

    self.leftAdjust = ko.observable(0);
    self.topAdjust = ko.observable(0);
    self.data = params.data;
    self.sourceType = params.sourceType;
    self.namespace = params.namespace;
    self.compute = params.compute;
    self.defaultDatabase = params.defaultDatabase;
    self.close = hidePopover;
    self.onSampleClick = params.onSampleClick;
github cloudera / hue / desktop / core / src / desktop / js / ko / components / assist / assistDbNamespace.js View on Github external
self.setDatabase = databaseName => {
      if (
        databaseName &&
        self.selectedDatabase() &&
        databaseName === self.selectedDatabase().catalogEntry.name
      ) {
        return;
      }
      if (databaseName && self.dbIndex[databaseName]) {
        self.selectedDatabase(self.dbIndex[databaseName]);
        self.selectedDatabaseChanged();
        return;
      }
      const lastSelectedDb = apiHelper.getFromTotalStorage(
        'assist_' + self.sourceType + '_' + self.namespace.id,
        'lastSelectedDb',
        'default'
      );
      if (lastSelectedDb && self.dbIndex[lastSelectedDb]) {
        self.selectedDatabase(self.dbIndex[lastSelectedDb]);
        self.selectedDatabaseChanged();
      } else if (self.databases().length > 0) {
        self.selectedDatabase(self.databases()[0]);
        self.selectedDatabaseChanged();
      }
    };
github cloudera / hue / desktop / core / src / desktop / js / ko / bindings / ace / ko.aceEditor.js View on Github external
return errorHighlightingEnabled;
      };
      editor.customMenuOptions.setClearIgnoredSyntaxChecks = function() {
        apiHelper.setInTotalStorage('hue.syntax.checker', 'suppressedRules', {});
        $('#setClearIgnoredSyntaxChecks')
          .hide()
          .before('<div style="margin-top:5px;float:right;">done</div>');
      };
      editor.customMenuOptions.getClearIgnoredSyntaxChecks = function() {
        return false;
      };
    }

    $.extend(editorOptions, aceOptions);

    editorOptions['enableBasicAutocompletion'] = apiHelper.getFromTotalStorage(
      'hue.ace',
      'enableBasicAutocompletion',
      true
    );
    if (editorOptions['enableBasicAutocompletion']) {
      editorOptions['enableLiveAutocompletion'] = apiHelper.getFromTotalStorage(
        'hue.ace',
        'enableLiveAutocompletion',
        true
      );
    }

    editor.setOptions(editorOptions);

    const AceAutocomplete = ace.require('ace/autocomplete').Autocomplete;
github cloudera / hue / desktop / core / src / desktop / js / ko / components / assist / assistDbSource.js View on Github external
constructor(options) {
    const self = this;

    self.sourceType = options.type;
    self.name = options.name;
    self.i18n = options.i18n;
    self.nonSqlType = options.nonSqlType;
    self.navigationSettings = options.navigationSettings;
    self.initialNamespace =
      options.initialNamespace ||
      apiHelper.getFromTotalStorage('contextSelector', 'lastSelectedNamespace');
    self.initialCompute =
      options.initialCompute ||
      apiHelper.getFromTotalStorage('contextSelector', 'lastSelectedCompute');

    self.selectedNamespace = ko.observable();
    self.namespaces = ko.observableArray();

    self.loadedDeferred = $.Deferred();
    self.loading = ko.observable(false);
    self.hasErrors = ko.observable(false);

    self.filter = {
      querySpec: ko.observable({}).extend({ rateLimit: 300 })
    };

    self.filteredNamespaces = ko.pureComputed(() => {
      if (
        !self.filter.querySpec() ||
        typeof self.filter.querySpec().query === 'undefined' ||