Skip to content

Commit

Permalink
feat: 💄 refactored routes + added a sidebar to the municipality + ref…
Browse files Browse the repository at this point in the history
…actored code to be more optimised
  • Loading branch information
snenenenenenene committed Oct 17, 2022
1 parent f4d6f5c commit 65c951f
Show file tree
Hide file tree
Showing 68 changed files with 707 additions and 405 deletions.
1 change: 0 additions & 1 deletion frontend/app/components/map.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
// import geoJSONData from '../data/BELGIUM_-_Municipalities.geojson';
import { soup as municipalityGeoJSONData } from '../data/munData';
import { action } from '@ember/object';
import MunicipalitiesService from '../services/municipalities';
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/components/modal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<:footer>
<AuButton @icon='unordered-list' @iconAlignment='right'>
<LinkTo
@route={{'municipality.info'}}
@route={{'index.municipality.index'}}
@onClick={{this.municipalities.closeModal}}
@model={{this.municipalities.modalData.title}}
style='color: white;'
Expand Down
20 changes: 17 additions & 3 deletions frontend/app/components/navbar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,25 @@
{{! <AuButton style='margin-right: 0;' @icon='sitemap' @iconAlignment='left'>
</AuButton> }}
<div class='diagonal-box'>
<LinkTo @route='dashboard' style='text-decoration:none;'>
<AuDropdown
@title='Aangemeld als ...'
@alignment='right'
style='margin-right: 10px;'
>
<AuButton @skin='tertiary' role='menuitem'>
<AuLink @route='index.dashboard'>
<AuIcon @icon='link' @alignment='left' />Kaart
</AuLink>
</AuButton>
<AuButton @skin='tertiary' role='menuitem'>
<AuIcon @icon='logout' @alignment='left' />Afmelden
</AuButton>
</AuDropdown>
{{! <div class='diagonal-box'>
<LinkTo @route='index.dashboard' style='text-decoration:none;'>
<p class='au-u-h5' style='font-weight: 500; color:black;'>
BEKIJK DE KAART
</p>
</LinkTo>
</div>
</div> }}
</AuMainHeader>
4 changes: 2 additions & 2 deletions frontend/app/components/table.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<AuLink
@model={{row.title}}
@route={{'municipality.decisions'}}
@route={{'index.municipality.decisions'}}
@icon='chevron-right'
>
Bekijk besluiten
Expand All @@ -47,7 +47,7 @@
<td>
<AuLink
@model={{row.title}}
@route={{'municipality.decisions'}}
@route={{'index.municipality.decisions'}}
@icon='chevron-right'
>
Bekijk besluiten
Expand Down
38 changes: 0 additions & 38 deletions frontend/app/controllers/besluiten-form.ts

This file was deleted.

14 changes: 14 additions & 0 deletions frontend/app/controllers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Controller from '@ember/controller';

export default class Index extends Controller.extend({
// anything which *must* be merged to prototype here
}) {
// normal class body definition here
}

// DO NOT DELETE: this is how TypeScript knows how to look up your controllers.
declare module '@ember/controller' {
interface Registry {
'index': Index;
}
}
73 changes: 73 additions & 0 deletions frontend/app/controllers/index/besluiten-form.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import axios from 'axios';
import ToasterService from 'frontend/services/toaster';
import { Municipality } from 'index';
import { municipality_data } from '../../data/municipality-data';

