Browse Source

Dashboard refactored

pull/1/head
Sebastian 9 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. 2
      src/Squidex/app/components/internal/app/settings/clients-page.component.ts
  4. 2
      src/Squidex/app/components/internal/app/settings/contributors-page.component.ts
  5. 20
      src/Squidex/app/framework/angular/autocomplete.component.ts
  6. 8
      src/Squidex/app/shared/services/app-clients.service.ts
  7. 6
      src/Squidex/app/shared/services/app-contributors.service.ts
  8. 2
      src/Squidex/app/shared/services/auth.service.ts
  9. 2
      src/Squidex/app/shared/services/users-provider.service.ts
  10. 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-left">
<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 { AppsStoreService, TitleService } from 'shared';
import {
AppComponentBase,
AppsStoreService,
NotificationService,
UsersProviderService
} from 'shared';
@Ng2.Component({
selector: 'sqx-dashboard-page',
styles,
template
})
export class DashboardPageComponent implements Ng2.OnInit {
private appSubscription: any | null = null;
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();
export class DashboardPageComponent extends AppComponentBase {
constructor(apps: AppsStoreService, notifications: NotificationService, users: UsersProviderService) {
super(apps, notifications, users);
}
}

2
src/Squidex/app/components/internal/app/settings/clients-page.component.ts

@ -31,7 +31,7 @@ function rename(client: AppClientDto, name: string) {
})
export class ClientsPageComponent extends AppComponentBase implements Ng2.OnInit {
public appClients: AppClientDto[];
public createForm =
this.formBuilder.group({
name: ['',

2
src/Squidex/app/components/internal/app/settings/contributors-page.component.ts

@ -110,7 +110,7 @@ export class ContributorsPageComponent extends AppComponentBase implements Ng2.O
this.selectedUser = null;
this.selectedUserName = null;
this.appName()
.switchMap(app => this.appContributorsService.postContributor(app, contributor))
.subscribe(() => {

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

@ -44,7 +44,7 @@ export const SQX_AUTOCOMPLETE_CONTROL_VALUE_ACCESSOR: any = {
template,
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 lastQuery: string | null;
private changeCallback: (value: any) => void = NOOP;
@ -76,7 +76,7 @@ export class AutocompleteComponent implements Ng2Forms.ControlValueAccessor {
} else {
item = this.items.find(i => i.model === value);
}
if (item) {
this.queryInput.setValue(value.title || '');
}
@ -93,6 +93,10 @@ export class AutocompleteComponent implements Ng2Forms.ControlValueAccessor {
this.touchedCallback = fn;
}
public ngOnDestroy() {
this.cancelRequest();
}
public setDisabledState(isDisabled: boolean): void {
if (isDisabled) {
this.reset();
@ -102,14 +106,18 @@ export class AutocompleteComponent implements Ng2Forms.ControlValueAccessor {
}
}
private loadItems(query: string) {
const source = this.source;
private cancelRequest() {
if (this.subscription != null) {
this.subscription.unsubscribe();
this.subscription = null;
}
}
private loadItems(query: string) {
const source = this.source;
this.cancelRequest();
if (!source) {
return;
}

8
src/Squidex/app/shared/services/app-clients.service.ts

@ -61,12 +61,12 @@ export class AppClientsService {
return this.authService.authGet(url)
.map(response => response.json())
.map(response => {
.map(response => {
const items: any[] = response;
return items.map(item => {
return new AppClientDto(
item.id,
item.id,
item.secret,
item.name,
DateTime.parseISO_UTC(item.expiresUtc));
@ -82,9 +82,9 @@ export class AppClientsService {
.map(response => response.json())
.map(response => {
return new AppClientDto(
response.id,
response.id,
response.secret,
response.name,
response.name,
DateTime.parseISO_UTC(response.expiresUtc));
})
.catch(response => handleError('Failed to add client. Please reload.', response));

6
src/Squidex/app/shared/services/app-contributors.service.ts

@ -35,12 +35,12 @@ export class AppContributorsService {
return this.authService.authGet(url)
.map(response => response.json())
.map(response => {
.map(response => {
const items: any[] = response;
return items.map(item => {
return new AppContributorDto(
item.contributorId,
item.contributorId,
item.permission);
});
})
@ -56,7 +56,7 @@ export class AppContributorsService {
public deleteContributor(appName: string, contributorId: string): Observable<any> {
const url = this.apiUrl.buildUrl(`api/apps/${appName}/contributors/${contributorId}`);
return this.authService.authDelete(url)
.catch(response => handleError('Failed to delete contributors. Please reload.', response));
}

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

@ -176,7 +176,7 @@ export class AuthService {
public authDelete(url: string, options?: Ng2Http.RequestOptions): Observable<Ng2Http.Response> {
options = this.setRequestOptions(options);
return this.checkResponse(this.http.delete(url, options));
}

2
src/Squidex/app/shared/services/users-provider.service.ts

@ -27,7 +27,7 @@ export class UsersProviderService {
let result = this.caches[id];
if (!result) {
const request =
const request =
this.usersService.getUser(id).retry(2)
.catch(err => {
return Observable.of(new UserDto('NOT FOUND', 'NOT FOUND', 'NOT FOUND', ''));

2
src/Squidex/tslint.json

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

Loading…
Cancel
Save