How to use electron-json-storage - 10 common examples

To help you get started, we’ve selected a few electron-json-storage 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 eNkru / electron-xiami / src / controller / app-tray-controller.js View on Github external
cleanupAndExit() {
    storage.clear((error) => {
      if (error) throw error;
      // console.log(app.getPath('userData'));
      app.exit(0);
    });
  }
}
github iamjohnbarker / button-switch / controller.js View on Github external
function recordStopStart() {
  if (recordingState == 0) {
    //wirecast.wirecastStartRecord();
    hyperdeck.record();
    //stopwatch.start();
    console.log( 'Started Recording' );
    recordingState = 1;
    tallyRecord.style.backgroundColor = "#ff4d4d";
    tallyRecord.innerText = "Stop";
    var d = new Date();
    var d2 = d.toISOString().slice(0,10);
    storage.get('recording-name', function(error, data) {
      if (error) throw error;
      tcToTxt.write(data.recordingName+" - "+d2+"\n");
    });
    for (var i = 0; i < 14; i++) {
      storage.get('sd'+i+'-button', function(error, data) {
        if (error) throw error;
        if (data.class == "hyperdeckRec") {
          var sd = data.name - 1 + 1;
          myStreamDeck.fillImageFromFile(sd, path.resolve(__dirname, 'assets/stream-deck/stop-red.png')).then(() => {
          });
        }
      });
    };

  } else {
    // STOP RECORDING
github OSDLabs / Open-Sesame / main.js View on Github external
storage.has('setup', function (error, hasKey) {
  if (error) {
    throw error;
  }
  if (!hasKey) {
    console.log('Application is yet to be setup.');
    // This method will be called when Electron has finished
    // initialization and is ready to create browser windows.
    // Some APIs can only be used after this event occurs.
    appCreate();
  } else {
    //Initiate endless poll
    setInterval(queryCheck, refreshinterval * 1000);
    queryCheck();
    storage.get('setup', function (error, data) {
      if (error) {
        throw error;
      }
      let userId = data.userId;
      let password = data.password;
      login(userId, password);
    });


  }
});
github Aveek-Saha / MusicPlayer / main.js View on Github external
function (filePath) {
      if (filePath) {
        // fs.writeFile('path.txt', filePath, function (err, data) {
        //   if (err) console.log(err);
        // });
        // console.log(walkSync(filePath[0]));

        storage.set('path', { path: filePath }, function (error) {
          if (error) throw error
        })

        scanDir(filePath)
      }
    }
  )
github mitchas / ffftp / app / controllers / base.js View on Github external
}).then((data) => {
      if (data.version !== $scope.appVersion.toString()) {
        $scope.showUpdate = true;
      }
    }, () => {
      console.log('Error getting update notification');
    });

    $scope.updateApp = () => {
      shell.openExternal('http://ffftp.site/download/' + $scope.appVersion);
    };

    // Load Favorites
    const storage = require('electron-json-storage');
    $scope.favorites = [];
    storage.has('favorites', (error, hasKey) => {
      if (error) throw error;

      if (hasKey) {
        storage.get('favorites', (error, data) => {
          if (error) throw error;

          $timeout(() => {
            $scope.favorites = data;
            console.log('FAVORITES');
            console.log(data);
          }, 0);
        });
      } else {
        console.log('No favs');
      }
    });
