mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
fix sortowania statusów dr; linting
This commit is contained in:
@@ -23,6 +23,9 @@ export default defineComponent({
|
|||||||
dispatcherStatus: {
|
dispatcherStatus: {
|
||||||
type: Number as PropType<Status.ActiveDispatcher | number>
|
type: Number as PropType<Status.ActiveDispatcher | number>
|
||||||
},
|
},
|
||||||
|
dispatcherTimestamp: {
|
||||||
|
type: Number as PropType<number | null>
|
||||||
|
},
|
||||||
isOnline: {
|
isOnline: {
|
||||||
type: Boolean
|
type: Boolean
|
||||||
}
|
}
|
||||||
@@ -59,7 +62,9 @@ export default defineComponent({
|
|||||||
return 'unknown';
|
return 'unknown';
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (this.dispatcherStatus >= Date.now() + 25500000) return 'no-limit';
|
if (this.dispatcherTimestamp != null && this.dispatcherStatus >= Date.now() + 25500000)
|
||||||
|
return 'no-limit';
|
||||||
|
|
||||||
return 'online';
|
return 'online';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
<StationStatusBadge
|
<StationStatusBadge
|
||||||
:isOnline="onlineScenery ? true : false"
|
:isOnline="onlineScenery ? true : false"
|
||||||
:dispatcherStatus="onlineScenery?.dispatcherStatus"
|
:dispatcherStatus="onlineScenery?.dispatcherStatus"
|
||||||
|
:dispatcherTimestamp="onlineScenery?.dispatcherTimestamp"
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
mixins: [modalTrainMixin],
|
mixins: [modalTrainMixin],
|
||||||
|
|
||||||
setup(props) {
|
setup() {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const searchedTrain = inject('searchedTrain') as Ref<string>;
|
const searchedTrain = inject('searchedTrain') as Ref<string>;
|
||||||
const searchedDriver = inject('searchedDriver') as Ref<string>;
|
const searchedDriver = inject('searchedDriver') as Ref<string>;
|
||||||
|
|||||||
@@ -3,6 +3,17 @@ import { Status } from '../../typings/common';
|
|||||||
import { HeadIdsTypes } from '../data/stationHeaderNames';
|
import { HeadIdsTypes } from '../data/stationHeaderNames';
|
||||||
import Station from '../interfaces/Station';
|
import Station from '../interfaces/Station';
|
||||||
|
|
||||||
|
const dispatcherStatusPriority = [
|
||||||
|
Status.ActiveDispatcher.UNKNOWN,
|
||||||
|
Status.ActiveDispatcher.INVALID,
|
||||||
|
Status.ActiveDispatcher.NOT_LOGGED_IN,
|
||||||
|
Status.ActiveDispatcher.UNAVAILABLE,
|
||||||
|
Status.ActiveDispatcher.AFK,
|
||||||
|
Status.ActiveDispatcher.ENDING,
|
||||||
|
Status.ActiveDispatcher.NO_SPACE,
|
||||||
|
undefined
|
||||||
|
];
|
||||||
|
|
||||||
export const sortStations = (
|
export const sortStations = (
|
||||||
a: Station,
|
a: Station,
|
||||||
b: Station,
|
b: Station,
|
||||||
@@ -19,7 +30,11 @@ export const sortStations = (
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'status':
|
case 'status':
|
||||||
diff = (a.onlineInfo?.dispatcherStatus || 0) - (b.onlineInfo?.dispatcherStatus || 0);
|
diff =
|
||||||
|
(a.onlineInfo?.dispatcherTimestamp ??
|
||||||
|
dispatcherStatusPriority.indexOf(a.onlineInfo?.dispatcherStatus)) -
|
||||||
|
(b.onlineInfo?.dispatcherTimestamp ??
|
||||||
|
dispatcherStatusPriority.indexOf(b.onlineInfo?.dispatcherStatus));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'dispatcher':
|
case 'dispatcher':
|
||||||
|
|||||||
@@ -138,6 +138,13 @@ export const useStore = defineStore('store', {
|
|||||||
[] as ScheduledTrain[]
|
[] as ScheduledTrain[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const dispatcherTimestamp =
|
||||||
|
scenery.dispatcherStatus == Status.ActiveDispatcher.NO_LIMIT
|
||||||
|
? Date.now() + 25500000
|
||||||
|
: scenery.dispatcherStatus > 5
|
||||||
|
? scenery.dispatcherStatus
|
||||||
|
: null;
|
||||||
|
|
||||||
list.push({
|
list.push({
|
||||||
name: scenery.stationName,
|
name: scenery.stationName,
|
||||||
hash: scenery.stationHash,
|
hash: scenery.stationHash,
|
||||||
@@ -153,6 +160,7 @@ export const useStore = defineStore('store', {
|
|||||||
scheduledTrains: scheduledTrains,
|
scheduledTrains: scheduledTrains,
|
||||||
stationTrains: stationTrains,
|
stationTrains: stationTrains,
|
||||||
dispatcherStatus: scenery.dispatcherStatus,
|
dispatcherStatus: scenery.dispatcherStatus,
|
||||||
|
dispatcherTimestamp: dispatcherTimestamp,
|
||||||
|
|
||||||
isOnline: scenery.isOnline == 1,
|
isOnline: scenery.isOnline == 1,
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ export interface OnlineScenery {
|
|||||||
dispatcherIsSupporter: boolean;
|
dispatcherIsSupporter: boolean;
|
||||||
|
|
||||||
dispatcherStatus: Status.ActiveDispatcher | number;
|
dispatcherStatus: Status.ActiveDispatcher | number;
|
||||||
|
dispatcherTimestamp: number | null;
|
||||||
|
|
||||||
isOnline: boolean;
|
isOnline: boolean;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user