export default class BesluitenForm extends Controller {
@service declare toaster: ToasterService;
@tracked category: string = 'Categorie';
@tracked name: string = 'Titel';
@tracked aanwezig: string = 'Senne Bels';
@tracked juridische_grond: string = 'Aarde';
@tracked context_en_argumentatie: string = 'Goeie argumentatie';
@tracked besluit: string = 'Besluit';
@tracked for: string = 'Voor';
@tracked against: string = 'Tegen';
@tracked neutral: string = 'Neutraal';
@tracked begin: string = 'Begin';
@tracked end: string = 'Einde';
@tracked accepted: boolean = true;
@tracked query: any = 'Antwerpen';
@tracked municipalityData = municipality_data;

@action toggleAccepted() {
this.accepted = !this.accepted;
}

@action searchRepo(term: string) {
if (term === '') {
return this.municipalityData;
}
return this.municipalityData.filter((municipality: Municipality) =>
municipality.title.toLowerCase().includes(term.toLowerCase())
);
}

@action async submitDecision() {
await axios
.post(
`http://localhost:3000/municipality/${this.query.title.toLowerCase()}/besluiten`,
{
category: this.category,
name: this.name,
date: {
begin: this.begin,
end: this.end,
},
body: {
aanwezig: this.aanwezig,
juridische_grond: this.juridische_grond,
context_en_argumentatie: this.context_en_argumentatie,
besluit: this.besluit,
},
municipal_vote: {
for: this.for,
against: this.against,
neutral: this.neutral,
},
accepted: this.accepted,
}
)
.then(() => {
this.toaster.success(`Besluit toegevoegd aan databank`, 'Success');
})
.catch((err) => {
console.log(err);
this.toaster.success(`Er is iets fout gegaan`, 'Error');
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export default class Login extends Controller {

@action login() {
console.log('u logged in');
this.router.transitionTo('BesluitenForm');
this.router.transitionTo('index.BesluitenForm');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@ import { action } from '@ember/object';
import { service } from '@ember/service';
// import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import axios from 'axios';
import MunicipalitiesService from 'frontend/services/municipalities';

export default class MunicipalityDecision extends Controller {
@service declare municipalities: MunicipalitiesService;
@tracked button1 = 'secondary';
@tracked button2 = 'secondary';
@tracked decision = this.fetchDecisions();

@action fetchDecisions() {
axios
.get(`http://localhost:3000/besluiten/${this.model}`)
.then((response) => {
console.log(response.data);
this.decision = response.data;
});
}

@action vote(buttonName: string) {
if (buttonName === 'button1') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class MunicipalityDecisionsSubscribe extends Controller {
@service router: any;
@tracked email = '';
@action closeModal() {
this.router.transitionTo('municipality.decisions');
this.router.transitionTo('index.municipality.decisions');
}

@service declare municipalities: MunicipalitiesService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,43 @@ import {
decisionAmountPerYear,
revenuePerCategory,
revenuePerYear,
} from '../helpers/apiInterface';
import MunicipalitiesService from '../services/municipalities';
} from '../../../helpers/apiInterface';
import MunicipalitiesService from '../../../services/municipalities';
import { action } from '@ember/object';
import { GraphOptions } from 'index';
import { infoTypes } from 'frontend/data/constants';
import axios from 'axios';
export default class Info extends Controller {

export default class MunicipalityIndex extends Controller {
@service declare municipalities: MunicipalitiesService;
@tracked thuiswerken: any;
@tracked infoTypes = infoTypes;
@tracked selected: any;
@service router: any;
@tracked selected: any = this.infoTypes[0];
@action handleSelect(value: any) {
this.selected = value;

switch (value) {
case 'Algemeen':
this.router.transitionTo('index.municipality.index');
break;
case 'Alle Indicatoren':
this.router.transitionTo('index.municipality.alle-indicatoren');
break;
case 'Lokaal Bestuur':
this.router.transitionTo('index.municipality.lokaal-bestuur');
break;
case 'Onderwijs en Vorming':
this.router.transitionTo('index.municipality.onderwijs-en-vorming');
break;
case 'Werk':
this.router.transitionTo('index.municipality.werk');
break;
case 'Wonen en Woonomgeving':
this.router.transitionTo('index.municipality.wonen-en-woonomgeving');
break;
}
}

@action setup() {
axios
.get(
`http://localhost:3000/alle_indicatoren/thuiswerk?gemeente=${this.municipalities?.modalData?.title.toLowerCase()}`
)
.then((resp: any) => {
this.thuiswerken = resp.data.Response[0]['2 dagen of meer (%)'];
});
revenuePerYear(this.municipalities?.modalData?.title).then((resp): any => {
this.graphData1 = {
x: 'x',
Expand All @@ -36,7 +53,7 @@ export default class Info extends Controller {
},
[['x'], ['Omzet']]
),
type: 'line',
type: 'spline',
};
});

Expand All @@ -52,7 +69,7 @@ export default class Info extends Controller {
},
[['x'], ['Aantal beslissingen']]
),
type: 'line',
type: 'spline',
};
}
);
Expand All @@ -77,7 +94,7 @@ export default class Info extends Controller {
@tracked graphData1: GraphOptions = {
x: 'x',
columns: [],
type: 'line',
type: 'spline',
};
@tracked graphData2: GraphOptions = {
columns: [],
Expand All @@ -86,7 +103,7 @@ export default class Info extends Controller {
@tracked graphData3: GraphOptions = {
x: 'x',
columns: [],
type: 'line',
type: 'spline',
};

@tracked graphTitle1 = { text: 'Omzet per jaar' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
decisionAmountPerYear,
revenuePerCategory,
revenuePerYear,
} from '../../helpers/apiInterface';
import MunicipalitiesService from '../../services/municipalities';
} from '../../../helpers/apiInterface';
import MunicipalitiesService from '../../../services/municipalities';
import { action } from '@ember/object';
import { GraphOptions } from 'index';
import { infoTypes } from 'frontend/data/constants';
Expand All @@ -21,22 +21,26 @@ export default class MunicipalityInfo extends Controller {

switch (value) {
case 'Algemeen':
this.router.transitionTo('municipality.info');
this.router.transitionTo('index.municipality.info');
break;
case 'Alle Indicatoren':
this.router.transitionTo('municipality.info.alle-indicatoren');
this.router.transitionTo('index.municipality.info.alle-indicatoren');
break;
case 'Lokaal Bestuur':
this.router.transitionTo('municipality.info.lokaal-bestuur');
this.router.transitionTo('index.municipality.info.lokaal-bestuur');
break;
case 'Onderwijs en Vorming':
this.router.transitionTo('municipality.info.onderwijs-en-vorming');
this.router.transitionTo(
'index.municipality.info.onderwijs-en-vorming'
);
break;
case 'Werk':
this.router.transitionTo('municipality.info.werk');
this.router.transitionTo('index.municipality.info.werk');
break;
case 'Wonen en Woonomgeving':
this.router.transitionTo('municipality.info.wonen-en-woonomgeving');
this.router.transitionTo(
'index.municipality.info.wonen-en-woonomgeving'
);
break;
}
}
Expand Down
Loading

0 comments on commit 65c951f

Please sign in to comment.