Commit f2ee2d79 authored by Matthias Möller's avatar Matthias Möller

erste Ansätze zum Lösen des Component-Problems

parent bd45d7d3
import Ember from 'ember';
import layout from '../templates/components/explorviz-frontend-plugin-bci';
export default Ember.Component.extend({
layout:layout,
emotivWebsocket: Ember.inject.service("emotiv-websocket"),
tagName: "span",
classNames: ["glyphicon", "glyphicon-user"],
classNameBindings: ["status"],
status : "disconnected"
});
export function initialize(/* application */) {
// application.inject('route', 'foo', 'service:foo');
export function initialize(application) {
application.inject('component:addon-button', 'emotivWebsocket', 'service:emotiv-websocket');
}
export default {
......
export function initialize(applicationInstance) {
applicationInstance.lookup("service:emotiv-websocket");
let addonService = applicationInstance.lookup("service:addon-service");
addonService.get("navbarLabels").push("explorviz-frontend-plugin-bci");
/*let addon = {
"domID" : "emotivSignal",
"className" : "glyphicon glyphicon-signal",
"actionName" : "connectBCI"
};
addonService.get("navbarLabels").push(addon);
//Fügt eine neue Action in eine Komponente hinzu
let component = applicationInstance.lookup("component:addon-button");
let connectBCI =
function(domID){
let button = document.getElementById(domID);
let isConnected = (button.dataset.type) ? button.dataset.type : "diconnected";
if(isConnected === "connected"){
}else{
button.dataset.type = "connecting";
console.log(this);
this.get("emotivWebsocket").start();
}
};
component.actions["connectBCI"] = connectBCI;*/
}
export default {
......
......@@ -7,39 +7,30 @@ export default Ember.Service.extend({
init: function(){
const self = this;
this._super();
$(document).ready(addButton);
this.start();
function addButton(){
let item = document.createElement("li");
let button = document.createElement("a");
let span = document.createElement("span");
//span.onclick = self.start;
span.className = "glyphicon glyphicon-signal";
span.dataset.type = "disconnected";
button.appendChild(span);
item.appendChild(button);
let field = document.getElementById("addon-bar");
field.appendChild(item);
}
},
start: function(){
let sockets = this.get("websockets").socketFor("ws://localhost:1313/");
let websockets = Ember.inject.service("emotiv-websocket");
let sockets = websockets.get("websockets").socketFor("ws://localhost:1313/");
sockets.on("open", this.openMessageHandler, this);
sockets.on("message", this.myMessageHandler, this);
sockets.on("close", function(){console.log("arr");}, this);
sockets.on("close", this.myCloseHandler, this);
},
openMessageHandler: function(event){
console.log("Verbindung aktiv: ", event);
let signalButton = document.getElementById("emotivSignal");
signalButton.dataset.type = "connected";
},
myMessageHandler: function(event){
let data = event.data;
console.log(data);
}
},
myCloseHandler: function(event){
console.log("closed");
let button = document.getElementById("emotivSignal");
button.dataset.type = "disconnected";
}
});
export { default } from 'explorviz-plugin-bci/components/explorviz-frontend-plugin-bci';
\ No newline at end of file
......@@ -7,28 +7,9 @@ module.exports = {
included: function(app) {
this.addons.forEach((addon) =>{
if(addon.name === "ember-websockets"){
//überschreibt eine Funktion, die einen allgemeinen Fehler verursacht
addon._readConfig =
function help(environment) {
let path = require("path");
let exists = require('exists-sync');
const project = this.parent.app.project;
const configPath = path.dirname(project.configPath());
let config = path.join(configPath, 'environment.js');
if (!path.isAbsolute(config)) {
config = path.join(project.root, config);
}
if (exists(config)) {
return require(config)(environment);
}
return {
'ember-websockets': {}
};
};
}
//workaround für nested addons
addon.project = addon.parent.app.project;
}
});
this._super.included.apply(this, arguments);
}
......
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('explorviz-frontend-plugin-bci', 'Integration | Component | explorviz frontend plugin bci', {
integration: true
});
test('it renders', function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.on('myAction', function(val) { ... });
this.render(hbs`{{explorviz-frontend-plugin-bci}}`);
assert.equal(this.$().text().trim(), '');
// Template block usage:
this.render(hbs`
{{#explorviz-frontend-plugin-bci}}
template block text
{{/explorviz-frontend-plugin-bci}}
`);
assert.equal(this.$().text().trim(), 'template block text');
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment