Skip to content

Commit 3798bda

Browse files
committed
upgrade Angular to v17.1
1 parent 2cc20aa commit 3798bda

File tree

12 files changed

+344
-313
lines changed

12 files changed

+344
-313
lines changed

package-lock.json

Lines changed: 241 additions & 204 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/features/assets/assets.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
height="115"
8888
loading="lazy"
8989
alt="thumbnail"
90-
ngSrc="/api/v1/spaces/{{ spaceId }}/assets/{{ element.id }}" />
90+
ngSrc="/api/v1/spaces/{{ spaceId() }}/assets/{{ element.id }}" />
9191
</ng-template>
9292
</ng-container>
9393
</mat-cell>

src/app/features/assets/assets.component.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, inject, Input, OnInit, ViewChild } from '@angular/core';
1+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, inject, input, OnInit, ViewChild } from '@angular/core';
22
import { ActivatedRoute, Router } from '@angular/router';
33
import { MatTableDataSource } from '@angular/material/table';
44
import { MatDialog } from '@angular/material/dialog';
@@ -42,8 +42,8 @@ export class AssetsComponent implements OnInit {
4242
@ViewChild(MatSort, { static: false }) sort?: MatSort;
4343
@ViewChild(MatPaginator, { static: false }) paginator?: MatPaginator;
4444

45-
@Input({ required: true })
46-
spaceId!: string;
45+
// Input
46+
spaceId = input.required<string>();
4747

4848
private destroyRef = inject(DestroyRef);
4949
dataSource: MatTableDataSource<Asset> = new MatTableDataSource<Asset>([]);
@@ -79,12 +79,12 @@ export class AssetsComponent implements OnInit {
7979
) {}
8080

8181
ngOnInit(): void {
82-
this.loadData(this.spaceId);
82+
this.loadData(this.spaceId());
8383

8484
this.fileUploadQueue$
8585
.pipe(
8686
tap(console.log),
87-
concatMap(it => this.assetService.createFile(this.spaceId, this.parentPath, it)),
87+
concatMap(it => this.assetService.createFile(this.spaceId(), this.parentPath, it)),
8888
takeUntilDestroyed(this.destroyRef)
8989
)
9090
.subscribe({
@@ -155,7 +155,7 @@ export class AssetsComponent implements OnInit {
155155
.afterClosed()
156156
.pipe(
157157
filter(it => it !== undefined),
158-
switchMap(it => this.assetService.createFolder(this.spaceId, this.parentPath, it!))
158+
switchMap(it => this.assetService.createFolder(this.spaceId(), this.parentPath, it!))
159159
)
160160
.subscribe({
161161
next: () => {
@@ -190,7 +190,7 @@ export class AssetsComponent implements OnInit {
190190
.afterClosed()
191191
.pipe(
192192
filter(it => it !== undefined),
193-
switchMap(it => this.assetService.updateFolder(this.spaceId, element.id, it!))
193+
switchMap(it => this.assetService.updateFolder(this.spaceId(), element.id, it!))
194194
)
195195
.subscribe({
196196
next: () => {
@@ -219,7 +219,7 @@ export class AssetsComponent implements OnInit {
219219
.afterClosed()
220220
.pipe(
221221
filter(it => it !== undefined),
222-
switchMap(it => this.assetService.updateFile(this.spaceId, element.id, it!))
222+
switchMap(it => this.assetService.updateFile(this.spaceId(), element.id, it!))
223223
)
224224
.subscribe({
225225
next: () => {
@@ -248,7 +248,7 @@ export class AssetsComponent implements OnInit {
248248
.afterClosed()
249249
.pipe(
250250
filter(it => it || false),
251-
switchMap(() => this.assetService.delete(this.spaceId, element.id))
251+
switchMap(() => this.assetService.delete(this.spaceId(), element.id))
252252
)
253253
.subscribe({
254254
next: () => {
@@ -335,14 +335,14 @@ export class AssetsComponent implements OnInit {
335335
.pipe(
336336
filter(it => it !== undefined),
337337
tap(console.log),
338-
switchMap(it => this.taskService.createAssetImportTask(this.spaceId, it!.file))
338+
switchMap(it => this.taskService.createAssetImportTask(this.spaceId(), it!.file))
339339
)
340340
.subscribe({
341341
next: () => {
342342
this.notificationService.success('Assets Import Task has been created.', [
343343
{
344344
label: 'To Tasks',
345-
link: `/features/spaces/${this.spaceId}/tasks`,
345+
link: `/features/spaces/${this.spaceId()}/tasks`,
346346
},
347347
]);
348348
},
@@ -357,20 +357,20 @@ export class AssetsComponent implements OnInit {
357357
.open<ExportDialogComponent, ExportDialogModel, ExportDialogReturn>(ExportDialogComponent, {
358358
width: '500px',
359359
data: {
360-
spaceId: this.spaceId,
360+
spaceId: this.spaceId(),
361361
},
362362
})
363363
.afterClosed()
364364
.pipe(
365365
filter(it => it !== undefined),
366-
switchMap(it => this.taskService.createAssetExportTask(this.spaceId, it?.path))
366+
switchMap(it => this.taskService.createAssetExportTask(this.spaceId(), it?.path))
367367
)
368368
.subscribe({
369369
next: () => {
370370
this.notificationService.success('Assets Export Task has been created.', [
371371
{
372372
label: 'To Tasks',
373-
link: `/features/spaces/${this.spaceId}/tasks`,
373+
link: `/features/spaces/${this.spaceId()}/tasks`,
374374
},
375375
]);
376376
},
@@ -385,7 +385,7 @@ export class AssetsComponent implements OnInit {
385385
// Prevent Default
386386
event.preventDefault();
387387
event.stopImmediatePropagation();
388-
window.open(`/api/v1/spaces/${this.spaceId}/assets/${element.id}?download`);
388+
window.open(`/api/v1/spaces/${this.spaceId()}/assets/${element.id}?download`);
389389
}
390390

391391
filesDragAndDrop(event: File[]) {

src/app/features/contents/contents.component.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, inject, Input, OnInit, ViewChild } from '@angular/core';
1+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, inject, input, Input, OnInit, ViewChild } from '@angular/core';
22
import { ActivatedRoute, Router } from '@angular/router';
33
import { MatTableDataSource } from '@angular/material/table';
44
import { MatDialog } from '@angular/material/dialog';
@@ -52,8 +52,8 @@ export class ContentsComponent implements OnInit {
5252
@ViewChild(MatSort, { static: false }) sort?: MatSort;
5353
@ViewChild(MatPaginator, { static: false }) paginator?: MatPaginator;
5454

55-
@Input({ required: true })
56-
spaceId!: string;
55+
// Input
56+
spaceId = input.required<string>();
5757

5858
isLoading = true;
5959
dataSource: MatTableDataSource<Content> = new MatTableDataSource<Content>([]);
@@ -89,7 +89,7 @@ export class ContentsComponent implements OnInit {
8989
) {}
9090

9191
ngOnInit(): void {
92-
this.loadData(this.spaceId);
92+
this.loadData(this.spaceId());
9393
}
9494

9595
loadData(spaceId: string): void {
@@ -142,7 +142,7 @@ export class ContentsComponent implements OnInit {
142142
.afterClosed()
143143
.pipe(
144144
filter(it => it !== undefined),
145-
switchMap(it => this.contentService.createDocument(this.spaceId, this.parentPath, it!))
145+
switchMap(it => this.contentService.createDocument(this.spaceId(), this.parentPath, it!))
146146
)
147147
.subscribe({
148148
next: () => {
@@ -166,7 +166,7 @@ export class ContentsComponent implements OnInit {
166166
.afterClosed()
167167
.pipe(
168168
filter(it => it !== undefined),
169-
switchMap(it => this.contentService.createFolder(this.spaceId, this.parentPath, it!))
169+
switchMap(it => this.contentService.createFolder(this.spaceId(), this.parentPath, it!))
170170
)
171171
.subscribe({
172172
next: () => {
@@ -194,7 +194,7 @@ export class ContentsComponent implements OnInit {
194194
.afterClosed()
195195
.pipe(
196196
filter(it => it !== undefined),
197-
switchMap(it => this.contentService.update(this.spaceId, element.id, this.parentPath, it!))
197+
switchMap(it => this.contentService.update(this.spaceId(), element.id, this.parentPath, it!))
198198
)
199199
.subscribe({
200200
next: () => {
@@ -222,7 +222,7 @@ export class ContentsComponent implements OnInit {
222222
.afterClosed()
223223
.pipe(
224224
filter(it => it || false),
225-
switchMap(() => this.contentService.delete(this.spaceId, element))
225+
switchMap(() => this.contentService.delete(this.spaceId(), element))
226226
)
227227
.subscribe({
228228
next: () => {
@@ -251,7 +251,7 @@ export class ContentsComponent implements OnInit {
251251
.afterClosed()
252252
.pipe(
253253
filter(it => it || false),
254-
switchMap(() => this.contentService.cloneDocument(this.spaceId, element))
254+
switchMap(() => this.contentService.cloneDocument(this.spaceId(), element))
255255
)
256256
.subscribe({
257257
next: () => {
@@ -289,7 +289,7 @@ export class ContentsComponent implements OnInit {
289289
if (element.kind === ContentKind.DOCUMENT) {
290290
element.publishedAt;
291291
if (this.schemasMap.has(element.schema)) {
292-
this.router.navigate(['features', 'spaces', this.spaceId, 'contents', element.id]);
292+
this.router.navigate(['features', 'spaces', this.spaceId(), 'contents', element.id]);
293293
} else {
294294
this.notificationService.warn(`Content Schema can not be found.`);
295295
}
@@ -317,10 +317,10 @@ export class ContentsComponent implements OnInit {
317317
}
318318

319319
openLinksInNewTab() {
320-
this.tokenService.findFirst(this.spaceId).subscribe({
320+
this.tokenService.findFirst(this.spaceId()).subscribe({
321321
next: tokens => {
322322
if (tokens.length === 1) {
323-
const url = new URL(`${location.origin}/api/v1/spaces/${this.spaceId}/links`);
323+
const url = new URL(`${location.origin}/api/v1/spaces/${this.spaceId()}/links`);
324324
url.searchParams.set('token', tokens[0].id);
325325
window.open(url, '_blank');
326326
} else {
@@ -339,14 +339,14 @@ export class ContentsComponent implements OnInit {
339339
.pipe(
340340
filter(it => it !== undefined),
341341
tap(console.log),
342-
switchMap(it => this.taskService.createContentImportTask(this.spaceId, it!.file))
342+
switchMap(it => this.taskService.createContentImportTask(this.spaceId(), it!.file))
343343
)
344344
.subscribe({
345345
next: () => {
346346
this.notificationService.success('Content Import Task has been created.', [
347347
{
348348
label: 'To Tasks',
349-
link: `/features/spaces/${this.spaceId}/tasks`,
349+
link: `/features/spaces/${this.spaceId()}/tasks`,
350350
},
351351
]);
352352
},
@@ -361,20 +361,20 @@ export class ContentsComponent implements OnInit {
361361
.open<ExportDialogComponent, ExportDialogModel, ExportDialogReturn>(ExportDialogComponent, {
362362
width: '500px',
363363
data: {
364-
spaceId: this.spaceId,
364+
spaceId: this.spaceId(),
365365
},
366366
})
367367
.afterClosed()
368368
.pipe(
369369
filter(it => it !== undefined),
370-
switchMap(it => this.taskService.createContentExportTask(this.spaceId, it?.path))
370+
switchMap(it => this.taskService.createContentExportTask(this.spaceId(), it?.path))
371371
)
372372
.subscribe({
373373
next: () => {
374374
this.notificationService.success('Content Export Task has been created.', [
375375
{
376376
label: 'To Tasks',
377-
link: `/features/spaces/${this.spaceId}/tasks`,
377+
link: `/features/spaces/${this.spaceId()}/tasks`,
378378
},
379379
]);
380380
},

src/app/features/contents/edit-document/edit-document.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@
238238
}
239239
@if (item.cData) {
240240
content
241+
} @else {
242+
nothing
241243
}
242244
</p>
243245
</div>

src/app/features/contents/edit-document/edit-document.component.ts

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, HostListener, inject, Input, OnInit } from '@angular/core';
1+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, HostListener, inject, input, OnInit } from '@angular/core';
22
import { FormBuilder } from '@angular/forms';
33
import { Schema, SchemaFieldKind } from '@shared/models/schema.model';
44
import { FormErrorHandlerService } from '@core/error-handler/form-error-handler.service';
@@ -34,10 +34,9 @@ import { ContentHistoryService } from '@shared/services/content-history.service'
3434
changeDetection: ChangeDetectionStrategy.OnPush,
3535
})
3636
export class EditDocumentComponent implements OnInit {
37-
@Input({ required: true })
38-
spaceId!: string;
39-
@Input({ required: true })
40-
contentId!: string;
37+
// Input
38+
spaceId = input.required<string>();
39+
contentId = input.required<string>();
4140

4241
showHistory = false;
4342

@@ -47,7 +46,6 @@ export class EditDocumentComponent implements OnInit {
4746
iframeUrl?: SafeUrl;
4847
availableLocales: Locale[] = [];
4948
availableLocalesMap: Map<string, string> = new Map<string, string>();
50-
entityId: string;
5149
document?: ContentDocument;
5250
documentData: ContentData = { _id: '', schema: '' };
5351
selectedDocumentData: ContentData = { _id: '', schema: '' };
@@ -88,13 +86,11 @@ export class EditDocumentComponent implements OnInit {
8886
private readonly contentHelperService: ContentHelperService,
8987
private readonly sanitizer: DomSanitizer,
9088
readonly fe: FormErrorHandlerService
91-
) {
92-
this.entityId = this.activatedRoute.snapshot.paramMap.get('contentId') || '';
93-
}
89+
) {}
9490

9591
ngOnInit(): void {
96-
this.loadData(this.entityId);
97-
this.history$ = this.contentHistoryService.findAll(this.spaceId, this.contentId);
92+
this.loadData(this.contentId());
93+
this.history$ = this.contentHistoryService.findAll(this.spaceId(), this.contentId());
9894
}
9995

10096
loadData(contentId: string): void {
@@ -160,7 +156,7 @@ export class EditDocumentComponent implements OnInit {
160156

161157
publish(): void {
162158
this.isPublishLoading = true;
163-
this.contentService.publish(this.selectedSpace!.id, this.entityId).subscribe({
159+
this.contentService.publish(this.spaceId(), this.contentId()).subscribe({
164160
next: () => {
165161
this.notificationService.success('Content has been published.');
166162
},
@@ -192,15 +188,13 @@ export class EditDocumentComponent implements OnInit {
192188

193189
if (this.contentErrors.length === 0) {
194190
if (this.document?.editorEnabled !== this.editorEnabledCtr.value) {
195-
this.contentService
196-
.updateDocumentEditorEnabled(this.selectedSpace!.id, this.entityId, this.editorEnabledCtr.value || false)
197-
.subscribe({
198-
next: () => {
199-
console.log('updateDocumentEditorEnabled updated');
200-
},
201-
});
191+
this.contentService.updateDocumentEditorEnabled(this.spaceId(), this.contentId(), this.editorEnabledCtr.value || false).subscribe({
192+
next: () => {
193+
console.log('updateDocumentEditorEnabled updated');
194+
},
195+
});
202196
}
203-
this.contentService.updateDocumentData(this.selectedSpace!.id, this.entityId, this.documentData).subscribe({
197+
this.contentService.updateDocumentData(this.spaceId(), this.contentId(), this.documentData).subscribe({
204198
next: () => {
205199
this.notificationService.success('Content has been updated.');
206200
},
@@ -222,14 +216,14 @@ export class EditDocumentComponent implements OnInit {
222216
}
223217

224218
back(): void {
225-
this.router.navigate(['features', 'spaces', this.spaceId, 'contents']);
219+
this.router.navigate(['features', 'spaces', this.spaceId(), 'contents']);
226220
}
227221

228222
openDraftInNewTab(locale: string): void {
229-
this.tokenService.findFirst(this.selectedSpace!.id).subscribe({
223+
this.tokenService.findFirst(this.spaceId()).subscribe({
230224
next: tokens => {
231225
if (tokens.length === 1) {
232-
const url = new URL(`${location.origin}/api/v1/spaces/${this.selectedSpace?.id}/contents/${this.entityId}`);
226+
const url = new URL(`${location.origin}/api/v1/spaces/${this.spaceId()}/contents/${this.contentId()}`);
233227
url.searchParams.set('locale', locale);
234228
url.searchParams.set('version', 'draft');
235229
url.searchParams.set('token', tokens[0].id);
@@ -242,10 +236,10 @@ export class EditDocumentComponent implements OnInit {
242236
}
243237

244238
openPublishedInNewTab(locale: string): void {
245-
this.tokenService.findFirst(this.selectedSpace!.id).subscribe({
239+
this.tokenService.findFirst(this.spaceId()).subscribe({
246240
next: tokens => {
247241
if (tokens.length === 1) {
248-
const url = new URL(`${location.origin}/api/v1/spaces/${this.selectedSpace?.id}/contents/${this.entityId}`);
242+
const url = new URL(`${location.origin}/api/v1/spaces/${this.spaceId()}/contents/${this.contentId()}`);
249243
url.searchParams.set('locale', locale);
250244
url.searchParams.set('token', tokens[0].id);
251245
window.open(url, '_blank');

0 commit comments

Comments
 (0)