Browse Source

Observable fixes

pull/1/head
Sebastian 10 years ago
parent
commit
8e9e1ea5d0
  1. 32
      src/Squidex/app/features/content/pages/content/content-page.component.ts
  2. 36
      src/Squidex/app/features/content/pages/contents/contents-page.component.ts
  3. 4
      src/Squidex/app/features/content/pages/schemas/schemas-page.component.ts
  4. 15
      src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts
  5. 4
      src/Squidex/app/features/schemas/pages/schema/types/boolean-validation.component.ts
  6. 4
      src/Squidex/app/features/schemas/pages/schema/types/date-time-validation.component.ts
  7. 4
      src/Squidex/app/features/schemas/pages/schema/types/number-ui.component.ts
  8. 4
      src/Squidex/app/features/schemas/pages/schema/types/number-validation.component.ts
  9. 15
      src/Squidex/app/features/schemas/pages/schema/types/string-ui.component.ts
  10. 8
      src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.ts
  11. 5
      src/Squidex/app/features/schemas/pages/schemas/schema-form.component.ts
  12. 11
      src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts
  13. 25
      src/Squidex/app/framework/angular/json-editor.component.ts
  14. 5
      src/Squidex/app/shared/components/app-form.component.ts
  15. 7
      src/Squidex/app/shared/services/apps-store.service.ts
  16. 17
      src/Squidex/app/shell/pages/internal/profile-menu.component.ts
  17. 17
      src/Squidex/app/shell/pages/login/login-page.component.ts
  18. 17
      src/Squidex/app/shell/pages/logout/logout-page.component.ts

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

