mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
refactor typów danych
This commit is contained in:
@@ -69,14 +69,14 @@
|
||||
import axios from 'axios';
|
||||
import { defineComponent, PropType } from 'vue';
|
||||
import dateMixin from '../../mixins/dateMixin';
|
||||
import { DataStatus } from '../../scripts/enums/DataStatus';
|
||||
import { DispatcherHistory } from '../../scripts/interfaces/api/DispatchersAPIData';
|
||||
import Station from '../../scripts/interfaces/Station';
|
||||
import { URLs } from '../../scripts/utils/apiURLs';
|
||||
import Loading from '../Global/Loading.vue';
|
||||
import styleMixin from '../../mixins/styleMixin';
|
||||
import listObserverMixin from '../../mixins/listObserverMixin';
|
||||
import { OnlineScenery } from '../../scripts/interfaces/store/storeTypes';
|
||||
import { OnlineScenery } from '../../store/typings';
|
||||
import { API } from '../../typings/api';
|
||||
import { Status } from '../../typings/common';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SceneryDispatchersHistory',
|
||||
@@ -95,9 +95,9 @@ export default defineComponent({
|
||||
|
||||
data() {
|
||||
return {
|
||||
historyList: [] as DispatcherHistory[],
|
||||
dataStatus: DataStatus.Loading,
|
||||
DataStatus
|
||||
historyList: [] as API.DispatcherHistory.Response,
|
||||
dataStatus: Status.Data.Loading,
|
||||
DataStatus: Status.Data
|
||||
};
|
||||
},
|
||||
|
||||
@@ -109,17 +109,22 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
async fetchAPIData(countFrom = 0, countLimit = 30): Promise<DispatcherHistory[] | null> {
|
||||
async fetchAPIData(
|
||||
countFrom = 0,
|
||||
countLimit = 30
|
||||
): Promise<API.DispatcherHistory.Response | null> {
|
||||
try {
|
||||
this.dataStatus = DataStatus.Loading;
|
||||
this.dataStatus = Status.Data.Loading;
|
||||
|
||||
const requestString = `${URLs.stacjownikAPI}/api/getDispatchers?stationName=${this.station.name}&countFrom=${countFrom}&countLimit=${countLimit}`;
|
||||
const historyAPIData: DispatcherHistory[] = await (await axios.get(requestString)).data;
|
||||
const historyAPIData: API.DispatcherHistory.Response = await (
|
||||
await axios.get(requestString)
|
||||
).data;
|
||||
|
||||
this.dataStatus = DataStatus.Loaded;
|
||||
this.dataStatus = Status.Data.Loaded;
|
||||
return historyAPIData;
|
||||
} catch (error) {
|
||||
this.dataStatus = DataStatus.Error;
|
||||
this.dataStatus = Status.Data.Error;
|
||||
console.error(error);
|
||||
return null;
|
||||
}
|
||||
@@ -153,3 +158,4 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
</style>
|
||||
../../store/storeTypes
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<script lang="ts">
|
||||
import { PropType, defineComponent } from 'vue';
|
||||
import Station from '../../scripts/interfaces/Station';
|
||||
import { OnlineScenery } from '../../scripts/interfaces/store/storeTypes';
|
||||
import { OnlineScenery } from '../../store/typings';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
@@ -58,3 +58,4 @@ export default defineComponent({
|
||||
font-size: 1.2em;
|
||||
}
|
||||
</style>
|
||||
../../store/storeTypes
|
||||
|
||||
@@ -90,7 +90,7 @@ import SceneryInfoUserList from './SceneryInfo/SceneryInfoUserList.vue';
|
||||
import SceneryInfoSpawnList from './SceneryInfo/SceneryInfoSpawnList.vue';
|
||||
import SceneryInfoRoutes from './SceneryInfo/SceneryInfoRoutes.vue';
|
||||
import Station from '../../scripts/interfaces/Station';
|
||||
import { OnlineScenery } from '../../scripts/interfaces/store/storeTypes';
|
||||
import { OnlineScenery } from '../../store/typings';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@@ -110,7 +110,7 @@ export default defineComponent({
|
||||
type: Object as PropType<OnlineScenery>,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import dateMixin from '../../../mixins/dateMixin';
|
||||
import routerMixin from '../../../mixins/routerMixin';
|
||||
import styleMixin from '../../../mixins/styleMixin';
|
||||
import StationStatusBadge from '../../Global/StationStatusBadge.vue';
|
||||
import { OnlineScenery } from '../../../scripts/interfaces/store/storeTypes';
|
||||
import { OnlineScenery } from '../../../store/typings';
|
||||
|
||||
export default defineComponent({
|
||||
mixins: [styleMixin, dateMixin, routerMixin],
|
||||
|
||||
@@ -7,7 +7,11 @@
|
||||
</h3>
|
||||
|
||||
<transition-group name="spawns-anim" tag="ul">
|
||||
<li class="badge spawn badge-none" v-if="!onlineScenery || onlineScenery.spawns.length == 0" key="no-spawns">
|
||||
<li
|
||||
class="badge spawn badge-none"
|
||||
v-if="!onlineScenery || onlineScenery.spawns.length == 0"
|
||||
key="no-spawns"
|
||||
>
|
||||
{{ $t('scenery.no-spawns') }}
|
||||
</li>
|
||||
|
||||
@@ -26,7 +30,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { PropType, defineComponent } from 'vue';
|
||||
import { OnlineScenery } from '../../../scripts/interfaces/store/storeTypes';
|
||||
import { OnlineScenery } from '../../../store/typings';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
import { PropType, defineComponent } from 'vue';
|
||||
import modalTrainMixin from '../../../mixins/modalTrainMixin';
|
||||
import routerMixin from '../../../mixins/routerMixin';
|
||||
import { OnlineScenery } from '../../../scripts/interfaces/store/storeTypes';
|
||||
import { OnlineScenery } from '../../../store/typings';
|
||||
|
||||
export default defineComponent({
|
||||
mixins: [routerMixin, modalTrainMixin],
|
||||
|
||||
@@ -185,10 +185,10 @@ import Loading from '../Global/Loading.vue';
|
||||
import dateMixin from '../../mixins/dateMixin';
|
||||
import routerMixin from '../../mixins/routerMixin';
|
||||
import Station from '../../scripts/interfaces/Station';
|
||||
import { useStore } from '../../store/store';
|
||||
import { useStore } from '../../store/mainStore';
|
||||
import modalTrainMixin from '../../mixins/modalTrainMixin';
|
||||
import ScheduledTrainStatus from './ScheduledTrainStatus.vue';
|
||||
import { OnlineScenery } from '../../scripts/interfaces/store/storeTypes';
|
||||
import { OnlineScenery } from '../../store/typings';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SceneryTimetable',
|
||||
|
||||
@@ -56,16 +56,14 @@
|
||||
import axios from 'axios';
|
||||
import { defineComponent, PropType } from 'vue';
|
||||
import dateMixin from '../../mixins/dateMixin';
|
||||
import { DataStatus } from '../../scripts/enums/DataStatus';
|
||||
import {
|
||||
TimetableHistory,
|
||||
SceneryTimetableHistory
|
||||
} from '../../scripts/interfaces/api/TimetablesAPIData';
|
||||
|
||||
import Station from '../../scripts/interfaces/Station';
|
||||
import { URLs } from '../../scripts/utils/apiURLs';
|
||||
import Loading from '../Global/Loading.vue';
|
||||
import listObserverMixin from '../../mixins/listObserverMixin';
|
||||
import { OnlineScenery } from '../../scripts/interfaces/store/storeTypes';
|
||||
import { OnlineScenery } from '../../store/typings';
|
||||
import { API } from '../../typings/api';
|
||||
import { Status } from '../../typings/common';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SceneryTimetablesHistory',
|
||||
@@ -83,28 +81,28 @@ export default defineComponent({
|
||||
|
||||
data() {
|
||||
return {
|
||||
historyList: [] as TimetableHistory[],
|
||||
dataStatus: DataStatus.Loading,
|
||||
DataStatus
|
||||
historyList: [] as API.TimetableHistory.Response,
|
||||
dataStatus: Status.Data.Loading,
|
||||
DataStatus: Status.Data
|
||||
};
|
||||
},
|
||||
|
||||
async activated() {
|
||||
const fetchedHistory = await this.fetchAPIData();
|
||||
if (fetchedHistory) this.historyList = fetchedHistory.timetables;
|
||||
this.fetchAPIData();
|
||||
},
|
||||
|
||||
methods: {
|
||||
async fetchAPIData(countFrom = 0, countLimit = 15): Promise<SceneryTimetableHistory | null> {
|
||||
async fetchAPIData(countFrom = 0, countLimit = 15) {
|
||||
try {
|
||||
const requestString = `${URLs.stacjownikAPI}/api/getIssuedTimetables?name=${this.station.name}&countFrom=${countFrom}&countLimit=${countLimit}`;
|
||||
const historyAPIData: SceneryTimetableHistory = await (await axios.get(requestString)).data;
|
||||
const requestString = `${URLs.stacjownikAPI}/api/getTimetables?issuedFrom=${this.station.name}&countFrom=${countFrom}&countLimit=${countLimit}`;
|
||||
|
||||
this.dataStatus = DataStatus.Loaded;
|
||||
return historyAPIData;
|
||||
const response: API.TimetableHistory.Response = await (await axios.get(requestString)).data;
|
||||
|
||||
this.historyList = response;
|
||||
|
||||
this.dataStatus = Status.Data.Loaded;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -120,3 +118,4 @@ export default defineComponent({
|
||||
@import '../../styles/responsive.scss';
|
||||
@import '../../styles/sceneryViewTables.scss';
|
||||
</style>
|
||||
../../store/storeTypes
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, PropType } from 'vue';
|
||||
import { ScheduledTrain, StopStatus } from '../../scripts/interfaces/ScheduledTrain';
|
||||
import { ScheduledTrain, StopStatus } from '../../store/typings';
|
||||
|
||||
interface ScheduledTrainComp extends ScheduledTrain {
|
||||
stopStatusIndicator: string;
|
||||
@@ -42,7 +42,7 @@ export default defineComponent({
|
||||
stopStatusIndicator = '';
|
||||
|
||||
switch (stopStatus) {
|
||||
case StopStatus.arriving:
|
||||
case StopStatus.ARRIVING:
|
||||
stopStatusIndicator = `${this.$t('timetables.from')}: ${prevDepartureIndicator}`;
|
||||
stopStatusDescription = this.$t('timetables.desc-arriving', {
|
||||
prevStationName,
|
||||
@@ -50,8 +50,8 @@ export default defineComponent({
|
||||
});
|
||||
break;
|
||||
|
||||
case StopStatus.online:
|
||||
case StopStatus.stopped:
|
||||
case StopStatus.ONLINE:
|
||||
case StopStatus.STOPPED:
|
||||
stopStatusIndicator = nextArrivalLine
|
||||
? `${this.$t('timetables.to')}: ${nextArrivalIndicator}`
|
||||
: `${this.$t('timetables.desc-end')}`;
|
||||
@@ -60,7 +60,7 @@ export default defineComponent({
|
||||
: '';
|
||||
break;
|
||||
|
||||
case StopStatus.departed:
|
||||
case StopStatus.DEPARTED:
|
||||
stopStatusIndicator = `${this.$t('timetables.to')}: ${nextArrivalIndicator}`;
|
||||
stopStatusDescription = this.$t('timetables.desc-departed', {
|
||||
nextStationName,
|
||||
@@ -68,7 +68,7 @@ export default defineComponent({
|
||||
});
|
||||
break;
|
||||
|
||||
case StopStatus['departed-away']:
|
||||
case StopStatus.DEPARTED_AWAY:
|
||||
stopStatusIndicator = `${this.$t('timetables.to')}: ${nextArrivalIndicator}`;
|
||||
stopStatusDescription = this.$t('timetables.desc-departed-away', {
|
||||
nextStationName,
|
||||
@@ -76,7 +76,7 @@ export default defineComponent({
|
||||
});
|
||||
break;
|
||||
|
||||
case StopStatus.terminated:
|
||||
case StopStatus.TERMINATED:
|
||||
stopStatusIndicator = `X ${this.$t('timetables.desc-terminated')}`;
|
||||
stopStatusDescription = this.$t('timetables.desc-terminated');
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user