Basic RS setup

This commit is contained in:
Basti 2017-11-08 00:55:11 +01:00
parent 42c657adf3
commit 5926575d50
13 changed files with 89 additions and 6 deletions

View File

@ -0,0 +1,12 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { alias } from '@ember/object/computed';
export default Controller.extend({
storage: service(),
connecting: alias('storage.connecting'),
connected: alias('storage.connected')
});

4
app/controllers/index.js Normal file
View File

@ -0,0 +1,4 @@
import Controller from '@ember/controller';
export default Controller.extend({
});

View File

@ -6,7 +6,6 @@ const Router = EmberRouter.extend({
rootURL: config.rootURL
});
Router.map(function() {
});
Router.map(function() {});
export default Router;

View File

@ -0,0 +1,5 @@
import Route from '@ember/routing/route';
export default Route.extend({
});

8
app/routes/index.js Normal file
View File

@ -0,0 +1,8 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default Route.extend({
storage: service()
});

View File

@ -13,7 +13,6 @@ export default Service.extend({
const rs = new RemoteStorage({
cache: false
});
this.set('rs', rs);
rs.access.claim('*', 'rw');
@ -25,7 +24,6 @@ export default Service.extend({
const widget = new Widget(rs, {
leaveOpen: true
});
this.set('widget', widget);
// Attach widget to DOM
widget.attach();
@ -64,6 +62,9 @@ export default Service.extend({
this.set('connecting', true);
this.set('connected', false);
});
this.set('rs', rs);
this.set('widget', widget);
}.on('init')
});

View File

@ -6,3 +6,9 @@ body {
font-family: sans-serif;
color: #222;
}
#remotestorage-widget {
position: fixed;
top: 0.5rem;
right: 0.5rem;
}

View File

@ -1,3 +1,13 @@
<h2 id="title">Welcome to Ember</h2>
<h2 id="title">Inspektor</h2>
{{#if connecting}}
Connecting...
{{else}}
{{#if connected}}
Connected.
{{else}}
Not connected.
{{/if}}
{{/if}}
{{outlet}}

3
app/templates/index.hbs Normal file
View File

@ -0,0 +1,3 @@
index.hbs
{{outlet}}

View File

@ -43,6 +43,6 @@
"remotestoragejs": "^1.0.0"
},
"engines": {
"node": "^4.5 || 6.* || >= 7.*"
"node": "6.* || >= 7.*"
}
}

View File

@ -0,0 +1,12 @@
import { moduleFor, test } from 'ember-qunit';
moduleFor('controller:application', 'Unit | Controller | application', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
// Replace this with your real tests.
test('it exists', function(assert) {
let controller = this.subject();
assert.ok(controller);
});

View File

@ -0,0 +1,12 @@
import { moduleFor, test } from 'ember-qunit';
moduleFor('controller:index', 'Unit | Controller | index', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
// Replace this with your real tests.
test('it exists', function(assert) {
let controller = this.subject();
assert.ok(controller);
});

View File

@ -0,0 +1,11 @@
import { moduleFor, test } from 'ember-qunit';
moduleFor('route:index', 'Unit | Route | index', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
test('it exists', function(assert) {
let route = this.subject();
assert.ok(route);
});