Browse Source

General code refactor

Removed useless code | formated files
main
Haris Razis 4 years ago
parent
commit
26db0473e9
  1. 2
      .gitignore
  2. 12
      .idea/runConfigurations/dev_client.xml
  3. 12
      .idea/runConfigurations/dev_server.xml
  4. 12
      .idea/runConfigurations/run_client.xml
  5. 12
      .idea/runConfigurations/run_server.xml
  6. 30
      server/routes/athletes.js
  7. 2
      server/routes/user.js
  8. 6
      web/babel.config.js
  9. 6
      web/public/index.html
  10. 16
      web/src/components/Navbar.vue
  11. 2
      web/src/slims-vuex.d.ts
  12. 10
      web/src/store/modules/athletes.ts
  13. 2
      web/src/store/modules/backend.ts
  14. 6
      web/src/views/Athletes.vue
  15. 7
      web/src/views/DashboardHome.vue
  16. 2
      web/src/views/Login.vue

2
.gitignore

@ -106,5 +106,7 @@ dist
.idea/workspace.xml
.DS_Store
/dist
mongo_example_swarmlab.js

12
.idea/runConfigurations/dev_client.xml

@ -1,12 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="dev client" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/client/package.json" />
<command value="run" />
<scripts>
<script value="dev" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>

12
.idea/runConfigurations/dev_server.xml

@ -1,12 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="dev server" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/server/package.json" />
<command value="run" />
<scripts>
<script value="dev" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>

12
.idea/runConfigurations/run_client.xml

@ -1,12 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="run client" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/client/package.json" />
<command value="run" />
<scripts>
<script value="run" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>

12
.idea/runConfigurations/run_server.xml

@ -1,12 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="run server" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/server/package.json" />
<command value="run" />
<scripts>
<script value="run" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>

30
server/routes/athletes.js

@ -28,33 +28,19 @@ router.get('/api/athletes/:id/edit',
async (req, res) => {
const athlete = await Athlete.findById(req.params.id)
res.send(athlete)
}
)
;
});
router.put('/api/athletes/:id',
requireAuth,
celebrate(athleteUpdateSchema, guid),
async (req, res) => {
const {name, _trainer} = req.body
const updateAthlete = {name, _trainer}
if (_trainer === '') {
updateAthlete._trainer = undefined
await Athlete.findByIdAndUpdate(req.params.id, updateAthlete, {}, (err, athlete) => {
if (err)
return res.status(400).json({errors: 'Something went wrong!'});
return res.send(athlete)
})
} else if (name || _trainer)
await Athlete.findByIdAndUpdate(req.params.id, updateAthlete, {}, (err, athlete) => {
if (err)
return res.status(400).json({errors: 'Something went wrong!'});
res.send(athlete)
})
await Athlete.findByIdAndUpdate(req.params.id, {name, _trainer}, {}, (err, athlete) => {
if (err)
return res.status(400).json({errors: 'Something went wrong!'});
res.send(athlete)
})
});
router.delete('/api/athlete/:id',
@ -62,8 +48,6 @@ router.delete('/api/athlete/:id',
celebrate(guid),
async (req, res) => {
await Athlete.findByIdAndDelete(req.params.id)
}
)
;
});
module.exports = router;

2
server/routes/user.js

@ -22,14 +22,12 @@ router.put('/api/user/:id',
if (isMatch) {
const user = {username, email, newPassword}
await User.findByIdAndUpdate(req.params.id, user)
res.send(req.user);
}
});
} else if (username || email) {
const user = {username, email}
await User.findByIdAndUpdate(req.params.id, user)
res.send(req.user);
}

6
web/babel.config.js

@ -1,5 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
presets: [
'@vue/cli-plugin-babel/preset'
]
}

6
web/public/index.html

@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width,initial-scale=1.0" name="viewport">
<link href="<%= BASE_URL %>favicon.ico" rel="icon">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<style>

16
web/src/components/Navbar.vue

