Browse Source

TSLint fixes

pull/329/head
Sebastian Stehle 7 years ago
parent
commit
8f3e66e170
  1. 4
      src/Squidex/app/features/administration/pages/users/user-page.component.ts
  2. 2
      src/Squidex/app/features/content/pages/content/content-history.component.ts
  3. 6
      src/Squidex/app/features/content/pages/content/content-page.component.ts
  4. 6
      src/Squidex/app/features/rules/pages/rules/rule-wizard.component.ts
  5. 2
      src/Squidex/app/features/schemas/pages/schema/field-wizard.component.ts
  6. 2
      src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts
  7. 2
      src/Squidex/app/features/schemas/pages/schema/schema-scripts-form.component.ts
  8. 2
      src/Squidex/app/features/settings/pages/contributors/contributors-page.component.ts
  9. 2
      src/Squidex/app/framework/angular/forms/validators.ts
  10. 12
      src/Squidex/app/framework/angular/http/http-extensions.ts
  11. 1
      src/Squidex/app/shared/internal.ts
  12. 2
      src/Squidex/app/shared/module.ts
  13. 2
      src/Squidex/app/shared/services/auth.service.ts
  14. 4
      src/Squidex/app/shared/services/comments.service.ts
  15. 2
      src/Squidex/app/shared/services/contents.service.ts
  16. 2
      src/Squidex/app/shared/services/schemas.service.ts
  17. 4
      src/Squidex/app/shared/state/apps.state.spec.ts
  18. 5
      src/Squidex/app/shared/state/apps.state.ts
  19. 119
      src/Squidex/app/shared/state/comments.state.ts
  20. 2
      src/Squidex/app/shared/state/contents.state.ts
  21. 2
      src/Squidex/app/shared/state/rules.state.ts
  22. 2
      src/Squidex/app/shared/state/schemas.state.ts

4
src/Squidex/app/features/administration/pages/users/user-page.component.ts

