Sessions: add year csv export (#21555)
This commit is contained in:
parent
e5b3ce8271
commit
931e77fbe3
29 changed files with 92 additions and 107 deletions
|
|
@ -144,40 +144,26 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="showTable">
|
||||
<SessionTable
|
||||
:sessions="currentSessions"
|
||||
:vehicleFilter="vehicleFilter"
|
||||
:loadpointFilter="loadpointFilter"
|
||||
:currency="currency"
|
||||
@show-session="showDetails"
|
||||
/>
|
||||
<div class="d-grid gap-2 d-md-block mt-3 mb-5">
|
||||
<a
|
||||
v-if="currentSessions.length"
|
||||
class="btn btn-sm btn-outline-secondary text-nowrap me-md-2"
|
||||
:href="csvLink"
|
||||
download
|
||||
>
|
||||
{{ $t("sessions.csvMonth", { month: headline }) }}
|
||||
</a>
|
||||
<a
|
||||
v-if="sessions.length"
|
||||
class="btn btn-sm btn-outline-secondary text-nowrap"
|
||||
:href="csvTotalLink"
|
||||
download
|
||||
>
|
||||
{{ $t("sessions.csvTotal") }}
|
||||
</a>
|
||||
</div>
|
||||
<SessionTable
|
||||
v-if="showTable"
|
||||
:sessions="currentSessions"
|
||||
:vehicleFilter="vehicleFilter"
|
||||
:loadpointFilter="loadpointFilter"
|
||||
:currency="currency"
|
||||
@show-session="showDetails"
|
||||
/>
|
||||
<div class="d-flex gap-2 mt-1 mb-5">
|
||||
<a class="btn btn-outline-secondary" tabindex="0" :href="csvLink" download>
|
||||
{{ csvLinkLabel }}
|
||||
</a>
|
||||
<button
|
||||
v-if="!showTable"
|
||||
class="btn btn-link text-muted"
|
||||
@click="changePeriod(periods.MONTH)"
|
||||
>
|
||||
{{ $t("sessions.showIndividualEntries") }}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
v-else
|
||||
class="btn btn-link text-muted mb-5"
|
||||
@click="changePeriod(periods.MONTH)"
|
||||
>
|
||||
{{ $t("sessions.showIndividualEntries") }}
|
||||
</button>
|
||||
</main>
|
||||
<SessionDetailsModal
|
||||
:session="selectedSession"
|
||||
|
|
@ -483,16 +469,26 @@ export default {
|
|||
date.setMonth(this.month - 1, 1);
|
||||
return this.fmtMonth(date);
|
||||
},
|
||||
headline() {
|
||||
const date = new Date();
|
||||
date.setMonth(this.month - 1, 1);
|
||||
date.setFullYear(this.year);
|
||||
return this.fmtMonthYear(date);
|
||||
csvLinkLabel() {
|
||||
if (this.period === PERIODS.MONTH) {
|
||||
const date = new Date();
|
||||
date.setMonth(this.month - 1, 1);
|
||||
date.setFullYear(this.year);
|
||||
const period = this.fmtMonthYear(date);
|
||||
return this.$t("sessions.csvPeriod", { period });
|
||||
} else if (this.period === PERIODS.YEAR) {
|
||||
const period = this.year;
|
||||
return this.$t("sessions.csvPeriod", { period });
|
||||
} else {
|
||||
return this.$t("sessions.csvTotal");
|
||||
}
|
||||
},
|
||||
csvLink() {
|
||||
return this.csvHrefLink(this.year, this.month);
|
||||
},
|
||||
csvTotalLink() {
|
||||
if (this.period === PERIODS.MONTH) {
|
||||
return this.csvHrefLink(this.year, this.month);
|
||||
} else if (this.period === PERIODS.YEAR) {
|
||||
return this.csvHrefLink(this.year);
|
||||
}
|
||||
return this.csvHrefLink();
|
||||
},
|
||||
colorMappings() {
|
||||
|
|
@ -691,10 +687,8 @@ export default {
|
|||
format: "csv",
|
||||
lang: this.$i18n?.locale,
|
||||
});
|
||||
if (year && month) {
|
||||
params.append("year", year);
|
||||
params.append("month", month);
|
||||
}
|
||||
if (year) params.append("year", year);
|
||||
if (month) params.append("month", month);
|
||||
return `./api/sessions?${params.toString()}`;
|
||||
},
|
||||
updateType(type) {
|
||||
|
|
|
|||
|
|
@ -862,10 +862,9 @@
|
|||
"solarpercentage": "Слънчева енергия (%)",
|
||||
"vehicle": "Превозно средство"
|
||||
},
|
||||
"csvMonth": "Изтегляне на {month} CSV",
|
||||
"csvPeriod": "Изтегляне на {period} CSV",
|
||||
"csvTotal": "Изтегляне на общ CSV",
|
||||
"date": "Начало",
|
||||
"downloadCsv": "Изтегляне като CSV",
|
||||
"energy": "Заредено",
|
||||
"filter": {
|
||||
"allLoadpoints": "Всички зарядни точки",
|
||||
|
|
|
|||
|
|
@ -261,7 +261,6 @@
|
|||
"vehicle": "Vehicle"
|
||||
},
|
||||
"date": "Període",
|
||||
"downloadCsv": "Descarregar com a CSV",
|
||||
"energy": "Carregada",
|
||||
"loadpoint": "Punt de recàrrega",
|
||||
"price": "Preu",
|
||||
|
|
|
|||
|
|
@ -873,10 +873,9 @@
|
|||
"solarpercentage": "Solární energie (%)",
|
||||
"vehicle": "Vozidlo"
|
||||
},
|
||||
"csvMonth": "Stažení {month} CSV",
|
||||
"csvPeriod": "Stažení {period} CSV",
|
||||
"csvTotal": "Stažení celkového CSV",
|
||||
"date": "Start",
|
||||
"downloadCsv": "Stáhnout jako CSV",
|
||||
"energy": "Nabito",
|
||||
"filter": {
|
||||
"allLoadpoints": "všechny nabíjecí body",
|
||||
|
|
|
|||
|
|
@ -873,10 +873,9 @@
|
|||
"solarpercentage": "Sol (%)",
|
||||
"vehicle": "Køretøj"
|
||||
},
|
||||
"csvMonth": "Download {month} CSV",
|
||||
"csvPeriod": "Download {period} CSV",
|
||||
"csvTotal": "Download total CSV",
|
||||
"date": "Start",
|
||||
"downloadCsv": "Download som CSV",
|
||||
"energy": "Opladet",
|
||||
"filter": {
|
||||
"allLoadpoints": "alle ladepunkter",
|
||||
|
|
|
|||
|
|
@ -874,10 +874,9 @@
|
|||
"solarpercentage": "Sonne (%)",
|
||||
"vehicle": "Fahrzeug"
|
||||
},
|
||||
"csvMonth": "Download {month} CSV",
|
||||
"csvPeriod": "Download {period} CSV",
|
||||
"csvTotal": "Gesamte CSV herunterladen",
|
||||
"date": "Anfang",
|
||||
"downloadCsv": "Als CSV herunterladen",
|
||||
"energy": "Geladen",
|
||||
"filter": {
|
||||
"allLoadpoints": "Alle Ladepunkte",
|
||||
|
|
|
|||
|
|
@ -861,10 +861,9 @@
|
|||
"solarpercentage": "Φ/Β (%)",
|
||||
"vehicle": "Όχημα"
|
||||
},
|
||||
"csvMonth": "Λήψη CSV {month}",
|
||||
"csvPeriod": "Λήψη CSV {period}",
|
||||
"csvTotal": "Λήψη CSV συνόλων",
|
||||
"date": "Ξεκίνησε",
|
||||
"downloadCsv": "Λήψη ως CSV",
|
||||
"energy": "Φόρτιση",
|
||||
"filter": {
|
||||
"allLoadpoints": "όλα τα σημεία φόρτισης",
|
||||
|
|
|
|||
|
|
@ -874,10 +874,9 @@
|
|||
"solarpercentage": "Solar (%)",
|
||||
"vehicle": "Vehicle"
|
||||
},
|
||||
"csvMonth": "Download {month} CSV",
|
||||
"csvPeriod": "Download {period} CSV",
|
||||
"csvTotal": "Download total CSV",
|
||||
"date": "Start",
|
||||
"downloadCsv": "Download as CSV",
|
||||
"energy": "Charged",
|
||||
"filter": {
|
||||
"allLoadpoints": "all charging points",
|
||||
|
|
|
|||
|
|
@ -646,10 +646,9 @@
|
|||
"solarpercentage": "Solar (%)",
|
||||
"vehicle": "Vehículo"
|
||||
},
|
||||
"csvMonth": "Descargar el {month} CSV",
|
||||
"csvPeriod": "Descargar el {period} CSV",
|
||||
"csvTotal": "Descargar todos los CSV",
|
||||
"date": "Comenzar",
|
||||
"downloadCsv": "Descargar como CSV",
|
||||
"energy": "Cargado",
|
||||
"filter": {
|
||||
"allLoadpoints": "todos los puntos de recarga",
|
||||
|
|
|
|||
|
|
@ -814,10 +814,9 @@
|
|||
"solarpercentage": "Aurinkoenergia (%)",
|
||||
"vehicle": "Ajoneuvo"
|
||||
},
|
||||
"csvMonth": "Lataa {month} CSV",
|
||||
"csvPeriod": "Lataa {period} CSV",
|
||||
"csvTotal": "Lataa kaikki CSV",
|
||||
"date": "Aloitettu",
|
||||
"downloadCsv": "Lataa CSV muodossa",
|
||||
"energy": "Ladattu",
|
||||
"filter": {
|
||||
"allLoadpoints": "kaikki latauspisteet",
|
||||
|
|
|
|||
|
|
@ -862,10 +862,9 @@
|
|||
"solarpercentage": "% solaire",
|
||||
"vehicle": "Véhicule"
|
||||
},
|
||||
"csvMonth": "Télécharger CSV {month}",
|
||||
"csvPeriod": "Télécharger CSV {period}",
|
||||
"csvTotal": "Télécharger CSV total",
|
||||
"date": "Début session",
|
||||
"downloadCsv": "Télécharger au format CSV",
|
||||
"energy": "Chargé",
|
||||
"filter": {
|
||||
"allLoadpoints": "tous les points de chargement",
|
||||
|
|
|
|||
|
|
@ -724,10 +724,9 @@
|
|||
"solarpercentage": "Solarno (%)",
|
||||
"vehicle": "Vozilo"
|
||||
},
|
||||
"csvMonth": "Preuzmi CSV za {month}",
|
||||
"csvPeriod": "Preuzmi CSV za {period}",
|
||||
"csvTotal": "Preuzmi CSV za ukupno",
|
||||
"date": "Početak",
|
||||
"downloadCsv": "Preuzmi kao CSV",
|
||||
"energy": "Napunjeno",
|
||||
"filter": {
|
||||
"allLoadpoints": "sva mjesta napajanja",
|
||||
|
|
|
|||
|
|
@ -862,10 +862,9 @@
|
|||
"solarpercentage": "Napenergia (%)",
|
||||
"vehicle": "Jármű"
|
||||
},
|
||||
"csvMonth": "Letöltés - {month} .CSV",
|
||||
"csvPeriod": "Letöltés - {period} .CSV",
|
||||
"csvTotal": "Letöltés - Összes időszak .CSV",
|
||||
"date": "Kezdés",
|
||||
"downloadCsv": "Letöltés mint: CSV",
|
||||
"energy": "Töltve",
|
||||
"filter": {
|
||||
"allLoadpoints": "minden töltőpont",
|
||||
|
|
|
|||
|
|
@ -862,10 +862,9 @@
|
|||
"solarpercentage": "Solare (%)",
|
||||
"vehicle": "Veicolo"
|
||||
},
|
||||
"csvMonth": "Scarica il CSV di {month}",
|
||||
"csvPeriod": "Scarica il CSV di {period}",
|
||||
"csvTotal": "Scarica il CSV complessivo",
|
||||
"date": "Avvio",
|
||||
"downloadCsv": "Scarica come CSV",
|
||||
"energy": "Caricato",
|
||||
"filter": {
|
||||
"allLoadpoints": "tutte le stazioni di ricarica",
|
||||
|
|
|
|||
|
|
@ -862,10 +862,9 @@
|
|||
"solarpercentage": "Sonn (%)",
|
||||
"vehicle": "Gefier"
|
||||
},
|
||||
"csvMonth": "Download {month} CSV",
|
||||
"csvPeriod": "Download {period} CSV",
|
||||
"csvTotal": "Gesamt CSV eroflueden",
|
||||
"date": "Ufank",
|
||||
"downloadCsv": "Als CSV eroflueden",
|
||||
"energy": "Opgelueden",
|
||||
"filter": {
|
||||
"allLoadpoints": "All Luedstatiounen",
|
||||
|
|
|
|||
|
|
@ -873,10 +873,9 @@
|
|||
"solarpercentage": "Saulės (%)",
|
||||
"vehicle": "Automobilis"
|
||||
},
|
||||
"csvMonth": "Atsisiųsti {month} CSV",
|
||||
"csvPeriod": "Atsisiųsti {period} CSV",
|
||||
"csvTotal": "Atsisiųsti visą CSV",
|
||||
"date": "Pradžia",
|
||||
"downloadCsv": "Atsisiųsti CSV failą",
|
||||
"energy": "Įkrauta",
|
||||
"filter": {
|
||||
"allLoadpoints": "visi įkrovikliai",
|
||||
|
|
|
|||
|
|
@ -862,10 +862,9 @@
|
|||
"solarpercentage": "Zonne-energie (%)",
|
||||
"vehicle": "Voertuig"
|
||||
},
|
||||
"csvMonth": "Download CSV van {month}",
|
||||
"csvPeriod": "Download CSV van {period}",
|
||||
"csvTotal": "Download totale CSV",
|
||||
"date": "Start",
|
||||
"downloadCsv": "Download als CSV",
|
||||
"energy": "Geladen",
|
||||
"filter": {
|
||||
"allLoadpoints": "alle oplaadpunten",
|
||||
|
|
|
|||
|
|
@ -298,10 +298,9 @@
|
|||
"odometer": "Kilometerstand",
|
||||
"vehicle": "Kjøretøy"
|
||||
},
|
||||
"csvMonth": "Last ned (måned) CSV",
|
||||
"csvPeriod": "Last ned (måned) CSV",
|
||||
"csvTotal": "Last ned total CSV",
|
||||
"date": "Start",
|
||||
"downloadCsv": "Last ned som CSV",
|
||||
"energy": "Oppladet",
|
||||
"filter": {
|
||||
"allLoadpoints": "alle ladepunkter",
|
||||
|
|
|
|||
|
|
@ -489,10 +489,9 @@
|
|||
"odometer": "Przebieg (km)",
|
||||
"vehicle": "Pojazd"
|
||||
},
|
||||
"csvMonth": "Pobierz plik {month} CSV",
|
||||
"csvPeriod": "Pobierz plik {period} CSV",
|
||||
"csvTotal": "Pobierz plik CSV",
|
||||
"date": "Rozpoczęty",
|
||||
"downloadCsv": "Pobierz jako CSV",
|
||||
"energy": "Naładowano",
|
||||
"filter": {
|
||||
"allLoadpoints": "wszystkie punkty ładowania",
|
||||
|
|
|
|||
|
|
@ -861,10 +861,9 @@
|
|||
"solarpercentage": "Solar (%)",
|
||||
"vehicle": "Veículo"
|
||||
},
|
||||
"csvMonth": "Download {month} CSV",
|
||||
"csvPeriod": "Download {period} CSV",
|
||||
"csvTotal": "Download tudo CSV",
|
||||
"date": "Início",
|
||||
"downloadCsv": "Download como CSV",
|
||||
"energy": "Carregado",
|
||||
"filter": {
|
||||
"allLoadpoints": "todos os postos de carregamento",
|
||||
|
|
|
|||
|
|
@ -380,10 +380,9 @@
|
|||
"odometer": "Kilometraj (km)",
|
||||
"vehicle": "Vehicul"
|
||||
},
|
||||
"csvMonth": "Descarca {month} CSV",
|
||||
"csvPeriod": "Descarca {period} CSV",
|
||||
"csvTotal": "Descarca total CSV",
|
||||
"date": "Start",
|
||||
"downloadCsv": "Descarcă ca CSV",
|
||||
"energy": "Încărcat",
|
||||
"filter": {
|
||||
"allLoadpoints": "toate punctele de incarcare",
|
||||
|
|
|
|||
|
|
@ -209,7 +209,6 @@
|
|||
"vehicle": "Транспортное средство"
|
||||
},
|
||||
"date": "Период",
|
||||
"downloadCsv": "Загрузить CSV",
|
||||
"energy": "Заряжено",
|
||||
"loadpoint": "Зарядная станция",
|
||||
"title": "Сессии зарядки",
|
||||
|
|
|
|||
|
|
@ -790,10 +790,9 @@
|
|||
"solarpercentage": "Sončna energija (%)",
|
||||
"vehicle": "Vozilo"
|
||||
},
|
||||
"csvMonth": "Prenesi {month} CSV",
|
||||
"csvPeriod": "Prenesi {period} CSV",
|
||||
"csvTotal": "Prenesi celoten CSV",
|
||||
"date": "Začetek",
|
||||
"downloadCsv": "Prenesi kot CSV",
|
||||
"energy": "Napolnjeno",
|
||||
"filter": {
|
||||
"allLoadpoints": "vsa polnilna mesta",
|
||||
|
|
|
|||
|
|
@ -873,10 +873,9 @@
|
|||
"solarpercentage": "Sol (%)",
|
||||
"vehicle": "Fordon"
|
||||
},
|
||||
"csvMonth": "Ladda hem {month} CSV",
|
||||
"csvPeriod": "Ladda hem {period} CSV",
|
||||
"csvTotal": "Ladda hem total CSV",
|
||||
"date": "Start",
|
||||
"downloadCsv": "Ladda hem som CSV",
|
||||
"energy": "Laddat",
|
||||
"filter": {
|
||||
"allLoadpoints": "alla laddplatser",
|
||||
|
|
|
|||
|
|
@ -646,10 +646,9 @@
|
|||
"solarpercentage": "சூரிய (%)",
|
||||
"vehicle": "வண்டி"
|
||||
},
|
||||
"csvMonth": "பதிவிறக்கம் {month} சிஎச்வி",
|
||||
"csvPeriod": "பதிவிறக்கம் {period} சிஎச்வி",
|
||||
"csvTotal": "மொத்த காபிம ஐ பதிவிறக்கவும்",
|
||||
"date": "தொடக்க",
|
||||
"downloadCsv": "சிஎச்வி ஆக பதிவிறக்கம்",
|
||||
"energy": "கட்டணம் வசூலிக்கப்பட்டது",
|
||||
"filter": {
|
||||
"allLoadpoints": "அனைத்து சார்சிங் புள்ளிகளும்",
|
||||
|
|
|
|||
|
|
@ -873,10 +873,9 @@
|
|||
"solarpercentage": "Güneş (%)",
|
||||
"vehicle": "Araç"
|
||||
},
|
||||
"csvMonth": "{month} CSV olarak indir",
|
||||
"csvPeriod": "{period} CSV olarak indir",
|
||||
"csvTotal": "CSV'nin tamamını indir",
|
||||
"date": "Başlangıç",
|
||||
"downloadCsv": "CSV olarak indir",
|
||||
"energy": "Doldurulan",
|
||||
"filter": {
|
||||
"allLoadpoints": "tüm doldurma noktaları",
|
||||
|
|
|
|||
|
|
@ -873,10 +873,9 @@
|
|||
"solarpercentage": "Соляр (%)",
|
||||
"vehicle": "Транспортний засіб"
|
||||
},
|
||||
"csvMonth": "Завантажити {month} CSV",
|
||||
"csvPeriod": "Завантажити {period} CSV",
|
||||
"csvTotal": "Завантажити повний CSV",
|
||||
"date": "Почати",
|
||||
"downloadCsv": "Завантажити як CSV",
|
||||
"energy": "Заряджено",
|
||||
"filter": {
|
||||
"allLoadpoints": "всі точки зарядки",
|
||||
|
|
|
|||
|
|
@ -862,10 +862,9 @@
|
|||
"solarpercentage": "太阳能 (%)",
|
||||
"vehicle": "车辆"
|
||||
},
|
||||
"csvMonth": "下载 {month} CSV 文件",
|
||||
"csvPeriod": "下载 {period} CSV 文件",
|
||||
"csvTotal": "下载总计 CSV 文件",
|
||||
"date": "开始",
|
||||
"downloadCsv": "下载为 CSV 文件",
|
||||
"energy": "已充电量",
|
||||
"filter": {
|
||||
"allLoadpoints": "所有充电点",
|
||||
|
|
|
|||
|
|
@ -245,28 +245,46 @@ test.describe("columns desktop", async () => {
|
|||
});
|
||||
});
|
||||
|
||||
const date = new Date();
|
||||
const YEAR = date.getFullYear();
|
||||
const MONTH = date.getMonth() + 1;
|
||||
const MONTH_YEAR = new Intl.DateTimeFormat("en", { month: "long", year: "numeric" }).format(date);
|
||||
|
||||
test.describe("csv export", async () => {
|
||||
test("total export", async ({ page }) => {
|
||||
await page.goto("/#/sessions?year=2023&month=5");
|
||||
await expect(page.getByRole("link", { name: "Download total CSV" })).toHaveAttribute(
|
||||
"href",
|
||||
"./api/sessions?format=csv&lang=en"
|
||||
);
|
||||
|
||||
await page.goto("/#/sessions?year=2023&month=6");
|
||||
await page.goto("/#/sessions?period=total");
|
||||
await expect(page.getByRole("link", { name: "Download total CSV" })).toHaveAttribute(
|
||||
"href",
|
||||
"./api/sessions?format=csv&lang=en"
|
||||
);
|
||||
});
|
||||
test("year export", async ({ page }) => {
|
||||
// fixed year
|
||||
await page.goto("/#/sessions?period=year&year=2023");
|
||||
await expect(page.getByRole("link", { name: "Download 2023 CSV" })).toHaveAttribute(
|
||||
"href",
|
||||
"./api/sessions?format=csv&lang=en&year=2023"
|
||||
);
|
||||
|
||||
// current year
|
||||
await page.goto(`/#/sessions?period=year`);
|
||||
await expect(page.getByRole("link", { name: `Download ${YEAR} CSV` })).toHaveAttribute(
|
||||
"href",
|
||||
`./api/sessions?format=csv&lang=en&year=${YEAR}`
|
||||
);
|
||||
});
|
||||
test("monthly export", async ({ page }) => {
|
||||
await page.goto("/#/sessions?year=2023&month=5");
|
||||
await page.goto("/#/sessions?&year=2023&month=5");
|
||||
await expect(page.getByRole("link", { name: "Download May 2023 CSV" })).toHaveAttribute(
|
||||
"href",
|
||||
"./api/sessions?format=csv&lang=en&year=2023&month=5"
|
||||
);
|
||||
|
||||
await page.goto("/#/sessions?year=2023&month=6");
|
||||
await expect(page.getByRole("link", { name: "Download June 2023 CSV" })).toHaveCount(0);
|
||||
// current month
|
||||
await page.goto(`/#/sessions`);
|
||||
await expect(page.getByRole("link", { name: `Download ${MONTH_YEAR} CSV` })).toHaveAttribute(
|
||||
"href",
|
||||
`./api/sessions?format=csv&lang=en&year=${YEAR}&month=${MONTH}`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue