|
|
@ -6,11 +6,13 @@ |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
import { Observable } from 'rxjs'; |
|
|
import { combineLatest } from 'rxjs'; |
|
|
import { map, take } from 'rxjs/operators'; |
|
|
import { map, take } from 'rxjs/operators'; |
|
|
import { AppDto, AppsState, AuthService, DialogModel, FeatureDto, LocalStoreService, NewsService, OnboardingService, TeamDto, TeamsState, TemplateDto, TemplatesState, UIOptions, UIState } from '@app/shared'; |
|
|
import { AppDto, AppsState, AuthService, DialogModel, FeatureDto, LocalStoreService, NewsService, OnboardingService, TeamDto, TeamsState, TemplateDto, TemplatesState, UIOptions, UIState } from '@app/shared'; |
|
|
import { Settings } from '@app/shared/state/settings'; |
|
|
import { Settings } from '@app/shared/state/settings'; |
|
|
|
|
|
|
|
|
|
|
|
type GroupedApps = { team?: TeamDto; apps: AppDto[] }; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'sqx-apps-page', |
|
|
selector: 'sqx-apps-page', |
|
|
styleUrls: ['./apps-page.component.scss'], |
|
|
styleUrls: ['./apps-page.component.scss'], |
|
|
@ -27,18 +29,42 @@ export class AppsPageComponent implements OnInit { |
|
|
|
|
|
|
|
|
public info = ''; |
|
|
public info = ''; |
|
|
|
|
|
|
|
|
public templates: Observable<TemplateDto[]> = |
|
|
public templates = |
|
|
this.templatesState.templates.pipe( |
|
|
this.templatesState.templates.pipe( |
|
|
map(x => x.filter(t => t.isStarter))); |
|
|
map(x => x.filter(t => t.isStarter))); |
|
|
|
|
|
|
|
|
|
|
|
public groupedApps = |
|
|
|
|
|
combineLatest([ |
|
|
|
|
|
this.appsState.apps, |
|
|
|
|
|
this.teamsState.teams, |
|
|
|
|
|
]).pipe(map(([apps, teams]) => { |
|
|
|
|
|
const grouped: GroupedApps[] = [{ apps: [] }]; |
|
|
|
|
|
|
|
|
|
|
|
for (const team of teams) { |
|
|
|
|
|
grouped.push({ team, apps: [] }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (const app of apps) { |
|
|
|
|
|
const group = grouped.find(x => x.team?.id === app.teamId) || grouped[0]; |
|
|
|
|
|
|
|
|
|
|
|
group.apps.push(app); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (grouped[0].apps.length === 0) { |
|
|
|
|
|
grouped.shift(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return grouped; |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
constructor( |
|
|
constructor( |
|
|
public readonly appsState: AppsState, |
|
|
|
|
|
public readonly authState: AuthService, |
|
|
public readonly authState: AuthService, |
|
|
public readonly uiState: UIState, |
|
|
public readonly uiState: UIState, |
|
|
public readonly teamsState: TeamsState, |
|
|
private readonly appsState: AppsState, |
|
|
private readonly localStore: LocalStoreService, |
|
|
private readonly localStore: LocalStoreService, |
|
|
private readonly newsService: NewsService, |
|
|
private readonly newsService: NewsService, |
|
|
private readonly onboardingService: OnboardingService, |
|
|
private readonly onboardingService: OnboardingService, |
|
|
|
|
|
private readonly teamsState: TeamsState, |
|
|
private readonly templatesState: TemplatesState, |
|
|
private readonly templatesState: TemplatesState, |
|
|
private readonly uiOptions: UIOptions, |
|
|
private readonly uiOptions: UIOptions, |
|
|
) { |
|
|
) { |
|
|
@ -92,7 +118,7 @@ export class AppsPageComponent implements OnInit { |
|
|
return app.id; |
|
|
return app.id; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public trackByTeam(_index: number, team: TeamDto) { |
|
|
public trackByGroup(_index: number, group: GroupedApps) { |
|
|
return team.id; |
|
|
return group.team?.id || '0'; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|