@ -55,14 +55,14 @@ export class UserPageComponent implements OnDestroy, OnInit {
if (value) {
if (this.user) {
this.usersState.update(this.user.user, value)
.subscribe(user => {
.subscribe(() => {
this.userForm.submitCompleted();
}, error => {
this.userForm.submitFailed(error);
});
} else {
this.usersState.create(value)
.subscribe(user => {
.subscribe(() => {
this.back();
}, error => {
this.userForm.submitFailed(error);

2
src/Squidex/app/features/content/pages/content/content-history.component.ts

@ -51,7 +51,7 @@ export class ContentHistoryComponent {
timer(0, 10000),
this.messageBus.of(HistoryChannelUpdated).pipe(delay(1000))
).pipe(
switchMap(app => this.historyService.getHistory(this.appsState.appName, this.channel)));
switchMap(() => this.historyService.getHistory(this.appsState.appName, this.channel)));
constructor(
private readonly appsState: AppsState,

6
src/Squidex/app/features/content/pages/content/content-page.component.ts

@ -141,14 +141,14 @@ export class ContentPageComponent implements CanComponentDeactivate, OnDestroy,
if (this.content) {
if (asProposal) {
this.contentsState.proposeUpdate(this.content, value)
.subscribe(dto => {
.subscribe(() => {
this.contentForm.submitCompleted();
}, error => {
this.contentForm.submitFailed(error);
});
} else {
this.contentsState.update(this.content, value)
.subscribe(dto => {
.subscribe(() => {
this.contentForm.submitCompleted();
}, error => {
this.contentForm.submitFailed(error);
@ -156,7 +156,7 @@ export class ContentPageComponent implements CanComponentDeactivate, OnDestroy,
}
} else {
this.contentsState.create(value, publish)
.subscribe(dto => {
.subscribe(() => {
this.back();
}, error => {
this.contentForm.submitFailed(error);

6
src/Squidex/app/features/rules/pages/rules/rule-wizard.component.ts

@ -121,7 +121,7 @@ export class RuleWizardComponent implements OnInit {
const requestDto = new CreateRuleDto(this.trigger, this.action);
this.rulesState.create(requestDto)
.subscribe(dto => {
.subscribe(() => {
this.complete();
this.actionForm.submitCompleted();
@ -134,7 +134,7 @@ export class RuleWizardComponent implements OnInit {
private updateTrigger() {
this.rulesState.updateTrigger(this.rule, this.trigger)
.subscribe(dto => {
.subscribe(() => {
this.complete();
this.triggerForm.submitCompleted();
@ -145,7 +145,7 @@ export class RuleWizardComponent implements OnInit {
private updateAction() {
this.rulesState.updateAction(this.rule, this.action)
.subscribe(dto => {
.subscribe(() => {
this.complete();
this.actionForm.submitCompleted();

2
src/Squidex/app/features/schemas/pages/schema/field-wizard.component.ts

@ -60,7 +60,7 @@ export class FieldWizardComponent implements OnInit {
if (value) {
this.schemasState.addField(this.schema, value, this.parent)
.subscribe(dto => {
.subscribe(() => {
this.addFieldForm.submitCompleted({ type: fieldTypes[0].type });
if (next) {

2
src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts

@ -47,7 +47,7 @@ export class SchemaEditFormComponent implements OnInit {
if (value) {
this.schemasState.update(this.schema, value)
.subscribe(dto => {
.subscribe(() => {
this.complete();
}, error => {
this.editForm.submitFailed(error);

2
src/Squidex/app/features/schemas/pages/schema/schema-scripts-form.component.ts

@ -53,7 +53,7 @@ export class SchemaScriptsFormComponent implements OnInit {
if (value) {
this.schemasState.configureScripts(this.schema, value)
.subscribe(dto => {
.subscribe(() => {
this.complete();
}, error => {
this.editForm.submitFailed(error);

2
src/Squidex/app/features/settings/pages/contributors/contributors-page.component.ts

@ -94,7 +94,7 @@ export class ContributorsPageComponent implements OnInit {
const requestDto = new AppContributorDto(user, 'Editor');
this.contributorsState.assign(requestDto)
.subscribe(dto => {
.subscribe(() => {
this.assignContributorForm.submitCompleted();
}, error => {
this.assignContributorForm.submitFailed(error);

2
src/Squidex/app/framework/angular/forms/validators.ts

@ -126,7 +126,7 @@ export module ValidatorsEx {
}
export function noop(): ValidatorFn {
return (control: AbstractControl) => {
return () => {
return null;
};
}

12
src/Squidex/app/framework/angular/http/http-extensions.ts

@ -17,31 +17,31 @@ export module HTTP {
export function getVersioned<T>(http: HttpClient, url: string, version?: Version): Observable<Versioned<HttpResponse<T>>> {
const headers = createHeaders(version);
return handleVersion(http.get<T>(url, { observe: 'response', headers }), version);
return handleVersion(http.get<T>(url, { observe: 'response', headers }));
}
export function postVersioned<T>(http: HttpClient, url: string, body: any, version?: Version): Observable<Versioned<HttpResponse<T>>> {
const headers = createHeaders(version);
return handleVersion(http.post<T>(url, body, { observe: 'response', headers }), version);
return handleVersion(http.post<T>(url, body, { observe: 'response', headers }));
}
export function putVersioned<T>(http: HttpClient, url: string, body: any, version?: Version): Observable<Versioned<HttpResponse<T>>> {
const headers = createHeaders(version);
return handleVersion(http.put<T>(url, body, { observe: 'response', headers }), version);
return handleVersion(http.put<T>(url, body, { observe: 'response', headers }));
}
export function patchVersioned<T>(http: HttpClient, url: string, body: any, version?: Version): Observable<Versioned<HttpResponse<T>>> {
const headers = createHeaders(version);
return handleVersion(http.request<T>('PATCH', url, { body, observe: 'response', headers }), version);
return handleVersion(http.request<T>('PATCH', url, { body, observe: 'response', headers }));
}
export function deleteVersioned<T>(http: HttpClient, url: string, version?: Version): Observable<Versioned<HttpResponse<T>>> {
const headers = createHeaders(version);
return handleVersion(http.delete<T>(url, { observe: 'response', headers }), version);
return handleVersion(http.delete<T>(url, { observe: 'response', headers }));
}
function createHeaders(version?: Version): HttpHeaders {
@ -52,7 +52,7 @@ export module HTTP {
}
}
function handleVersion<T>(httpRequest: Observable<HttpResponse<T>>, version?: Version): Observable<Versioned<HttpResponse<T>>> {
function handleVersion<T>(httpRequest: Observable<HttpResponse<T>>): Observable<Versioned<HttpResponse<T>>> {
return httpRequest.pipe(map((response: HttpResponse<T>) => {
const etag = response.headers.get('etag') || '';

1
src/Squidex/app/shared/internal.ts

@ -50,6 +50,7 @@ export * from './state/backups.forms';
export * from './state/backups.state';
export * from './state/clients.forms';
export * from './state/clients.state';
export * from './state/comments.state';
export * from './state/contents.forms';
export * from './state/contents.state';
export * from './state/contributors.forms';

2
src/Squidex/app/shared/module.ts

@ -35,6 +35,7 @@ import {
BackupsState,
ClientsState,
CommentsService,
CommentsState,
ContentMustExistGuard,
ContentsService,
ContentsState,
@ -165,6 +166,7 @@ export class SqxSharedModule {
BackupsState,
ClientsState,
CommentsService,
CommentsState,
ContentMustExistGuard,
ContentsService,
ContentsState,

2
src/Squidex/app/shared/services/auth.service.ts

@ -185,7 +185,7 @@ export class AuthService {
}
return true;
}, err => {
}, error => {
this.user$.next(null);
return false;

4
src/Squidex/app/shared/services/comments.service.ts

@ -38,6 +38,10 @@ export class CommentDto extends Model {
) {
super();
}
public with(value: Partial<CommentDto>): CommentDto {
return this.clone(value);
}
}
export class UpsertCommentDto {

2
src/Squidex/app/shared/services/contents.service.ts

@ -190,7 +190,7 @@ export class ContentsService {
body.data,
response.version);
}),
tap(content => {
tap(() => {
this.analytics.trackEvent('Content', 'Created', appName);
}),
pretifyError('Failed to create content. Please reload.'));

2
src/Squidex/app/shared/services/schemas.service.ts

@ -344,7 +344,7 @@ export class SchemasService {
body.scriptDelete,
body.scriptChange);
}),
tap(schema => {
tap(() => {
this.analytics.trackEvent('Schema', 'Created', appName);
}),
pretifyError('Failed to create schema. Please reload.'));

4
src/Squidex/app/shared/state/apps.state.spec.ts

@ -87,7 +87,7 @@ describe('AppsState', () => {
appsService.setup(x => x.postApp(request))
.returns(() => of(newApp));
appsState.create(request, now).subscribe();
appsState.create(request).subscribe();
expect(appsState.snapshot.apps.values).toEqual([newApp, ...oldApps]);
});
@ -101,7 +101,7 @@ describe('AppsState', () => {
appsService.setup(x => x.deleteApp(newApp.name))
.returns(() => of({}));
appsState.create(request, now).subscribe();
appsState.create(request).subscribe();
const appsAfterCreate = appsState.snapshot.apps.values;

5
src/Squidex/app/shared/state/apps.state.ts

@ -10,7 +10,6 @@ import { Observable, of } from 'rxjs';
import { distinctUntilChanged, map, tap } from 'rxjs/operators';
import {
DateTime,
DialogService,
ImmutableArray,
notify,
@ -73,7 +72,7 @@ export class AppsState extends State<Snapshot> {
}));
}
public create(request: CreateAppDto, now?: DateTime): Observable<AppDto> {
public create(request: CreateAppDto): Observable<AppDto> {
return this.appsService.postApp(request).pipe(
tap(dto => {
this.next(s => {
@ -86,7 +85,7 @@ export class AppsState extends State<Snapshot> {
public delete(name: string): Observable<any> {
return this.appsService.deleteApp(name).pipe(
tap(app => {
tap(() => {
this.next(s => {
const apps = s.apps.filter(x => x.name !== name);

119
src/Squidex/app/shared/state/comments.state.ts

@ -0,0 +1,119 @@
/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { distinctUntilChanged, map, tap } from 'rxjs/operators';
import {
DateTime,
DialogService,
ImmutableArray,
notify,
State,
Version
} from '@app/framework';
import {
CommentDto,
CommentsService,
UpsertCommentDto
} from './../services/comments.service';
interface Snapshot {
comments: ImmutableArray<CommentDto>;
version: Version;
isLoaded?: boolean;
}
@Injectable()
export class CommentsState extends State<Snapshot> {
public comments =
this.changes.pipe(map(x => x.comments),
distinctUntilChanged());
public isLoaded =
this.changes.pipe(map(x => !!x.isLoaded),
distinctUntilChanged());
constructor(
private readonly commentsId: string,
private readonly commentsService: CommentsService,
private readonly dialogs: DialogService
) {
super({ comments: ImmutableArray.empty(), version: new Version('') });
}
public load(): Observable<any> {
return this.commentsService.getComments(this.commentsId, this.version).pipe(
tap(dtos => {
this.next(s => {
let comments = s.comments;
for (let created of dtos.createdComments) {
comments = comments.push(created);
}
for (let updated of dtos.updatedComments) {
comments = comments.replaceBy('id', updated);
}
for (let deleted of dtos.deletedComments) {
comments = comments.filter(x => x.id !== deleted);
}
return { ...s, comments, isLoaded: true, version: dtos.version };
});
}),
notify(this.dialogs));
}
public create(request: UpsertCommentDto): Observable<any> {
return this.commentsService.postComment(this.commentsId, request).pipe(
tap(dto => {
this.next(s => {
const comments = s.comments.push(dto);
return { ...s, comments };
});
}),
notify(this.dialogs));
}
public update(commentId: string, request: UpsertCommentDto, now?: DateTime): Observable<any> {
return this.commentsService.putComment(this.commentsId, commentId, request).pipe(
tap(() => {
this.next(s => {
const comments = s.comments.map(c => c.id === commentId ? update(c, request, now || DateTime.now()) : c);
return { ...s, comments };
});
}),
notify(this.dialogs));
}
public delete(commentId: string): Observable<any> {
return this.commentsService.deleteComment(this.commentsId, commentId).pipe(
tap(dto => {
this.next(s => {
const comments = s.comments.filter(c => c.id !== commentId);
return { ...s, comments, version: dto.version };
});
}),
notify(this.dialogs));
}
private get version() {
return this.snapshot.version;
}
}
const update = (comment: CommentDto, request: UpsertCommentDto, now: DateTime) =>
comment.with({ text: request.text, time: now });

2
src/Squidex/app/shared/state/contents.state.ts

@ -132,7 +132,7 @@ export abstract class ContentsStateBase extends State<Snapshot> {
notify(this.dialogs));
}
public create(request: any, publish: boolean, now?: DateTime) {
public create(request: any, publish: boolean) {
return this.contentsService.postContent(this.appName, this.schemaName, request, publish).pipe(
tap(dto => {
this.dialogs.notifyInfo('Contents created successfully.');

2
src/Squidex/app/shared/state/rules.state.ts

@ -87,7 +87,7 @@ export class RulesState extends State<Snapshot> {
public delete(rule: RuleDto): Observable<any> {
return this.rulesService.deleteRule(this.appName, rule.id, rule.version).pipe(
tap(dto => {
tap(() => {
this.next(s => {
const rules = s.rules.removeAll(x => x.id === rule.id);

2
src/Squidex/app/shared/state/schemas.state.ts

@ -140,7 +140,7 @@ export class SchemasState extends State<Snapshot> {
public delete(schema: SchemaDto): Observable<any> {
return this.schemasService.deleteSchema(this.appName, schema.name, schema.version).pipe(
tap(dto => {
tap(() => {
return this.next(s => {
const schemas = s.schemas.filter(x => x.id !== schema.id);
const selectedSchema = s.selectedSchema && s.selectedSchema.id === schema.id ? null : s.selectedSchema;

Loading…
Cancel
Save