mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
Zmiany w wyglądzie tabelki, połączenie kolumn ze szlakami
This commit is contained in:
+228
-149
@@ -1,175 +1,254 @@
|
||||
import * as functions from "firebase-functions";
|
||||
import * as admin from "firebase-admin";
|
||||
// import * as functions from "firebase-functions";
|
||||
// import * as admin from "firebase-admin";
|
||||
|
||||
admin.initializeApp();
|
||||
// admin.initializeApp();
|
||||
// const db = admin.firestore();
|
||||
|
||||
import axios from "axios";
|
||||
// import axios from "axios";
|
||||
|
||||
import stationJSONList from "./stations.json";
|
||||
// import stationJSONList from "./stations.json";
|
||||
|
||||
let stationAPIData: {
|
||||
stationName: string;
|
||||
dispatcherName: string;
|
||||
isOnline: boolean;
|
||||
region: string;
|
||||
}[] = [];
|
||||
// let stationAPIData: {
|
||||
// stationName: string;
|
||||
// dispatcherName: string;
|
||||
// isOnline: boolean;
|
||||
// region: string;
|
||||
// }[] = [];
|
||||
|
||||
let previousOnlineStations: {
|
||||
stationName: string;
|
||||
dispatcherName: string;
|
||||
occupiedFrom: number;
|
||||
}[] = [];
|
||||
// let previousOnlineStations: {
|
||||
// stationName: string;
|
||||
// dispatcherName: string;
|
||||
// occupiedFrom: number;
|
||||
// }[] = [];
|
||||
|
||||
const API_URL = "https://api.td2.info.pl:9640/?method=getStationsOnline";
|
||||
// const API_URL = "https://api.td2.info.pl:9640/?method=getStationsOnline";
|
||||
|
||||
exports.updateHistory = functions.pubsub
|
||||
.schedule("*/5 * * * *")
|
||||
.onRun(async () => {
|
||||
try {
|
||||
stationAPIData = await (await axios.get(API_URL)).data.message;
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
// exports.updateHistory = functions.pubsub
|
||||
// .schedule("*/5 * * * *")
|
||||
// .onRun(async (context) => {
|
||||
// try {
|
||||
// stationAPIData = await (await axios.get(API_URL)).data.message;
|
||||
// } catch (error) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// On server start
|
||||
if (previousOnlineStations.length == 0) {
|
||||
stationAPIData
|
||||
.filter(
|
||||
(station) =>
|
||||
station.isOnline &&
|
||||
station.region === "eu" &&
|
||||
stationJSONList.some(
|
||||
(data) => data.stationName === station.stationName
|
||||
)
|
||||
)
|
||||
.forEach((station) => {
|
||||
const occupiedFrom = Date.now();
|
||||
// // On server start
|
||||
// if (previousOnlineStations.length == 0) {
|
||||
// stationAPIData
|
||||
// .filter(
|
||||
// (station) =>
|
||||
// station.isOnline &&
|
||||
// station.region === "eu" &&
|
||||
// stationJSONList.some(
|
||||
// (data) => data.stationName === station.stationName
|
||||
// )
|
||||
// )
|
||||
// .forEach((station) => {
|
||||
// const occupiedFrom = Date.now();
|
||||
|
||||
previousOnlineStations.push({
|
||||
stationName: station.stationName,
|
||||
dispatcherName: station.dispatcherName,
|
||||
occupiedFrom,
|
||||
});
|
||||
});
|
||||
// previousOnlineStations.push({
|
||||
// stationName: station.stationName,
|
||||
// dispatcherName: station.dispatcherName,
|
||||
// occupiedFrom,
|
||||
// });
|
||||
// });
|
||||
|
||||
return;
|
||||
}
|
||||
// return;
|
||||
// }
|
||||
|
||||
// When array with previous stations isn't empty
|
||||
previousOnlineStations.forEach((prevStation) => {
|
||||
const currStationData = stationAPIData.find(
|
||||
(currStation) => currStation.stationName === prevStation.stationName
|
||||
);
|
||||
// // When array with previous stations isn't empty
|
||||
// previousOnlineStations.forEach((prevStation) => {
|
||||
// const currStationData = stationAPIData.find(
|
||||
// (currStation) => currStation.stationName === prevStation.stationName
|
||||
// );
|
||||
|
||||
// Dispatcher left
|
||||
if (!currStationData) {
|
||||
previousOnlineStations = previousOnlineStations.filter(
|
||||
(s) => s.stationName !== prevStation.stationName
|
||||
);
|
||||
}
|
||||
// Dispatchers switched
|
||||
else if (prevStation.dispatcherName !== currStationData.dispatcherName) {
|
||||
previousOnlineStations = previousOnlineStations.filter(
|
||||
(s) => s.stationName !== prevStation.stationName
|
||||
);
|
||||
// // Dispatcher left
|
||||
// if (!currStationData) {
|
||||
// previousOnlineStations = previousOnlineStations.filter(
|
||||
// (s) => s.stationName !== prevStation.stationName
|
||||
// );
|
||||
// }
|
||||
// // Dispatchers switched
|
||||
// else if (prevStation.dispatcherName !== currStationData.dispatcherName) {
|
||||
// previousOnlineStations = previousOnlineStations.filter(
|
||||
// (s) => s.stationName !== prevStation.stationName
|
||||
// );
|
||||
|
||||
previousOnlineStations.push({
|
||||
stationName: currStationData.stationName,
|
||||
dispatcherName: currStationData.dispatcherName,
|
||||
occupiedFrom: Date.now(),
|
||||
});
|
||||
}
|
||||
});
|
||||
// previousOnlineStations.push({
|
||||
// stationName: currStationData.stationName,
|
||||
// dispatcherName: currStationData.dispatcherName,
|
||||
// occupiedFrom: Date.now(),
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
stationAPIData
|
||||
.filter(
|
||||
(stationData) =>
|
||||
!previousOnlineStations.find(
|
||||
(prevStation) => prevStation.stationName === stationData.stationName
|
||||
)
|
||||
)
|
||||
.forEach((stationData) => {
|
||||
previousOnlineStations.push({
|
||||
stationName: stationData.stationName,
|
||||
dispatcherName: stationData.dispatcherName,
|
||||
occupiedFrom: Date.now(),
|
||||
});
|
||||
});
|
||||
});
|
||||
// stationAPIData
|
||||
// .filter(
|
||||
// (stationData) =>
|
||||
// !previousOnlineStations.find(
|
||||
// (prevStation) => prevStation.stationName === stationData.stationName
|
||||
// )
|
||||
// )
|
||||
// .forEach((stationData) => {
|
||||
// previousOnlineStations.push({
|
||||
// stationName: stationData.stationName,
|
||||
// dispatcherName: stationData.dispatcherName,
|
||||
// occupiedFrom: Date.now(),
|
||||
// });
|
||||
// });
|
||||
|
||||
exports.getHistoryData = functions.https.onCall((data, context) => {
|
||||
return { previousOnlineStations };
|
||||
});
|
||||
// const stationsDoc = db.collection("stations").doc("previous");
|
||||
|
||||
// // const scheduledUpdate = functions.pubsub
|
||||
// // .schedule("0 * * * *")
|
||||
// // .onRun(async (context) => {
|
||||
// // let stationData: {
|
||||
// // stationName: string;
|
||||
// // dispatcherName: string;
|
||||
// // isOnline: boolean;
|
||||
// // region: string;
|
||||
// // }[];
|
||||
// stationsDoc.set({ previousOnlineStations });
|
||||
// });
|
||||
|
||||
// // try {
|
||||
// // stationData = await (
|
||||
// // await axios.get(
|
||||
// // "https://api.td2.info.pl:9640/?method=getStationsOnline"
|
||||
// // )
|
||||
// // ).data.message;
|
||||
// // } catch (error) {
|
||||
// // return;
|
||||
// // }
|
||||
// exports.test = functions.https.onRequest(async (req, res) => {
|
||||
// try {
|
||||
// stationAPIData = await (await axios.get(API_URL)).data.message;
|
||||
// } catch (error) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // const historyRef = db.collection("history");
|
||||
// // On server start
|
||||
// if (previousOnlineStations.length == 0) {
|
||||
// stationAPIData
|
||||
// .filter(
|
||||
// (station) =>
|
||||
// station.isOnline &&
|
||||
// station.region === "eu" &&
|
||||
// stationJSONList.some(
|
||||
// (data) => data.stationName === station.stationName
|
||||
// )
|
||||
// )
|
||||
// .forEach((station) => {
|
||||
// const occupiedFrom = Date.now();
|
||||
|
||||
// // stationData.forEach(async (station) => {
|
||||
// // const docRef = historyRef.doc(station.stationName);
|
||||
// // const docSnapshot = await docRef.get();
|
||||
// previousOnlineStations.push({
|
||||
// stationName: station.stationName,
|
||||
// dispatcherName: station.dispatcherName,
|
||||
// occupiedFrom,
|
||||
// });
|
||||
// });
|
||||
|
||||
// // if (!docSnapshot.exists) {
|
||||
// // docRef.set({
|
||||
// // occupiedFrom: Date.now(),
|
||||
// // currentDispatcherName: station.dispatcherName,
|
||||
// // });
|
||||
// // return;
|
||||
// // }
|
||||
// // });
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // const snapshot = await historyRef.get();
|
||||
// // When array with previous stations isn't empty
|
||||
// previousOnlineStations.forEach((prevStation) => {
|
||||
// const currStationData = stationAPIData.find(
|
||||
// (currStation) => currStation.stationName === prevStation.stationName
|
||||
// );
|
||||
|
||||
// // snapshot.forEach(async (doc) => {
|
||||
// // const docData = doc.data();
|
||||
// // const docRef = historyRef.doc(doc.id);
|
||||
// // Dispatcher left
|
||||
// if (!currStationData) {
|
||||
// previousOnlineStations = previousOnlineStations.filter(
|
||||
// (s) => s.stationName !== prevStation.stationName
|
||||
// );
|
||||
// }
|
||||
// // Dispatchers switched
|
||||
// else if (prevStation.dispatcherName !== currStationData.dispatcherName) {
|
||||
// previousOnlineStations = previousOnlineStations.filter(
|
||||
// (s) => s.stationName !== prevStation.stationName
|
||||
// );
|
||||
|
||||
// // const APIStationData = stationData
|
||||
// // .filter((station) => station.isOnline && station.region === "eu")
|
||||
// // .find((station) => station.stationName == doc.id);
|
||||
// previousOnlineStations.push({
|
||||
// stationName: currStationData.stationName,
|
||||
// dispatcherName: currStationData.dispatcherName,
|
||||
// occupiedFrom: Date.now(),
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
// // if (docData.currentDispatcherName != "") {
|
||||
// // if (
|
||||
// // !APIStationData ||
|
||||
// // APIStationData.dispatcherName != docData.currentDispatcherName
|
||||
// // ) {
|
||||
// // docRef.update({
|
||||
// // currentDispatcherName: !APIStationData
|
||||
// // ? ""
|
||||
// // : APIStationData.dispatcherName,
|
||||
// // occupiedFrom: !APIStationData ? 0 : Date.now(),
|
||||
// // });
|
||||
// stationAPIData
|
||||
// .filter(
|
||||
// (stationData) =>
|
||||
// !previousOnlineStations.find(
|
||||
// (prevStation) => prevStation.stationName === stationData.stationName
|
||||
// )
|
||||
// )
|
||||
// .forEach((stationData) => {
|
||||
// previousOnlineStations.push({
|
||||
// stationName: stationData.stationName,
|
||||
// dispatcherName: stationData.dispatcherName,
|
||||
// occupiedFrom: Date.now(),
|
||||
// });
|
||||
// });
|
||||
|
||||
// // docRef.collection("dispatcherHistory").add({
|
||||
// // currentDispatcherName: docData.currentDispatcherName,
|
||||
// // occupiedFrom: docData.occupiedFrom,
|
||||
// // occupiedTo: Date.now(),
|
||||
// // });
|
||||
// // }
|
||||
// // } else if (APIStationData) {
|
||||
// // docRef.update({
|
||||
// // currentDispatcherName: APIStationData.dispatcherName,
|
||||
// // occupiedFrom: Date.now(),
|
||||
// // });
|
||||
// // }
|
||||
// // });
|
||||
// // });
|
||||
// const stationsDoc = db.collection("stations").doc("previous");
|
||||
|
||||
// stationsDoc.set({ previousOnlineStations });
|
||||
|
||||
// res.status(200);
|
||||
// });
|
||||
|
||||
// // // const scheduledUpdate = functions.pubsub
|
||||
// // // .schedule("0 * * * *")
|
||||
// // // .onRun(async (context) => {
|
||||
// // // let stationData: {
|
||||
// // // stationName: string;
|
||||
// // // dispatcherName: string;
|
||||
// // // isOnline: boolean;
|
||||
// // // region: string;
|
||||
// // // }[];
|
||||
|
||||
// // // try {
|
||||
// // // stationData = await (
|
||||
// // // await axios.get(
|
||||
// // // "https://api.td2.info.pl:9640/?method=getStationsOnline"
|
||||
// // // )
|
||||
// // // ).data.message;
|
||||
// // // } catch (error) {
|
||||
// // // return;
|
||||
// // // }
|
||||
|
||||
// // // const historyRef = db.collection("history");
|
||||
|
||||
// // // stationData.forEach(async (station) => {
|
||||
// // // const docRef = historyRef.doc(station.stationName);
|
||||
// // // const docSnapshot = await docRef.get();
|
||||
|
||||
// // // if (!docSnapshot.exists) {
|
||||
// // // docRef.set({
|
||||
// // // occupiedFrom: Date.now(),
|
||||
// // // currentDispatcherName: station.dispatcherName,
|
||||
// // // });
|
||||
// // // return;
|
||||
// // // }
|
||||
// // // });
|
||||
|
||||
// // // const snapshot = await historyRef.get();
|
||||
|
||||
// // // snapshot.forEach(async (doc) => {
|
||||
// // // const docData = doc.data();
|
||||
// // // const docRef = historyRef.doc(doc.id);
|
||||
|
||||
// // // const APIStationData = stationData
|
||||
// // // .filter((station) => station.isOnline && station.region === "eu")
|
||||
// // // .find((station) => station.stationName == doc.id);
|
||||
|
||||
// // // if (docData.currentDispatcherName != "") {
|
||||
// // // if (
|
||||
// // // !APIStationData ||
|
||||
// // // APIStationData.dispatcherName != docData.currentDispatcherName
|
||||
// // // ) {
|
||||
// // // docRef.update({
|
||||
// // // currentDispatcherName: !APIStationData
|
||||
// // // ? ""
|
||||
// // // : APIStationData.dispatcherName,
|
||||
// // // occupiedFrom: !APIStationData ? 0 : Date.now(),
|
||||
// // // });
|
||||
|
||||
// // // docRef.collection("dispatcherHistory").add({
|
||||
// // // currentDispatcherName: docData.currentDispatcherName,
|
||||
// // // occupiedFrom: docData.occupiedFrom,
|
||||
// // // occupiedTo: Date.now(),
|
||||
// // // });
|
||||
// // // }
|
||||
// // // } else if (APIStationData) {
|
||||
// // // docRef.update({
|
||||
// // // currentDispatcherName: APIStationData.dispatcherName,
|
||||
// // // occupiedFrom: Date.now(),
|
||||
// // // });
|
||||
// // // }
|
||||
// // // });
|
||||
// // // });
|
||||
|
||||
@@ -53,8 +53,6 @@ import Loading from "@/components/App/Loading.vue";
|
||||
|
||||
import Clock from "@/components/App/Clock.vue";
|
||||
|
||||
// import firebase from "@/scripts/firebase/firebaseInit";
|
||||
|
||||
@Component({
|
||||
components: { Error, Loading, Clock },
|
||||
})
|
||||
@@ -69,9 +67,6 @@ export default class App extends Vue {
|
||||
|
||||
async mounted() {
|
||||
this.initStations();
|
||||
|
||||
// const getData = firebase.functions.httpsCallable("getHistoryData");
|
||||
// getData().then((res) => console.log(res.data));
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -222,6 +222,14 @@ export default class StationCard extends styleMixin {
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
|
||||
&-exit {
|
||||
img {
|
||||
width: 1.5em;
|
||||
}
|
||||
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&-content {
|
||||
display: grid;
|
||||
grid-template-areas: "main main" "icons icons" "dispatcher hours" "users spawns" "history history";
|
||||
|
||||
@@ -102,9 +102,9 @@
|
||||
class="track no-catenary"
|
||||
:title="'Liczba niezelektryfikowanych szlaków dwutorowych: ' + station.routes.twoWay.noCatenary"
|
||||
>{{station.routes.twoWay.noCatenary}}</span>
|
||||
</td>
|
||||
|
||||
<td class="item-tracks oneway">
|
||||
<span class="separator"></span>
|
||||
|
||||
<span
|
||||
v-if="station.routes && station.routes.oneWay.catenary > 0"
|
||||
class="track catenary"
|
||||
@@ -117,6 +117,8 @@
|
||||
:title="'Liczba niezelektryfikowanych szlaków jednotorowych: ' + station.routes.oneWay.noCatenary"
|
||||
>{{station.routes.oneWay.noCatenary}}</span>
|
||||
</td>
|
||||
|
||||
<!-- <td class="item-tracks oneway"></td> -->
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -147,14 +149,13 @@ export default class StationTable extends styleMixin {
|
||||
|
||||
headTitles: string[][] = [
|
||||
["Stacja"],
|
||||
["Wymagany poz.", "dyżurnego"],
|
||||
["Min. poziom", "dyżurnego"],
|
||||
["Status"],
|
||||
["Dyżurny"],
|
||||
["Poziom", "dyżurnego"],
|
||||
["Maszyniści"],
|
||||
["Informacje", "ogólne"],
|
||||
["Szlaki", "dwutorowe"],
|
||||
["Szlaki", "jednotorowe"],
|
||||
["Szlaki", "2tor | 1tor"],
|
||||
];
|
||||
|
||||
changeSorter(index: number) {
|
||||
@@ -215,6 +216,10 @@ export default class StationTable extends styleMixin {
|
||||
@import "../../styles/variables.scss";
|
||||
@import "../../styles/global.scss";
|
||||
|
||||
.separator {
|
||||
border-left: 3px solid #b3b3b3;
|
||||
}
|
||||
|
||||
.table {
|
||||
&-wrapper {
|
||||
overflow: auto;
|
||||
|
||||
Reference in New Issue
Block a user