|
@ -4,29 +4,26 @@ |
|
|
<div class="notification is-link is-light"> |
|
|
<div class="notification is-link is-light"> |
|
|
Your adopted athletes are displayed on this table. Choose an athlete and view his details, data. |
|
|
Your adopted athletes are displayed on this table. Choose an athlete and view his details, data. |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="section"> |
|
|
<div class="section"> |
|
|
<div class="table-container"> |
|
|
<div class="table-container"> |
|
|
<table |
|
|
<table class="table is-striped is-large is-hoverable is-fullwidth has-text-centered"> |
|
|
class="table |
|
|
|
|
|
is-striped |
|
|
|
|
|
is-large |
|
|
|
|
|
is-hoverable |
|
|
|
|
|
is-fullwidth |
|
|
|
|
|
has-text-centered"> |
|
|
|
|
|
<thead> |
|
|
<thead> |
|
|
<tr> |
|
|
<tr> |
|
|
<th><span class="icon mr-1"><i class="fa fa-plug"></i></span> |
|
|
<th> |
|
|
Athlete status |
|
|
<span class="icon mr-1"><i class="fa fa-plug"></i></span>Athlete status |
|
|
</th> |
|
|
</th> |
|
|
<th><span class="icon mr-1"><i class="fas fa-running"></i></span> |
|
|
<th> |
|
|
Name |
|
|
<span class="icon mr-1"><i class="fas fa-running"></i></span>Name |
|
|
</th> |
|
|
</th> |
|
|
<th><span class="icon mr-1"><i class="fas fa-id-badge"></i></span> |
|
|
<th> |
|
|
ID |
|
|
<span class="icon mr-1"><i class="fas fa-id-badge"></i></span>ID |
|
|
</th> |
|
|
</th> |
|
|
<th>Actions</th> |
|
|
<th>Actions</th> |
|
|
</tr> |
|
|
</tr> |
|
|
</thead> |
|
|
</thead> |
|
|
|
|
|
|
|
|
<tr v-for="(athlete, index) in myAthletes" :key="index"> |
|
|
<tr v-for="(athlete, index) in myAthletes" :key="index"> |
|
|
<td v-if="athlete.name" class="is-family-monospace"> |
|
|
<td v-if="athlete.name" class="is-family-monospace"> |
|
|
<span v-if="athlete.socketID">Online</span> |
|
|
<span v-if="athlete.socketID">Online</span> |
|
@ -39,47 +36,48 @@ |
|
|
<span>{{ athlete.id }}</span> |
|
|
<span>{{ athlete.id }}</span> |
|
|
</td> |
|
|
</td> |
|
|
<td v-if="athlete.name"> |
|
|
<td v-if="athlete.name"> |
|
|
<router-link :to="{ name: 'Table', params: { id: athlete._id }}" @click="saveAthlete(athlete)"> |
|
|
<router-link :to="{ name: 'Table', params: { id: athlete._id }}" @click="athlete_save(athlete)"> |
|
|
<span class="icon is-medium has-background-primary has-text-white mr-1"> |
|
|
<span class="icon is-medium has-background-primary has-text-white mr-1"> |
|
|
<i class="fa fa-lg fa-table"></i> |
|
|
<i class="fa fa-lg fa-table"></i> |
|
|
</span> |
|
|
</span> |
|
|
</router-link> |
|
|
</router-link> |
|
|
<router-link :to="{ name: 'Chart', params: { id: athlete._id }}" @click="saveAthlete(athlete)"> |
|
|
<router-link :to="{ name: 'Chart', params: { id: athlete._id }}" @click="athlete_save(athlete)"> |
|
|
<span class="icon is-medium has-background-primary has-text-white mr-1"> |
|
|
<span class="icon is-medium has-background-primary has-text-white mr-1"> |
|
|
<i class="fa fa-lg fa-chart-area"></i> |
|
|
<i class="fa fa-lg fa-chart-area"></i> |
|
|
</span> |
|
|
</span> |
|
|
</router-link> |
|
|
</router-link> |
|
|
<router-link :to="{ name: 'Athlete', params: { id: athlete._id }}" @click="saveAthlete(athlete)"> |
|
|
<router-link :to="{ name: 'Athlete', params: { id: athlete._id }}" @click="athlete_save(athlete)"> |
|
|
<span class="icon is-medium has-background-warning has-text-white mr-1"> |
|
|
<span class="icon is-medium has-background-warning has-text-white mr-1"> |
|
|
<i class="fa fa-lg fa-user-edit"></i> |
|
|
<i class="fa fa-lg fa-user-edit"></i> |
|
|
</span> |
|
|
</span> |
|
|
</router-link> |
|
|
</router-link> |
|
|
<a @click="removeMyAthlete(athlete, index)"> |
|
|
<a @click="athlete_delete(athlete, index)"> |
|
|
<span class="icon is-medium has-background-danger has-text-white mr-1"> |
|
|
<span class="icon is-medium has-background-danger has-text-white mr-1"> |
|
|
<i class="fa fa-lg fa-user-times"></i> |
|
|
<i class="fa fa-lg fa-user-times"></i> |
|
|
</span> |
|
|
</span> |
|
|
</a> |
|
|
</a> |
|
|
</td> |
|
|
</td> |
|
|
</tr> |
|
|
</tr> |
|
|
|
|
|
|
|
|
</table> |
|
|
</table> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="section is-medium"> |
|
|
<div class="section is-medium"> |
|
|
<div class="container"> |
|
|
<div class="container"> |
|
|
<h3 class="title is-4">Search all athletes</h3> |
|
|
<h3 class="title is-4">Search all athletes</h3> |
|
|
<p class="subtitle">All athletes are displayed on this table.</p> |
|
|
<p class="subtitle">All athletes are displayed on this table.</p> |
|
|
<div class="control"> |
|
|
<div class="control"> |
|
|
|
|
|
<label> |
|
|
<input class="input is-focused" placeholder="Search Athletes" type="text"> |
|
|
<input class="input is-focused" placeholder="Search Athletes" type="text"> |
|
|
|
|
|
</label> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="table-container"> |
|
|
<div class="table-container"> |
|
|
<table |
|
|
<table |
|
|
class="table |
|
|
class="table is-striped is-large is-hoverable is-fullwidth has-text-centered"> |
|
|
is-striped |
|
|
|
|
|
is-large |
|
|
|
|
|
is-hoverable |
|
|
|
|
|
is-fullwidth |
|
|
|
|
|
has-text-centered"> |
|
|
|
|
|
<thead> |
|
|
<thead> |
|
|
<tr> |
|
|
<tr> |
|
|
<th><span class="icon mr-1"><i class="fa fa-plug"></i></span> |
|
|
<th><span class="icon mr-1"><i class="fa fa-plug"></i></span> |
|
@ -92,6 +90,7 @@ |
|
|
<th>Actions</th> |
|
|
<th>Actions</th> |
|
|
</tr> |
|
|
</tr> |
|
|
</thead> |
|
|
</thead> |
|
|
|
|
|
|
|
|
<tr v-for="(athlete, index) in athletes" :key="index"> |
|
|
<tr v-for="(athlete, index) in athletes" :key="index"> |
|
|
<td class="is-family-monospace"> |
|
|
<td class="is-family-monospace"> |
|
|
<span v-if="athlete.socketID">Online</span> |
|
|
<span v-if="athlete.socketID">Online</span> |
|
@ -107,23 +106,24 @@ |
|
|
<span class="icon mr-1"><i class="fa fa-times"></i></span> |
|
|
<span class="icon mr-1"><i class="fa fa-times"></i></span> |
|
|
</td> |
|
|
</td> |
|
|
<td> |
|
|
<td> |
|
|
<router-link :to="{ name: 'Table', params: { id: athlete._id }}" @click="saveAthlete(athlete)"> |
|
|
<router-link :to="{ name: 'Table', params: { id: athlete._id }}" @click="athlete_save(athlete)"> |
|
|
<span class="icon is-medium has-background-primary has-text-white mr-1"> |
|
|
<span class="icon is-medium has-background-primary has-text-white mr-1"> |
|
|
<i class="fa fa-lg fa-table"></i> |
|
|
<i class="fa fa-lg fa-table"></i> |
|
|
</span> |
|
|
</span> |
|
|
</router-link> |
|
|
</router-link> |
|
|
<router-link :to="{ name: 'Chart', params: { id: athlete._id }}" @click="saveAthlete(athlete)"> |
|
|
<router-link :to="{ name: 'Chart', params: { id: athlete._id }}" @click="athlete_save(athlete)"> |
|
|
<span class="icon is-medium has-background-primary has-text-white mr-1"> |
|
|
<span class="icon is-medium has-background-primary has-text-white mr-1"> |
|
|
<i class="fa fa-lg fa-chart-area"></i> |
|
|
<i class="fa fa-lg fa-chart-area"></i> |
|
|
</span> |
|
|
</span> |
|
|
</router-link> |
|
|
</router-link> |
|
|
<router-link :to="{ name: 'Athlete', params: { id: athlete._id }}" @click="saveAthlete(athlete)"> |
|
|
<router-link :to="{ name: 'Athlete', params: { id: athlete._id }}" @click="athlete_save(athlete)"> |
|
|
<span class="icon is-medium has-background-warning has-text-white mr-1"> |
|
|
<span class="icon is-medium has-background-warning has-text-white mr-1"> |
|
|
<i class="fa fa-lg fa-user-edit"></i> |
|
|
<i class="fa fa-lg fa-user-edit"></i> |
|
|
</span> |
|
|
</span> |
|
|
</router-link> |
|
|
</router-link> |
|
|
</td> |
|
|
</td> |
|
|
</tr> |
|
|
</tr> |
|
|
|
|
|
|
|
|
</table> |
|
|
</table> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
@ -135,32 +135,32 @@ import {AthleteInterface} from "@/store/modules/athletes"; |
|
|
import {UserInterface} from "@/store/modules/user"; |
|
|
import {UserInterface} from "@/store/modules/user"; |
|
|
|
|
|
|
|
|
export default class Athletes extends Vue { |
|
|
export default class Athletes extends Vue { |
|
|
private athletes = [<AthleteInterface>{}] |
|
|
private athletes = [<AthleteInterface>{}]; |
|
|
private myAthletes = [<AthleteInterface>{}] |
|
|
private myAthletes = [<AthleteInterface>{}]; |
|
|
private user = <UserInterface>{} |
|
|
private user = <UserInterface>{}; |
|
|
private msg = '' |
|
|
private msg = ''; |
|
|
|
|
|
|
|
|
mounted() { |
|
|
mounted() { |
|
|
this.$store.dispatch('getAthletes') |
|
|
this.$store.dispatch('athlete_getAll') |
|
|
.then((res: any) => { |
|
|
.then((res: any) => { |
|
|
this.athletes = res.data; |
|
|
this.athletes = res.data; |
|
|
this.user = this.$store.getters.currentUser |
|
|
this.user = this.$store.getters.user_current |
|
|
for (const athlete of this.athletes) { |
|
|
for (const athlete of this.athletes) { |
|
|
if (athlete._trainer === this.user._id) |
|
|
if (athlete._trainer === this.user._id) |
|
|
this.myAthletes.push(athlete) |
|
|
this.myAthletes.push(athlete); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
.catch((err: any) => this.msg = err.response.data.errors.message || err.message || 'Something went wrong!') |
|
|
.catch((err: any) => this.msg = err.response.data.errors.message || err.message || 'Something went wrong!'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private saveAthlete(athlete: AthleteInterface) { |
|
|
private athlete_save(athlete: AthleteInterface) { |
|
|
this.$store.dispatch('saveAthlete', athlete) |
|
|
this.$store.dispatch('athlete_saveLocal', athlete); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private removeMyAthlete(athlete: AthleteInterface, index: number) { |
|
|
private athlete_delete(athlete: AthleteInterface, index: number) { |
|
|
athlete._trainer = undefined |
|
|
athlete._trainer = undefined; |
|
|
this.$store.dispatch('updateAthlete', athlete) |
|
|
this.$store.dispatch('athlete_update', athlete) |
|
|
.then(() => this.myAthletes.splice(index, 1)) |
|
|
.then(() => this.myAthletes.splice(index, 1)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|