@ -67,23 +67,27 @@ export class ContentPageComponent extends AppComponentBase implements OnDestroy,
public ngOnInit() { public ngOnInit() {
this.messageSubscription = this.messageSubscription =
this.messageBus.of(ContentDeleted).subscribe(message => { this.messageBus.of(ContentDeleted)
if (message.id === this.contentId) { .subscribe(message => {
this.router.navigate(['../'], { relativeTo: this.route }); if (message.id === this.contentId) {
} this.router.navigate(['../'], { relativeTo: this.route });
}); }
});
this.route.parent.data.map(p => p['appLanguages']).subscribe((languages: AppLanguageDto[]) => { this.route.parent.data.map(p => p['appLanguages'])
this.languages = languages; .subscribe((languages: AppLanguageDto[]) => {
}); this.languages = languages;
});
this.route.parent.data.map(p => p['schema']).subscribe((schema: SchemaDetailsDto) => { this.route.parent.data.map(p => p['schema'])
this.setupForm(schema); .subscribe((schema: SchemaDetailsDto) => {
}); this.setupForm(schema);
});
this.route.data.map(p => p['content']).subscribe((content: ContentDto) => { this.route.data.map(p => p['content'])
this.populateForm(content); .subscribe((content: ContentDto) => {
}); this.populateForm(content);
});
} }
public saveContent() { public saveContent() {

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

@ -84,27 +84,31 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy
public ngOnInit() { public ngOnInit() {
this.messageCreatedSubscription = this.messageCreatedSubscription =
this.messageBus.of(ContentCreated).subscribe(message => { this.messageBus.of(ContentCreated)
this.itemLast++; .subscribe(message => {
this.contentTotal++; this.itemLast++;
this.contentItems = this.contentItems.pushFront(this.createContent(message.id, message.data, message.version)); this.contentTotal++;
}); this.contentItems = this.contentItems.pushFront(this.createContent(message.id, message.data, message.version));
});
this.messageUpdatedSubscription = this.messageUpdatedSubscription =
this.messageBus.of(ContentUpdated).subscribe(message => { this.messageBus.of(ContentUpdated)
this.updateContents(message.id, undefined, message.data, message.version); .subscribe(message => {
}); this.updateContents(message.id, undefined, message.data, message.version);
});
this.route.data.map(p => p['appLanguages']).subscribe((languages: AppLanguageDto[]) => { this.route.data.map(p => p['appLanguages'])
this.languages = languages; .subscribe((languages: AppLanguageDto[]) => {
}); this.languages = languages;
});
this.route.data.map(p => p['schema']).subscribe(schema => { this.route.data.map(p => p['schema'])
this.schema = schema; .subscribe(schema => {
this.schema = schema;
this.reset(); this.reset();
this.load(); this.load();
}); });
} }
public search() { public search() {

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

@ -26,8 +26,8 @@ import {
export class SchemasPageComponent extends AppComponentBase { export class SchemasPageComponent extends AppComponentBase {
public schemasFilter = new FormControl(); public schemasFilter = new FormControl();
public schemasFiltered = public schemasFiltered =
Observable.of(null) this.schemasFilter.valueChanges
.merge(this.schemasFilter.valueChanges) .startWith(null)
.distinctUntilChanged() .distinctUntilChanged()
.debounceTime(300) .debounceTime(300)
.combineLatest(this.loadSchemas(), .combineLatest(this.loadSchemas(),

15
src/Squidex/app/features/schemas/pages/schema/schema-page.component.ts

@ -84,15 +84,16 @@ export class SchemaPageComponent extends AppComponentBase implements OnInit {
} }
public ngOnInit() { public ngOnInit() {
this.route.data.map(p => p['schema']).subscribe((schema: SchemaDetailsDto) => { this.route.data.map(p => p['schema'])
this.schemaName = schema.name; .subscribe((schema: SchemaDetailsDto) => {
this.schemaFields = ImmutableArray.of(schema.fields); this.schemaName = schema.name;
this.schemaProperties = new SchemaPropertiesDto(schema.name, schema.label, schema.hints); this.schemaFields = ImmutableArray.of(schema.fields);
this.schemaProperties = new SchemaPropertiesDto(schema.name, schema.label, schema.hints);
this.version = schema.version; this.version = schema.version;
this.isPublished = schema.isPublished; this.isPublished = schema.isPublished;
}); });
} }
public publish() { public publish() {

4
src/Squidex/app/features/schemas/pages/schema/types/boolean-validation.component.ts

@ -30,8 +30,8 @@ export class BooleanValidationComponent implements OnInit {
new FormControl(this.properties.defaultValue)); new FormControl(this.properties.defaultValue));
this.hideDefaultValue = this.hideDefaultValue =
Observable.of(this.properties.isRequired) this.editForm.get('isRequired').valueChanges
.merge(this.editForm.get('isRequired').valueChanges) .startWith(this.properties.isRequired)
.map(x => !!x); .map(x => !!x);
} }
} }

4
src/Squidex/app/features/schemas/pages/schema/types/date-time-validation.component.ts

@ -42,8 +42,8 @@ export class DateTimeValidationComponent implements OnInit {
])); ]));
this.hideDefaultValue = this.hideDefaultValue =
Observable.of(this.properties.isRequired) this.editForm.get('isRequired').valueChanges
.merge(this.editForm.get('isRequired').valueChanges) .startWith(this.properties.isRequired)
.map(x => !!x); .map(x => !!x);
} }
} }

4
src/Squidex/app/features/schemas/pages/schema/types/number-ui.component.ts

@ -46,8 +46,8 @@ export class NumberUIComponent implements OnDestroy, OnInit {
new FormControl(this.properties.allowedValues, [])); new FormControl(this.properties.allowedValues, []));
this.hideAllowedValues = this.hideAllowedValues =
Observable.of(this.properties.editor) this.editForm.get('editor').valueChanges
.merge(this.editForm.get('editor').valueChanges) .startWith(this.properties.editor)
.map(x => !x || x === 'Input' || x === 'Textarea'); .map(x => !x || x === 'Input' || x === 'Textarea');
this.editorSubscription = this.editorSubscription =

4
src/Squidex/app/features/schemas/pages/schema/types/number-validation.component.ts

