diff --git a/src/Squidex/app/features/api/api-area.component.ts b/src/Squidex/app/features/api/api-area.component.ts index a66bff1b4..cf4864388 100644 --- a/src/Squidex/app/features/api/api-area.component.ts +++ b/src/Squidex/app/features/api/api-area.component.ts @@ -10,6 +10,7 @@ import { Component } from '@angular/core'; import { AppComponentBase, AppsStoreService, + AuthService, DialogService } from 'shared'; @@ -19,8 +20,8 @@ import { templateUrl: './api-area.component.html' }) export class ApiAreaComponent extends AppComponentBase { - constructor(apps: AppsStoreService, dialogs: DialogService + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService ) { - super(dialogs, apps); + super(dialogs, apps, authService); } } \ No newline at end of file diff --git a/src/Squidex/app/features/api/pages/graphql/graphql-page.component.ts b/src/Squidex/app/features/api/pages/graphql/graphql-page.component.ts index a4da0799d..c045b75df 100644 --- a/src/Squidex/app/features/api/pages/graphql/graphql-page.component.ts +++ b/src/Squidex/app/features/api/pages/graphql/graphql-page.component.ts @@ -18,6 +18,7 @@ const GraphiQL = require('graphiql'); import { AppComponentBase, AppsStoreService, + AuthService, DialogService, GraphQlService, LocalStoreService @@ -33,11 +34,11 @@ export class GraphQLPageComponent extends AppComponentBase implements OnInit { @ViewChild('graphiQLContainer') public graphiQLContainer: ElementRef; - constructor(apps: AppsStoreService, dialogs: DialogService, + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService, private readonly graphQlService: GraphQlService, private readonly localStoreService: LocalStoreService ) { - super(dialogs, apps); + super(dialogs, apps, authService); } public ngOnInit() { diff --git a/src/Squidex/app/features/assets/pages/assets-page.component.ts b/src/Squidex/app/features/assets/pages/assets-page.component.ts index afa2a854e..f1d7bc2a0 100644 --- a/src/Squidex/app/features/assets/pages/assets-page.component.ts +++ b/src/Squidex/app/features/assets/pages/assets-page.component.ts @@ -17,6 +17,7 @@ import { AssetDto, AssetsService, AssetUpdated, + AuthService, DialogService, ImmutableArray, MessageBus, @@ -38,11 +39,11 @@ export class AssetsPageComponent extends AppComponentBase implements OnDestroy, public assetsFilter = new FormControl(); public assertQuery = ''; - constructor(apps: AppsStoreService, dialogs: DialogService, + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService, private readonly assetsService: AssetsService, private readonly messageBus: MessageBus ) { - super(dialogs, apps); + super(dialogs, apps, authService); } public ngOnInit() { diff --git a/src/Squidex/app/features/content/pages/content/content-history.component.ts b/src/Squidex/app/features/content/pages/content/content-history.component.ts index 5a7547e6b..cc4ed02ed 100644 --- a/src/Squidex/app/features/content/pages/content/content-history.component.ts +++ b/src/Squidex/app/features/content/pages/content/content-history.component.ts @@ -13,6 +13,7 @@ import { allParams, AppComponentBase, AppsStoreService, + AuthService, DialogService, HistoryChannelUpdated, HistoryEventDto, @@ -55,13 +56,13 @@ export class ContentHistoryComponent extends AppComponentBase { .switchMap(() => this.appNameOnce()) .switchMap(app => this.historyService.getHistory(app, this.channel).retry(2)); - constructor(appsStore: AppsStoreService, dialogs: DialogService, + constructor(appsStore: AppsStoreService, dialogs: DialogService, authService: AuthService, private readonly users: UsersProviderService, private readonly historyService: HistoryService, private readonly messageBus: MessageBus, private readonly route: ActivatedRoute ) { - super(dialogs, appsStore); + super(dialogs, appsStore, authService); } private userName(userId: string): Observable { diff --git a/src/Squidex/app/features/content/pages/content/content-page.component.ts b/src/Squidex/app/features/content/pages/content/content-page.component.ts index 2fdc5edd0..aa85c4da8 100644 --- a/src/Squidex/app/features/content/pages/content/content-page.component.ts +++ b/src/Squidex/app/features/content/pages/content/content-page.component.ts @@ -55,14 +55,13 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone public languages: AppLanguageDto[] = []; - constructor(apps: AppsStoreService, dialogs: DialogService, - private readonly authService: AuthService, + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService, private readonly contentsService: ContentsService, private readonly route: ActivatedRoute, private readonly router: Router, private readonly messageBus: MessageBus ) { - super(dialogs, apps); + super(dialogs, apps, authService); } public ngOnDestroy() { @@ -87,7 +86,7 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone this.messageBus.of(ContentPublished) .subscribe(message => { if (this.content && message.content.id === this.content.id) { - this.content = this.content.replaceVersion(message.content.version); + this.content = this.content.publish(message.content.lastModifiedBy, message.content.version, message.content.lastModified); } }); @@ -95,7 +94,7 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone this.messageBus.of(ContentUnpublished) .subscribe(message => { if (this.content && message.content.id === this.content.id) { - this.content = this.content.replaceVersion(message.content.version); + this.content = this.content.unpublish(message.content.lastModifiedBy, message.content.version, message.content.lastModified); } }); @@ -158,7 +157,7 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone this.appNameOnce() .switchMap(app => this.contentsService.putContent(app, this.schema.name, this.content.id, requestDto, this.content.version)) .subscribe(dto => { - this.content = this.content.update(dto, this.authService.user!.token); + this.content = this.content.update(dto.payload, this.userToken, dto.version); this.emitContentUpdated(this.content); this.notifyInfo('Content saved successfully.'); diff --git a/src/Squidex/app/features/content/pages/contents/contents-page.component.ts b/src/Squidex/app/features/content/pages/contents/contents-page.component.ts index 057eeb839..76e94b060 100644 --- a/src/Squidex/app/features/content/pages/contents/contents-page.component.ts +++ b/src/Squidex/app/features/content/pages/contents/contents-page.component.ts @@ -63,13 +63,12 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy public columnWidth: number; - constructor(apps: AppsStoreService, dialogs: DialogService, - private readonly authService: AuthService, + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService, private readonly contentsService: ContentsService, private readonly route: ActivatedRoute, private readonly messageBus: MessageBus ) { - super(dialogs, apps); + super(dialogs, apps, authService); } public ngOnDestroy() { @@ -92,7 +91,7 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy this.contentUpdatedSubscription = this.messageBus.of(ContentUpdated) .subscribe(message => { - this.contentItems = this.contentItems.replaceBy('id', message.content, (o, n) => o.update(n.data, n.lastModifiedBy)); + this.contentItems = this.contentItems.replaceBy('id', message.content, (o, n) => o.update(n.data, n.lastModifiedBy, n.version, n.lastModified)); }); this.route.params.map(p => p['language']) @@ -118,8 +117,10 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy public publishContent(content: ContentDto) { this.appNameOnce() .switchMap(app => this.contentsService.publishContent(app, this.schema.name, content.id, content.version)) - .subscribe(() => { - this.contentItems = this.contentItems.replaceBy('id', content.publish(this.authService.user!.token)); + .subscribe(dto => { + content = content.publish(this.userToken, dto.version); + + this.contentItems = this.contentItems.replaceBy('id', content); this.emitContentPublished(content); }, error => { @@ -130,8 +131,10 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy public unpublishContent(content: ContentDto) { this.appNameOnce() .switchMap(app => this.contentsService.unpublishContent(app, this.schema.name, content.id, content.version)) - .subscribe(() => { - this.contentItems = this.contentItems.replaceBy('id', content.unpublish(this.authService.user!.token)); + .subscribe(dto => { + content = content.unpublish(this.userToken, dto.version); + + this.contentItems = this.contentItems.replaceBy('id', content); this.emitContentUnpublished(content); }, error => { @@ -142,8 +145,8 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy public archiveContent(content: ContentDto) { this.appNameOnce() .switchMap(app => this.contentsService.archiveContent(app, this.schema.name, content.id, content.version)) - .subscribe(() => { - content = content.archive(this.authService.user!.token); + .subscribe(dto => { + content = content.archive(this.userToken, dto.version); this.removeContent(content); }, error => { @@ -154,8 +157,8 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy public restoreContent(content: ContentDto) { this.appNameOnce() .switchMap(app => this.contentsService.restoreContent(app, this.schema.name, content.id, content.version)) - .subscribe(() => { - content = content.restore(this.authService.user!.token); + .subscribe(dto => { + content = content.restore(this.userToken, dto.version); this.removeContent(content); }, error => { diff --git a/src/Squidex/app/features/content/pages/schemas/schemas-page.component.ts b/src/Squidex/app/features/content/pages/schemas/schemas-page.component.ts index af1cbc5a2..0664d01ff 100644 --- a/src/Squidex/app/features/content/pages/schemas/schemas-page.component.ts +++ b/src/Squidex/app/features/content/pages/schemas/schemas-page.component.ts @@ -12,6 +12,7 @@ import { Observable } from 'rxjs'; import { AppComponentBase, AppsStoreService, + AuthService, DialogService, SchemaDto, SchemasService @@ -52,10 +53,10 @@ export class SchemasPageComponent extends AppComponentBase { }); }); - constructor(apps: AppsStoreService, dialogs: DialogService, + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService, private readonly schemasService: SchemasService ) { - super(dialogs, apps); + super(dialogs, apps, authService); } private loadSchemas(): Observable { diff --git a/src/Squidex/app/features/content/shared/assets-editor.component.ts b/src/Squidex/app/features/content/shared/assets-editor.component.ts index a8176fc71..48d82ae43 100644 --- a/src/Squidex/app/features/content/shared/assets-editor.component.ts +++ b/src/Squidex/app/features/content/shared/assets-editor.component.ts @@ -17,6 +17,7 @@ import { AssetDto, AssetsService, AssetUpdated, + AuthService, DialogService, ImmutableArray, MessageBus, @@ -43,11 +44,11 @@ export class AssetsEditorComponent extends AppComponentBase implements ControlVa public isDisabled = false; - constructor(apps: AppsStoreService, dialogs: DialogService, + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService, private readonly assetsService: AssetsService, private readonly messageBus: MessageBus ) { - super(dialogs, apps); + super(dialogs, apps, authService); } public ngOnInit() { diff --git a/src/Squidex/app/features/content/shared/content-item.component.ts b/src/Squidex/app/features/content/shared/content-item.component.ts index 8c476f578..f386cf1d6 100644 --- a/src/Squidex/app/features/content/shared/content-item.component.ts +++ b/src/Squidex/app/features/content/shared/content-item.component.ts @@ -10,6 +10,7 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angu import { AppComponentBase, AppsStoreService, + AuthService, ContentDto, DialogService, fadeAnimation, @@ -66,8 +67,8 @@ export class ContentItemComponent extends AppComponentBase implements OnInit, On public values: any[] = []; - constructor(apps: AppsStoreService, dialogs: DialogService) { - super(dialogs, apps); + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService) { + super(dialogs, apps, authService); } public ngOnChanges() { diff --git a/src/Squidex/app/features/content/shared/references-editor.component.ts b/src/Squidex/app/features/content/shared/references-editor.component.ts index eb25bb748..4456241c8 100644 --- a/src/Squidex/app/features/content/shared/references-editor.component.ts +++ b/src/Squidex/app/features/content/shared/references-editor.component.ts @@ -13,6 +13,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { AppComponentBase, AppsStoreService, + AuthService, ContentDto, ContentsService, DialogService, @@ -53,11 +54,11 @@ export class ReferencesEditorComponent extends AppComponentBase implements Contr public isDisabled = false; public isInvalidSchema = false; - constructor(apps: AppsStoreService, dialogs: DialogService, + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService, private readonly contentsService: ContentsService, private readonly schemasService: SchemasService ) { - super(dialogs, apps); + super(dialogs, apps, authService); } public ngOnInit() { diff --git a/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts b/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts index c3ec3adad..15ded7f97 100644 --- a/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts +++ b/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts @@ -60,11 +60,10 @@ export class DashboardPageComponent extends AppComponentBase implements OnInit { public callsCurrent = 0; public callsMax = 0; - constructor(apps: AppsStoreService, dialogs: DialogService, - private readonly authService: AuthService, + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService, private readonly usagesService: UsagesService ) { - super(dialogs, apps); + super(dialogs, apps, authService); } public ngOnInit() { diff --git a/src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts b/src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts index 974e4989a..54e66a16e 100644 --- a/src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts +++ b/src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts @@ -30,7 +30,8 @@ import { SchemasService, UpdateFieldDto, UpdateSchemaScriptsDto, - ValidatorsEx + ValidatorsEx, + Version } from 'shared'; import { @@ -82,15 +83,14 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, return this.addFieldForm.controls['name'].value && this.addFieldForm.controls['name'].value.length > 0; } - constructor(apps: AppsStoreService, dialogs: DialogService, - private readonly authService: AuthService, + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService, private readonly formBuilder: FormBuilder, private readonly messageBus: MessageBus, private readonly route: ActivatedRoute, private readonly router: Router, private readonly schemasService: SchemasService ) { - super(dialogs, apps); + super(dialogs, apps, authService); } public ngOnDestroy() { @@ -129,8 +129,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, public publish() { this.appNameOnce() .switchMap(app => this.schemasService.publishSchema(app, this.schema.name, this.schema.version)).retry(2) - .subscribe(() => { - this.updateSchema(this.schema.publish(this.authService.user!.token)); + .subscribe(dto => { + this.updateSchema(this.schema.publish(this.userToken, dto.version)); }, error => { this.notifyError(error); }); @@ -139,8 +139,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, public unpublish() { this.appNameOnce() .switchMap(app => this.schemasService.unpublishSchema(app, this.schema.name, this.schema.version)).retry(2) - .subscribe(() => { - this.updateSchema(this.schema.unpublish(this.authService.user!.token)); + .subscribe(dto => { + this.updateSchema(this.schema.unpublish(this.userToken, dto.version)); }, error => { this.notifyError(error); }); @@ -149,8 +149,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, public enableField(field: FieldDto) { this.appNameOnce() .switchMap(app => this.schemasService.enableField(app, this.schema.name, field.fieldId, this.schema.version)).retry(2) - .subscribe(() => { - this.updateSchema(this.schema.updateField(field.enable(), this.authService.user!.token)); + .subscribe(dto => { + this.updateSchema(this.schema.updateField(field.enable(), this.userToken, dto.version)); }, error => { this.notifyError(error); }); @@ -159,8 +159,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, public disableField(field: FieldDto) { this.appNameOnce() .switchMap(app => this.schemasService.disableField(app, this.schema.name, field.fieldId, this.schema.version)).retry(2) - .subscribe(() => { - this.updateSchema(this.schema.updateField(field.disable(), this.authService.user!.token)); + .subscribe(dto => { + this.updateSchema(this.schema.updateField(field.disable(), this.userToken, dto.version)); }, error => { this.notifyError(error); }); @@ -169,8 +169,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, public lockField(field: FieldDto) { this.appNameOnce() .switchMap(app => this.schemasService.lockField(app, this.schema.name, field.fieldId, this.schema.version)).retry(2) - .subscribe(() => { - this.updateSchema(this.schema.updateField(field.lock(), this.authService.user!.token)); + .subscribe(dto => { + this.updateSchema(this.schema.updateField(field.lock(), this.userToken, dto.version)); }, error => { this.notifyError(error); }); @@ -179,8 +179,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, public showField(field: FieldDto) { this.appNameOnce() .switchMap(app => this.schemasService.showField(app, this.schema.name, field.fieldId, this.schema.version)).retry(2) - .subscribe(() => { - this.updateSchema(this.schema.updateField(field.show(), this.authService.user!.token)); + .subscribe(dto => { + this.updateSchema(this.schema.updateField(field.show(), this.userToken, dto.version)); }, error => { this.notifyError(error); }); @@ -189,8 +189,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, public hideField(field: FieldDto) { this.appNameOnce() .switchMap(app => this.schemasService.hideField(app, this.schema.name, field.fieldId, this.schema.version)).retry(2) - .subscribe(() => { - this.updateSchema(this.schema.updateField(field.hide(), this.authService.user!.token)); + .subscribe(dto => { + this.updateSchema(this.schema.updateField(field.hide(), this.userToken, dto.version)); }, error => { this.notifyError(error); }); @@ -199,8 +199,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, public deleteField(field: FieldDto) { this.appNameOnce() .switchMap(app => this.schemasService.deleteField(app, this.schema.name, field.fieldId, this.schema.version)).retry(2) - .subscribe(() => { - this.updateSchema(this.schema.removeField(field, this.authService.user!.token)); + .subscribe(dto => { + this.updateSchema(this.schema.removeField(field, this.userToken, dto.version)); }, error => { this.notifyError(error); }); @@ -209,8 +209,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, public sortFields(fields: FieldDto[]) { this.appNameOnce() .switchMap(app => this.schemasService.putFieldOrdering(app, this.schema.name, fields.map(t => t.fieldId), this.schema.version)).retry(2) - .subscribe(() => { - this.updateSchema(this.schema.replaceFields(fields, this.authService.user!.token)); + .subscribe(dto => { + this.updateSchema(this.schema.replaceFields(fields, this.userToken, dto.version)); }, error => { this.notifyError(error); }); @@ -221,8 +221,8 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, this.appNameOnce() .switchMap(app => this.schemasService.putField(app, this.schema.name, field.fieldId, requestDto, this.schema.version)).retry(2) - .subscribe(() => { - this.updateSchema(this.schema.updateField(field, this.authService.user!.token)); + .subscribe(dto => { + this.updateSchema(this.schema.updateField(field, this.userToken, dto.version)); }, error => { this.notifyError(error); }); @@ -253,7 +253,7 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, this.appNameOnce() .switchMap(app => this.schemasService.postField(app, this.schema.name, requestDto, this.schema.version)) .subscribe(dto => { - this.updateSchema(this.schema.addField(dto, this.authService.user!.token)); + this.updateSchema(this.schema.addField(dto.payload, this.userToken, dto.version)); this.resetFieldForm(); }, error => { this.notifyError(error); @@ -266,14 +266,14 @@ export class SchemaPageComponent extends AppComponentBase implements OnDestroy, this.resetFieldForm(); } - public onSchemaSaved(properties: SchemaPropertiesDto) { - this.updateSchema(this.schema.update(properties, this.authService.user!.token)); + public onSchemaSaved(properties: SchemaPropertiesDto, version: Version) { + this.updateSchema(this.schema.update(properties, this.userToken, version)); this.editSchemaDialog.hide(); } - public onSchemaScriptsSaved(scripts: UpdateSchemaScriptsDto) { - this.updateSchema(this.schema.configureScripts(scripts, this.authService.user!.token)); + public onSchemaScriptsSaved(scripts: UpdateSchemaScriptsDto, version: Version) { + this.updateSchema(this.schema.configureScripts(scripts, this.userToken, version)); this.configureScriptsDialog.hide(); } diff --git a/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts b/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts index d51a15659..5442c6b70 100644 --- a/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts +++ b/src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts @@ -15,8 +15,7 @@ import { fadeAnimation, SchemaDetailsDto, SchemasService, - ValidatorsEx, - Version + ValidatorsEx } from 'shared'; const FALLBACK_NAME = 'my-schema'; @@ -83,14 +82,12 @@ export class SchemaFormComponent { if (this.createForm.valid) { this.createForm.disable(); - const schemaVersion = new Version(); const schemaName = this.createForm.controls['name'].value; - - const requestDto = Object.assign(this.createForm.controls['import'].value || {}, { name: schemaName }); + const schemaDto = Object.assign(this.createForm.controls['import'].value || {}, { name: schemaName }); const me = this.authService.user!.token; - this.schemas.postSchema(this.appName, requestDto, me, DateTime.now(), schemaVersion) + this.schemas.postSchema(this.appName, schemaDto, me, DateTime.now()) .subscribe(dto => { this.emitCreated(dto); this.resetCreateForm(); diff --git a/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts b/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts index a5a60875e..d087820aa 100644 --- a/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts +++ b/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts @@ -13,6 +13,7 @@ import { Subscription } from 'rxjs'; import { AppComponentBase, AppsStoreService, + AuthService, DialogService, fadeAnimation, ImmutableArray, @@ -47,12 +48,12 @@ export class SchemasPageComponent extends AppComponentBase implements OnDestroy, public schemasFilter = new FormControl(); public schemasFiltered = ImmutableArray.empty(); - constructor(apps: AppsStoreService, dialogs: DialogService, + constructor(apps: AppsStoreService, dialogs: DialogService, authService: AuthService, private readonly schemasService: SchemasService, private readonly messageBus: MessageBus, private readonly route: ActivatedRoute ) { - super(dialogs, apps); + super(dialogs, apps, authService); } public ngOnDestroy() { diff --git a/src/Squidex/app/features/settings/pages/clients/clients-page.component.html b/src/Squidex/app/features/settings/pages/clients/clients-page.component.html index 23c258084..7e4343c8d 100644 --- a/src/Squidex/app/features/settings/pages/clients/clients-page.component.html +++ b/src/Squidex/app/features/settings/pages/clients/clients-page.component.html @@ -13,18 +13,18 @@
-
+
No client created yet.
-
+
-