-
-
+
+
-
-
{{ currentDispatcher }}
+
{{ new Date(currentDispatcherFrom).toLocaleDateString('pl-PL') }}
{{ new Date(currentDispatcherFrom).toLocaleTimeString('pl-PL', { hour: '2-digit', minute: '2-digit' })}}
+
-
-
{{history.dispatcherName }}
+
{{history.dispatcherFromDate }}
@@ -48,7 +53,6 @@
-
BRAK ZEBRANYCH DANYCH O RUCHU!
@@ -69,12 +73,13 @@ interface ISceneryHistory {
stationHash: string;
stationName: string;
currentDispatcher: string;
- currentDispatcherId: string;
+ currentDispatcherId: number;
currentDispatcherFrom: number;
currentDispatcherTo: number;
dispatcherHistory: {
dispatcherName: string;
dispatcherFrom: number;
+ dispatcherId: number;
dispatcherTo: number;
}[];
}
@@ -83,12 +88,31 @@ interface ISceneryHistory {
export default class HistoryView extends Vue {
@Getter("getStationList") stationList!: Station[];
+ sceneryHistoryList: ISceneryHistory[] = [];
+
currentSceneryHistory: ISceneryHistory["dispatcherHistory"] = [];
currentDispatcher: string = "";
+ currentDispatcherId: number = 0;
currentDispatcherFrom: number = -1;
inputStationName = "";
- dataLoading = false;
+ dataLoading = true;
+
+ async mounted() {
+ try {
+ const responseData: ISceneryHistory[] = await (
+ await axios.get(
+ "https://stacjownik.herokuapp.com/api/getSceneryHistory"
+ )
+ ).data;
+
+ this.sceneryHistoryList = responseData;
+ } catch (error) {
+ console.error(error);
+ }
+
+ this.dataLoading = false;
+ }
@Watch("inputStationName")
onInputChanged(val: string) {
@@ -96,55 +120,46 @@ export default class HistoryView extends Vue {
}
get filteredStationList() {
- return this.stationList
+ return this.sceneryHistoryList
.map((station) => station.stationName)
.sort((a, b) => (a.toLowerCase() >= b.toLowerCase() ? 1 : -1));
}
get computedHistoryList() {
return this.currentSceneryHistory
- .map(({ dispatcherName, dispatcherFrom, dispatcherTo }) => ({
- dispatcherName,
- dispatcherFrom,
- dispatcherTo,
- dispatcherFromDate: new Date(dispatcherFrom).toLocaleDateString(
- "pl-PL"
- ),
- dispatcherFromTime: new Date(dispatcherFrom).toLocaleTimeString(
- "pl-PL",
- { hour: "2-digit", minute: "2-digit" }
- ),
- dispatcherToDate: new Date(dispatcherTo).toLocaleDateString("pl-PL"),
- dispatcherToTime: new Date(dispatcherTo).toLocaleTimeString("pl-PL", {
- hour: "2-digit",
- minute: "2-digit",
- }),
- }))
+ .map(
+ ({ dispatcherName, dispatcherFrom, dispatcherTo, dispatcherId }) => ({
+ dispatcherName,
+ dispatcherFrom,
+ dispatcherTo,
+ dispatcherId,
+ dispatcherFromDate: new Date(dispatcherFrom).toLocaleDateString(
+ "pl-PL"
+ ),
+ dispatcherFromTime: new Date(
+ dispatcherFrom
+ ).toLocaleTimeString("pl-PL", { hour: "2-digit", minute: "2-digit" }),
+ dispatcherToDate: new Date(dispatcherTo).toLocaleDateString("pl-PL"),
+ dispatcherToTime: new Date(dispatcherTo).toLocaleTimeString("pl-PL", {
+ hour: "2-digit",
+ minute: "2-digit",
+ }),
+ })
+ )
.reverse();
}
- async itemSelected(itemName: string) {
- this.dataLoading = true;
+ itemSelected(itemName: string) {
+ const selectedScenery = this.sceneryHistoryList.find(
+ (scenery) => scenery.stationName == itemName
+ );
- try {
- const responseData: ISceneryHistory = await (
- await axios.get(
- `https://stacjownik.herokuapp.com/api/getSceneryHistory?name=${itemName.replaceAll(
- " ",
- "_"
- )}`
- )
- ).data;
+ if (!selectedScenery) return;
- this.currentSceneryHistory = responseData.dispatcherHistory;
- this.currentDispatcher = responseData.currentDispatcher;
- this.currentDispatcherFrom = responseData.currentDispatcherFrom;
- } catch (error) {
- this.currentSceneryHistory = [];
- this.currentDispatcher = "";
- this.currentDispatcherFrom = -1;
- }
- this.dataLoading = false;
+ this.currentSceneryHistory = selectedScenery.dispatcherHistory;
+ this.currentDispatcher = selectedScenery.currentDispatcher;
+ this.currentDispatcherId = selectedScenery.currentDispatcherId;
+ this.currentDispatcherFrom = selectedScenery.currentDispatcherFrom;
}
}
@@ -219,6 +234,10 @@ export default class HistoryView extends Vue {
label {
position: relative;
+ &.disabled::after {
+ color: gray;
+ }
+
&::after {
content: "<>";