Commit 0a1b27fd authored by Matt Glorion's avatar Matt Glorion
Browse files

[CLN] 馃Ч refactoring, cleanup, typos

parent e7250163
......@@ -147,8 +147,8 @@ async function computeEquivalentDamages (scenarios) {
const spheres = ['HUMAN_HEALTH', 'ECOSYSTEM_QUALITY', 'CLIMATE_CHANGE', 'RESOURCES'];
for (const sphere of spheres) {
for (const equivalent in equivalentDamages) {
ret[sphere][equivalent] = {};
for (const scenario of scenarios) {
ret[sphere][equivalent] = !ret[sphere].hasOwnProperty(equivalent) ? {} : ret[sphere][equivalent];
ret[sphere][equivalent][scenario.id] = roundTo(
scenario.damage.totalDamage[sphere] / equivalentDamages[equivalent][sphere],
1
......
......@@ -17,7 +17,7 @@
<Scenario ref="scenario1" id=1 title="Scenario B"></Scenario>
<Scenario ref="scenario2" id=2 title="Scenario C"></Scenario>
</div>
<ResultsDetailledView :selectedView="results_detailled_view_choice" v-show="!display_scenarios" :key="re_render_results_detailled_view" />
<ResultsDetailedView :selectedView="results_detailed_view_choice" v-show="!display_scenarios" :key="re_render_results_detailed_view" />
<Results />
</main>
</div>
......@@ -27,7 +27,7 @@
import Header from "./components/Header.vue";
import SinglePage from "./components/SinglePage.vue";
import Results from "./components/Results.vue";
import ResultsDetailledView from "./components/ResultsDetailledView.vue";
import ResultsDetailedView from "./components/ResultsDetailedView.vue";
import Scenario from "./components/Scenario.vue";
export default {
......@@ -35,15 +35,15 @@ export default {
components: {
Header,
SinglePage,
ResultsDetailledView,
ResultsDetailedView,
Results,
Scenario,
},
data() {
return {
display_scenarios: true,
results_detailled_view_choice: "",
re_render_results_detailled_view: false,
results_detailed_view_choice: "",
re_render_results_detailed_view: false,
display_single_page: false,
displayed_single_page: null,
activeScenarios: [],
......@@ -70,16 +70,16 @@ export default {
this.$root.$on("hide_single_page", () => {
this.display_single_page = false;
});
this.$root.$on("re_render_results_detailled", () => {
this.$root.$on("re_render_results_detailed", () => {
// We re-render the component as a workaround to force chart to update
this.re_render_results_detailled_view = !this
.re_render_results_detailled_view;
this.re_render_results_detailed_view = !this
.re_render_results_detailed_view;
});
this.$root.$on("display_results_detailled_view", (choice) => {
this.$root.$on("display_results_detailed_view", (choice) => {
this.display_scenarios = false;
this.results_detailled_view_choice = choice;
this.results_detailed_view_choice = choice;
});
this.$root.$on("hide_results_detailled_view", () => {
this.$root.$on("hide_results_detailed_view", () => {
this.display_scenarios = true;
});
},
......
......@@ -18,7 +18,7 @@
<div class="results-content">
<div
class="results-section"
@click="display_results_detailled_view(section.name)"
@click="display_results_detailed_view(section.name)"
v-for="section in sections_comparatif"
:key="section.name"
>
......@@ -84,7 +84,7 @@ export default {
store.commit("updateScenarios", new_scenarios);
store.dispatch("callAPI").then(() => {
this.re_render_results = !this.re_render_results;
this.$root.$emit("re_render_results_detailled");
this.$root.$emit("re_render_results_detailed");
});
},
exportResults() {
......@@ -194,9 +194,9 @@ export default {
doc.save(pdfName + ".pdf");
},
display_results_detailled_view(choice) {
this.$root.$emit("display_results_detailled_view", choice);
this.$root.$emit("re_render_results_detailled");
display_results_detailed_view(choice) {
this.$root.$emit("display_results_detailed_view", choice);
this.$root.$emit("re_render_results_detailed");
},
},
computed: {
......
......@@ -4,7 +4,7 @@ import Vuex from "vuex";
Vue.use(Vuex);
let labels = ["A", "B", "C"];
let labels_detailled = ["Scenario A", "Scenario B", "Scenario C"];
let labels_detailed = ["Scenario A", "Scenario B", "Scenario C"];
let backgroundColor = ["#e97272", "#e7dc73", "#83bdec"];
const state = {
......@@ -48,9 +48,9 @@ const state = {
],
},
},
impact_on_spheres_detailled: {
impact_on_spheres_detailed: {
HUMAN_HEALTH: {
labels: labels_detailled,
labels: labels_detailed,
datasets: [
{
label: "Mat茅riel",
......@@ -70,7 +70,7 @@ const state = {
],
},
ECOSYSTEM_QUALITY: {
labels: labels_detailled,
labels: labels_detailed,
datasets: [
{
label: "Mat茅riel",
......@@ -90,7 +90,7 @@ const state = {
],
},
CLIMATE_CHANGE: {
labels: labels_detailled,
labels: labels_detailed,
datasets: [
{
label: "Mat茅riel",
......@@ -110,7 +110,7 @@ const state = {
],
},
RESOURCES: {
labels: labels_detailled,
labels: labels_detailed,
datasets: [
{
label: "Mat茅riel",
......@@ -141,13 +141,13 @@ let store = new Vuex.Store({
async updateImpact(state, { sphere, values }) {
state.impact_on_spheres[sphere].datasets[0].data = values;
},
async updateDetailledImpacts(
async updateDetailedImpacts(
state,
{ sphere, hardware, software, journey }
) {
state.impact_on_spheres_detailled[sphere].datasets[0].data = hardware;
state.impact_on_spheres_detailled[sphere].datasets[1].data = software;
state.impact_on_spheres_detailled[sphere].datasets[2].data = journey;
state.impact_on_spheres_detailed[sphere].datasets[0].data = hardware;
state.impact_on_spheres_detailed[sphere].datasets[1].data = software;
state.impact_on_spheres_detailed[sphere].datasets[2].data = journey;
},
async updateEquivalents(state, { equivalents }) {
state.equivalents = equivalents;
......@@ -218,7 +218,7 @@ let store = new Vuex.Store({
);
}
store.commit("updateImpact", { sphere, values });
store.commit("updateDetailledImpacts", {
store.commit("updateDetailedImpacts", {
sphere,
hardware,
software,
......
......@@ -2,7 +2,7 @@
"name": "impactometre",
"version": "0.0.0",
"private": true,
"browserslist": "last 4 versions",
"browserslist": ["last 4 versions"],
"scripts": {
"postinstall": "(cd front && npm install);",
"start": "node ./bin/www",
......
<h1><%= message %></h1>
<h2><%= error.status %></h2>
<pre><%= error.stack %></pre>
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
</head>
<body>
<h1><%= title %></h1>
<center>
<p style="font-size:160%;">Bienvenue sur Impactom猫tre, outil d'茅valuation de l'impact environnemental de technologies num茅riques.</p>
<p style="font-size:160%;">L'outil permet actuellement de comparer l'impact de diff茅rents sc茅narios de visio-conf茅rence : </p>
<a href="/reunion">
<h2>Lancer une comparaison</h2>
</a>
</center>
</body>
</html>
<fieldset>
<legend><%= title %></legend>
<div>
Utilisez-vous un ou plusieurs ordinateurs ? <br>
<input type="radio" name="hasComputer" id="hasComputer" value="yes" class="conditionalForm--activator">
<label for="hasComputer">
Oui
</label>
<input type="radio" name="hasComputer" id="hasntComputer" value="no">
<label for="hasntComputer">
Non
</label><br>
<div class="conditionalForm">
Combien ? <br>
<div>
<label for="laptopNumber">
ordinateurs portables
</label><br>
<input type="number" name="hardware[<%= hardwareDb.LAPTOP.name %>]" id="laptopNumber" min="0" max="50"><br>
</div>
<div>
<label for="desktopNumber">
ordinateurs de bureau
</label><br>
<input type="number" name="hardware[<%= hardwareDb.DESKTOP.name %>]" id="desktopNumber" min="0" max="50"><br>
</div>
</div>
</div>
<div>
Faites-vous usage d'un syst猫me de visioconf茅rence d茅di茅 ? <br>
<input type="radio" name="hasVisioKit" id="hasVisioKit" class="conditionalForm--activator">
<label for="hasVisioKit">
Oui
</label>
<input type="radio" name="hasVisioKit" id="hasntVisioKit" value="no">
<label for="hasntVisioKit">
Non
</label><br>
<div class="conditionalForm">
Combien ? <br>
<div>
<input type="number" name="hardware[<%= hardwareDb.LOGITECH_KIT.name %>]" min="1" max="50">
</div>
</div>
</div>
<div>
Vous servez-vous d'茅crans suppl茅mentaires ? <br>
<input type="radio" name="hasMoreScreens" id="hasMoreScreens" value="yes" class="conditionalForm--activator">
<label for="hasMoreScreens">
Oui
</label>
<input type="radio" name="hasMoreScreens" id="hasntMoreScreens" value="no">
<label for="hasntMoreScreens">
Non
</label><br>
<div id="additionalScreens" class="conditionalForm">
Combien ? <br>
<div>
<label for="computerScreenNumber">
茅crans d'ordinateur
</label><br>
<input type="number" name="hardware[<%= hardwareDb.COMPUTER_SCREEN_LCD.name %>]" id="computerScreenNumber" min="0" max="50">
</div>
<div>
<button type="button" onclick="removeATvScreen()" class="plusMinusBtn">-</button>
<span id="tvScreenNumber"> 0 </span>
<button type="button" onclick="addATvScreen()" class="plusMinusBtn">+</button>
茅crans de t茅l茅vision
</div>
</div>
<div>
Utilisez-vous un support multi-茅crans (de type support m茅tallique mobile sur pied) ? <br>
<input type="radio" name="hasScreenStand" id="hasScreenStand" class="conditionalForm--activator">
<label for="hasScreenStand">
Oui
</label>
<input type="radio" name="hasScreenStand" id="hasntScreenStand" value="no">
<label for="hasntScreenStand">
Non
</label><br>
<div class="conditionalForm">
Combien ? <br>
<div>
<input type="number" name="hardware[<%= hardwareDb.METAL_STRUCTURE.name %>]" min="1" max="50">
</div>
</div>
</div>
</div>
<div>
Utilisez-vous un ou plusieurs vid茅oprojecteurs ? <br>
<input type="radio" name="hasVideoproj" id="hasVideoproj" class="conditionalForm--activator">
<label for="hasVideoproj">
Oui
</label>
<input type="radio" name="hasVideoproj" id="hasntVideoproj" value="no">
<label for="hasntVideoproj">
Non
</label><br>
<div class="conditionalForm">
Combien ? <br>
<div>
<input type="number" name="hardware[<%= hardwareDb.PROJECTOR.name %>]" min="1" max="50">
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend><%= title %></legend>
<div id="travellers">
<%- include('tmpl-traveller', { p: '1'}) %>
<%- include('tmpl-traveller', { p: '2'}) %>
<template id="travellerTmpl">
<%- include('tmpl-traveller', { p: 'p'}) %>
</template>
</div>
</fieldset>
\ No newline at end of file
<fieldset>
<legend><%= title %></legend>
<div>
Quel logiciel de visioconf茅rence utilisez-vous ? <br>
<% Object.values(softwareDb).forEach(software => { %>
<input type="radio" name="softwareChoice" id="<%= software.name %>" value="<%= software.name %>">
<label for="<%= software.name %>"><%= software.french %></label><br>
<% }) %>
<input type="radio" name="softwareChoice" id="other" value="other">
<label for="other">
Autre
</label><br>
<input type="radio" name="softwareChoice" id="noSoftware" value="noSoftware">
<label for="noSoftware">
Aucun logiciel
</label>
</div>
</fieldset>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="/javascripts/jquery.serializejson.js"></script>
<script type="text/javascript" src="/javascripts/meeting/form.js"></script>
<script type="text/javascript" src="/javascripts/meeting/submit.js"></script>
</head>
<body>
<div id="multiWrapper" class="wrapper" style="display: grid; grid-template-columns: repeat(3, 1fr);">
<div class="form" style="grid-column: 2; grid-row: 1">
<div class="form__header">
<h1><%= title %></h1>
<h4>En quelques questions</h4>
</div>
<form id="meetingForm">
Combien de personnes assisteront 脿 la r茅union ?<br>
<div>
<button type="button" onclick="removeAParticipant()" class="plusMinusBtn">-</button>
<span id="participantNumber"> 2 </span>
<button type="button" onclick="addAParticipant()" class="plusMinusBtn">+</button>
participants
<input type="number" value="2" name="numberOfParticipants" id="numberOfParticipants" hidden>
</div>
<label for="duration">
脌 combien estimez-vous sa dur茅e ?
</label><br>
<input type="number" name="meetingDuration" id="meetingDuration" min="0" max="1200"> minutes<br>
<%- include('fieldset-hardware', { title: 'Mat茅riel' }) %>
<%- include('fieldset-software', { title: 'Logiciel' }) %>
<%- include('fieldset-journey', { title: 'Trajets' }) %>
<button type="button" onclick="submitMeeting()">Voir les impacts</button>
</form>
</div>
</div>
</body>
</html>
<div id="traveller-<%= p %>__journeyItem-n" class="traveller__journeyItem">
<!--<button type="button" id="removeBtn-1-n" onclick="removeJourneyItem(id)">-</button>-->
<div>
<input name="journeys[traveller-<%= p %>__journeyItem-n][user]"
type="hidden" value="Participant <%= p %>">
<input name="journeys[traveller-<%= p %>__journeyItem-n][distance]"
type="number" min="0" max="3000" value="0" id="kmNumber-p-n"
oninput="kmNumberUpdate(value, id)" />
km parcourus en
<select name="journeys[traveller-<%= p %>__journeyItem-n][mean]">
<% Object.values(transportationMeanDb).forEach(mean => { %>
<option value="<%= mean.name %>"><%= mean.french %></option>
<% }) %>
</select>
<br>
<input type="range" min="0" max="3000" value="0" id="kmSlider-p-n"
oninput="kmSliderUpdate(value, id)" />
<br>
</div>
</div>
\ No newline at end of file
<div id="traveller-<%= p %>" class="traveller">
<div class="traveller__header">
<h4>Participant <%= p %></h4>
</div>
<div class="traveller__journeys">
<template id="journeyTmpl">
<%- include('tmpl-journey') %>
</template>
<div class="traveller__journeyItem traveller__journeyItem--add">
<button type="button" onclick="addJourneyItem(id)" id="traveller-<%= p %>__addJourneyItem" class="plusMinusBtn">+</button>
Ajouter un trajet
</div>
</div>
</div>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.css' />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<script type="text/javascript" src="/javascripts/meeting/utils.js"></script>
<script type="text/javascript" src="/javascripts/meeting/switchVue.js"></script>
</head>
<body>
<h1><%= title %></h1>
<button id="switchVue" onclick="switchVue()" type="button">
D茅tailler les graphiques
</button>
<div id="multiWrapper" class="wrapper" style="display: grid; grid-template-columns: repeat(3, 1fr);">
<div id="monoDiv" style=" grid-column: 1 / span 2; grid-row: 1">
<canvas id="monoChart"></canvas>
</div>
<div id="humanHealthChart" style="grid-column: 1; grid-row: 1" hidden>
<canvas id="humanHealth"></canvas>
</div>
<div id="climateChangeChart" style="grid-column: 2; grid-row: 1" hidden>
<canvas id="climateChange"></canvas>
</div>
<div id="resourcesChart" style="grid-column: 1; grid-row: 2" hidden>
<canvas id="resources"></canvas>
</div>
<div id="ecosystemQualityChart" style="grid-column: 2; grid-row: 2" hidden>
<canvas id="ecosystemQuality"></canvas>
</div>
</div>
<script>
const damages = JSON.parse('<%- JSON.stringify(normalisedDamages) %>');
const scenarios = JSON.parse('<%- JSON.stringify(scenarios) %>');
// Draw graphs when page reload
const ctx = document.getElementById('monoChart').getContext('2d');
barChart(ctx)
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment