Skip to content

Commit 2fe54ec

Browse files
committed
feat: add interfaces library
1 parent 85b3518 commit 2fe54ec

36 files changed

+652
-137
lines changed

.eslintrc.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
]
2020
}
2121
]
22-
}
22+
},
23+
"plugins": ["ngrx"],
24+
"extends": []
2325
},
2426
{
2527
"files": ["*.ts", "*.tsx"],
2628
"extends": ["plugin:@nrwl/nx/typescript"],
27-
"rules": {}
29+
"rules": {},
30+
"plugins": ["ngrx"]
2831
},
2932
{
3033
"files": ["*.js", "*.jsx"],

angular.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
{
22
"version": 1,
33
"projects": {
4+
"interfaces": {
5+
"root": "libs/interfaces",
6+
"sourceRoot": "libs/interfaces/src",
7+
"projectType": "library",
8+
"architect": {
9+
"build": {
10+
"builder": "@nrwl/node:package",
11+
"outputs": ["{options.outputPath}"],
12+
"options": {
13+
"outputPath": "dist/libs/interfaces",
14+
"tsConfig": "libs/interfaces/tsconfig.lib.json",
15+
"packageJson": "libs/interfaces/package.json",
16+
"main": "libs/interfaces/src/index.ts",
17+
"assets": ["libs/interfaces/*.md"]
18+
}
19+
},
20+
"lint": {
21+
"builder": "@nrwl/linter:eslint",
22+
"outputs": ["{options.outputFile}"],
23+
"options": {
24+
"lintFilePatterns": ["libs/interfaces/**/*.ts"]
25+
}
26+
},
27+
"test": {
28+
"builder": "@nrwl/jest:jest",
29+
"outputs": ["coverage/libs/interfaces"],
30+
"options": {
31+
"jestConfig": "libs/interfaces/jest.config.js",
32+
"passWithNoTests": true
33+
}
34+
}
35+
}
36+
},
437
"nodeplotlib": {
538
"root": "libs/nodeplotlib",
639
"sourceRoot": "libs/nodeplotlib/src",

apps/web/src/app/app.module.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
import { HttpClientModule } from '@angular/common/http';
12
import { NgModule } from '@angular/core';
3+
import { MatButtonModule } from '@angular/material/button';
24
import { MatToolbarModule } from '@angular/material/toolbar';
35
import { BrowserModule } from '@angular/platform-browser';
46
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
57
import { AppRoutingModule } from './app-routing.module';
68
import { AppComponent } from './components/app/app.component';
9+
import { OverviewComponent } from './components/overview/overview.component';
710
import { StackComponent } from './components/stack/stack.component';
811
import { StacksComponent } from './components/stacks/stacks.component';
912
import { TutorialComponent } from './components/tutorial/tutorial.component';
10-
import { MatButtonModule } from '@angular/material/button';
11-
import { OverviewComponent } from './components/overview/overview.component';
13+
import { PlotsService } from './services/plots.service';
1214

1315
@NgModule({
1416
declarations: [
@@ -24,8 +26,9 @@ import { OverviewComponent } from './components/overview/overview.component';
2426
BrowserModule,
2527
MatButtonModule,
2628
MatToolbarModule,
29+
HttpClientModule,
2730
],
28-
providers: [],
31+
providers: [PlotsService],
2932
bootstrap: [AppComponent],
3033
})
3134
export class AppModule {}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
2+
import { PlotsService } from '../../services/plots.service';
23

34
@Component({
45
selector: 'npl-root',
56
templateUrl: './app.component.html',
67
styleUrls: ['./app.component.css'],
78
changeDetection: ChangeDetectionStrategy.OnPush,
89
})
9-
export class AppComponent {}
10+
export class AppComponent {
11+
constructor(private plotsService: PlotsService) {
12+
this.plotsService.loadPlots().subscribe();
13+
}
14+
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { Injectable } from '@angular/core';
22
import { Observable } from 'rxjs';
33
import { HttpClient } from '@angular/common/http';
4+
import { DataTransferObject } from '@npl/interfaces';
5+
46

57
@Injectable()
68
export class PlotsService {
79
constructor(private http: HttpClient) {}
810

9-
loadPlotsStack(id: number): Observable<any> {
10-
return this.http.get(`http://localhost:{{port}}/data/${id}`);
11+
loadPlots(): Observable<DataTransferObject> {
12+
return this.http.get<DataTransferObject>(`/api/plots`);
1113
}
1214
}

apps/web/src/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
<body class="mat-typography">
1717
<npl-root></npl-root>
1818
<!--<div id="container" data-plotid="{{plotid}}"></div>-->
19-
<script type="text/javascript" src="https://cdn.plot.ly/plotly-1.58.4.min.js"></script>
19+
<script
20+
type="text/javascript"
21+
src="https://cdn.plot.ly/plotly-1.58.4.min.js"
22+
async
23+
defer
24+
></script>
2025
</body>
2126
</html>

libs/interfaces/.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]]
3+
}

libs/interfaces/.eslintrc.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}

libs/interfaces/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# interfaces
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Running unit tests
6+
7+
Run `nx test interfaces` to execute the unit tests via [Jest](https://jestjs.io).

libs/interfaces/jest.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
displayName: 'interfaces',
3+
preset: '../../jest.preset.js',
4+
globals: {
5+
'ts-jest': {
6+
tsconfig: '<rootDir>/tsconfig.spec.json',
7+
},
8+
},
9+
testEnvironment: 'node',
10+
transform: {
11+
'^.+\\.[tj]sx?$': 'ts-jest',
12+
},
13+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
14+
coverageDirectory: '../../coverage/libs/interfaces',
15+
};

0 commit comments

Comments
 (0)