From 08c81e1fdbcafbd5139df21cbb37826e64f2a865 Mon Sep 17 00:00:00 2001
From: Aegir Thorsteinsson
Date: Tue, 14 Sep 2021 00:00:24 +0000
Subject: [PATCH] Add term to frontend
---
.../src/components/about/index.js | 8 ++-
.../src/components/mp-details/index.js | 72 +++++++++----------
.../src/components/mps/index.js | 44 ++++++------
.../src/components/parties/index.js | 20 ++----
.../src/components/party-details/index.js | 61 ++++++++--------
.../src/components/totals/index.js | 49 +++++++------
thingmenn-frontend/src/routes.js | 11 ++-
thingmenn-frontend/src/services/mp-service.js | 17 ++---
.../src/services/mp-summary-service.js | 29 ++++----
.../src/services/party-service.js | 9 +--
.../src/services/party-summary-service.js | 29 ++++----
.../src/services/totals-service.js | 29 ++++----
thingmenn-frontend/src/utility/get-path.js | 7 ++
.../src/widgets/details-menu/index.js | 2 +-
.../src/widgets/friends/index.js | 5 +-
thingmenn-frontend/src/widgets/mp/index.js | 7 +-
thingmenn-frontend/src/widgets/nav/index.js | 2 +-
thingmenn-frontend/src/widgets/party/index.js | 2 +-
18 files changed, 203 insertions(+), 200 deletions(-)
create mode 100644 thingmenn-frontend/src/utility/get-path.js
diff --git a/thingmenn-frontend/src/components/about/index.js b/thingmenn-frontend/src/components/about/index.js
index fd626e0..fb55edf 100644
--- a/thingmenn-frontend/src/components/about/index.js
+++ b/thingmenn-frontend/src/components/about/index.js
@@ -15,7 +15,7 @@ export default class About extends React.Component {
Markmið vefsins er að sækja gögn sem finna má á vef{' '}
-
+
Alþingis
, vinna úr þeim og setja fram á skemmtilegan, fræðandi og helst af
@@ -43,6 +43,7 @@ export default class About extends React.Component {
className="u-link"
href="http://twitter.com/baerinq"
target="_blank"
+ rel="noopener noreferrer"
>
Bæring Gunnar Steinþórsson
@@ -50,7 +51,7 @@ export default class About extends React.Component {
Sérstakar þakkir fá samstarfsfélagar mínir hjá{' '}
-
+
Aranja
; {' '}
@@ -58,6 +59,7 @@ export default class About extends React.Component {
className="u-link"
href="http://twitter.com/dbjcodes"
target="_blank"
+ rel="noopener noreferrer"
>
Davíð Bachmann Jóhannesson
@@ -66,6 +68,7 @@ export default class About extends React.Component {
className="u-link"
href="http://twitter.com/herrhelms"
target="_blank"
+ rel="noopener noreferrer"
>
Sebastian Helms
{' '}
@@ -74,6 +77,7 @@ export default class About extends React.Component {
className="u-link"
href="http://twitter.com/thorsteinsson"
target="_blank"
+ rel="noopener noreferrer"
>
Ægir Giraldo Þorsteinsson
{' '}
diff --git a/thingmenn-frontend/src/components/mp-details/index.js b/thingmenn-frontend/src/components/mp-details/index.js
index 7e06b8f..690389c 100644
--- a/thingmenn-frontend/src/components/mp-details/index.js
+++ b/thingmenn-frontend/src/components/mp-details/index.js
@@ -25,10 +25,9 @@ export default class MpDetails extends React.Component {
super(props)
this.state = {
- mp: { description: {}, lthings: [] },
- lthing: null,
- lthings: [],
- lthingLookup: {},
+ mp: { description: {}, terms: [] },
+ params: {},
+ terms: [],
voteSummary: { votePercentages: [], voteSummary: [] },
speechSummary: [],
documentSummary: [],
@@ -46,25 +45,25 @@ export default class MpDetails extends React.Component {
}
componentWillReceiveProps(nextProps) {
- this.getData(nextProps.routeParams.mpId, nextProps.routeParams.lthing)
+ this.getData(nextProps.routeParams.mpId, nextProps.routeParams)
}
- getData(id, lthing) {
+ getData(id, nextParams) {
// TODO: HOC withData that injects correct props into components
const mpId = id || this.props.params.mpId
- const lthingId = lthing || this.props.params.lthing
+ const params = nextParams || this.props.params
if (this.state.mp.id === mpId) return
- mpService.getMpDetailsByLthing(mpId, lthingId).then((mp) => {
+ mpService.getMpDetails(mpId, params).then((mp) => {
this.setState(() => ({
mp,
}))
})
mpSummaryService
- .getMpVoteSummaryByLthing(mpId, lthingId)
+ .getMpVoteSummary(mpId, params)
.then((voteSummary) => {
this.setState(() => ({
voteSummary,
@@ -72,7 +71,7 @@ export default class MpDetails extends React.Component {
})
mpSummaryService
- .getMpSpeechSummaryByLthing(mpId, lthingId)
+ .getMpSpeechSummary(mpId, params)
.then((speechSummary) => {
this.setState(() => ({
speechSummary,
@@ -80,7 +79,7 @@ export default class MpDetails extends React.Component {
})
mpSummaryService
- .getMpDocumentSummaryByLthing(mpId, lthingId)
+ .getMpDocumentSummary(mpId, params)
.then((documentSummary) => {
this.setState(() => ({
documentSummary,
@@ -88,7 +87,7 @@ export default class MpDetails extends React.Component {
})
mpSummaryService
- .getMpVotePositionsByLthing(mpId, lthingId)
+ .getMpVotePositions(mpId, params)
.then((votePositions) => {
this.setState(() => ({
votePositions,
@@ -96,7 +95,7 @@ export default class MpDetails extends React.Component {
})
mpSummaryService
- .getMpSpeechPositionsByLthing(mpId, lthingId)
+ .getMpSpeechPositions(mpId, params)
.then((speechPositions) => {
this.setState(() => ({
speechPositions,
@@ -104,7 +103,7 @@ export default class MpDetails extends React.Component {
})
mpSummaryService
- .getMpDocumentPositionsByLthing(mpId, lthingId)
+ .getMpDocumentPositions(mpId, params)
.then((documentPositions) => {
this.setState(() => ({
documentPositions,
@@ -112,58 +111,54 @@ export default class MpDetails extends React.Component {
})
mpSummaryService
- .getMpAbsentSummaryByLthing(mpId, lthingId)
+ .getMpAbsentSummary(mpId, params)
.then((absentSummary) => {
this.setState(() => ({
absentSummary,
}))
})
- mpService.getSimilarMpsByLthing(mpId, lthingId).then((similarMps) => {
+ mpService.getSimilarMps(mpId, params).then((similarMps) => {
this.setState(() => ({
similarMps,
}))
})
- mpService.getDifferentMpsByLthing(mpId, lthingId).then((differentMps) => {
+ mpService.getDifferentMps(mpId, params).then((differentMps) => {
this.setState(() => ({
differentMps,
}))
})
- totalsService.getLthings().then((lthings) => {
- const lthingLookup = {}
- lthings.forEach((lthing) => (lthingLookup[lthing.id] = lthing))
+ totalsService.getTerms().then((terms) => {
this.setState(() => ({
- lthings,
- lthingLookup,
+ terms,
}))
})
}
- generateLthingList(mp, lthings, lthingLookup) {
+ generateTermsList(mp, terms) {
const initialList = [
{
name: 'Samtölur',
- url: `/thingmenn/${mp.id}/thing/allt`,
+ url: `/thingmenn/${mp.id}/kjortimabil/allt`,
},
]
- if (!mp.lthings.length || !lthings.length) {
+ if (!mp.terms || !mp.terms.length || !terms.length) {
return initialList
}
- const lthingsFormatted = mp.lthings.map((lthingInfo) => ({
- year: lthingLookup[lthingInfo.lthing].start.split('.')[2],
- thing: lthingInfo.lthing,
- url: `/thingmenn/${mp.id}/thing/${lthingInfo.lthing}`,
+ const termsFormatted = mp.terms.map((termInfo) => ({
+ name: termInfo.id,
+ url: `/thingmenn/${mp.id}/kjortimabil/${termInfo.id}`,
}))
- return initialList.concat(lthingsFormatted)
+ return initialList.concat(termsFormatted)
}
- getDividerSize(tabName, lthing) {
- if (lthing === 'allt') {
+ getDividerSize(tabName, params) {
+ if (params.term === 'allt' || params.lthing === 'allt') {
if (tabName === 'speeches') {
return 3
} else if (tabName === 'documents') {
@@ -183,8 +178,7 @@ export default class MpDetails extends React.Component {
render() {
const {
mp,
- lthings,
- lthingLookup,
+ terms,
voteSummary,
speechSummary,
documentSummary,
@@ -195,12 +189,12 @@ export default class MpDetails extends React.Component {
differentMps,
} = this.state
- const lthing = this.props.params.lthing
+ const { params } = this.props
return (
@@ -214,7 +208,7 @@ export default class MpDetails extends React.Component {
title="Samherjar"
subTitle="Eins greidd atkvæði"
friends={similarMps.slice(0, 10)}
- lthing={lthing}
+ params={params}
isDisplayingFriends={true}
/>
@@ -264,7 +258,7 @@ export default class MpDetails extends React.Component {
Ræður eftir flokkum
@@ -277,7 +271,7 @@ export default class MpDetails extends React.Component {
Þingskjöl eftir flokkum
diff --git a/thingmenn-frontend/src/components/mps/index.js b/thingmenn-frontend/src/components/mps/index.js
index e8da7a2..ee5aa28 100644
--- a/thingmenn-frontend/src/components/mps/index.js
+++ b/thingmenn-frontend/src/components/mps/index.js
@@ -12,8 +12,8 @@ let searchInput = ''
const initialLthingsMenuList = [
{
- name: 'Öll þing',
- url: '/thing/allt',
+ name: 'Öll kjörtímabil',
+ url: '/kjortimabil/allt',
},
]
@@ -22,34 +22,33 @@ export default class Mps extends React.Component {
super(props)
this.state = {
- lthing: null,
+ params: null,
mps: [],
- lthings: [],
+ terms: [],
searchInput: '',
sortByParty: false,
}
}
componentWillMount() {
- const lthing = this.props.params.lthing
- this.getData(lthing)
+ const { lthing, term } = this.props.params
+ this.getData({ lthing, term })
this.setSorting(this.props)
}
componentWillReceiveProps(nextProps) {
- const lthing = nextProps.params.lthing
-
- this.getData(lthing)
+ const { lthing, term } = nextProps.params
+ this.getData({ lthing, term })
this.setSorting(this.props)
}
- getData(lthing) {
- mpService.getMpsByLthing(lthing).then((mps) => {
- this.setState(() => ({ mps, lthing }))
+ getData(params) {
+ mpService.getMps(params).then((mps) => {
+ this.setState(() => ({ mps, params }))
})
- totalService.getLthings().then((lthings) => {
- this.setState(() => ({ lthings }))
+ totalService.getTerms().then((terms) => {
+ this.setState(() => ({ terms }))
})
}
@@ -82,27 +81,24 @@ export default class Mps extends React.Component {
}
render() {
- const { mps, sortByParty, lthing, lthings } = this.state
+ const { mps, params, terms } = this.state
const items = mps
.filter(this.searchFilter.bind(this))
.sort(this.sortItem.bind(this))
- const lthingsFormatted = lthings.map((lthing) => ({
- year: lthing.start.split('.')[2],
- thing: lthing.id,
- url: `/thing/${lthing.id}`,
- }))
-
- const lthingsToRender = initialLthingsMenuList.concat(lthingsFormatted)
+ const termsToRender = initialLthingsMenuList.concat(terms.map((term) => ({
+ name: term.id,
+ url: `/kjortimabil/${term.id}`,
+ })))
return (
Allir þingmenn
-
+
{items.map((mp) => (
-
+
))}
diff --git a/thingmenn-frontend/src/components/parties/index.js b/thingmenn-frontend/src/components/parties/index.js
index d616919..f0b40e8 100644
--- a/thingmenn-frontend/src/components/parties/index.js
+++ b/thingmenn-frontend/src/components/parties/index.js
@@ -1,7 +1,6 @@
import React from 'react'
import partyService from '../../services/party-service'
-import totalService from '../../services/totals-service'
import Party from '../../widgets/party'
import List from '../../widgets/list'
@@ -14,33 +13,25 @@ export default class Mps extends React.Component {
this.state = {
parties: [],
- lthings: [],
}
}
componentWillMount() {
- const lthing = this.props.params.lthing
- this.getData(lthing)
+ this.getData(this.props.params)
}
componentWillReceiveProps(nextProps) {
- const lthing = nextProps.params.lthing
-
- this.getData(lthing)
+ this.getData(nextProps.params)
}
- getData(lthing) {
- partyService.getPartiesByLthing(lthing).then((parties) => {
+ getData(params) {
+ partyService.getParties(params).then((parties) => {
this.setState(() => ({ parties }))
})
-
- totalService.getLthings().then((lthings) => {
- this.setState(() => ({ lthings }))
- })
}
render() {
- const { parties, lthings } = this.state
+ const { parties } = this.state
return (
@@ -49,7 +40,6 @@ export default class Mps extends React.Component {
{parties.map((party) => (
))}
diff --git a/thingmenn-frontend/src/components/party-details/index.js b/thingmenn-frontend/src/components/party-details/index.js
index 80e3a1c..043d81f 100644
--- a/thingmenn-frontend/src/components/party-details/index.js
+++ b/thingmenn-frontend/src/components/party-details/index.js
@@ -23,10 +23,10 @@ export default class PartyDetails extends React.Component {
super(props)
this.state = {
- party: { lthings: [] },
- lthing: null,
- lthings: [],
- lthingLookup: {},
+ party: { terms: [] },
+ params: null,
+ terms: [],
+ termsLookup: {},
voteSummary: { votePercentages: [], voteSummary: [] },
speechSummary: [],
documentSummary: [],
@@ -42,19 +42,19 @@ export default class PartyDetails extends React.Component {
}
componentWillReceiveProps(nextProps) {
- this.getData(nextProps.routeParams.partyId, nextProps.routeParams.lthing)
+ this.getData(nextProps.routeParams.partyId, nextProps.routeParams)
}
- getData(id, lthing) {
+ getData(id, nextParams) {
const partyId = id || this.props.params.partyId
- const lthingId = lthing || this.props.params.lthing
+ const params = nextParams || this.props.params
- partyService.getPartyDetailsByLthing(partyId, 'allt').then((party) => {
+ partyService.getPartyDetails(partyId, { term: 'allt' }).then((party) => {
this.setState(() => ({ party }))
})
partySummaryService
- .getPartyVoteSummaryByLthing(partyId, lthingId)
+ .getPartyVoteSummary(partyId, params)
.then((voteSummary) => {
this.setState(() => ({
voteSummary,
@@ -62,7 +62,7 @@ export default class PartyDetails extends React.Component {
})
partySummaryService
- .getPartySpeechSummaryByLthing(partyId, lthingId)
+ .getPartySpeechSummary(partyId, params)
.then((speechSummary) => {
this.setState(() => ({
speechSummary,
@@ -70,7 +70,7 @@ export default class PartyDetails extends React.Component {
})
partySummaryService
- .getPartyDocumentSummaryByLthing(partyId, lthingId)
+ .getPartyDocumentSummary(partyId, params)
.then((documentSummary) => {
this.setState(() => ({
documentSummary,
@@ -78,7 +78,7 @@ export default class PartyDetails extends React.Component {
})
partySummaryService
- .getPartyAbsentSummaryByLthing(partyId, lthingId)
+ .getPartyAbsentSummary(partyId, params)
.then((absentSummary) => {
this.setState(() => ({
absentSummary,
@@ -86,7 +86,7 @@ export default class PartyDetails extends React.Component {
})
partySummaryService
- .getPartyVotePositionsByLthing(partyId, lthingId)
+ .getPartyVotePositions(partyId, params)
.then((votePositions) => {
this.setState(() => ({
votePositions,
@@ -94,7 +94,7 @@ export default class PartyDetails extends React.Component {
})
partySummaryService
- .getPartySpeechPositionsByLthing(partyId, lthingId)
+ .getPartySpeechPositions(partyId, params)
.then((speechPositions) => {
this.setState(() => ({
speechPositions,
@@ -102,44 +102,43 @@ export default class PartyDetails extends React.Component {
})
partySummaryService
- .getPartyDocumentPositionsByLthing(partyId, lthingId)
+ .getPartyDocumentPositions(partyId, params)
.then((documentPositions) => {
this.setState(() => ({
documentPositions,
}))
})
- totalsService.getLthings().then((lthings) => {
- const lthingLookup = {}
- lthings.forEach((lthing) => (lthingLookup[lthing.id] = lthing))
+ totalsService.getTerms().then((terms) => {
+ const termsLookup = {}
+ terms.forEach((term) => (termsLookup[term.id] = term))
this.setState(() => ({
- lthings,
- lthingLookup,
+ terms,
+ termsLookup,
}))
})
}
- generateLthingList(party, lthings, lthingLookup) {
+ generateTermsList(party, terms) {
const initialList = [
{
name: 'Samtölur',
- url: `/thingflokkar/${party.id}/thing/allt`,
+ url: `/thingflokkar/${party.id}/kjortimabil/allt`,
},
]
- if (!party.lthings.length || !lthings.length) {
+ if (!party.terms.length || !terms.length) {
return initialList
}
- const lthingsFormatted = party.lthings.map((lthingInfo) => {
+ const termsFormatted = party.terms.map((termInfo) => {
return {
- year: lthingLookup[lthingInfo.lthing].start.split('.')[2],
- thing: lthingInfo.lthing,
- url: `/thingflokkar/${party.id}/thing/${lthingInfo.lthing}`,
+ name: termInfo.id,
+ url: `/thingflokkar/${party.id}/kjortimabil/${termInfo.id}`,
}
})
- return initialList.concat(lthingsFormatted)
+ return initialList.concat(termsFormatted)
}
getDividerSize(tabName, lthing) {
@@ -163,8 +162,8 @@ export default class PartyDetails extends React.Component {
render() {
const {
party,
- lthings,
- lthingLookup,
+ terms,
+ termsLookup,
voteSummary,
speechSummary,
documentSummary,
@@ -178,7 +177,7 @@ export default class PartyDetails extends React.Component {
return (
{
- const lthingLookup = {}
- lthings.forEach((lthing) => (lthingLookup[lthing.id] = lthing))
+ totalsService.getTerms().then((terms) => {
+ const termsLookup = {}
+ terms.forEach((term) => (termsLookup[term.id] = term))
this.setState(() => ({
- lthings,
- lthingLookup,
+ terms,
+ termsLookup,
}))
})
totalsService
- .getTopMpsAttendanceByLthing(lthingId)
+ .getTopMpsAttendance(params)
.then((topMpsAttendance) => {
this.setState(() => ({ topMpsAttendance }))
})
totalsService
- .getBottomMpsAttendanceByLthing(lthingId)
+ .getBottomMpsAttendance(params)
.then((bottomMpsAttendance) => {
this.setState(() => ({ bottomMpsAttendance }))
})
- totalsService.getTopMpsStandsByLthing(lthingId).then((topMpsStands) => {
+ totalsService.getTopMpsStands(params).then((topMpsStands) => {
this.setState(() => ({ topMpsStands }))
})
totalsService
- .getBottomMpsStandsByLthing(lthingId)
+ .getBottomMpsStands(params)
.then((bottomMpsStands) => {
this.setState(() => ({ bottomMpsStands }))
})
totalsService
- .getTopMpsMinutesByLthing(lthingId)
+ .getTopMpsMinutes(params)
.then((topMpMinutesTalked) => {
this.setState(() => ({ topMpMinutesTalked }))
})
totalsService
- .getBottomMpsMinutesByLthing(lthingId)
+ .getBottomMpsMinutes(params)
.then((bottomMpMinutesTalked) => {
this.setState(() => ({ bottomMpMinutesTalked }))
})
}
- generateLthingList(lthings) {
- if (!lthings.length) {
+ generateTermsList(terms) {
+ if (!terms.length) {
return []
}
- return lthings.map((lthing) => ({
- year: lthing.start.split('.')[2],
- thing: lthing.id,
- url: `/samantekt/thing/${lthing.id}`,
+ return terms.map((term) => ({
+ name: term.id,
+ url: `/samantekt/kjortimabil/${term.id}`,
}))
}
render() {
const {
- lthings,
- lthingLookup,
+ terms,
+ termsLookup,
topMpsAttendance,
bottomMpsAttendance,
topMpsStands,
@@ -106,7 +105,7 @@ export default class Totals extends React.Component {
return (
diff --git a/thingmenn-frontend/src/routes.js b/thingmenn-frontend/src/routes.js
index b3a6479..5e06cfd 100644
--- a/thingmenn-frontend/src/routes.js
+++ b/thingmenn-frontend/src/routes.js
@@ -40,16 +40,23 @@ function onRouterUpdate() {
const Routes = (props) => (
-
+
+
+
-
+
+
+
diff --git a/thingmenn-frontend/src/services/mp-service.js b/thingmenn-frontend/src/services/mp-service.js
index 833ea50..618328f 100644
--- a/thingmenn-frontend/src/services/mp-service.js
+++ b/thingmenn-frontend/src/services/mp-service.js
@@ -1,22 +1,23 @@
import { apiUrl } from '../config'
import CacheService from './cache-service'
+import getPath from '../utility/get-path'
class MpService extends CacheService {
- getMpsByLthing(lthing = 'allt') {
- return this.fetchData(`${apiUrl}/api/lthing/${lthing}/mps`)
+ getMps(params) {
+ return this.fetchData(`${apiUrl}/api/${getPath(params)}/mps`)
}
- getMpDetailsByLthing(mpId, lthing = 'allt') {
- return this.fetchData(`${apiUrl}/api/lthing/${lthing}/mps/${mpId}`)
+ getMpDetails(mpId, params) {
+ return this.fetchData(`${apiUrl}/api/${getPath(params)}/mps/${mpId}`)
}
- getSimilarMpsByLthing(mpId, lthing = 'allt') {
- return this.fetchData(`${apiUrl}/api/lthing/${lthing}/mps/${mpId}/similar`)
+ getSimilarMps(mpId, params) {
+ return this.fetchData(`${apiUrl}/api/${getPath(params)}/mps/${mpId}/similar`)
}
- getDifferentMpsByLthing(mpId, lthing = 'allt') {
+ getDifferentMps(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/mps/${mpId}/different`,
+ `${apiUrl}/api/${getPath(params)}/mps/${mpId}/different`,
)
}
}
diff --git a/thingmenn-frontend/src/services/mp-summary-service.js b/thingmenn-frontend/src/services/mp-summary-service.js
index ac5630b..6e32ee8 100644
--- a/thingmenn-frontend/src/services/mp-summary-service.js
+++ b/thingmenn-frontend/src/services/mp-summary-service.js
@@ -1,46 +1,47 @@
import { apiUrl } from '../config'
import CacheService from './cache-service'
+import getPath from '../utility/get-path'
class MpSummaryService extends CacheService {
- getMpVoteSummaryByLthing(mpId, lthing = 'allt') {
+ getMpVoteSummary(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/summary/votes/mp/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/summary/votes/mp/${mpId}`,
)
}
- getMpSpeechSummaryByLthing(mpId, lthing = 'allt') {
+ getMpSpeechSummary(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/summary/speeches/mp/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/summary/speeches/mp/${mpId}`,
)
}
- getMpDocumentSummaryByLthing(mpId, lthing = 'allt') {
+ getMpDocumentSummary(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/summary/documents/mp/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/summary/documents/mp/${mpId}`,
)
}
- getMpAbsentSummaryByLthing(mpId, lthing = 'allt') {
+ getMpAbsentSummary(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/summary/absent/mp/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/summary/absent/mp/${mpId}`,
)
}
- getMpVotePositionsByLthing(mpId, lthing = 'allt') {
+ getMpVotePositions(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/positions/votes/mp/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/positions/votes/mp/${mpId}`,
)
}
- getMpSpeechPositionsByLthing(mpId, lthing = 'allt') {
+ getMpSpeechPositions(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/positions/speeches/mp/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/positions/speeches/mp/${mpId}`,
)
}
- getMpDocumentPositionsByLthing(mpId, lthing = 'allt') {
+ getMpDocumentPositions(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/positions/documents/mp/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/positions/documents/mp/${mpId}`,
)
}
}
diff --git a/thingmenn-frontend/src/services/party-service.js b/thingmenn-frontend/src/services/party-service.js
index 07d789c..c2f9917 100644
--- a/thingmenn-frontend/src/services/party-service.js
+++ b/thingmenn-frontend/src/services/party-service.js
@@ -1,13 +1,14 @@
import { apiUrl } from '../config'
import CacheService from './cache-service'
+import getPath from '../utility/get-path'
class PartyService extends CacheService {
- getPartiesByLthing(lthing = 'allt') {
- return this.fetchData(`${apiUrl}/api/lthing/${lthing}/parties`)
+ getParties(params) {
+ return this.fetchData(`${apiUrl}/api/${getPath(params)}/parties`)
}
- getPartyDetailsByLthing(partyId, lthing = 'allt') {
- return this.fetchData(`${apiUrl}/api/lthing/${lthing}/parties/${partyId}`)
+ getPartyDetails(partyId, params) {
+ return this.fetchData(`${apiUrl}/api/${getPath(params)}/parties/${partyId}`)
}
}
diff --git a/thingmenn-frontend/src/services/party-summary-service.js b/thingmenn-frontend/src/services/party-summary-service.js
index cff3b76..8faaff2 100644
--- a/thingmenn-frontend/src/services/party-summary-service.js
+++ b/thingmenn-frontend/src/services/party-summary-service.js
@@ -1,46 +1,47 @@
import { apiUrl } from '../config'
import CacheService from './cache-service'
+import getPath from '../utility/get-path'
class PartySummaryService extends CacheService {
- getPartyVoteSummaryByLthing(mpId, lthing = 'allt') {
+ getPartyVoteSummary(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/summary/votes/party/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/summary/votes/party/${mpId}`,
)
}
- getPartySpeechSummaryByLthing(mpId, lthing = 'allt') {
+ getPartySpeechSummary(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/summary/speeches/party/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/summary/speeches/party/${mpId}`,
)
}
- getPartyDocumentSummaryByLthing(mpId, lthing = 'allt') {
+ getPartyDocumentSummary(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/summary/documents/party/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/summary/documents/party/${mpId}`,
)
}
- getPartyAbsentSummaryByLthing(mpId, lthing = 'allt') {
+ getPartyAbsentSummary(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/summary/absent/party/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/summary/absent/party/${mpId}`,
)
}
- getPartyVotePositionsByLthing(mpId, lthing = 'allt') {
+ getPartyVotePositions(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/positions/votes/party/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/positions/votes/party/${mpId}`,
)
}
- getPartySpeechPositionsByLthing(mpId, lthing = 'allt') {
+ getPartySpeechPositions(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/positions/speeches/party/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/positions/speeches/party/${mpId}`,
)
}
- getPartyDocumentPositionsByLthing(mpId, lthing = 'allt') {
+ getPartyDocumentPositions(mpId, params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/positions/documents/party/${mpId}`,
+ `${apiUrl}/api/${getPath(params)}/positions/documents/party/${mpId}`,
)
}
}
diff --git a/thingmenn-frontend/src/services/totals-service.js b/thingmenn-frontend/src/services/totals-service.js
index 22943ef..ad65f7b 100644
--- a/thingmenn-frontend/src/services/totals-service.js
+++ b/thingmenn-frontend/src/services/totals-service.js
@@ -1,35 +1,40 @@
import { apiUrl } from '../config'
import CacheService from './cache-service'
+import getPath from '../utility/get-path'
class TotalsService extends CacheService {
getLthings() {
return this.fetchData(`${apiUrl}/api/lthings`)
}
- getTopMpsAttendanceByLthing(lthing) {
- return this.fetchData(`${apiUrl}/api/lthing/${lthing}/top/attendance/mps`)
+ getTerms() {
+ return this.fetchData(`${apiUrl}/api/terms`)
}
- getBottomMpsAttendanceByLthing(lthing) {
+ getTopMpsAttendance(params) {
+ return this.fetchData(`${apiUrl}/api/${getPath(params)}/top/attendance/mps`)
+ }
+
+ getBottomMpsAttendance(params) {
return this.fetchData(
- `${apiUrl}/api/lthing/${lthing}/bottom/attendance/mps`,
+ `${apiUrl}/api/${getPath(params)}/bottom/attendance/mps`,
)
}
- getTopMpsStandsByLthing(lthing) {
- return this.fetchData(`${apiUrl}/api/lthing/${lthing}/top/stands/mps`)
+ getTopMpsStands(params) {
+ return this.fetchData(`${apiUrl}/api/${getPath(params)}/top/stands/mps`)
}
- getBottomMpsStandsByLthing(lthing) {
- return this.fetchData(`${apiUrl}/api/lthing/${lthing}/bottom/stands/mps`)
+ getBottomMpsStands(params) {
+ return this.fetchData(`${apiUrl}/api/${getPath(params)}/bottom/stands/mps`)
}
- getTopMpsMinutesByLthing(lthing) {
- return this.fetchData(`${apiUrl}/api/lthing/${lthing}/top/minutes/mps`)
+ getTopMpsMinutes(params) {
+ return this.fetchData(`${apiUrl}/api/${getPath(params)}/top/minutes/mps`)
}
- getBottomMpsMinutesByLthing(lthing) {
- return this.fetchData(`${apiUrl}/api/lthing/${lthing}/bottom/minutes/mps`)
+ getBottomMpsMinutes(params) {
+ return this.fetchData(`${apiUrl}/api/${getPath(params)}/bottom/minutes/mps`)
}
}
diff --git a/thingmenn-frontend/src/utility/get-path.js b/thingmenn-frontend/src/utility/get-path.js
new file mode 100644
index 0000000..df6f384
--- /dev/null
+++ b/thingmenn-frontend/src/utility/get-path.js
@@ -0,0 +1,7 @@
+export const getLocalPath = (params) => {
+ if (!params) return 'kjortimabil/allt'
+
+ return `${params.lthing ? 'thing' : 'kjortimabil'}/${params.lthing || params.term || 'allt'}`;
+}
+
+export default (params) => `${params.lthing ? 'lthing' : 'term'}/${params.lthing || params.term || 'allt'}`;
diff --git a/thingmenn-frontend/src/widgets/details-menu/index.js b/thingmenn-frontend/src/widgets/details-menu/index.js
index 245b414..e23c9b4 100644
--- a/thingmenn-frontend/src/widgets/details-menu/index.js
+++ b/thingmenn-frontend/src/widgets/details-menu/index.js
@@ -56,7 +56,7 @@ const DetailsMenu = ({ menuItems = testMenu }) => (
{menuItems.map((item, index) => {
const isFirst = index === 0
- let label = `Þing ${item.thing}`
+ let label = item.name
if (isFirst && item.name) {
label = item.name
}
diff --git a/thingmenn-frontend/src/widgets/friends/index.js b/thingmenn-frontend/src/widgets/friends/index.js
index f4c76a4..033d7d9 100644
--- a/thingmenn-frontend/src/widgets/friends/index.js
+++ b/thingmenn-frontend/src/widgets/friends/index.js
@@ -2,6 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import { Link } from 'react-router'
import { formatPercentage } from '../../utils'
+import { getLocalPath } from '../../utility/get-path'
import PartyBadge from '../partybadge'
@@ -12,7 +13,7 @@ const Friends = ({
subTitle,
friends,
isDisplayingFriends,
- lthing = 'allt',
+ params,
valueFormatter = (friend) =>
`${friend.votes} (${formatPercentage(friend.similarity)})`,
icon = true,
@@ -41,7 +42,7 @@ const Friends = ({
{friends.map((friend) => [
-
+
{friend.mp.name}
,
diff --git a/thingmenn-frontend/src/widgets/mp/index.js b/thingmenn-frontend/src/widgets/mp/index.js
index 8235b3e..ccfc730 100644
--- a/thingmenn-frontend/src/widgets/mp/index.js
+++ b/thingmenn-frontend/src/widgets/mp/index.js
@@ -8,11 +8,8 @@ import PartyBadge from '../partybadge'
import './styles.css'
-const Mp = ({ id, imagePath, lthing, mpName, partyId }) => {
- let url = `/thingmenn/${id}/thing/allt`
- if (lthing) {
- url = `/thingmenn/${id}/thing/${lthing}`
- }
+const Mp = ({ id, imagePath, params, mpName, partyId }) => {
+ let url = `/thingmenn/${id}/kjortimabil/${params.term || 'allt'}`
return (
diff --git a/thingmenn-frontend/src/widgets/nav/index.js b/thingmenn-frontend/src/widgets/nav/index.js
index 9e3808e..8eae783 100644
--- a/thingmenn-frontend/src/widgets/nav/index.js
+++ b/thingmenn-frontend/src/widgets/nav/index.js
@@ -12,7 +12,7 @@ class Nav extends React.Component {
diff --git a/thingmenn-frontend/src/widgets/party/index.js b/thingmenn-frontend/src/widgets/party/index.js
index 2ddbcb4..8f89ff8 100644
--- a/thingmenn-frontend/src/widgets/party/index.js
+++ b/thingmenn-frontend/src/widgets/party/index.js
@@ -5,7 +5,7 @@ import ListItem from '../list-item'
import ListItemImage from '../list-item-image'
import ListItemContent from '../list-item-content'
-const Party = ({ id, imagePath, lthing, name }) => {
+const Party = ({ id, imagePath, name }) => {
const url = `/thingflokkar/${id}/thing/allt`
return (