Basic setup
This commit is contained in:
69
app/services/storage.js
Normal file
69
app/services/storage.js
Normal file
@@ -0,0 +1,69 @@
|
||||
import Service from '@ember/service';
|
||||
import RemoteStorage from 'npm:remotestoragejs';
|
||||
import Widget from 'npm:remotestorage-widget';
|
||||
|
||||
export default Service.extend({
|
||||
|
||||
rs: null,
|
||||
widget: null,
|
||||
connecting: true,
|
||||
connected: false,
|
||||
|
||||
setup: function() {
|
||||
const rs = new RemoteStorage({
|
||||
cache: false
|
||||
});
|
||||
this.set('rs', rs);
|
||||
|
||||
rs.access.claim('*', 'rw');
|
||||
|
||||
// rs.setApiKeys({
|
||||
// dropbox: config.dropboxAppKey,
|
||||
// googledrive: config.gdriveClientId
|
||||
// });
|
||||
|
||||
const widget = new Widget(rs, {
|
||||
leaveOpen: true
|
||||
});
|
||||
this.set('widget', widget);
|
||||
|
||||
// Attach widget to DOM
|
||||
widget.attach();
|
||||
|
||||
rs.on('ready', () => {
|
||||
console.debug('rs.on ready');
|
||||
// this.set('connecting', false);
|
||||
});
|
||||
|
||||
rs.on('connected', () => {
|
||||
console.debug('rs.on connected');
|
||||
this.set('connecting', false);
|
||||
this.set('connected', true);
|
||||
});
|
||||
|
||||
rs.on('not-connected', () => {
|
||||
console.debug('rs.on not-connected');
|
||||
this.set('connecting', false);
|
||||
this.set('connected', false);
|
||||
});
|
||||
|
||||
rs.on('disconnected', () => {
|
||||
console.debug('rs.on disconnected');
|
||||
this.set('connecting', false);
|
||||
this.set('connected', false);
|
||||
});
|
||||
|
||||
rs.on('connecting', () => {
|
||||
console.debug('rs.on connecting');
|
||||
this.set('connecting', true);
|
||||
this.set('connected', false);
|
||||
});
|
||||
|
||||
rs.on('authing', () => {
|
||||
console.debug('rs.on authing');
|
||||
this.set('connecting', true);
|
||||
this.set('connected', false);
|
||||
});
|
||||
}.on('init')
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user