Browse Source

Dashboard refactored

pull/1/head
Sebastian 10 years ago
parent
commit
749dd43df8
  1. 3
      src/Squidex/app/components/internal/app/dashboard/dashboard-page.component.html
  2. 30
      src/Squidex/app/components/internal/app/dashboard/dashboard-page.component.ts
  3. 16
      src/Squidex/app/framework/angular/autocomplete.component.ts
  4. 2
      src/Squidex/tslint.json

3
src/Squidex/app/components/internal/app/dashboard/dashboard-page.component.html

@ -1,3 +1,6 @@
<sqx-title message="{app} | Dashboard" parameter="app" value="{{appName() | async}}"></sqx-title>
<div class="layout"> <div class="layout">
<div class="layout-left"> <div class="layout-left">
<sqx-left-menu></sqx-left-menu> <sqx-left-menu></sqx-left-menu>

30
src/Squidex/app/components/internal/app/dashboard/dashboard-page.component.ts

@ -7,33 +7,21 @@
import * as Ng2 from '@angular/core'; import * as Ng2 from '@angular/core';
import { AppsStoreService, TitleService } from 'shared'; import {
AppComponentBase,
AppsStoreService,
NotificationService,
UsersProviderService
} from 'shared';
@Ng2.Component({ @Ng2.Component({
selector: 'sqx-dashboard-page', selector: 'sqx-dashboard-page',
styles, styles,
template template
}) })
export class DashboardPageComponent implements Ng2.OnInit { export class DashboardPageComponent extends AppComponentBase {
private appSubscription: any | null = null; constructor(apps: AppsStoreService, notifications: NotificationService, users: UsersProviderService) {
super(apps, notifications, users);
constructor(
private readonly titles: TitleService,
private readonly appsStore: AppsStoreService
) {
}
public ngOnInit() {
this.appSubscription =
this.appsStore.selectedApp.subscribe(app => {
if (app) {
this.titles.setTitle('{appName} | Dashboard', { appName: app.name });
}
});
}
public ngOnDestroy() {
this.appSubscription.unsubscribe();
} }
} }

16
src/Squidex/app/framework/angular/autocomplete.component.ts

@ -44,7 +44,7 @@ export const SQX_AUTOCOMPLETE_CONTROL_VALUE_ACCESSOR: any = {
template, template,
providers: [SQX_AUTOCOMPLETE_CONTROL_VALUE_ACCESSOR] providers: [SQX_AUTOCOMPLETE_CONTROL_VALUE_ACCESSOR]
}) })
export class AutocompleteComponent implements Ng2Forms.ControlValueAccessor { export class AutocompleteComponent implements Ng2Forms.ControlValueAccessor, Ng2.OnDestroy {
private subscription: Subscription | null = null; private subscription: Subscription | null = null;
private lastQuery: string | null; private lastQuery: string | null;
private changeCallback: (value: any) => void = NOOP; private changeCallback: (value: any) => void = NOOP;
@ -93,6 +93,10 @@ export class AutocompleteComponent implements Ng2Forms.ControlValueAccessor {
this.touchedCallback = fn; this.touchedCallback = fn;
} }
public ngOnDestroy() {
this.cancelRequest();
}
public setDisabledState(isDisabled: boolean): void { public setDisabledState(isDisabled: boolean): void {
if (isDisabled) { if (isDisabled) {
this.reset(); this.reset();
@ -102,13 +106,17 @@ export class AutocompleteComponent implements Ng2Forms.ControlValueAccessor {
} }
} }
private loadItems(query: string) { private cancelRequest() {
const source = this.source;
if (this.subscription != null) { if (this.subscription != null) {
this.subscription.unsubscribe(); this.subscription.unsubscribe();
this.subscription = null; this.subscription = null;
} }
}
private loadItems(query: string) {
const source = this.source;
this.cancelRequest();
if (!source) { if (!source) {
return; return;

2
src/Squidex/tslint.json

@ -47,7 +47,7 @@
"no-shadowed-variable": true, "no-shadowed-variable": true,
"no-string-literal": false, "no-string-literal": false,
"no-switch-case-fall-through": true, "no-switch-case-fall-through": true,
"no-trailing-whitespace": false, "no-trailing-whitespace": true,
"no-unused-expression": true, "no-unused-expression": true,
"no-unused-variable": true, "no-unused-variable": true,
"no-use-before-declare": true, "no-use-before-declare": true,

Loading…
Cancel
Save