Skip to content

Commit d5ad606

Browse files
Update/angular 10 to angular 15 (#364)
1 parent 6b14e6f commit d5ad606

File tree

111 files changed

+7774
-7296
lines changed

Some content is hidden

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

111 files changed

+7774
-7296
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
!.vscode/extensions.json
3232

3333
# misc
34+
/.angular/cache
3435
/.sass-cache
3536
/connect.lock
3637
/coverage

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
## [2.3.0-dev-test] - 2023-08-11
10+
11+
- Migrate to angular 16
12+
913
### Fixed
1014

1115
- Fixed error lint with eslint ([#332](https://github.com/reyesoft/ngx-jsonapi/pull/332))

angular.json

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,23 @@
1111
"build": {
1212
"builder": "@angular-devkit/build-angular:browser",
1313
"options": {
14-
"aot": true,
1514
"outputPath": "demo-dist",
1615
"index": "demo/index.html",
1716
"main": "demo/main.ts",
1817
"tsConfig": "demo/tsconfig.app.json",
19-
"showCircularDependencies": false,
2018
"polyfills": "demo/polyfills.ts",
2119
"assets": [
2220
"demo/assets",
2321
"demo/favicon.ico"
2422
],
2523
"styles": [],
26-
"scripts": []
24+
"scripts": [],
25+
"vendorChunk": true,
26+
"extractLicenses": false,
27+
"buildOptimizer": false,
28+
"sourceMap": true,
29+
"optimization": false,
30+
"namedChunks": true
2731
},
2832
"configurations": {
2933
"production": {
@@ -36,9 +40,7 @@
3640
"optimization": true,
3741
"outputHashing": "all",
3842
"sourceMap": false,
39-
"extractCss": true,
4043
"namedChunks": false,
41-
"aot": true,
4244
"extractLicenses": true,
4345
"vendorChunk": false,
4446
"buildOptimizer": true,
@@ -49,7 +51,8 @@
4951
}
5052
]
5153
}
52-
}
54+
},
55+
"defaultConfiguration": ""
5356
},
5457
"serve": {
5558
"builder": "@angular-devkit/build-angular:dev-server",
@@ -67,16 +70,6 @@
6770
"options": {
6871
"browserTarget": "ngx-jsonapi:build"
6972
}
70-
},
71-
"lint": {
72-
"builder": "@angular-devkit/build-angular:tslint",
73-
"options": {
74-
"tsConfig": [
75-
"demo/tsconfig.app.json",
76-
"demo/tsconfig.spec.json"
77-
],
78-
"exclude": []
79-
}
8073
}
8174
}
8275
},
@@ -91,20 +84,43 @@
9184
"protractorConfig": "./protractor.conf.js",
9285
"devServerTarget": "ngx-jsonapi:serve"
9386
}
87+
}
88+
}
89+
},
90+
"ngx-jsonapi-lib": {
91+
"projectType": "library",
92+
"root": "projects/ngx-jsonapi-lib",
93+
"sourceRoot": "projects/ngx-jsonapi-lib/src",
94+
"prefix": "lib",
95+
"architect": {
96+
"build": {
97+
"builder": "@angular-devkit/build-angular:ng-packagr",
98+
"options": {
99+
"project": "projects/ngx-jsonapi-lib/ng-package.json"
100+
},
101+
"configurations": {
102+
"production": {
103+
"tsConfig": "projects/ngx-jsonapi-lib/tsconfig.lib.prod.json"
104+
},
105+
"development": {
106+
"tsConfig": "projects/ngx-jsonapi-lib/tsconfig.lib.json"
107+
}
108+
},
109+
"defaultConfiguration": "production"
94110
},
95-
"lint": {
96-
"builder": "@angular-devkit/build-angular:tslint",
111+
"test": {
112+
"builder": "@angular-devkit/build-angular:karma",
97113
"options": {
98-
"tsConfig": [
99-
"e2e/tsconfig.e2e.json"
100-
],
101-
"exclude": []
114+
"tsConfig": "projects/ngx-jsonapi-lib/tsconfig.spec.json",
115+
"polyfills": [
116+
"zone.js",
117+
"zone.js/testing"
118+
]
102119
}
103120
}
104121
}
105122
}
106123
},
107-
"defaultProject": "ngx-jsonapi",
108124
"schematics": {
109125
"@schematics/angular:component": {
110126
"inlineStyle": true,

build/tasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function compilePackagesWithNgc(config: Config): Promise<void> {
2626

2727
async function _compilePackagesWithNgc(pkg: string): Promise<void> {
2828
// await util.exec('ngc', [`-p ./src/${pkg}/tsconfig-build.json`]);
29-
await util.exec('ngc', [`-p ./src/tsconfig-build.json`]);
29+
await util.exec('ng build', [`-p ./src/tsconfig-build.json`]);
3030

3131
/**
3232
* Test modules are treated differently because nested inside top-level.

demo/app/app.module.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import { SharedModule } from './shared/shared.module';
1313

1414
import { StoreService } from 'ngx-jsonapi/sources/store.service';
1515
import { JsonRipper } from 'ngx-jsonapi/services/json-ripper';
16-
import { AuthorsModule } from './authors/authors.module';
17-
import { BooksModule } from './books/books.module';
1816

1917
const appRoutes: Routes = [
2018
{
@@ -24,11 +22,15 @@ const appRoutes: Routes = [
2422
},
2523
{
2624
path: 'authors',
27-
loadChildren: (): Promise<AuthorsModule> => import('./authors/authors.module').then((m): AuthorsModule => m.AuthorsModule)
25+
loadChildren: () => import('./authors/authors.module').then((m) => m.AuthorsModule)
26+
},
27+
{
28+
path: 'systems',
29+
loadChildren: () => import('./systems/systems.module').then((m) => m.SystemsModule)
2830
},
2931
{
3032
path: 'books',
31-
loadChildren: (): Promise<BooksModule> => import('./books/books.module').then((m): BooksModule => m.BooksModule)
33+
loadChildren: () => import('./books/books.module').then((m) => m.BooksModule)
3234
}
3335
];
3436

@@ -52,7 +54,7 @@ const appRoutes: Routes = [
5254
SharedModule,
5355
RouterModule.forRoot(appRoutes, { useHash: true }),
5456
NgxJsonapiModule.forRoot({
55-
url: environment.jsonapi_url
57+
url: environment.api_saldo,
5658
})
5759
],
5860
declarations: [AppComponent],
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<h3>systems</h3>
2+
<demo-collection-info [collection]="systems"></demo-collection-info>
3+
<table class="table table-striped">
4+
<thead>
5+
<tr>
6+
<th>ID</th>
7+
<th>Name</th>
8+
</tr>
9+
</thead>
10+
<tr *ngFor="let systems of systems.data; trackBy: systems.trackBy">
11+
<td>{{ systems.id }}</td>
12+
<td>
13+
<a [routerLink]="['/systems', systems.id]">{{ systems.attributes.name }}</a>
14+
<code><small>{{ systems.source }}</small></code>
15+
</td>
16+
</tr>
17+
</table>
18+
<demo-collection-paginator [collection]="systems"></demo-collection-paginator>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { ActivatedRoute } from '@angular/router';
3+
import { DocumentCollection } from 'ngx-jsonapi';
4+
import { System, SystemsService } from './systems.service';
5+
6+
@Component({
7+
selector: 'bc-systems',
8+
templateUrl: './systems.component.html',
9+
styles: [
10+
]
11+
})
12+
export class SystemsComponent {
13+
public systems: DocumentCollection<System>;
14+
15+
public constructor(private route: ActivatedRoute, private authorsService: SystemsService) {
16+
route.queryParams.subscribe(({ page }) => {
17+
authorsService
18+
.all()
19+
.subscribe(
20+
systems => {
21+
this.systems = systems;
22+
},
23+
error => console.error('Could not load authors :(', error)
24+
);
25+
});
26+
}
27+
}

demo/app/systems/systems.module.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import { SystemsComponent } from './systems.component';
4+
import { RouterModule, Routes } from '@angular/router';
5+
import { SharedModule } from '../shared/shared.module';
6+
import { SystemsService } from './systems.service';
7+
8+
export const routes: Routes = [
9+
{
10+
path: '',
11+
component: SystemsComponent
12+
}
13+
];
14+
15+
@NgModule({
16+
imports: [RouterModule.forChild(routes)],
17+
exports: [RouterModule]
18+
})
19+
export class SystemsRoutingModule { }
20+
21+
22+
@NgModule({
23+
declarations: [
24+
SystemsComponent
25+
],
26+
imports: [
27+
CommonModule,
28+
SharedModule,
29+
SystemsRoutingModule
30+
],
31+
providers: [SystemsService]
32+
})
33+
export class SystemsModule { }
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Injectable } from '@angular/core';
2+
import { Service, Resource, DocumentCollection } from 'ngx-jsonapi';
3+
import { Book } from '../books/books.service';
4+
import { Photo } from '../photos/photos.service';
5+
6+
export class System extends Resource {
7+
public attributes: any;
8+
9+
public relationships: {
10+
books: DocumentCollection<Book>;
11+
photos: DocumentCollection<Photo>
12+
} = {
13+
books: new DocumentCollection<Book>(),
14+
photos: new DocumentCollection<Photo>()
15+
};
16+
}
17+
18+
@Injectable()
19+
export class SystemsService extends Service<System> {
20+
public resource: typeof System = System;
21+
public type: string = 'systems';
22+
}

demo/environments/environment.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55

66
export const environment: { [key: string]: any } = {
77
production: false,
8-
jsonapi_url: '//jsonapiplayground.reyesoft.com/v2/'
8+
jsonapi_url: '//jsonapiplayground.reyesoft.com/v2/',
9+
api_saldo: 'https://api.saldo.com.ar/v3/'
910
};

0 commit comments

Comments
 (0)