-
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.
- Loading branch information
1 parent
9993287
commit 197f6d9
Showing
16 changed files
with
405 additions
and
290 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,47 @@ | ||
<template> | ||
<div id="app"> | ||
<Header></Header> | ||
<Footer></Footer> | ||
</div> | ||
<div id="app"> | ||
<Header></Header> | ||
<Footer></Footer> | ||
</div> | ||
</template> | ||
<script> | ||
import Header from "./components/Header"; | ||
import Footer from "./components/Footer"; | ||
export default { | ||
components: {Header, Footer}, | ||
data(){ | ||
data() { | ||
return { | ||
senator: [], | ||
} | ||
}, | ||
created: function () { | ||
this.getData(); | ||
}, | ||
methods: { | ||
getData() { | ||
let pathSenate = 'senate'; | ||
let url = ''; | ||
let currentPage = window.location.href; | ||
if (currentPage.includes(pathSenate)) { | ||
url = 'https://api.myjson.com/bins/1eja30'; | ||
} else { | ||
url = 'https://api.myjson.com/bins/j83do'; | ||
} | ||
fetch(url) | ||
.then(response => response.json()) | ||
.then((jsonData) => { | ||
let data = jsonData; | ||
this.senator = data.results[0].members; | ||
this.senator.forEach(mem => { | ||
mem.fullname = (mem.first_name + ' ' + mem.middle_name + ' ' + mem.last_name).replace(null, ''); | ||
}); | ||
this.$store.commit('setCurrentSenator', this.senator); | ||
console.log(this.$store.state.senator); | ||
}); | ||
}, | ||
}, | ||
} | ||
</script> | ||
<style> | ||
</style> |
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,50 @@ | ||
<template> | ||
<div> | ||
<h5>Least Engaged (Top 10% of least votes with party)</h5> | ||
<table class="table table-bordered mt-3 table-hover"> | ||
<thead class="thead-dark"> | ||
<tr> | ||
<th v-for="label in TopTableHeader">{{label}}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="mem in getDataBottom"> | ||
<td>{{mem.fullname}}</td> | ||
<td>{{mem.missed_votes}}</td> | ||
<td>{{mem.missed_votes_pct}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "BottomTable", | ||
data() { | ||
return { | ||
TopTableHeader: ['Full name', 'Number of missed votes', 'Percent missed votes'], | ||
BottomTableBody: [], | ||
} | ||
}, | ||
props: { | ||
senatorB: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
computed: { | ||
getDataBottom() { | ||
let length = this.senatorB.length * 0.1; | ||
return this.senatorB.slice(0, length).sort(function (a, b) { | ||
return b.missed_votes - a.missed_votes | ||
}); | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<!-- Add "scoped" attribute to limit CSS to this component only --> | ||
<style scoped> | ||
</style> |
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,50 @@ | ||
<template> | ||
<div> | ||
<h5>Most Engaged (Top 10% of most votes with party)</h5> | ||
<table class="table table-bordered mt-3 table-hover"> | ||
<thead class="thead-dark"> | ||
<tr> | ||
<th v-for="label in TopTableHeaderL">{{label}}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="mem in getDataBottom"> | ||
<td>{{mem.fullname}}</td> | ||
<td>{{Math.round(((mem.total_votes - mem.missed_votes) * mem.votes_with_party_pct) / 100)}}</td> | ||
<td>{{mem.votes_with_party_pct}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "BottomTableLoyalty", | ||
data() { | ||
return { | ||
TopTableHeaderL: ['Full name', 'Number of party votes', 'Percent party votes'], | ||
BottomTableBody: [], | ||
} | ||
}, | ||
props: { | ||
senatorB: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
computed: { | ||
getDataBottom() { | ||
let length = this.senatorB.length * 0.1; | ||
return this.senatorB.slice(0, length).sort(function (a, b) { | ||
return a.votes_with_party_pct - b.votes_with_party_pct | ||
}); | ||
}, | ||
} | ||
} | ||
</script> | ||
|
||
<!-- Add "scoped" attribute to limit CSS to this component only --> | ||
<style scoped> | ||
</style> |
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.