@ -36,8 +36,8 @@ export class NumberValidationComponent implements OnInit {
new FormControl(this.properties.defaultValue)); new FormControl(this.properties.defaultValue));
this.hideDefaultValue = this.hideDefaultValue =
Observable.of(this.properties.isRequired) this.editForm.get('isRequired').valueChanges
.merge(this.editForm.get('isRequired').valueChanges) .startWith(this.properties.isRequired)
.map(x => !!x); .map(x => !!x);
} }
} }

15
src/Squidex/app/features/schemas/pages/schema/types/string-ui.component.ts

@ -46,15 +46,16 @@ export class StringUIComponent implements OnDestroy, OnInit {
new FormControl(this.properties.allowedValues)); new FormControl(this.properties.allowedValues));
this.hideAllowedValues = this.hideAllowedValues =
Observable.of(this.properties.editor) this.editForm.get('editor').valueChanges
.merge(this.editForm.get('editor').valueChanges) .startWith(this.properties.editor)
.map(x => !x || x === 'Input' || x === 'TextArea' || x === 'RichText' || x === 'Markdown'); .map(x => !x || x === 'Input' || x === 'TextArea' || x === 'RichText' || x === 'Markdown');
this.editorSubscription = this.editorSubscription =
this.hideAllowedValues.subscribe(isSelection => { this.hideAllowedValues
if (isSelection) { .subscribe(isSelection => {
this.editForm.get('allowedValues').setValue(undefined); if (isSelection) {
} this.editForm.get('allowedValues').setValue(undefined);
}); }
});
} }
} }

8
src/Squidex/app/features/schemas/pages/schema/types/string-validation.component.ts

@ -49,13 +49,13 @@ export class StringValidationComponent implements OnDestroy, OnInit {
new FormControl(this.properties.defaultValue)); new FormControl(this.properties.defaultValue));
this.hideDefaultValue = this.hideDefaultValue =
Observable.of(false) this.editForm.get('isRequired').valueChanges
.merge(this.editForm.get('isRequired').valueChanges) .startWith(this.properties.isRequired)
.map(x => !!x); .map(x => !!x);
this.hidePatternMessage = this.hidePatternMessage =
Observable.of(false) this.editForm.get('pattern').valueChanges
.merge(this.editForm.get('pattern').valueChanges) .startWith('')
.map(x => !x || x.trim().length === 0); .map(x => !x || x.trim().length === 0);
this.patternSubscription = this.patternSubscription =

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

@ -7,7 +7,6 @@
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Observable } from 'rxjs';
import { import {
ApiUrlConfig, ApiUrlConfig,
@ -54,8 +53,8 @@ export class SchemaFormComponent {
}); });
public schemaName = public schemaName =
Observable.of(FALLBACK_NAME) this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME)
.merge(this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME)); .startWith(FALLBACK_NAME);
constructor( constructor(
public readonly apiUrl: ApiUrlConfig, public readonly apiUrl: ApiUrlConfig,

11
src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.ts

@ -67,11 +67,12 @@ export class SchemasPageComponent extends AppComponentBase implements OnDestroy,
this.updateSchemas(this.schemas, this.schemaQuery = q); this.updateSchemas(this.schemas, this.schemaQuery = q);
}); });
this.route.params.map(q => q['showDialog']).subscribe(showDialog => { this.route.params.map(q => q['showDialog'])
if (showDialog) { .subscribe(showDialog => {
this.addSchemaDialog.show(); if (showDialog) {
} this.addSchemaDialog.show();
}); }
});
this.messageSubscription = this.messageSubscription =
this.messageBus.of(SchemaUpdated) this.messageBus.of(SchemaUpdated)

25
src/Squidex/app/framework/angular/json-editor.component.ts

