Browse Source

Observable fixes

pull/1/head
Sebastian 9 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() {
this.messageSubscription =
this.messageBus.of(ContentDeleted).subscribe(message => {
if (message.id === this.contentId) {
this.router.navigate(['../'], { relativeTo: this.route });
}
});
this.messageBus.of(ContentDeleted)
.subscribe(message => {
if (message.id === this.contentId) {
this.router.navigate(['../'], { relativeTo: this.route });
}
});
this.route.parent.data.map(p => p['appLanguages']).subscribe((languages: AppLanguageDto[]) => {
this.languages = languages;
});
this.route.parent.data.map(p => p['appLanguages'])
.subscribe((languages: AppLanguageDto[]) => {
this.languages = languages;
});
this.route.parent.data.map(p => p['schema']).subscribe((schema: SchemaDetailsDto) => {
this.setupForm(schema);
});
this.route.parent.data.map(p => p['schema'])
.subscribe((schema: SchemaDetailsDto) => {
this.setupForm(schema);
});
this.route.data.map(p => p['content']).subscribe((content: ContentDto) => {
this.populateForm(content);
});
this.route.data.map(p => p['content'])
.subscribe((content: ContentDto) => {
this.populateForm(content);
});
}
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() {
this.messageCreatedSubscription =
this.messageBus.of(ContentCreated).subscribe(message => {
this.itemLast++;
this.contentTotal++;
this.contentItems = this.contentItems.pushFront(this.createContent(message.id, message.data, message.version));
});
this.messageBus.of(ContentCreated)
.subscribe(message => {
this.itemLast++;
this.contentTotal++;
this.contentItems = this.contentItems.pushFront(this.createContent(message.id, message.data, message.version));
});
this.messageUpdatedSubscription =
this.messageBus.of(ContentUpdated).subscribe(message => {
this.updateContents(message.id, undefined, message.data, message.version);
});
this.messageBus.of(ContentUpdated)
.subscribe(message => {
this.updateContents(message.id, undefined, message.data, message.version);
});
this.route.data.map(p => p['appLanguages']).subscribe((languages: AppLanguageDto[]) => {
this.languages = languages;
});
this.route.data.map(p => p['appLanguages'])
.subscribe((languages: AppLanguageDto[]) => {
this.languages = languages;
});
this.route.data.map(p => p['schema']).subscribe(schema => {
this.schema = schema;
this.route.data.map(p => p['schema'])
.subscribe(schema => {
this.schema = schema;
this.reset();
this.load();
});
this.reset();
this.load();
});
}
public search() {

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

@ -26,8 +26,8 @@ import {
export class SchemasPageComponent extends AppComponentBase {
public schemasFilter = new FormControl();
public schemasFiltered =
Observable.of(null)
.merge(this.schemasFilter.valueChanges)
this.schemasFilter.valueChanges
.startWith(null)
.distinctUntilChanged()
.debounceTime(300)
.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() {
this.route.data.map(p => p['schema']).subscribe((schema: SchemaDetailsDto) => {
this.schemaName = schema.name;
this.schemaFields = ImmutableArray.of(schema.fields);
this.schemaProperties = new SchemaPropertiesDto(schema.name, schema.label, schema.hints);
this.route.data.map(p => p['schema'])
.subscribe((schema: SchemaDetailsDto) => {
this.schemaName = schema.name;
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() {

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));
this.hideDefaultValue =
Observable.of(this.properties.isRequired)
.merge(this.editForm.get('isRequired').valueChanges)
this.editForm.get('isRequired').valueChanges
.startWith(this.properties.isRequired)
.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 =
Observable.of(this.properties.isRequired)
.merge(this.editForm.get('isRequired').valueChanges)
this.editForm.get('isRequired').valueChanges
.startWith(this.properties.isRequired)
.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, []));
this.hideAllowedValues =
Observable.of(this.properties.editor)
.merge(this.editForm.get('editor').valueChanges)
this.editForm.get('editor').valueChanges
.startWith(this.properties.editor)
.map(x => !x || x === 'Input' || x === 'Textarea');
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));
this.hideDefaultValue =
Observable.of(this.properties.isRequired)
.merge(this.editForm.get('isRequired').valueChanges)
this.editForm.get('isRequired').valueChanges
.startWith(this.properties.isRequired)
.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));
this.hideAllowedValues =
Observable.of(this.properties.editor)
.merge(this.editForm.get('editor').valueChanges)
this.editForm.get('editor').valueChanges
.startWith(this.properties.editor)
.map(x => !x || x === 'Input' || x === 'TextArea' || x === 'RichText' || x === 'Markdown');
this.editorSubscription =
this.hideAllowedValues.subscribe(isSelection => {
if (isSelection) {
this.editForm.get('allowedValues').setValue(undefined);
}
});
this.hideAllowedValues
.subscribe(isSelection => {
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));
this.hideDefaultValue =
Observable.of(false)
.merge(this.editForm.get('isRequired').valueChanges)
this.editForm.get('isRequired').valueChanges
.startWith(this.properties.isRequired)
.map(x => !!x);
this.hidePatternMessage =
Observable.of(false)
.merge(this.editForm.get('pattern').valueChanges)
this.editForm.get('pattern').valueChanges
.startWith('')
.map(x => !x || x.trim().length === 0);
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 { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Observable } from 'rxjs';
import {
ApiUrlConfig,
@ -54,8 +53,8 @@ export class SchemaFormComponent {
});
public schemaName =
Observable.of(FALLBACK_NAME)
.merge(this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME));
this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME)
.startWith(FALLBACK_NAME);
constructor(
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.route.params.map(q => q['showDialog']).subscribe(showDialog => {
if (showDialog) {
this.addSchemaDialog.show();
}
});
this.route.params.map(q => q['showDialog'])
.subscribe(showDialog => {
if (showDialog) {
this.addSchemaDialog.show();
}
});
this.messageSubscription =
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() {
this.valueChanged.debounceTime(1000).subscribe(() => {
const isValid = this.aceEditor.getSession().getAnnotations().length === 0;
this.valueChanged.debounceTime(1000)
.subscribe(() => {
const isValid = this.aceEditor.getSession().getAnnotations().length === 0;
if (!isValid) {
this.changeCallback(null);
} else {
try {
const value = JSON.parse(this.aceEditor.getValue());
this.changeCallback(value);
} catch (e) {
if (!isValid) {
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.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 { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Observable } from 'rxjs';
import { ApiUrlConfig, ValidatorsEx } from 'framework';
@ -41,8 +40,8 @@ export class AppFormComponent {
});
public appName =
Observable.of(FALLBACK_NAME)
.merge(this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME));
this.createForm.get('name').valueChanges.map(n => n || FALLBACK_NAME)
.startWith(FALLBACK_NAME);
constructor(
public readonly apiUrl: ApiUrlConfig,

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

@ -74,9 +74,10 @@ export class AppsStoreService {
}
private load() {
this.appsService.getApps().subscribe(apps => {
this.apps$.next(apps);
});
this.appsService.getApps()
.subscribe(apps => {
this.apps$.next(apps);
});
}
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() {
this.authenticationSubscription =
this.auth.isAuthenticated.take(1).subscribe(() => {
const user = this.auth.user;
this.auth.isAuthenticated.take(1)
.subscribe(() => {
const user = this.auth.user;
if (user) {
this.profilePictureUrl = user.pictureUrl;
this.profileDisplayName = user.displayName;
if (user) {
this.profilePictureUrl = user.pictureUrl;
this.profileDisplayName = user.displayName;
this.isAdmin = user.isAdmin;
}
});
this.isAdmin = user.isAdmin;
}
});
}
public logout() {

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

@ -22,13 +22,14 @@ export class LoginPageComponent implements OnInit {
}
public ngOnInit() {
this.auth.loginRedirectComplete().subscribe(
() => {
this.router.navigate(['/app'], { replaceUrl: true });
},
() => {
this.router.navigate(['/'], { replaceUrl: true });
}
);
this.auth.loginRedirectComplete()
.subscribe(
() => {
this.router.navigate(['/app'], { 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() {
this.auth.logoutRedirectComplete().subscribe(
() => {
this.router.navigate(['/'], { replaceUrl: true });
},
() => {
this.router.navigate(['/'], { replaceUrl: true });
}
);
this.auth.logoutRedirectComplete()
.subscribe(
() => {
this.router.navigate(['/'], { replaceUrl: true });
},
() => {
this.router.navigate(['/'], { replaceUrl: true });
}
);
}
}
Loading…
Cancel
Save