-
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.
infra: setup custom routing, fix error page, refactoring
* infra: logic encapsulation, refactoring * infra: axios interceptors
- Loading branch information
Showing
21 changed files
with
608 additions
and
475 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"root": true, | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
}, | ||
"parser": "vue-eslint-parser", | ||
"parserOptions": { | ||
"parser": "@typescript-eslint/parser", | ||
}, | ||
"extends": ["@nuxtjs/eslint-config-typescript", "plugin:prettier/recommended"], | ||
"plugins": [], | ||
"rules": { | ||
"vue/no-multiple-template-root": "off", | ||
"vue/attribute-hyphenation": "off", | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,14 @@ | ||
import type { RouterConfig } from "@nuxt/schema"; | ||
|
||
export default <RouterConfig>{ | ||
routes: (_routes) => [ | ||
{ | ||
name: "home", | ||
path: "/", | ||
component: () => | ||
import("@/pages/Dashboard/DashboardPage.vue").then( | ||
(r) => r.default || r, | ||
), | ||
}, | ||
], | ||
}; |
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
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
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
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,19 @@ | ||
import { useEventBus, useDebounceFn } from "@vueuse/core"; | ||
import { debounceTime } from "@/constants"; | ||
|
||
const { emit } = useEventBus("vue-use-event-bus"); | ||
|
||
export const showNotification = useDebounceFn((errors) => { | ||
const uniqueErrors: string[] = Array.from(new Set(errors)); | ||
|
||
uniqueErrors.forEach((errorMessage) => { | ||
emit({ | ||
type: "error", | ||
title: "Error", | ||
message: errorMessage, | ||
position: "bottom-right", | ||
}); | ||
}); | ||
|
||
errors = []; | ||
}, debounceTime); |
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
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,7 +1,22 @@ | ||
import axios from "axios"; | ||
import { showNotification } from "@/helpers"; | ||
|
||
export const api = axios.create({ | ||
baseURL: `${import.meta.env.VITE_BACKEND_URL},${ | ||
import.meta.env.VITE_BACKEND_VERSION | ||
}`, | ||
}); | ||
|
||
const errors: string[] = []; | ||
|
||
api.interceptors.response.use( | ||
function (response) { | ||
return response; | ||
}, | ||
function (error) { | ||
errors.push(`Message: ${error.message}. Code: ${error.code}`); | ||
showNotification(errors); | ||
|
||
return Promise.reject(error); | ||
}, | ||
); |
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,40 @@ | ||
<template> | ||
<section class="m-t-2"> | ||
<section> | ||
<h2 class="m-b-1">Different countries | one element</h2> | ||
<h3>Absolute values</h3> | ||
<TheDefaultChart /> | ||
</section> | ||
|
||
<section> | ||
<h2 class="m-b-1 m-t-2">Different countries | one element | one year</h2> | ||
<h3>Absolute values</h3> | ||
<ThePiaChartAbsolute /> | ||
</section> | ||
<section> | ||
<h2 class="m-b-1 m-t-2">Different countries | one element | 2020 year</h2> | ||
<h3>Relative values</h3> | ||
<ThePiaChartRelative /> | ||
</section> | ||
</section> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import TheDefaultChart from "@/pages/Dashboard/components/TheDefaultChart.vue"; | ||
import ThePiaChartAbsolute from "@/pages/Dashboard/components/ThePiaChartAbsolute.vue"; | ||
import ThePiaChartRelative from "@/pages/Dashboard/components/ThePiaChartRelative.vue"; | ||
</script> | ||
|
||
<style lang="scss"> | ||
.chart { | ||
flex: 3; | ||
} | ||
.radio-buttons { | ||
flex: 1; | ||
} | ||
.chart--pie { | ||
width: 30%; | ||
} | ||
</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
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,5 @@ | ||
import environment from "@/pages/Dashboard/api/environment"; | ||
|
||
export default { | ||
environment, | ||
}; |
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,101 @@ | ||
<template> | ||
<VForm class="d-flex gap-1 m-b-1"> | ||
<VFormItem> | ||
<VSelect | ||
v-model="elementForDefaultChart" | ||
:options="elements" | ||
placeholder="Elements" | ||
filterable | ||
@change="modifyDefaultChartCriteria" | ||
/> | ||
</VFormItem> | ||
|
||
<VFormItem> | ||
<VSelect | ||
v-model="countriesForDefaultChart" | ||
:options="countries" | ||
filterable | ||
placeholder="Countries" | ||
multiple | ||
@change="modifyDefaultChartCriteria" | ||
/> | ||
</VFormItem> | ||
</VForm> | ||
<div class="d-flex"> | ||
<VChart | ||
class="chart" | ||
:data="chartDefault" | ||
:type="chartType" | ||
caption="Picture 1. Emissions from various countries, measured in tons, over different years." | ||
/> | ||
<VRadioButtons | ||
v-model="chartType" | ||
class="radio-buttons" | ||
:options="chartTypes" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { countries, elements, years } from "@/constants"; | ||
import type { IParamsEnvironment } from "@/pages/Dashboard/interfaces/environment.ts"; | ||
import type { IChartDefault } from "@/interfaces/chart"; | ||
import { EChartType } from "@/interfaces/enums"; | ||
import { useDashboard } from "@/pages/Dashboard/composables/dashboard"; | ||
import { useEnvironmentStore } from "@/pages/Dashboard/store/environment"; | ||
const { getDefaultChartData } = useDashboard(); | ||
const store = useEnvironmentStore(); | ||
const { dataSetsSeriesForDefaultChart, structureSeriesForDefaultChart } = | ||
storeToRefs(store); | ||
const { readEnvironmentDefaultChart } = store; | ||
const elementForDefaultChart = ref("EN_ATM_CO2E_XLULUCF"); | ||
const countriesForDefaultChart = ref(["AUS"]); | ||
const chartDefault = ref<IChartDefault>({ | ||
labels: [], | ||
datasets: [], | ||
}); | ||
const chartType = ref(EChartType.Line); | ||
const chartTypes = [ | ||
{ | ||
value: EChartType.Line, | ||
label: EChartType.Line, | ||
}, | ||
{ | ||
value: EChartType.Bar, | ||
label: EChartType.Bar, | ||
}, | ||
]; | ||
const modifyDefaultChartCriteria = async () => { | ||
const params: IParamsEnvironment = { | ||
detail: "full", | ||
startPeriod: "1960-01-01", | ||
endPeriod: "2020-12-31", | ||
dimensionAtObservation: "TIME_PERIOD", | ||
}; | ||
await readEnvironmentDefaultChart( | ||
elementForDefaultChart.value, | ||
countriesForDefaultChart.value.join("+"), | ||
params, | ||
); | ||
const datasets = getDefaultChartData( | ||
dataSetsSeriesForDefaultChart.value, | ||
structureSeriesForDefaultChart.value, | ||
); | ||
chartDefault.value = { | ||
datasets, | ||
labels: years, | ||
}; | ||
}; | ||
onMounted(async () => { | ||
await modifyDefaultChartCriteria(); | ||
}); | ||
</script> |
Oops, something went wrong.