@ -1,19 +1,17 @@
<template>
<nav class="navbar is-fixed-top is-black" role="navigation" aria-label="main navigation">
<nav aria-label="main navigation" class="navbar is-fixed-top is-black" role="navigation">
<div class="navbar-brand">
<router-link to="/">
<a class="navbar-item">
<img src="../assets/undraw_server_q2pb.svg" width="60" height="150"/>
<img height="150" src="../assets/undraw_server_q2pb.svg" width="60"/>
<h3 class="is-size-4 has-text-white">Ichnaea</h3>
</a>
</router-link>
<a
role="button"
class="navbar-burger burger"
aria-label="menu"
aria-expanded="false"
data-target="navbarBasicExample"
>
<a aria-expanded="false"
aria-label="menu"
class="navbar-burger burger"
data-target="navbarBasicExample"
role="button">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>

2
web/src/slims-vuex.d.ts

@ -1,4 +1,4 @@
import { Store } from '@/store';// path to store file
import {Store} from '@/store'; // path to store file
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {

10
web/src/store/modules/athletes.ts

@ -8,7 +8,7 @@ export interface AthleteInterface {
id: string,
socketID: string,
name: string,
_trainer: string
_trainer: string | undefined
}
@Module
@ -34,15 +34,15 @@ export default class Athletes extends VuexModule {
return this.err
}
@Mutation save_trainer(trainer: UserInterface) {
this.trainer = trainer;
}
@Mutation
private save_athlete(athlete: AthleteInterface) {
this.athlete = athlete;
}
@Mutation save_trainer(trainer: UserInterface) {
this.trainer = trainer;
}
@Mutation
private api_athletes(athletes: [AthleteInterface]) {
this.athletes = athletes;

2
web/src/store/modules/backend.ts

@ -4,7 +4,7 @@ import {Module, Mutation, VuexModule} from 'vuex-module-decorators'
export default class Backend extends VuexModule {
private serverStatus = false
get currentStatus() {
get currentServerStatus() {
return this.serverStatus
}

6
web/src/views/Athletes.vue

@ -28,7 +28,7 @@
</tr>
</thead>
<tr v-for="(athlete, index) in myAthletes" :key="index">
<td class="is-family-monospace" v-if="athlete.name">
<td v-if="athlete.name" class="is-family-monospace">
<span v-if="athlete.socketID">Online</span>
<span v-else>Offline</span>
</td>
@ -141,7 +141,6 @@ export default class Athletes extends Vue {
private msg = ''
mounted() {
this.myAthletes = [<AthleteInterface>{}]
this.$store.dispatch('getAthletes')
.then((res: any) => {
this.athletes = res.data;
@ -159,12 +158,11 @@ export default class Athletes extends Vue {
}
private removeMyAthlete(athlete: AthleteInterface, index: number) {
athlete._trainer = ''
athlete._trainer = undefined
this.$store.dispatch('updateAthlete', athlete)
.then(() => this.myAthletes.splice(index, 1))
}
}
</script>

7
web/src/views/DashboardHome.vue

@ -25,16 +25,17 @@
<div class="tile is-parent is-vertical">
<article class="tile is-child box">
<p class="title">System status</p>
<p class="subtitle">All systems operational</p>
<p v-if="this.$store.getters.currentServerStatus" class="subtitle">All systems operational</p>
<p v-else class="subtitle">Something does not seem right</p>
</article>
<article class="tile is-child box">
<p class="title">...tiles</p>
<p class="title">App Info</p>
<p class="subtitle">Bottom tile</p>
</article>
</div>
<div class="tile is-parent">
<article class="tile is-child box">
<figure class="image is-4by3">
<figure class="image">
<img src="../assets/undraw_finish_line_katerina_limpitsouni_xy20.svg">
</figure>
</article>

2
web/src/views/Login.vue

@ -29,7 +29,7 @@
</p>
</div>
</form>
<div class="m-4" v-if="msg">
<div v-if="msg" class="m-4">
<div class="notification is-danger has-text-centered">
<b>{{ msg }}</b>
</div>

Loading…
Cancel
Save