@ -67,21 +67,22 @@ export class JsonEditorComponent implements ControlValueAccessor, AfterViewInit
} }
public ngAfterViewInit() { public ngAfterViewInit() {
this.valueChanged.debounceTime(1000).subscribe(() => { this.valueChanged.debounceTime(1000)
const isValid = this.aceEditor.getSession().getAnnotations().length === 0; .subscribe(() => {
const isValid = this.aceEditor.getSession().getAnnotations().length === 0;
if (!isValid) { if (!isValid) {
this.changeCallback(null);
} else {
try {
const value = JSON.parse(this.aceEditor.getValue());
this.changeCallback(value);
} catch (e) {
this.changeCallback(null); this.changeCallback(null);
} else {
try {
const value = JSON.parse(this.aceEditor.getValue());
this.changeCallback(value);
} catch (e) {
this.changeCallback(null);
}
} }
} });
});
this.resourceLoader.loadScript('https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js').then(() => { this.resourceLoader.loadScript('https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js').then(() => {
this.aceEditor = ace.edit(this.editor.nativeElement); this.aceEditor = ace.edit(this.editor.nativeElement);

5
src/Squidex/app/shared/components/app-form.component.ts

@ -7,7 +7,6 @@
import { Component, EventEmitter, Output } from '@angular/core'; import { Component, EventEmitter, Output } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Observable } from 'rxjs';
import { ApiUrlConfig, ValidatorsEx } from 'framework'; import { ApiUrlConfig, ValidatorsEx } from 'framework';
@ -41,8 +40,8 @@ export class AppFormComponent {
}); });
public appName = public appName =
Observable.of(FALLBACK_NAME) this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME)
.merge(this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME)); .startWith(FALLBACK_NAME);
constructor( constructor(
public readonly apiUrl: ApiUrlConfig, public readonly apiUrl: ApiUrlConfig,

7
src/Squidex/app/shared/services/apps-store.service.ts

@ -74,9 +74,10 @@ export class AppsStoreService {
} }
private load() { private load() {
this.appsService.getApps().subscribe(apps => { this.appsService.getApps()
this.apps$.next(apps); .subscribe(apps => {
}); this.apps$.next(apps);
});
} }
public selectApp(name: string | null): Promise<boolean> { public selectApp(name: string | null): Promise<boolean> {

17
src/Squidex/app/shell/pages/internal/profile-menu.component.ts

@ -43,16 +43,17 @@ export class ProfileMenuComponent implements OnInit, OnDestroy {
public ngOnInit() { public ngOnInit() {
this.authenticationSubscription = this.authenticationSubscription =
this.auth.isAuthenticated.take(1).subscribe(() => { this.auth.isAuthenticated.take(1)
const user = this.auth.user; .subscribe(() => {
const user = this.auth.user;
if (user) { if (user) {
this.profilePictureUrl = user.pictureUrl; this.profilePictureUrl = user.pictureUrl;
this.profileDisplayName = user.displayName; this.profileDisplayName = user.displayName;
this.isAdmin = user.isAdmin; this.isAdmin = user.isAdmin;
} }
}); });
} }
public logout() { public logout() {

17
src/Squidex/app/shell/pages/login/login-page.component.ts

@ -22,13 +22,14 @@ export class LoginPageComponent implements OnInit {
} }
public ngOnInit() { public ngOnInit() {
this.auth.loginRedirectComplete().subscribe( this.auth.loginRedirectComplete()
() => { .subscribe(
this.router.navigate(['/app'], { replaceUrl: true }); () => {
}, this.router.navigate(['/app'], { replaceUrl: true });
() => { },
this.router.navigate(['/'], { replaceUrl: true }); () => {
} this.router.navigate(['/'], { replaceUrl: true });
); }
);
} }
} }

17
src/Squidex/app/shell/pages/logout/logout-page.component.ts

@ -22,13 +22,14 @@ export class LogoutPageComponent implements OnInit {
} }
public ngOnInit() { public ngOnInit() {
this.auth.logoutRedirectComplete().subscribe( this.auth.logoutRedirectComplete()
() => { .subscribe(
this.router.navigate(['/'], { replaceUrl: true }); () => {
}, this.router.navigate(['/'], { replaceUrl: true });
() => { },
this.router.navigate(['/'], { replaceUrl: true }); () => {
} this.router.navigate(['/'], { replaceUrl: true });
); }
);
} }
} }
Loading…
Cancel
Save