github gielcobben / caption / main.development.js View on Github external
Storage.get("moveApp", async (error, value) => {
          if (value) {
            try {
              const moved = await moveToApplications();
            } catch (error) {
              console.log(error);
            }
          } else {
            console.log("user choosed to not move the app!");
          }
        });
      }
    });

    // Set default property for nothing-found-window
    Storage.has("noting-found-window", (error, hasKey) => {
      if (error) throw error;
      if (!hasKey) {
        Storage.set("noting-found-window", true, error => {
          if (error) throw error;
          nothingFoundWindowValue = true;
        });
      }
    });
  }

  app.setAboutPanelOptions({
    applicationName: "Caption",
    applicationVersion: pkg.version,
    copyright: "Made with 💖 by Giel Cobben. \n www.gielcobben.com",
    credits: `With the invaluable help of: \n OpenSubtitles.org and Addic7ed.com`,
    version: pkg.version
github yafp / ttth / app / js / ttth / ttth.js View on Github external
function updateAllUserServiceConfigurationsSince_1_9_0 () {
    // 1.9.0 introduced userAgents per service. See #158
    // TODO:
    // patch all user-services:
    // add: userAgentDefault

    const storage = require('electron-json-storage')

    writeLog('info', 'updateAllUserServiceConfigurationsSince_1_9_0 ::: Starting to validate all user service configurations')

    // loop over all json files - and see if we need to patch something
    storage.getAll(function (error, data) {
        if (error) {
            writeLog('error', 'updateAllUserServiceConfigurationsSince_1_9_0 ::: Got error while trying to fetch all service configs. Error: ' + error)
            throw error
        }

        // show object which contains all config files
        // writeLog("info", "loadEnabledUserServices ::: Object: " + data);
        // console.error(data);

        var userAgentDefaultMissing
        var newUserAgentDefaultString
        var userAgentCustomMissing
        var userUserAgentCustomString

        // loop over upper object
        for (var key in data) {
github yafp / ttth / app / js / ttth / ttth.js View on Github external
function loadEnabledUserServices () {
    const storage = require('electron-json-storage')

    writeLog('info', 'loadEnabledUserServices ::: Starting to fetch all user configured service files')

    // loop over all json files - add tab for the enabled ones
    storage.getAll(function (error, data) {
        if (error) {
            throw error
        }

        // show object which contains all config files
        // writeLog("info", "loadEnabledUserServices ::: Object: " + data);
        // console.error(data);

        // loop over upper object
        for (var key in data) {
            if (data.hasOwnProperty(key)) {
                writeLog('info', 'loadEnabledUserServices ::: ' + key)
                writeLog('info', 'loadEnabledUserServices ::: ' + key + ' -> ' + data[key])

                // show enabled configured service
                if (data[key].serviceEnableStatus === true) {
github yafp / ttth / app / js / ttth / ttth.js View on Github external
function updateAllUserServiceConfigurationsSince_1_8_0 () {
    // changes from 1.7.0 to 1.8.0:
    // - inject files got re-structured. Path & names are stored in the user-services configuration files
    //
    const storage = require('electron-json-storage')

    writeLog('info', 'updateAllUserServiceConfigurationsSince_1_8_0 ::: Starting to validate all user service configurations')

    // loop over all json files - and see if we need to patch something
    storage.getAll(function (error, data) {
        if (error) {
            writeLog('error', 'updateAllUserServiceConfigurationsSince_1_8_0 ::: Got error while trying to fetch all service configs. Error: ' + error)
            throw error
        }

        // show object which contains all config files
        // writeLog("info", "loadEnabledUserServices ::: Object: " + data);
        // console.error(data);

        var shouldConfigBeUpdated = false
        var newInjectCodePath

        // loop over upper object
        for (var key in data) {
            if (data.hasOwnProperty(key)) {
                writeLog('info', 'updateAllUserServiceConfigurationsSince_1_8_0 ::: ' + key + ' -> ' + data[key])
github iamjohnbarker / button-switch / controller.js View on Github external
const path = require('path');
const StreamDeck = require('elgato-stream-deck');
const fs = require('fs');
const homedir = require('homedir');
const objChange = require('object-change');


// CREATE TXT FILE FOR MARKERS
var tcToTxt = fs.createWriteStream(homedir()+'/desktop/button-switch-log.txt', {
  flags: 'a' // 'a' means appending (old data will be preserved)
});


// SETTINGS JSON FILE //
// GRAB SAVED IP ADDRESS FROM STORAGE
const dataPath = storage.getDataPath();
//console.log(dataPath);
storage.get('atem-ip-address', function(error, data) {
  if (error) throw error;
  if (data.atemIPAddress === undefined) {
    document.getElementById('idAddressInput').value = "";
  } else {
    document.getElementById('idAddressInput').value = data.atemIPAddress;
  };
});
storage.get('hyperdeck-ip-address', function(error, data) {
  if (error) throw error;
  if (data.hyperdeckIPAddress === undefined) {
    document.getElementById('ipAddressInputHyperDeck').value = "";
  } else {
    document.getElementById('ipAddressInputHyperDeck').value = data.hyperdeckIPAddress;
  };