-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from SwimResults/develop
`v1.0.4` User Athlete
- Loading branch information
Showing
33 changed files
with
370 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './settings-view/settings-view.component'; | ||
export * from './user-profile-view/user-profile-view.component'; |
25 changes: 25 additions & 0 deletions
25
...app/content/account/components/settings-user-athlete/settings-user-athlete.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<h1>{{'USER.SETTINGS.USER_ATHLETE.TITLE' | translate}}</h1> | ||
<p>{{'USER.SETTINGS.USER_ATHLETE.INFO_TEXT' | translate}}</p> | ||
|
||
<ng-container *ngIf="user"> | ||
<ng-container *ngIf="listUserAthlete && userAthlete"> | ||
<h2>{{'USER.SETTINGS.USER_ATHLETE.THIS_IS_YOU_TITLE' | translate}}</h2> | ||
<sr-list-view | ||
[data]="listUserAthlete" | ||
[useSearch]="false" | ||
[config]="configUserAthlete" | ||
></sr-list-view> | ||
</ng-container> | ||
<div *ngIf="!user.own_athlete_id"> | ||
<i>{{'USER.SETTINGS.USER_ATHLETE.NO_USER_SET' | translate}}</i> | ||
</div> | ||
|
||
<br><br> | ||
|
||
<sr-list-view *ngIf="listAthletes" | ||
[data]="listAthletes" | ||
[fetching]="fetchingAthletes" | ||
[config]="config" | ||
(refreshData)="fetchAthletes($event)" | ||
></sr-list-view> | ||
</ng-container> |
Empty file.
29 changes: 29 additions & 0 deletions
29
.../content/account/components/settings-user-athlete/settings-user-athlete.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SettingsUserAthleteComponent } from './settings-user-athlete.component'; | ||
import {HttpClientTestingModule} from "@angular/common/http/testing"; | ||
import {TranslateModule} from "@ngx-translate/core"; | ||
|
||
describe('SettingsUserAthleteComponent', () => { | ||
let component: SettingsUserAthleteComponent; | ||
let fixture: ComponentFixture<SettingsUserAthleteComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ SettingsUserAthleteComponent ], | ||
imports: [ | ||
HttpClientTestingModule, | ||
TranslateModule.forRoot() | ||
] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SettingsUserAthleteComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
73 changes: 73 additions & 0 deletions
73
src/app/content/account/components/settings-user-athlete/settings-user-athlete.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import {Component, Input, OnInit} from '@angular/core'; | ||
import {IListTile} from "../../../../core/model/list/list-tile.model"; | ||
import {Athlete} from "../../../../core/model"; | ||
import {AthleteService, UserService} from "../../../../core/service/api"; | ||
import {RefreshListRequest} from "../../../../core/model/list/refresh-list-request.model"; | ||
import {FetchingModel} from "../../../../core/model/common/fetching.model"; | ||
import {ListConfig} from "../../../../core/model/list/list-config.model"; | ||
import {User} from "../../../../core/model/user/user.model"; | ||
import {UserAthleteListTile} from "../../../../core/model/list/user-athlete-list-tile.model"; | ||
|
||
@Component({ | ||
selector: 'sr-settings-user-athlete', | ||
templateUrl: './settings-user-athlete.component.html', | ||
styleUrls: ['./settings-user-athlete.component.scss'] | ||
}) | ||
export class SettingsUserAthleteComponent implements OnInit { | ||
user?: User; | ||
|
||
userAthlete?: Athlete; | ||
listUserAthlete: IListTile[] = []; | ||
|
||
athletes: Athlete[] = []; | ||
listAthletes: IListTile[] = []; | ||
fetchingAthletes: FetchingModel = {fetching: false}; | ||
|
||
config: ListConfig = {showSetUserAthleteButton: true, showUnsetUserAthleteButton: false, showMoreButton: true}; | ||
configUserAthlete: ListConfig = {showUnsetUserAthleteButton: true, showMoreButton: true, showSetUserAthleteButton: false}; | ||
|
||
constructor( | ||
private athleteService: AthleteService, | ||
private userService: UserService | ||
) { | ||
} | ||
|
||
ngOnInit() { | ||
this.fetchUser(); | ||
} | ||
|
||
fetchUser() { | ||
this.userService.getUser().subscribe(data => { | ||
console.log("fetching athlete for user: " + data.keycloak_id); | ||
this.user = data; | ||
if (this.user && this.user.own_athlete_id) { | ||
this.athleteService.getAthleteById(this.user.own_athlete_id).subscribe(data => { | ||
this.userAthlete = data; | ||
this.listUserAthlete = []; | ||
this.listUserAthlete.push(new UserAthleteListTile(this.userAthlete)); | ||
}) | ||
} | ||
}); | ||
} | ||
|
||
fetchAthletes(request: RefreshListRequest) { | ||
this.fetchingAthletes.fetching = true; | ||
if (request.paging.offset == 0) { | ||
this.athletes = []; | ||
this.listAthletes = []; | ||
this.fetchUser(); // update user on list update; | ||
} | ||
this.athleteService.getAthletes(request.paging).subscribe(data => { | ||
this.appendAthletes(data); | ||
this.fetchingAthletes.fetching = false; | ||
}) | ||
} | ||
|
||
appendAthletes(athletes: Athlete[]) { | ||
if (!athletes) return; | ||
this.athletes.concat(athletes); | ||
athletes.forEach(athlete => { | ||
this.listAthletes.push(new UserAthleteListTile(athlete)); | ||
}) | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/app/content/account/components/settings-view/settings-view.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<sr-settings-user-athlete></sr-settings-user-athlete> |
Empty file.
31 changes: 31 additions & 0 deletions
31
src/app/content/account/components/settings-view/settings-view.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SettingsViewComponent } from './settings-view.component'; | ||
import {HttpClientTestingModule} from "@angular/common/http/testing"; | ||
import {TranslateModule} from "@ngx-translate/core"; | ||
import {AccountModule} from "../../account.module"; | ||
|
||
describe('SettingsViewComponent', () => { | ||
let component: SettingsViewComponent; | ||
let fixture: ComponentFixture<SettingsViewComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ SettingsViewComponent ], | ||
imports: [ | ||
HttpClientTestingModule, | ||
TranslateModule.forRoot(), | ||
AccountModule | ||
] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SettingsViewComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
src/app/content/account/components/settings-view/settings-view.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {User} from "../../../../core/model/user/user.model"; | ||
import {UserService} from "../../../../core/service/api"; | ||
|
||
@Component({ | ||
selector: 'sr-settings-view', | ||
templateUrl: './settings-view.component.html', | ||
styleUrls: ['./settings-view.component.scss'] | ||
}) | ||
export class SettingsViewComponent implements OnInit { | ||
user?: User; | ||
|
||
constructor( | ||
private userService: UserService | ||
) { | ||
} | ||
|
||
ngOnInit() { | ||
this.fetchUser(); | ||
} | ||
|
||
fetchUser() { | ||
this.userService.getUser().subscribe(data => this.user = data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './user-profile/user-profile.component'; | ||
export * from './page-user-settings/page-user-settings.component'; |
1 change: 1 addition & 0 deletions
1
src/app/content/account/pages/page-user-settings/page-user-settings.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<sr-settings-view></sr-settings-view> |
Empty file.
29 changes: 29 additions & 0 deletions
29
src/app/content/account/pages/page-user-settings/page-user-settings.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PageUserSettingsComponent } from './page-user-settings.component'; | ||
import {AccountModule} from "../../account.module"; | ||
import {TranslateModule} from "@ngx-translate/core"; | ||
|
||
describe('PageUserSettingsComponent', () => { | ||
let component: PageUserSettingsComponent; | ||
let fixture: ComponentFixture<PageUserSettingsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ PageUserSettingsComponent ], | ||
imports: [ | ||
AccountModule, | ||
TranslateModule.forRoot() | ||
] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PageUserSettingsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
src/app/content/account/pages/page-user-settings/page-user-settings.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'sr-page-user-settings', | ||
templateUrl: './page-user-settings.component.html', | ||
styleUrls: ['./page-user-settings.component.scss'] | ||
}) | ||
export class PageUserSettingsComponent { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export class ListConfig { | ||
showMoreButton: boolean = true; | ||
showSetUserAthleteButton: boolean = false; | ||
showUnsetUserAthleteButton: boolean = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,4 @@ export interface IListTile { | |
teamLink?: string; | ||
country?: string; | ||
entryType: "athlete" | "team" | undefined; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {IListTile} from "./list-tile.model"; | ||
import {Athlete} from "../athlete"; | ||
|
||
export class UserAthleteListTile implements IListTile { | ||
id: string; | ||
name: string; | ||
nameLink?: string; | ||
badge?: string; | ||
team?: string; | ||
teamLink?: string; | ||
entryType: "athlete" = "athlete"; | ||
|
||
constructor(athlete: Athlete) { | ||
this.id = athlete._id; | ||
this.name = athlete.name; | ||
this.badge = athlete.year; | ||
this.team = athlete.team.name; | ||
this.nameLink = "../../athlete/" + athlete.alias[0] + "-" + athlete.year; | ||
this.teamLink = "../../team/@" + athlete.team.alias[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.