Skip to content

Commit

Permalink
EDITOR-#304 clean up useless code & config files (#308)
Browse files Browse the repository at this point in the history
* fix: remove unused components/files/slices/types

* fix: remove some unused packages and file upload download old api

* fix: remove pixi simulator

* refactor: change utils folder structure

* fix: modify docker-compose file and update README. add 2022 dance configs

* fix: update gif of the README.md
  • Loading branch information
Kenchu123 committed Nov 6, 2022
1 parent 15a7ad1 commit a4b57d6
Show file tree
Hide file tree
Showing 258 changed files with 256 additions and 1,508,915 deletions.
29 changes: 7 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
</p>

<p align="center">
An Editor for editing and simulating light dance show
An online editor to design, simulate and control the lights
</p>
<div align="center" >
<img src="https://user-images.githubusercontent.com/17617373/126040650-b25e5a8f-5b40-4636-93b9-4a79e690e816.gif" width="100%">
<img src="https://user-images.githubusercontent.com/17617373/199907047-a87e1cea-4ff4-45c9-9f41-e05d28a47473.gif" width="100%">
</div>

## Architecture
Expand Down Expand Up @@ -65,20 +65,6 @@ You need to have MongoDB running on `mongodb://localhost:27017`
docker-compose -f dev.docker-compose.yml up -d mongodb redisdb
```

### Initialize Database

After starting all services, one can add 2021's control and position data into mongoDB.

```bash
cd utils
yarn
export NODE_OPTIONS="--max-old-space-size=8192" // Incase heap out of memory
node initDB.js ${filePath}
// node initDB.js ../others/dance_json/export.json
node initLED.js ${filePath}
// node initLED.js ../others/dance_json/test_exportLED.json
```

## Production

Create the `eeinfo` network
Expand All @@ -90,7 +76,7 @@ docker network create eeinfo
Run services `nginx`, `editor`, `editor-server`, `file-server`, `redisdb`, `mongodb`.

```bash
docker-compose -f prod.docker-compose.yml up -d
docker-compose -f prod-support/prod.docker-compose.yml up -d
```

Editor will run on `http://localhost:8080`.
Expand All @@ -99,14 +85,13 @@ Editor-server will run on `http://localhost:4000`.

### Initialize Database

After starting all services, one can add 2021's control and position data into mongoDB.
After starting all services, one must initialize the database.

```bash
cd utils
yarn
cd utils && yarn
export NODE_OPTIONS="--max-old-space-size=8192" // Incase heap out of memory
node initDB.js ${filePath}
// node initDB.js ../others/dance_json/export.json
// node initDB.js ../others/2022_ee_night/exportData.json
node initLED.js ${filePath}
// node initLED.js ../others/dance_json/test_exportLED.json
// node initLED.js ../others/2022_ee_night/exportLED.json
```
3 changes: 1 addition & 2 deletions controller-server/websocket/dancerSocket.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CommandType } from "../constants";
import led from "../../files/data/led.json";
import WebSocket from "ws";
import {
ClientType,
Expand Down Expand Up @@ -176,7 +175,7 @@ class DancerSocket {
this.sendDataToRpiSocket({ command: CommandType.GREEN });
};
stmInit = () => {
this.sendDataToRpiSocket({ command: CommandType.STMINIT});
this.sendDataToRpiSocket({ command: CommandType.STMINIT });
};
darkAll = () => {
this.sendDataToRpiSocket({ command: CommandType.DARKALL });
Expand Down
1 change: 1 addition & 0 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ EXPOSE 8080
EXPOSE 8081
EXPOSE 8082
EXPOSE 4000
ENV NODE_OPTIONS='--max-old-space-size=8192'

CMD ["yarn", "dev"]

4 changes: 3 additions & 1 deletion dev.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
version: "3.3"
services:
all:
lightdance-editor-dev:
image: lightdance-editor-dev
container_name: lightdance-editor-dev
build:
context: .
dockerfile: dev.Dockerfile
Expand Down
32 changes: 32 additions & 0 deletions editor/api/fileAgent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import axios from "./axios";
import { notification } from "core/utils";

export const uploadeExportDataApi = async (uploadFile) => {
const formData = new FormData();
formData.append("data", uploadFile);
const response = await axios.post("/uploadData", formData);
if (response.request.statusText === "OK")
notification.success("Upload Success. Please refresh.");
else notification.error("Upload Failed.");
};

export const downloadExportDataApi = async () => {
const response = await axios.get("/exportData.json");
if (response.request.statusText === "OK") return response.data;
else notification.error("Download Failed.");
};

export const uploadLedDataApi = async (ledFile) => {
const formData = new FormData();
formData.append("data", ledFile);
const response = await axios.post("/uploadLED", formData);
if (response.request.statusText === "OK")
notification.success("Upload Success. Please refresh.");
else notification.error("Upload Failed.");
};

export const downloadLedDataApi = async () => {
const response = await axios.get("/exportLED.json");
if (response.request.statusText === "OK") return response.data;
else notification.error("Download Failed.");
};
104 changes: 1 addition & 103 deletions editor/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,108 +1,6 @@
import store from "../store";

//axios for api
import axios from "./axios";

import { notification } from "core/utils";

export * from "./controlAgent";
export * from "./positionAgent";
export * from "./dancerAgent";
export * from "./ledAgent";
export * from "./effectListAgent";

// TODO add type
export const uploadJson = (file, type) => {
const formData = new FormData();

formData.append(type, file);
if (type === "position" && type === "control") {
fetch(`/api/editor/upload/${type}`, {
method: "POST",
body: formData,
})
.then((response) => response.json())
.then((data) => {
console.log(data);
})
.catch((error) => {
console.error(error);
});
}
};

export const uploadeExportDataApi = async (uploadFile) => {
const formData = new FormData();
formData.append("data", uploadFile);
const response = await axios.post("/uploadData", formData);
if (response.request.statusText === "OK") notification.success("Upload Success. Please refresh.");
else notification.error("Upload Failed.");
};
export const downloadExportDataApi = async () => {
const response = await axios.get("/exportData.json");
if (response.request.statusText === "OK") return response.data;
else notification.error("Download Failed.");
};
export const uploadLedDataApi = async (ledFile) => {
const formData = new FormData();
formData.append("data", ledFile);
const response = await axios.post("/uploadLED", formData);
if (response.request.statusText === "OK") notification.success("Upload Success. Please refresh.");
else notification.error("Upload Failed.");
};
export const downloadLedDataApi = async () => {
const response = await axios.get("/exportLED.json");
if (response.request.statusText === "OK") return response.data;
else notification.error("Download Failed.");
};
export const uploadImages = (files, path, imagePrefix) => {
const formData = new FormData();
files.forEach((file, i) => {
formData.append(`image${i}`, file);
});

formData.append("filePath", path);
formData.append("imagePrefix", imagePrefix);

fetch("/api/editor/upload/images", {
method: "POST",
body: formData,
})
.then((response) => response.json())
.then((data) => {
console.log(data);
})
.catch((error) => {
console.error(error);
});
};

export const requestDownload = (control, position, texture) => {
const payload = JSON.stringify({ control, position, texture });

fetch("/api/editor/download", {
method: "POST",
body: payload,
headers: {
"Content-Type": "application/json",
},
})
.then((response) => response.text())
.then((data) => {
console.log(data);
})
.catch((error) => {
console.error(error);
});
};

export const fetchTexture = () => {
const texturePath = store.getState().load.load.Texture;
return fetch(texturePath, {
method: "GET",
})
.then((response) => response.json())
.catch((error) => {
console.error(error);
});
};
export * from "./fileAgent";
2 changes: 1 addition & 1 deletion editor/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function Header() {
<Toolbar style={{ minHeight: "6vh", width: "100%" }}>
<Box sx={{ height: "6vh", p: "1vh 1vw", mr: "3vw" }}>
<img
src="/asset/Header/LDlogoWhite.png"
src="LDlogoWhite.png"
alt="NTUEE Light Dance logo"
style={{ height: "100%" }}
/>
Expand Down
105 changes: 0 additions & 105 deletions editor/components/LightEditor/ElEditor/index.tsx

This file was deleted.

38 changes: 0 additions & 38 deletions editor/components/LightEditor/Fade.tsx

This file was deleted.

Loading

0 comments on commit a4b57d6

Please sign in to comment.