Skip to content

Commit e1e6f8e

Browse files
committed
cleaning up unused code and fixing styling on the tiny screens
1 parent d3fbf6d commit e1e6f8e

File tree

7 files changed

+61
-40
lines changed

7 files changed

+61
-40
lines changed

app/brightness.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ init = async () => {
1515
}
1616
})
1717
pixelBlazeData = discoverPixelBlazes()
18-
pixelBlazeIds = _.map(pixelBlazeData, 'id')
18+
pixelBlazeIds = _.map(pixelBlazeData, 'id')
1919
}
2020

2121
initInterval = setInterval(init, 100)
@@ -72,7 +72,8 @@ initThis().then(()=>{})
7272

7373
module.exports.BrightnessWebsocketMessageHandler = function (utils) {
7474
const brightness = new Brightness(utils)
75-
this.utils = utils
75+
this.utils = utils
76+
7677
this.receiveMessage = async function (data) {
7778
let message
7879
try {

app/firestormWebsocket.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@ const {PlaylistWebSocketMessageHandler} = require('./playlist')
33
const {Utils} = require('./utils')
44
const {BrightnessWebsocketMessageHandler} = require("./brightness");
55

6-
// start playlist server
6+
// start FireStorm WebSocket server
77
const address = '0.0.0.0';
88
const port = 1890;
99
const firestormServer = new WebSocketServer({host: address , port: port});
1010
console.log(`Firestorm server is running on ${address}:${port}`);
11+
1112
firestormServer.on('connection', function (connection) {
1213
const utils = new Utils(connection)
13-
const brightnessWebsocket = new BrightnessWebsocketMessageHandler(utils)
14-
const playlistWebSocket = new PlaylistWebSocketMessageHandler(utils)
14+
const brightnessWebsocketMessageHandler = new BrightnessWebsocketMessageHandler(utils)
15+
const playlistWebSocketMessageHandler = new PlaylistWebSocketMessageHandler(utils)
1516
if(utils.addFirestormClient(connection)) {
1617
return
1718
}
1819
connection.on('message', async function message(data, isBinary) {
1920
const message = isBinary ? data : data.toString();
2021
// console.log(`incoming msg from: ${utils.getFirestormClientBySocket(connection)}, message: ${message}`)
21-
if (await playlistWebSocket.receiveMessage(message)) {
22+
if (await playlistWebSocketMessageHandler.receiveMessage(message)) {
2223
return
2324
}
24-
if (await brightnessWebsocket.receiveMessage(message)) {
25+
if (await brightnessWebsocketMessageHandler.receiveMessage(message)) {
2526
return
2627
}
2728
})

app/playlist.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const _ = require("lodash");
22
const {getPlaylistFromDB, addPatternToPlaylist, removeAllPatterns} = require("../db/controllers/playlist");
33
const {discoverPixelBlazes, sendCommand} = require("./pixelBlazeUtils");
44

5-
let currentPlaylistData = []
65
let currentPlaylist = []
76
let currentRunningPattern = null
87
let initInterval
@@ -17,10 +16,6 @@ init = async () => {
1716
try {
1817
currentPlaylist = [] // resetting current playlist so it doesn't grow to infinity
1918
currentPlaylist.push(...data) // adding new playlist items to list
20-
if (JSON.stringify(currentPlaylist) !== JSON.stringify(currentPlaylistData)) {
21-
currentPlaylistData = []
22-
currentPlaylistData.push(...data)
23-
}
2419
} catch (err) {
2520
console.warn(`Error: ${err}`)
2621
}
@@ -36,7 +31,7 @@ initInterval = setInterval(init, 100)
3631

3732
class Playlist {
3833
constructor(utils) {
39-
this.utils = utils ? utils : null
34+
this.utils = utils ? utils : null
4035
}
4136

4237
playlistLoop = async () => {
@@ -47,9 +42,9 @@ class Playlist {
4742
if(pixelBlazeIds.length) {
4843
await this.iterateOnPlaylist()
4944
}
50-
initInterval = null
51-
playlistTimeout = null
45+
initInterval = null
5246
playlistLoopTimeout = null
47+
playlistTimeout = null
5348
}
5449
}
5550
iterateOnPlaylist = async () => {
@@ -127,7 +122,7 @@ class Playlist {
127122
await this.playlistLoop()
128123
}
129124
sendPattern = async (pattern) => {
130-
const name = pattern.name
125+
const name = pattern.name
131126
currentRunningPattern = name
132127
sendCommand(pixelBlazeIds, name)
133128
let message = {
@@ -157,6 +152,7 @@ initThe.playlistLoop()
157152
module.exports.PlaylistWebSocketMessageHandler = function (utils) {
158153
const playlist = new Playlist(utils)
159154
this.utils = utils
155+
160156
this.receiveMessage = async function (data) {
161157
let message
162158
try {

server.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const bodyParser = require('body-parser');
55
const compression = require('compression');
66
const repl = require('repl');
77
require("./app/firestormWebsocket");
8-
// require("./app/playlist");
98
discovery.start({
109
host: '0.0.0.0',
1110
port: 1889

src/App.css

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,11 @@
2222
font-size: large;
2323
}
2424

25-
.btn-playlist-bulk {
26-
margin-left: 10px;
27-
}
28-
2925
.btn-playlist-add {
3026
border: 0;
3127
padding: 2rem 0rem;
3228
}
3329

34-
.btn-playlist-bulk {
35-
margin-left: 10px;
36-
}
37-
3830
/* !importants below override many combos of .active and :active */
3931
.btn-playlist-add {
4032
outline: none ! important;

src/App.js

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,40 @@ class App extends Component {
559559
if (this.state.showCurrentPlaylist) {
560560
playlistDialog = (
561561
<>
562-
<div className="row mx-n2" ref={this.playlistDialogRef} key='a02'>
563-
<div className="py-1 col-8">
564-
<h5 className="">Current Playlist</h5>
562+
<div className="row mx-xl-n4 mx-lg-n4 mx-md-n4 mx-n4" ref={this.playlistDialogRef}>
563+
<div className="py-1 col-xl-12 px-xl-4 col-lg-12 px-lg-4 col-md-12 col-12 px-4">
564+
<div className="row px-xl-2 pr-lg-2 px-md-2 px-2">
565+
<div className="col-xl-1 px-xl-1 mr-xl-auto col-lg-1 px-lg-1 mr-lg-auto col-md-1 px-md-1 mr-md-auto col-12 px-1">
566+
<h3 className="">Current Playlist</h3>
567+
</div>
568+
</div>
569+
</div>
570+
<div className="py-1 col-xl-12 px-xl-4 col-lg-12 px-lg-4 col-md-12 col-12">
571+
<div className="row rows-cols-3">
572+
<div className="py-2 col-xl-auto px-xl-1 col-lg-auto px-lg-1 col-md-auto px-md-1 col-3 text-nowrap ml-3">
573+
<button
574+
className="btn btn-secondary text-left playlist btn-playlist-bulk"
575+
disabled={this.state.deactivateEnableAllButton}
576+
onClick={this.enableAllPatterns}>
577+
Enable All
578+
</button>
579+
</div>
580+
<div className="py-2 col-xl-auto px-xl-1 col-lg-auto px-lg-1 col-md-auto px-md-1 col-3 text-nowrap mr-1">
581+
<button
582+
className="btn btn-secondary text-left playlist btn-playlist-bulk"
583+
disabled={this.state.deactivateDisableAllButton}
584+
onClick={this.disableAllPatterns}>
585+
Disable All
586+
</button>
587+
</div>
588+
<div className="py-2 col-xl-auto px-xl-1 col-lg-auto px-lg-1 col-md-auto px-md-1 col-3 text-nowrap mr-1">
589+
<button
590+
className="btn btn-secondary text-left btn-playlist-bulk"
591+
onClick={(e) => this.openPlaylistDialog(e)}>
592+
Current Playlist
593+
</button>
594+
</div>
595+
</div>
565596
</div>
566597
</div>
567598
<div className="row">
@@ -588,11 +619,11 @@ class App extends Component {
588619
{pattern.duration}
589620
</div>
590621
{(getStatus(pattern.name) === 'running') ? (
591-
<div className="alert alert-success col-3 p-1 col-auto" role="alert">
622+
<div className="alert alert-success col-3 p-1 col-auto py-0 mb-0" role="alert">
592623
running
593624
</div>
594625
) : (
595-
<div className="alert alert-dark col-3 p-1 col-auto" role="alert">
626+
<div className="alert alert-dark col-3 p-1 col-auto py-0 mb-0" role="alert">
596627
queued
597628
</div>
598629
)}
@@ -693,34 +724,35 @@ class App extends Component {
693724
Patterns
694725
</h3>
695726
</div>
696-
<div className="py-2 col-xl-auto px-xl-1 col-lg-auto px-lg-1 col-md-auto px-md-1 col-auto px-1">
727+
</div>
728+
</div>
729+
<div className="py-1 col-xl-12 px-xl-4 col-lg-12 px-lg-4 col-md-12 col-12">
730+
<div className="row rows-cols-3">
731+
<div className="py-2 col-xl-auto px-xl-1 col-lg-auto px-lg-1 col-md-auto px-md-1 col-3 text-nowrap ml-3">
697732
<button
698733
className="btn btn-secondary text-left playlist btn-playlist-bulk"
699734
disabled={this.state.deactivateEnableAllButton}
700735
onClick={this.enableAllPatterns}>
701736
Enable All
702737
</button>
703738
</div>
704-
<div className="py-2 col-xl-auto px-xl-1 col-lg-auto px-lg-1 col-md-auto px-md-1 col-auto px-1">
739+
<div className="py-2 col-xl-auto px-xl-1 col-lg-auto px-lg-1 col-md-auto px-md-1 col-3 text-nowrap mr-1">
705740
<button
706741
className="btn btn-secondary text-left playlist btn-playlist-bulk"
707742
disabled={this.state.deactivateDisableAllButton}
708743
onClick={this.disableAllPatterns}>
709744
Disable All
710745
</button>
711746
</div>
712-
<div className="py-2 col-xl-auto px-xl-1 col-lg-auto px-lg-1 col-md-auto px-md-1 col-auto px-1">
747+
<div className="py-2 col-xl-auto px-xl-1 col-lg-auto px-lg-1 col-md-auto px-md-1 col-3 text-nowrap mr-1">
713748
<button
714749
className="btn btn-secondary text-left btn-playlist-bulk"
715750
onClick={(e) => this.openPlaylistDialog(e)}>
716-
View Current Playlist
751+
Current Playlist
717752
</button>
718753
</div>
719754
</div>
720755
</div>
721-
</div>
722-
<div className="row mx-xl-n4 mx-n4">
723-
724756
</div>
725757
<div className="list-group">
726758
{(this.state.isProcessing) &&

src/utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const connect = () => {
55
let connectInterval;
66

77
ws.onopen = () => {
8-
console.log("connected websocket main component");
8+
console.log("Connected to FireStorm WebSocket Server");
99

1010
this.setState({ ws: ws });
1111

@@ -14,7 +14,7 @@ export const connect = () => {
1414

1515
ws.onclose = e => {
1616
console.log(
17-
`Socket is closed. Reconnect will be attempted in ${Math.min(
17+
`WebSocket is closed. Reconnect will be attempted in ${Math.min(
1818
10000 / 1000,
1919
(timeout + timeout) / 1000
2020
)} second.`,
@@ -27,7 +27,7 @@ export const connect = () => {
2727

2828
ws.onerror = err => {
2929
console.error(
30-
"Socket encountered error: ",
30+
"WebSocket encountered error: ",
3131
err.message,
3232
"Closing socket"
3333
);

0 commit comments

Comments
 (0)