From 0ff5ca344fc0a615c279d3d1b2642ad784822f2d Mon Sep 17 00:00:00 2001 From: Spythere Date: Wed, 26 Jan 2022 14:58:47 +0100 Subject: [PATCH] =?UTF-8?q?Dodano=20filtry=20do=20widoku=20historii=20rozk?= =?UTF-8?q?=C5=82ad=C3=B3w=20jazdy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/JournalView/JournalOptions.vue | 188 ++++++++++++++ src/components/StationsView/FilterOption.vue | 167 +++++------- src/locales/en.json | 8 +- src/locales/pl.json | 8 +- src/router/index.ts | 4 +- src/scripts/interfaces/FilterOption.ts | 6 + src/store/index.ts | 8 +- src/styles/option.scss | 36 +++ ...metableHistoryView.vue => JournalView.vue} | 243 ++++++++---------- 9 files changed, 421 insertions(+), 247 deletions(-) create mode 100644 src/components/JournalView/JournalOptions.vue create mode 100644 src/scripts/interfaces/FilterOption.ts create mode 100644 src/styles/option.scss rename src/views/{TimetableHistoryView.vue => JournalView.vue} (75%) diff --git a/src/components/JournalView/JournalOptions.vue b/src/components/JournalView/JournalOptions.vue new file mode 100644 index 0000000..ff41ea0 --- /dev/null +++ b/src/components/JournalView/JournalOptions.vue @@ -0,0 +1,188 @@ + + + + + diff --git a/src/components/StationsView/FilterOption.vue b/src/components/StationsView/FilterOption.vue index f1f633a..fe21e30 100644 --- a/src/components/StationsView/FilterOption.vue +++ b/src/components/StationsView/FilterOption.vue @@ -1,8 +1,7 @@ \ No newline at end of file + diff --git a/src/locales/en.json b/src/locales/en.json index 1fbfe7f..fae189f 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -143,7 +143,13 @@ "journal": { "title": "DISPATCHER HISTORY", "loading": "Loading dispatcher history data...", - "no-history": "No dispatcher history found!" + "no-history": "No dispatcher history found!", + + "search-train": "Train no.", + "search-driver": "Driver name", + + "option-distance": "distance", + "option-total-stops": "total stops" }, "scenery": { "users": "PLAYERS ONLINE", diff --git a/src/locales/pl.json b/src/locales/pl.json index aa4a525..2171aef 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -143,7 +143,13 @@ "journal": { "title": "HISTORIA DYŻURÓW", "loading": "Ładowanie historii dyżurów...", - "no-history": "Brak historii dyżurów dla tej scenerii!" + "no-history": "Brak historii dyżurów dla tej scenerii!", + + "search-train": "Numer pociągu", + "search-driver": "Nick maszynisty", + + "option-distance": "kilometraż", + "option-total-stops": "stacje" }, "scenery": { "users": "GRACZE ONLINE", diff --git a/src/router/index.ts b/src/router/index.ts index be38a0f..753668c 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -22,8 +22,8 @@ const routes: Array = [ }, { path: "/journal", - name: "TimetableHistoryView", - component: () => import("@/views/TimetableHistoryView.vue"), + name: "JournalView", + component: () => import("@/views/JournalView.vue"), }, { path: '/:catchAll(.*)', diff --git a/src/scripts/interfaces/FilterOption.ts b/src/scripts/interfaces/FilterOption.ts new file mode 100644 index 0000000..02e8c78 --- /dev/null +++ b/src/scripts/interfaces/FilterOption.ts @@ -0,0 +1,6 @@ +export default interface FilterOption { + id: string; + name: string; + value: boolean; + defaultValue: boolean; +} \ No newline at end of file diff --git a/src/store/index.ts b/src/store/index.ts index 08cc9dc..332f5eb 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -182,7 +182,13 @@ export const store = createStore({ async fetchTimetableData({ commit }) { const reducedList = this.state.trainList.reduce(async (acc: Promise, train: Train) => { - const timetable: TimetableAPIData = await (await axios.get(URLs.getTimetableURL(train.trainNo, this.state.region.id))).data.message; + const data: { success: boolean; message: TimetableAPIData } = await (await axios.get(URLs.getTimetableURL(train.trainNo, this.state.region.id))).data; + + if (!data.success) { + return acc; + } + + const timetable = data.message; const trainInfo = timetable.trainInfo; if (!timetable || !trainInfo) return acc; diff --git a/src/styles/option.scss b/src/styles/option.scss new file mode 100644 index 0000000..0b1edcc --- /dev/null +++ b/src/styles/option.scss @@ -0,0 +1,36 @@ + +.option { + font-size: 1em; + + input { + display: none; + } + + span { + user-select: none; + -moz-user-select: none; + -webkit-user-select: none; + + width: 100%; + text-align: center; + + cursor: pointer; + + padding: 0.5em 0.55em; + + display: inline-block; + position: relative; + + transition: all 0.2s; + + border-radius: 0.5em; + + &:not(.checked) { + background-color: #585858; + + &::before { + box-shadow: none; + } + } + } +} diff --git a/src/views/TimetableHistoryView.vue b/src/views/JournalView.vue similarity index 75% rename from src/views/TimetableHistoryView.vue rename to src/views/JournalView.vue index 56fe5f5..65af776 100644 --- a/src/views/TimetableHistoryView.vue +++ b/src/views/JournalView.vue @@ -1,25 +1,7 @@