Skip to content

Commit

Permalink
Mass style correction (eslint) and reuse of some components.
Browse files Browse the repository at this point in the history
The issue related to the loading display is also resolved while the metrics are reanalyzed.
  • Loading branch information
gmarcos87 committed Sep 3, 2017
1 parent cce8261 commit 79d2ab7
Show file tree
Hide file tree
Showing 85 changed files with 2,285 additions and 2,431 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test/*.conf.js
build/
57 changes: 1 addition & 56 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,58 +1,3 @@
{
"parser": "babel-eslint",
"extends": "eslint:recommended",
"env": {
"browser": true,
"node": true,
"mocha": true,
"es6": true
},
"parserOptions": {
"ecmaFeatures": {
"modules": true,
"jsx": true
}
},
"globals": {},
"rules": {
"no-empty": 0,
"no-console": 0,
"no-empty-pattern": 0,
"no-unused-vars": [0, { "varsIgnorePattern": "^h$" }],
"no-cond-assign": 1,
"semi": 2,
"camelcase": 0,
"comma-style": 2,
"comma-dangle": [2, "never"],
"indent": [2, 2, {"SwitchCase": 1}],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"no-trailing-spaces": [2, { "skipBlankLines": true }],
"max-nested-callbacks": [2, 3],
"no-eval": 2,
"no-implied-eval": 2,
"no-new-func": 2,
"guard-for-in": 2,
"eqeqeq": 1,
"no-else-return": 2,
"no-redeclare": 2,
"no-dupe-keys": 2,
"radix": 2,
"strict": [2, "never"],
"no-shadow": 0,
"no-delete-var": 2,
"no-undef-init": 2,
"no-shadow-restricted-names": 2,
"handle-callback-err": 0,
"no-lonely-if": 2,
"keyword-spacing": 2,
"constructor-super": 2,
"no-this-before-super": 2,
"no-dupe-class-members": 2,
"no-const-assign": 2,
"prefer-spread": 2,
"no-useless-concat": 2,
"no-var": 2,
"object-shorthand": 2,
"prefer-arrow-callback": 2
}
"extends": "eslint-config-synacor"
}
4 changes: 0 additions & 4 deletions netlify.toml

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"deploy": "gh-pages -d build",
"test": "npm run -s lint && npm run -s test:karma",
"test:karma": "karma start test/karma.conf.js --single-run",
"lint": "eslint src",
"lint": "eslint ./",
"translations": "node ./node_modules/i18nline/bin/i18nline.js export"
},
"keywords": [
Expand Down Expand Up @@ -42,6 +42,7 @@
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"eslint": "^4.5.0",
"eslint-config-synacor": "^1.1.1",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.2",
"gh-pages": "^1.0.0",
Expand Down
20 changes: 10 additions & 10 deletions plugins/lime-plugin-align/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import Page from './src/alignPage';
import { AlignMenu } from './src/alignMenu';

export default {
name: 'Align',
page: Page,
menu: AlignMenu,
store: {
name: 'align',
epics,
reducer,
selector,
constants
}
name: 'Align',
page: Page,
menu: AlignMenu,
store: {
name: 'align',
epics,
reducer,
selector,
constants
}
};
52 changes: 26 additions & 26 deletions plugins/lime-plugin-align/src/alignActions.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import {
IFACE_CHANGE,
STATION_SET,
IFACES_LOAD,
TIMER_STOP
IFACE_CHANGE,
STATION_SET,
IFACES_LOAD,
TIMER_STOP
} from './alignConstants';

export const changeInterface = (iface) => (dispatch, getState) => {
if (iface === getState().align.currentReading.iface) {
return;
}
dispatch({
type: IFACE_CHANGE,
payload: {
iface
}
});
if (iface === getState().align.currentReading.iface) {
return;
}
dispatch({
type: IFACE_CHANGE,
payload: {
iface
}
});
};

export const changeStation = (mac) => (dispatch, getState) => {
if (mac === getState().align.currentReading.mac) {
return;
}
dispatch({
type: STATION_SET,
payload: getState().align.stations.filter(x => x.mac === mac)[0]
});
if (mac === getState().align.currentReading.mac) {
return;
}
dispatch({
type: STATION_SET,
payload: getState().align.stations.filter(x => x.mac === mac)[0]
});
};

export const startAlign = () => (dispatch) => {
dispatch({
type:IFACES_LOAD
});
dispatch({
type: IFACES_LOAD
});
};

export const stopTimer = () => (dispatch) => {
dispatch({
type:TIMER_STOP
});
dispatch({
type: TIMER_STOP
});
};
74 changes: 32 additions & 42 deletions plugins/lime-plugin-align/src/alignApi.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,35 @@
export const getIfaceStation = (api, sid, iface) => {
return api.call(sid, 'get_iface_stations', { iface })
.map(x => x.stations)
.map(data => Object.keys(data).map((key, index)=>data[key]).reduce((x,y) => x.concat(y), []))
.map((nodes) => nodes.map(node => {
if (node.signal) {
node.signal = Number(node.signal);
}
return node;
}))
.map((nodes) => { return { iface, nodes }; })
.map( x => {
if (x.nodes.length > 0) { return x; }
throw new Error();
});
};
export const getIfaceStation = (api, sid, iface) => api.call(sid, 'get_iface_stations', { iface })
.map(x => x.stations)
.map(data => Object.keys(data).map((key, index) => data[key]).reduce((x,y) => x.concat(y), []))
.map((nodes) => nodes.map(node => {
if (node.signal) {
node.signal = Number(node.signal);
}
return node;
}))
.map((nodes) => ({ iface, nodes }))
.map( x => {
if (x.nodes.length > 0) { return x; }
throw new Error();
});

export const getStationSignal = (api, sid, node) => {
return api.call(sid, 'get_station_signal', { station_mac: node.mac, iface: node.iface });
};
export const getStationSignal = (api, sid, node) => api.call(sid, 'get_station_signal', { station_mac: node.mac, iface: node.iface });

export const getInterfaces = (api, sid) => {
return api.call(sid, 'get_interfaces', {})
.map(res => res.interfaces)
.map(iface => iface.map((x) => { return { name: x }; }));
};
export const getInterfaces = (api, sid) => api.call(sid, 'get_interfaces', {})
.map(res => res.interfaces)
.map(iface => iface.map((x) => ({ name: x })));

export const getStations = (api,sid) => {
return new Promise((res,rej) => {
api.call(sid, 'get_stations', {})
.map(x => x.stations)
.map(data => Object.keys(data).map((key, index)=>data[key]).reduce((x,y) => x.concat(y), []))
.map((y) => {
return y.reduce((a, b) => a.concat(b), []);
})
.map((nodes) => nodes.map(node => {
node.signal = Number(node.signal);
return node;
}))
.subscribe( x => {
if (x.length > 0) { res(x); }
rej(x);
});
});
};
export const getStations = (api,sid) => new Promise((res,rej) => {
api.call(sid, 'get_stations', {})
.map(x => x.stations)
.map(data => Object.keys(data).map((key, index) => data[key]).reduce((x,y) => x.concat(y), []))
.map((y) => y.reduce((a, b) => a.concat(b), []))
.map((nodes) => nodes.map(node => {
node.signal = Number(node.signal);
return node;
}))
.subscribe( x => {
if (x.length > 0) { res(x); }
rej(x);
});
});
Loading

0 comments on commit 79d2ab7

Please sign in to comment.