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

Neues Aufsetzen

parent f399a0e6
The MIT License (MIT)
Copyright (c) 2017
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# explorviz-frontend-plugin-bci
This README outlines the details of collaborating on this Ember addon.
## Installation
* `git clone <repository-url>` this repository
* `cd explorviz-frontend-plugin-bci`
* `npm install`
## Running
* `ember serve`
* Visit your app at [http://localhost:4200](http://localhost:4200).
## Running Tests
* `npm test` (Runs `ember try:each` to test your addon against multiple Ember versions)
* `ember test`
* `ember test --server`
## Building
* `ember build`
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
import Ember from 'ember';
import layout from '../templates/components/explorviz-frontend-plugin-bci-button';
export default Ember.Component.extend({
layout: layout,
emotivWebsocket: Ember.inject.service("explorviz-frontend-plugin-bci"),
tagName: "a",
classNameBindings: ["status"],
status : "",
click: function(){
this.get("emotivWebsocket").start();
},
attributeBindings:["title"],
title: Ember.computed("emotivWebsocket.isActivated", "emotivWebsocket.status", function(){
let emotivWebsocket = this.get("emotivWebsocket");
if(emotivWebsocket !== "connected"){
return "press button to start BCI-Connection";
}
else if(emotivWebsocket.isActivated){
return "press ctrl+b to deactivate BCI-mode";
}else{
return "press ctrl+b to activate BCI-mode";
}
}),
isActivated: false,
init(){
this._super(...arguments);
this.status=Ember.computed("emotivWebsocket.status", function(){return this.get("emotivWebsocket").status;}.bind(this));
this.click=this.click.bind(this);
$(document)[0].addEventListener("keyup", function(evt){
if(evt.ctrlKey && evt.key=="b"){
this.get("emotivWebsocket").toogleActivation();
}
}.bind(this));
}
});
import Ember from 'ember';
import layout from '../templates/components/explorviz-frontend-plugin-bci';
export default Ember.Component.extend({
layout
});
export function initialize(applicationInstance) {
let addonService = applicationInstance.lookup("service:configuration");
addonService.get("addonNavbarRight").push("explorviz-frontend-plugin-bci-button");
}
export default {
name: 'explorviz-frontend-plugin-bci',
initialize
};
import Ember from 'ember';
export default Ember.Service.extend({
websockets : Ember.inject.service("websockets"),
socketReference:null,
status:"",
isActivated: false,
start: function(){
this.set("status", "connecting");
let sockets = this.get("socketReference");
if(sockets){
sockets.reconnect();
}else{
sockets = this.get("websockets").socketFor("ws://localhost:1313/");
sockets.on("open", this.openMessageHandler, this);
sockets.on("message", this.myMessageHandler, this);
sockets.on("close", this.myCloseHandler, this);
this.set("socketReference", sockets);
}
},
openMessageHandler: function(event){
this.set("status", "connected");
},
myMessageHandler: function(event){
let data = event.data;
data = JSON.parse(data);
let mentalCommand = data[mentalCommand];
//MentalCommand is a push
if(mentalCommand === 2){
this.triggerZoom(-0.5);
//MentalCommand is a pull
}else if(mentalCommand === 4){
this.triggerZoom(0.5);
}
},
myCloseHandler: function(event){
Ember.run.later(this, function(){this.set("status", "disconnected")}, 1000);
},
triggerZoom(wheelDelta){
let canvas = $("#threeCanvas")[0];
let event = new Event("mousewheel",
{
"bubbles":true,
"cancelable":false
});
event.clientX = canvas.clientX;
event.clientY = canvas.clientY;
event.wheelDelta = wheelDelta;
canvas.dispatchEvent(event);
},
toogleActivation: function(){
this.set("isActivated", !this.get("isActivated"));
}
});
@keyframes connecting{
0% {color:grey;}
50% {color:#7FFF00;}
100% {color:grey;}
}
@keyframes disconnected{
0% {color: grey;}
50% {color :red;}
100%{color: grey;}
}
#addon-navbar-right > li > a.connected{
color: #7FFF00;
}
#addon-navbar-right > li > a.disconnected{
animation-name: disconnected;
animation-duration: 1s;
animation-iteration-count: 1;
}
#addon-navbar-right > li > a.connecting{
animation-name: connecting;
animation-duration: 1s;
animation-iteration-count: infinite;
cursor: wait;
}
<span class="glyphicon glyphicon-signal">
</span>
export { default } from 'explorviz-frontend-plugin-bci/components/explorviz-frontend-plugin-bci-button';
\ No newline at end of file
export { default } from 'explorviz-frontend-plugin-bci/components/explorviz-frontend-plugin-bci';
\ No newline at end of file
export { default, initialize } from 'explorviz-frontend-plugin-bci/instance-initializers/explorviz-frontend-plugin-bci';
export { default } from 'explorviz-frontend-plugin-bci/services/explorviz-frontend-plugin-bci';
/* eslint-env node */
module.exports = {
scenarios: [
{
name: 'ember-lts-2.8',
bower: {
dependencies: {
'ember': 'components/ember#lts-2-8'
},
resolutions: {
'ember': 'lts-2-8'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
name: 'ember-lts-2.12',
npm: {
devDependencies: {
'ember-source': '~2.12.0'
}
}
},
{
name: 'ember-release',
bower: {
dependencies: {
'ember': 'components/ember#release'
},
resolutions: {
'ember': 'release'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
name: 'ember-beta',
bower: {
dependencies: {
'ember': 'components/ember#beta'
},
resolutions: {
'ember': 'beta'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
name: 'ember-canary',
bower: {
dependencies: {
'ember': 'components/ember#canary'
},
resolutions: {
'ember': 'canary'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
name: 'ember-default',
npm: {
devDependencies: {}
}
}
]
};
/* eslint-env node */
'use strict';
module.exports = function(/* environment, appConfig */) {
return { };
};
/* eslint-env node */
'use strict';
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
module.exports = function(defaults) {
let app = new EmberAddon(defaults, {
// Add options here
});
/*
This build file specifies the options for the dummy test app of this
addon, located in `/tests/dummy`
This build file does *not* influence how the addon or the app using it
behave. You most likely want to be modifying `./index.js` or app's build file
*/
return app.toTree();
};
/* eslint-env node */
'use strict';
module.exports = {
name: 'explorviz-frontend-plugin-bci',
included: function(app) {
this.addons.forEach((addon) =>{
if(addon.name === "ember-websockets"){
//workaround für nested addons
addon.project = addon.parent.app.project;
}
});
this._super.included.apply(this, arguments);
}
};
{
"name": "explorviz-frontend-plugin-bci",
"version": "0.0.0",
"description": "The default blueprint for ember-cli addons.",
"keywords": [
"ember-addon"
],
"license": "MIT",
"author": "",
"directories": {
"doc": "doc",
"test": "tests"
},
"repository": "",
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember try:each"
},
"dependencies": {
"ember-cli-htmlbars": "^2.0.1",
"ember-cli-babel": "^6.3.0",
"ember-websockets": "^7.0.4"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-cli": "~2.14.1",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-eslint": "^3.0.0",
"ember-cli-htmlbars-inline-precompile": "^0.4.3",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-qunit": "^4.0.0",
"ember-cli-shims": "^1.1.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.0.0",
"ember-source": "~2.14.1",
"loader.js": "^4.2.3"
},
"engines": {
"node": "^4.5 || 6.* || >= 7.*"
},
"ember-addon": {
"configPath": "tests/dummy/config"
}
}
/* eslint-env node */
module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: [
'PhantomJS'
],
launch_in_dev: [
'PhantomJS',
'Chrome'
]
};
module.exports = {
env: {
embertest: true
}
};
import Ember from 'ember';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
const App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
});
loadInitializers(App, config.modulePrefix);
export default App;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Dummy</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{content-for "head"}}
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
{{content-for "head-footer"}}
</head>
<body>
{{content-for "body"}}
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
{{content-for "body-footer"}}
</body>
</html>
import Resolver from 'ember-resolver';
export default Resolver;
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType,
rootURL: config.rootURL
});
Router.map(function() {
});
export default Router;
<h2 id="title">Welcome to Ember</h2>
{{outlet}}
\ No newline at end of file
/* eslint-env node */
'use strict';
module.exports = function(environment) {
let ENV = {
modulePrefix: 'dummy',
environment,
rootURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false
}
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
};
if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
}
if (environment === 'test') {
// Testem prefers this...
ENV.locationType = 'none';
// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
}
if (environment === 'production') {
}
return ENV;
};
/* eslint-env node */
module.exports = {
browsers: [
'ie 9',
'last 1 Chrome versions',
'last 1 Firefox versions',
'last 1 Safari versions'
]
};
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->
<!-- Most restrictive policy: -->
<site-control permitted-cross-domain-policies="none"/>
<!-- Least restrictive policy: -->
<!--
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
-->
</cross-domain-policy>
# http://www.robotstxt.org
User-agent: *
Disallow:
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import { module } from 'qunit';
import Ember from 'ember';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';
const { RSVP: { resolve } } = Ember;
export default function(name, options = {}) {
module(name, {
beforeEach() {
this.application = startApp();
if (options.beforeEach) {
return options.beforeEach.apply(this, arguments);
}
},
afterEach() {
let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
return resolve(afterEach).then(() => destroyApp(this.application));
}
});
}
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
export default function startApp(attrs) {
let attributes = Ember.merge({}, config.APP);
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
return Ember.run(() => {
let application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
return application;
});
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Dummy Tests</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{content-for "head"}}
{{content-for "test-head"}}
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css">
{{content-for "head-footer"}}
{{content-for "test-head-footer"}}
</head>
<body>
{{content-for "body"}}
{{content-for "test-body"}}
<script src="/testem.js" integrity=""></script>
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/test-support.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
<script src="{{rootURL}}assets/tests.js"></script>
{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
</body>
</html>
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('explorviz-frontend-plugin-bci-button', 'Integration | Component | explorviz frontend plugin bci button', {
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-button}}`);
assert.equal(this.$().text().trim(), '');
// Template block usage:
this.render(hbs`
{{#explorviz-frontend-plugin-bci-button}}
template block text
{{/explorviz-frontend-plugin-bci-button}}
`);
assert.equal(this.$().text().trim(), 'template block text');
});
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');