From aa7a6b220ef47b1f8b97d4b15d951ed08769b482 Mon Sep 17 00:00:00 2001 From: Spythere Date: Mon, 2 Jan 2023 18:30:09 +0100 Subject: [PATCH] =?UTF-8?q?feature:=20lvl=20maszynisty=20przy=20dzienniku?= =?UTF-8?q?=20i=20poci=C4=85gach?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JournalView/JournalTimetablesList.vue | 10 +++++++++- src/components/TrainsView/TrainInfo.vue | 11 ++++++++--- src/mixins/styleMixin.ts | 16 +++++++++++----- src/scripts/interfaces/Train.ts | 1 + src/scripts/interfaces/api/TimetablesAPIData.ts | 4 ++++ src/scripts/interfaces/api/TrainAPIData.ts | 1 + src/store/store.ts | 1 + 7 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/components/JournalView/JournalTimetablesList.vue b/src/components/JournalView/JournalTimetablesList.vue index ee08f29..b798f17 100644 --- a/src/components/JournalView/JournalTimetablesList.vue +++ b/src/components/JournalView/JournalTimetablesList.vue @@ -17,6 +17,13 @@ {{ timetable.trainNo }} | {{ timetable.driverName }} | #{{ timetable.id }} + + + | + + {{ timetable.driverLevel < 2 ? 'L' : `${timetable.driverLevel} lvl` }} + + @@ -140,6 +147,7 @@ import { defineComponent, PropType, ref } from 'vue'; import dateMixin from '../../mixins/dateMixin'; import imageMixin from '../../mixins/imageMixin'; import modalTrainMixin from '../../mixins/modalTrainMixin'; +import styleMixin from '../../mixins/styleMixin'; import { TimetableHistory } from '../../scripts/interfaces/api/TimetablesAPIData'; export default defineComponent({ @@ -150,7 +158,7 @@ export default defineComponent({ }, }, - mixins: [dateMixin, imageMixin, modalTrainMixin], + mixins: [dateMixin, imageMixin, modalTrainMixin, styleMixin], computed: { computedTimetableHistory() { diff --git a/src/components/TrainsView/TrainInfo.vue b/src/components/TrainsView/TrainInfo.vue index 59541d2..97d4585 100644 --- a/src/components/TrainsView/TrainInfo.vue +++ b/src/components/TrainsView/TrainInfo.vue @@ -14,8 +14,12 @@  {{ train.trainNo }} | - {{ train.driverName }} - + + {{ train.driverName }} | + + {{ train.driverLevel < 2 ? 'L' : `${train.driverLevel} lvl` }} + + ? @@ -94,6 +98,7 @@ diff --git a/src/mixins/styleMixin.ts b/src/mixins/styleMixin.ts index 396180f..f7d9073 100644 --- a/src/mixins/styleMixin.ts +++ b/src/mixins/styleMixin.ts @@ -4,13 +4,19 @@ export default defineComponent({ methods: { calculateExpStyle(exp: number, isSupporter = false): string { const bgColor = exp > -1 ? (exp < 2 ? '#26B0D9' : `hsl(${-exp * 5 + 100}, 85%, 50%)`) : '#666'; - + const fontColor = exp > 14 || exp == -1 ? 'white' : 'black'; const boxShadow = isSupporter ? `box-shadow: 0 0 10px 2px ${bgColor};` : ''; - + return `background-color: ${bgColor}; color: ${fontColor}; ${boxShadow}`; }, + calculateTextExpStyle(exp: number): string { + const textColor = exp > -1 ? (exp < 2 ? '#26B0D9' : `hsl(${-exp * 5 + 100}, 75%, 50%)`) : '#666'; + + return `color: ${textColor};`; + }, + statusClasses(occupiedTo: string) { let className = ''; @@ -41,6 +47,6 @@ export default defineComponent({ } return className; - } - } -}) + }, + }, +}); diff --git a/src/scripts/interfaces/Train.ts b/src/scripts/interfaces/Train.ts index a57c8d6..b4e4dfb 100644 --- a/src/scripts/interfaces/Train.ts +++ b/src/scripts/interfaces/Train.ts @@ -12,6 +12,7 @@ export default interface Train { driverId: number; trainNo: number; driverName: string; + driverLevel: number; currentStationName: string; currentStationHash: string; locoURL: string; diff --git a/src/scripts/interfaces/api/TimetablesAPIData.ts b/src/scripts/interfaces/api/TimetablesAPIData.ts index c64ebfc..da13061 100644 --- a/src/scripts/interfaces/api/TimetablesAPIData.ts +++ b/src/scripts/interfaces/api/TimetablesAPIData.ts @@ -4,8 +4,12 @@ export interface TimetableHistory { timetableId: number; trainNo: number; trainCategoryCode: string; + driverId: number; driverName: string; + driverLevel: number | null; + driverIsSupporter: boolean; + route: string; twr: number; skr: number; diff --git a/src/scripts/interfaces/api/TrainAPIData.ts b/src/scripts/interfaces/api/TrainAPIData.ts index f417ca4..3147114 100644 --- a/src/scripts/interfaces/api/TrainAPIData.ts +++ b/src/scripts/interfaces/api/TrainAPIData.ts @@ -13,6 +13,7 @@ export default interface TrainAPIData { driverName: string; driverId: number; driverIsSupporter: boolean; + driverLevel?: number; currentStationName: string; currentStationHash: string; diff --git a/src/store/store.ts b/src/store/store.ts index 85d7a1b..b72cdc8 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -101,6 +101,7 @@ export const useStore = defineStore('store', { isTimeout: train.isTimeout, isSupporter: train.driverIsSupporter, + driverLevel: train.driverLevel, timetableData: timetable ? {