Skip to content

Commit ab87cf5

Browse files
committed
feat: establish socket.io connection
1 parent cfbdc51 commit ab87cf5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+415
-405
lines changed

NOTES.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
These are notes for the stream implementation of Nodeplotlib.
22

33
## General
4+
45
- A plot window (**apps/web**) tries to connect to the server via a realtime api (e.g. websockets).
56
- The server recognizes the count of connected apps.
67
- If the user executes the `plot` function several times, it will only open a window if there is no
78
open connection to a **apps/web**.
89

910
## Server lifecycle
11+
1012
- The server starts with the execution of the `plot` function if there is no active server running.
1113
- The server stops if all **apps/web** are disconnected (and there were connections before).
1214

1315
## The plot function
16+
1417
- The plot function can either handle a `Plot` or an `Observable<Plot>`.
1518
- It creates an `Observable<Plot>` by using Rxjs' `of` observable constructor.
1619
- The plot streams are saved in a Plots Set.
@@ -21,13 +24,25 @@ These are notes for the stream implementation of Nodeplotlib.
2124
the server as mentioned in the **server lifecycle** section.
2225

2326
## The stack function
27+
2428
- Is the `stack` function really needed? Stack served the purpose that only one window opens which
2529
could display several plots.
2630

2731
## Backlog
32+
2833
- The user can remove plots from the frontend. If that happened it submits a message to the
2934
backend so that the subscription can be cancelled and the plot stream can be removed from the plots set.
3035

3136
## Frontend only
37+
3238
- The user has the possibility to rearrange plots per drag and drop.
33-
- The user can resize the individual plot windows.
39+
- The user can resize the individual plot windows.
40+
41+
## Development
42+
43+
To start the app for development purposes run
44+
45+
```
46+
npm run build web -- --watch
47+
npm start dev-server
48+
```

angular.json

Lines changed: 71 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
{
22
"version": 1,
33
"projects": {
4+
"core": {
5+
"root": "libs/core",
6+
"sourceRoot": "libs/core/src",
7+
"projectType": "library",
8+
"architect": {
9+
"build": {
10+
"builder": "@nrwl/node:package",
11+
"outputs": ["{options.outputPath}"],
12+
"options": {
13+
"outputPath": "dist/libs/core",
14+
"tsConfig": "libs/core/tsconfig.lib.json",
15+
"packageJson": "libs/core/package.json",
16+
"main": "libs/core/src/index.ts",
17+
"assets": ["libs/core/*.md"]
18+
}
19+
},
20+
"lint": {
21+
"builder": "@nrwl/linter:eslint",
22+
"outputs": ["{options.outputFile}"],
23+
"options": {
24+
"lintFilePatterns": ["libs/core/**/*.ts"]
25+
}
26+
},
27+
"test": {
28+
"builder": "@nrwl/jest:jest",
29+
"outputs": ["coverage/libs/core"],
30+
"options": {
31+
"jestConfig": "libs/core/jest.config.js",
32+
"passWithNoTests": true
33+
}
34+
}
35+
}
36+
},
437
"dev-server": {
538
"root": "apps/dev-server",
639
"sourceRoot": "apps/dev-server/src",
@@ -13,7 +46,14 @@
1346
"outputPath": "dist/apps/dev-server",
1447
"main": "apps/dev-server/src/main.ts",
1548
"tsConfig": "apps/dev-server/tsconfig.app.json",
16-
"assets": ["apps/dev-server/src/assets"]
49+
"assets": [
50+
"apps/dev-server/src/assets",
51+
{
52+
"glob": "**/*",
53+
"input": "dist/apps/web",
54+
"output": "web"
55+
}
56+
]
1757
},
1858
"configurations": {
1959
"production": {
@@ -86,66 +126,54 @@
86126
}
87127
},
88128
"nodeplotlib": {
89-
"root": "libs/nodeplotlib",
90-
"sourceRoot": "libs/nodeplotlib/src",
91-
"projectType": "library",
129+
"root": "apps/nodeplotlib",
130+
"sourceRoot": "apps/nodeplotlib/src",
131+
"projectType": "application",
92132
"architect": {
93133
"build": {
94-
"builder": "@nrwl/node:package",
134+
"builder": "@nrwl/node:build",
95135
"outputs": ["{options.outputPath}"],
96136
"options": {
97-
"outputPath": "dist/libs/nodeplotlib",
98-
"tsConfig": "libs/nodeplotlib/tsconfig.lib.json",
99-
"packageJson": "libs/nodeplotlib/package.json",
100-
"main": "libs/nodeplotlib/src/index.ts",
101-
"assets": ["libs/nodeplotlib/*.md"]
102-
}
103-
},
104-
"lint": {
105-
"builder": "@nrwl/linter:eslint",
106-
"outputs": ["{options.outputFile}"],
107-
"options": {
108-
"lintFilePatterns": ["libs/nodeplotlib/**/*.ts"]
137+
"outputPath": "dist/apps/nodeplotlib",
138+
"main": "apps/nodeplotlib/src/main.ts",
139+
"tsConfig": "apps/nodeplotlib/tsconfig.app.json",
140+
"assets": [
141+
"apps/nodeplotlib/src/assets",
142+
"apps/nodeplotlib/src/package.json"
143+
]
144+
},
145+
"configurations": {
146+
"production": {
147+
"optimization": true,
148+
"extractLicenses": true,
149+
"inspect": false,
150+
"fileReplacements": [
151+
{
152+
"replace": "apps/nodeplotlib/src/environments/environment.ts",
153+
"with": "apps/nodeplotlib/src/environments/environment.prod.ts"
154+
}
155+
]
156+
}
109157
}
110158
},
111-
"test": {
112-
"builder": "@nrwl/jest:jest",
113-
"outputs": ["coverage/libs/nodeplotlib"],
114-
"options": {
115-
"jestConfig": "libs/nodeplotlib/jest.config.js",
116-
"passWithNoTests": true
117-
}
118-
}
119-
}
120-
},
121-
"server": {
122-
"root": "libs/server",
123-
"sourceRoot": "libs/server/src",
124-
"projectType": "library",
125-
"architect": {
126-
"build": {
127-
"builder": "@nrwl/node:package",
128-
"outputs": ["{options.outputPath}"],
159+
"serve": {
160+
"builder": "@nrwl/node:execute",
129161
"options": {
130-
"outputPath": "dist/libs/server",
131-
"tsConfig": "libs/server/tsconfig.lib.json",
132-
"packageJson": "libs/server/package.json",
133-
"main": "libs/server/src/index.ts",
134-
"assets": ["libs/server/*.md"]
162+
"buildTarget": "nodeplotlib:build"
135163
}
136164
},
137165
"lint": {
138166
"builder": "@nrwl/linter:eslint",
139167
"outputs": ["{options.outputFile}"],
140168
"options": {
141-
"lintFilePatterns": ["libs/server/**/*.ts"]
169+
"lintFilePatterns": ["apps/nodeplotlib/**/*.ts"]
142170
}
143171
},
144172
"test": {
145173
"builder": "@nrwl/jest:jest",
146-
"outputs": ["coverage/libs/server"],
174+
"outputs": ["coverage/apps/nodeplotlib"],
147175
"options": {
148-
"jestConfig": "libs/server/jest.config.js",
176+
"jestConfig": "apps/nodeplotlib/jest.config.js",
149177
"passWithNoTests": true
150178
}
151179
}

apps/dev-server/src/main.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,6 @@
33
* This is only a minimal backend to get started.
44
*/
55

6-
import { NestFactory } from '@nestjs/core';
7-
import { ServerModule } from '@npl/server';
6+
import { bootstrap, plot } from '@npl/core';
87

9-
async function bootstrap() {
10-
const app = await NestFactory.create(ServerModule);
11-
app.enableCors();
12-
await app.listen(3333);
13-
console.log(
14-
'Server runnng at',
15-
`http://localhost:${app.getHttpServer().address().port}`
16-
);
17-
}
18-
19-
bootstrap();
8+
plot([]);
File renamed without changes.

libs/nodeplotlib/jest.config.js renamed to apps/nodeplotlib/jest.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module.exports = {
88
},
99
testEnvironment: 'node',
1010
transform: {
11-
'^.+\\.[tj]sx?$': 'ts-jest',
11+
'^.+\\.[tj]s$': 'ts-jest',
1212
},
13-
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
14-
coverageDirectory: '../../coverage/libs/nodeplotlib',
13+
moduleFileExtensions: ['ts', 'js', 'html'],
14+
coverageDirectory: '../../coverage/apps/nodeplotlib',
1515
};
File renamed without changes.

apps/nodeplotlib/src/assets/.gitkeep

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
production: true,
3+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
production: false,
3+
};

apps/nodeplotlib/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { plot, Plot, Layout } from '@npl/core';

0 commit comments

Comments
 (0)