diff --git a/back/dist/app.js b/back/dist/app.js index 096f6e5..17b88ae 100644 --- a/back/dist/app.js +++ b/back/dist/app.js @@ -1,12 +1,26 @@ import express from 'express'; import { createClient } from 'hafas-client'; import { profile as dbProfile } from 'hafas-client/p/db/index.js'; +import { profile as vbbProfile } from 'hafas-client/p/vbb/index.js'; +import { profile as pkpProfile } from 'hafas-client/p/pkp/index.js'; +import { profile as irishProfile } from 'hafas-client/p/irish-rail/index.js'; +import { profile as oebbProfile } from 'hafas-client/p/oebb/index.js'; +import { profile as luProfile } from 'hafas-client/p/mobiliteit-lu/index.js'; +import { profile as zvvProfile } from 'hafas-client/p/zvv/index.js'; const app = express(); const port = 3000; // Adapt this to your project! createClient() won't work with this string. const userAgent = 'sperwing@sperwing.de'; // create a client with the Deutsche Bahn profile const client = createClient(dbProfile, userAgent); +let clients = new Map(); +clients.set("db", client); +clients.set("vbb", createClient(vbbProfile, userAgent)); +clients.set("zvv", createClient(zvvProfile, userAgent)); +clients.set("pkp", createClient(pkpProfile, userAgent)); +clients.set("irish", createClient(irishProfile, userAgent)); +clients.set("oebb", createClient(oebbProfile, userAgent)); +clients.set("lu", createClient(luProfile, userAgent)); app.use((req, res, next) => { res.append('Access-Control-Allow-Origin', ['*']); res.append('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE'); @@ -14,15 +28,47 @@ app.use((req, res, next) => { next(); }); app.get('/', (req, res) => { - client.journeys('8011167', '8000261', { results: 1 }).then(result => res.send(result)); + client.journeys('8011167', '8000261', { results: 1 }).then(result => res.send(result)).catch(error => res.status(500).send(error)); }); app.get('/searchStation', (req, res) => { - let query = req.query; - client.locations(query.text, { results: 1 }).then(result => res.send({ name: result[0].name, id: result[0].id })); + if (!req.query || !req.query.text) { + res.send([]); + } + else { + let query = req.query; + clients.get((String)(req.query.service)).locations(query.text, { results: 1 }).then(result => res.send({ name: result[0].name, id: result[0].id })).catch(error => res.status(500).send(error)); + } +}); +app.get('/searchStations', (req, res) => { + console.log(req); + if (!req.query || !req.query.text) { + res.send([]); + } + else { + let query = req.query; + try { + clients.get((String)(req.query.service)).locations(query.text, { results: 6 }).then(result => res.send(result.map(entry => { return { name: entry.name, id: entry.id }; }))).catch(error => res.status(500).send(error)); + } + catch (e) { + res.status(500).send(e); + } + } }); app.get('/searchConnection', (req, res) => { - let query = req.query; - client.journeys(query.from, query.to, { results: 5 }).then(result => res.send(result.journeys)).catch(error => res.sendStatus(500)); + if (!req.query || !req.query.from || !req.query.to || !req.query.date || !req.query.service) { + console.log(req.query); + res.send([]); + } + else { + let query = req.query; + let date = new Date((String)(req.query.date)); + try { + clients.get((String)(req.query.service)).journeys(query.from, query.to, { results: 5, departure: date }).then(result => res.send(result.journeys)).catch(error => res.status(500).send(error)); + } + catch (e) { + res.status(500).send(e); + } + } }); app.listen(port, () => { return console.log(`Express is listening at http://localhost:${port}`); diff --git a/back/dist/app.js.map b/back/dist/app.js.map index 8326c71..47e7ad5 100644 --- a/back/dist/app.js.map +++ b/back/dist/app.js.map @@ -1 +1 @@ -{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAA;AACzC,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,4BAA4B,CAAA;AAC/D,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;AACtB,MAAM,IAAI,GAAG,IAAI,CAAC;AAElB,0EAA0E;AAC1E,MAAM,SAAS,GAAG,sBAAsB,CAAA;AAExC,iDAAiD;AACjD,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;AAEjD,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IACvB,GAAG,CAAC,MAAM,CAAC,6BAA6B,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACjD,GAAG,CAAC,MAAM,CA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OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAC,EAAC,OAAO,EAAC,CAAC,EAAE,SAAS,EAAC,IAAI,EAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/L,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC3B,CAAC;IACL,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;IACpB,OAAO,OAAO,CAAC,GAAG,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;AACzE,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/back/src/app.ts b/back/src/app.ts index d77d5d7..40f2299 100644 --- a/back/src/app.ts +++ b/back/src/app.ts @@ -1,6 +1,12 @@ import express from 'express'; -import {createClient} from 'hafas-client' +import {createClient, HafasClient} from 'hafas-client' import {profile as dbProfile} from 'hafas-client/p/db/index.js' +import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' +import {profile as pkpProfile} from 'hafas-client/p/pkp/index.js' +import {profile as irishProfile} from 'hafas-client/p/irish-rail/index.js' +import {profile as oebbProfile} from 'hafas-client/p/oebb/index.js' +import {profile as luProfile} from 'hafas-client/p/mobiliteit-lu/index.js' +import {profile as zvvProfile} from 'hafas-client/p/zvv/index.js' const app = express(); const port = 3000; @@ -9,6 +15,14 @@ const userAgent = 'sperwing@sperwing.de' // create a client with the Deutsche Bahn profile const client = createClient(dbProfile, userAgent) +let clients = new Map(); +clients.set("db", client); +clients.set("vbb", createClient(vbbProfile, userAgent)); +clients.set("zvv", createClient(zvvProfile, userAgent)); +clients.set("pkp", createClient(pkpProfile, userAgent)); +clients.set("irish", createClient(irishProfile, userAgent)); +clients.set("oebb", createClient(oebbProfile, userAgent)); +clients.set("lu", createClient(luProfile, userAgent)); app.use((req, res, next) => { res.append('Access-Control-Allow-Origin', ['*']); @@ -18,15 +32,42 @@ app.use((req, res, next) => { }); app.get('/', (req, res) => { - client.journeys('8011167', '8000261', {results: 1}).then(result => res.send(result)); + client.journeys('8011167', '8000261', {results: 1}).then(result => res.send(result)).catch(error => res.status(500).send(error)); }); app.get('/searchStation', (req, res) => { - let query: any = req.query; - client.locations(query.text, {results:1}).then(result => res.send({name: result[0].name, id:result[0].id})); + if(!req.query || !req.query.text){ + res.send([]); + } else { + let query: any = req.query; + clients.get((String) (req.query.service)).locations(query.text, {results:1}).then(result => res.send({name: result[0].name, id:result[0].id})).catch(error => res.status(500).send(error)); + } +}); +app.get('/searchStations', (req, res) => { + console.log(req) + if(!req.query || !req.query.text){ + res.send([]); + } else { + let query: any = req.query; + try { + clients.get((String) (req.query.service)).locations(query.text, {results:6}).then(result => res.send(result.map(entry => {return {name:entry.name, id:entry.id}}))).catch(error => res.status(500).send(error)); + } catch (e) { + res.status(500).send(e) + } + } }); app.get('/searchConnection', (req, res) => { - let query: any = req.query; - client.journeys(query.from, query.to,{results:5}).then(result => res.send(result.journeys)).catch(error => res.sendStatus(500)); + if(!req.query || !req.query.from || !req.query.to || !req.query.date || !req.query.service){ + console.log(req.query); + res.send([]); + } else { + let query: any = req.query; + let date: Date = new Date((String)(req.query.date)); + try { + clients.get((String) (req.query.service)).journeys(query.from, query.to,{results:5, departure:date}).then(result => res.send(result.journeys)).catch(error => res.status(500).send(error)); + } catch (e) { + res.status(500).send(e) + } + } }); app.listen(port, () => { diff --git a/front/bahnui-front/package-lock.json b/front/bahnui-front/package-lock.json index aeabd3a..4eae6c3 100644 --- a/front/bahnui-front/package-lock.json +++ b/front/bahnui-front/package-lock.json @@ -10,11 +10,17 @@ "dependencies": { "axios": "^1.7.7", "core-js": "^3.8.3", - "vue": "^3.2.13" + "vue": "^3.2.13", + "vuetify": "^3.7.4" }, "devDependencies": { "@babel/core": "^7.12.16", "@babel/eslint-parser": "^7.12.16", + "@fortawesome/fontawesome-free": "^6.7.1", + "@fortawesome/fontawesome-svg-core": "^6.7.1", + "@fortawesome/free-regular-svg-icons": "^6.7.1", + "@fortawesome/free-solid-svg-icons": "^6.7.1", + "@fortawesome/vue-fontawesome": "^3.0.8", "@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-eslint": "~5.0.0", "@vue/cli-service": "~5.0.0", @@ -1738,6 +1744,70 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@fortawesome/fontawesome-common-types": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.7.1.tgz", + "integrity": "sha512-gbDz3TwRrIPT3i0cDfujhshnXO9z03IT1UKRIVi/VEjpNHtSBIP2o5XSm+e816FzzCFEzAxPw09Z13n20PaQJQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/@fortawesome/fontawesome-free": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.7.1.tgz", + "integrity": "sha512-ALIk/MOh5gYe1TG/ieS5mVUsk7VUIJTJKPMK9rFFqOgfp0Q3d5QiBXbcOMwUvs37fyZVCz46YjOE6IFeOAXCHA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/@fortawesome/fontawesome-svg-core": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.7.1.tgz", + "integrity": "sha512-8dBIHbfsKlCk2jHQ9PoRBg2Z+4TwyE3vZICSnoDlnsHA6SiMlTwfmW6yX0lHsRmWJugkeb92sA0hZdkXJhuz+g==", + "dev": true, + "dependencies": { + "@fortawesome/fontawesome-common-types": "6.7.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@fortawesome/free-regular-svg-icons": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/@fortawesome/free-regular-svg-icons/-/free-regular-svg-icons-6.7.1.tgz", + "integrity": "sha512-e13cp+bAx716RZOTQ59DhqikAgETA9u1qTBHO3e3jMQQ+4H/N1NC1ZVeFYt1V0m+Th68BrEL1/X6XplISutbXg==", + "dev": true, + "dependencies": { + "@fortawesome/fontawesome-common-types": "6.7.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@fortawesome/free-solid-svg-icons": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-6.7.1.tgz", + "integrity": "sha512-BTKc0b0mgjWZ2UDKVgmwaE0qt0cZs6ITcDgjrti5f/ki7aF5zs+N91V6hitGo3TItCFtnKg6cUVGdTmBFICFRg==", + "dev": true, + "dependencies": { + "@fortawesome/fontawesome-common-types": "6.7.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@fortawesome/vue-fontawesome": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/@fortawesome/vue-fontawesome/-/vue-fontawesome-3.0.8.tgz", + "integrity": "sha512-yyHHAj4G8pQIDfaIsMvQpwKMboIZtcHTUvPqXjOHyldh1O1vZfH4W03VDPv5RvI9P6DLTzJQlmVgj9wCf7c2Fw==", + "dev": true, + "peerDependencies": { + "@fortawesome/fontawesome-svg-core": "~1 || ~6", + "vue": ">= 3.0.0 < 4" + } + }, "node_modules/@hapi/hoek": { "version": "9.3.0", "resolved": "https://registry.npmmirror.com/@hapi/hoek/-/hoek-9.3.0.tgz", @@ -10530,6 +10600,35 @@ "integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==", "dev": true }, + "node_modules/vuetify": { + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/vuetify/-/vuetify-3.7.4.tgz", + "integrity": "sha512-Y8UU5wUDQXC3oz2uumPb8IOdvB4XMCxtxnmqdOc+LihNuPlkSgxIwf92ndRzbOtJFKHsggFUxpyLqpQp+A+5kg==", + "engines": { + "node": "^12.20 || >=14.13" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/johnleider" + }, + "peerDependencies": { + "typescript": ">=4.7", + "vite-plugin-vuetify": ">=1.0.0", + "vue": "^3.3.0", + "webpack-plugin-vuetify": ">=2.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "vite-plugin-vuetify": { + "optional": true + }, + "webpack-plugin-vuetify": { + "optional": true + } + } + }, "node_modules/watchpack": { "version": "2.4.2", "resolved": "https://registry.npmmirror.com/watchpack/-/watchpack-2.4.2.tgz", diff --git a/front/bahnui-front/package.json b/front/bahnui-front/package.json index ddc74a9..b7525d4 100644 --- a/front/bahnui-front/package.json +++ b/front/bahnui-front/package.json @@ -10,11 +10,17 @@ "dependencies": { "axios": "^1.7.7", "core-js": "^3.8.3", - "vue": "^3.2.13" + "vue": "^3.2.13", + "vuetify": "^3.7.4" }, "devDependencies": { "@babel/core": "^7.12.16", "@babel/eslint-parser": "^7.12.16", + "@fortawesome/fontawesome-free": "^6.7.1", + "@fortawesome/fontawesome-svg-core": "^6.7.1", + "@fortawesome/free-regular-svg-icons": "^6.7.1", + "@fortawesome/free-solid-svg-icons": "^6.7.1", + "@fortawesome/vue-fontawesome": "^3.0.8", "@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-eslint": "~5.0.0", "@vue/cli-service": "~5.0.0", diff --git a/front/bahnui-front/src/App.vue b/front/bahnui-front/src/App.vue index 3be916a..22f45f7 100644 --- a/front/bahnui-front/src/App.vue +++ b/front/bahnui-front/src/App.vue @@ -1,15 +1,15 @@ diff --git a/front/bahnui-front/src/assets/logos/bvg_berlin.svg b/front/bahnui-front/src/assets/logos/bvg_berlin.svg new file mode 100644 index 0000000..64f6d57 --- /dev/null +++ b/front/bahnui-front/src/assets/logos/bvg_berlin.svg @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/front/bahnui-front/src/components/HelloWorld.vue b/front/bahnui-front/src/components/HelloWorld.vue deleted file mode 100644 index 879051a..0000000 --- a/front/bahnui-front/src/components/HelloWorld.vue +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - diff --git a/front/bahnui-front/src/components/routing.vue b/front/bahnui-front/src/components/routing.vue index 6704082..1f443a5 100644 --- a/front/bahnui-front/src/components/routing.vue +++ b/front/bahnui-front/src/components/routing.vue @@ -1,25 +1,20 @@ @@ -343,8 +99,13 @@ width:100px; font-family:"Raveo-display-bold"; align-content: center; - margin-top:10px; - margin-bottom:10px + display:inline-flex; + width:max-content; + } + .linenameinner { + padding-left: 10px; + padding-right: 10px; + margin: 15px; } .operator { diff --git a/front/bahnui-front/src/components/search.vue b/front/bahnui-front/src/components/search.vue new file mode 100644 index 0000000..f78a760 --- /dev/null +++ b/front/bahnui-front/src/components/search.vue @@ -0,0 +1,270 @@ + + + + + diff --git a/front/bahnui-front/src/lib/operators.js b/front/bahnui-front/src/lib/operators.js new file mode 100644 index 0000000..11435c9 --- /dev/null +++ b/front/bahnui-front/src/lib/operators.js @@ -0,0 +1,171 @@ +let operatorfunctions = { + getOperatorLogo(operator){ + if (!operator){ + return (null); + } else if (operator.id.startsWith("db-regio") || operator.id === "regionalverkehr-alb-bodensee"){ + return new URL('../assets/logos/dbregio.svg', import.meta.url); + } else if (operator.id.startsWith("db-")){ + return new URL('../assets/logos/db.svg', import.meta.url); + } else if (operator.id === "national-express"){ + return new URL('../assets/logos/nationalexpress.svg', import.meta.url); + } else if (operator.id === "eurobahn"){ + return new URL('../assets/logos/eurobahn.svg', import.meta.url); + } else if (operator.id === "schweizerische-bundesbahnen" || operator.id === "sbb-gmbh"){ + return new URL('../assets/logos/sbb.svg', import.meta.url); + } else if (operator.id === "verkehrsbetriebe-zurich"){ + return new URL('../assets/logos/vbz.svg', import.meta.url); + } else if (operator.id === "thurbo"){ + return new URL('../assets/logos/thurbo.svg', import.meta.url); + } else if (operator.id === "arverio-baden-wurttemberg"){ + return new URL('../assets/logos/avi-bw.svg', import.meta.url); + } else if (operator.id === "arverio-bayern"){ + return new URL('../assets/logos/avi-by.svg', import.meta.url); + } else if (operator.id === "euskotren"){ + return new URL('../assets/logos/euskotren.svg', import.meta.url); + } else if (operator.id.startsWith("arriva")){ + return new URL('../assets/logos/arriva.svg', import.meta.url); + } else if (operator.id.startsWith("abellio")){ + return new URL('../assets/logos/abellio.png', import.meta.url); + } else if (operator.id === "nederlandse-spoorwegen"){ + return new URL('../assets/logos/ns.svg', import.meta.url); + } else if (operator.id === "blauwnet"){ + return new URL('../assets/logos/blauwnet.png', import.meta.url); + } else if (operator.id === "waldbahn-die-landerbahn-gmbh-dlb"){ + return new URL('../assets/logos/waldbahn.png', import.meta.url); + } else if (operator.id === "ostdeutsche-eisenbahn-gmbh"){ + return new URL('../assets/logos/odeg.svg', import.meta.url); + } else if (operator.id === "trenitalia"){ + return new URL('../assets/logos/trenitalia.svg', import.meta.url); + } else if (operator.id === "osterreichische-bundesbahnen"){ + return new URL('../assets/logos/oebb.svg', import.meta.url); + } else if (operator.id === "sj"){ + return new URL('../assets/logos/sj.svg', import.meta.url); + } else if (operator.id === "vy"){ + return new URL('../assets/logos/vy.svg', import.meta.url); + } else if (operator.id === "danische-staatsbahnen"){ + return new URL('../assets/logos/dsb.png', import.meta.url); + } else if (operator.id === "skanetrafiken-oresundstag"){ + return new URL('../assets/logos/oresundtag.svg', import.meta.url); + } else if (operator.id === "schweizerische-sudostbahn-sob"){ + return new URL('../assets/logos/sob.svg', import.meta.url); + } else if (operator.id === "sncf"){ + return new URL('../assets/logos/sncf.svg', import.meta.url); + } else if (operator.id === "mitteldeutsche-regiobahn"){ + return new URL('../assets/logos/mrb.svg', import.meta.url); + } else if (operator.id === "cp"){ + return new URL('../assets/logos/cp-pt.svg', import.meta.url); + } else if (operator.id === "renfe"){ + return new URL('../assets/logos/renfe.svg', import.meta.url); + } else if (operator.id.startsWith("sncf-voyages")){ + return new URL('../assets/logos/sncf-voyageurs.svg', import.meta.url); + } else if (operator.id === "pkp-intercity"){ + return new URL('../assets/logos/pkp-i.svg', import.meta.url); + } else if (operator.id === "bayerische-regiobahn"){ + return new URL('../assets/logos/brb.svg', import.meta.url); + } else if (operator.id === "postauto-schweiz"){ + return new URL('../assets/logos/postauto.svg', import.meta.url); + } else if (operator.id === "lner-london-north-eastern-railway"){ + return new URL('../assets/logos/lner.svg', import.meta.url); + } else if (operator.id === "eurostar"){ + return new URL('../assets/logos/eurostar.svg', import.meta.url); + } else if (operator.id === "european-sleeper"){ + return new URL('../assets/logos/europesleep.svg', import.meta.url); + } else if (operator.id === "ceske-drahy"){ + return new URL('../assets/logos/cd.svg', import.meta.url); + } else if (operator.id === "mav"){ + return new URL('../assets/logos/mav.svg', import.meta.url); + } else if (operator.id === "serbische-eisenbahnen-zeleznice-srbije"){ + return new URL('../assets/logos/zsrbije.png', import.meta.url); + } else if (operator.id === "sncb"){ + return new URL('../assets/logos/sncb.svg', import.meta.url); + } else if (operator.id === "cfl"){ + return new URL('../assets/logos/cfl.svg', import.meta.url); + } else if (operator.id.startsWith("s-bahn-berlin")){ + return new URL('../assets/logos/sbahnberlin.svg', import.meta.url); + } else if (operator.id === "rhatische-bahn"){ + return new URL('../assets/logos/rhb.svg', import.meta.url); + } else if (operator.id === "matterhorn-gotthard-bahn-bvz"){ + return new URL('../assets/logos/mgb.svg', import.meta.url); + } else if (operator.id === "s-bahn-hamburg"){ + return new URL('../assets/logos/sbahnhamburg.png', import.meta.url); + } else if (operator.id === "akn-eisenbahn-gmbh"){ + return new URL('../assets/logos/akn.svg', import.meta.url); + } else if (operator.id === "wurttembergische-eisenbahn-gesellschaft-mbh"){ + return new URL('../assets/logos/weg.svg', import.meta.url); + } else if (operator.id === "wynental-und-suhrental-bahn" || operator.id === "bdwm-transport"){ + return new URL('../assets/logos/ava.svg', import.meta.url); + } else if (operator.id === "appenzeller-bahnen"){ + return new URL('../assets/logos/ab.svg', import.meta.url); + } else if (operator.id === "agilis"){ + return new URL('../assets/logos/agilis.svg', import.meta.url); + } else if (operator.id === "hzpp"){ + return new URL('../assets/logos/hzpp.png', import.meta.url); + } else if (operator.id === "obb-postbus"){ + return new URL('../assets/logos/oebb-postbus.png', import.meta.url); + } else if (operator.id === "snalltaget"){ + return new URL('../assets/logos/snalltaget.svg', import.meta.url); + } else if (operator.id === "schwabische-alb-bahn"){ + return new URL('../assets/logos/sab.svg', import.meta.url); + } else if (operator.id.startsWith("sweg-bahn")){ + return new URL('../assets/logos/sweg.svg', import.meta.url); + } else if (operator.id === "ferrocarils-de-la-generalitat-de-catalunya"){ + return new URL('../assets/logos/fgc.svg', import.meta.url); + } else if (operator.id === "albtal-verkehrs-gesellschaft-mbh"){ + return new URL('../assets/logos/avg.svg', import.meta.url); + } else if (operator.id === "westfalenbahn"){ + return new URL('../assets/logos/wfb.png', import.meta.url); + } else if (operator.id === "coras-iompair-eireann"){ + return new URL('../assets/logos/cie.svg', import.meta.url); + } else if (operator.id === "avanti-west-coast"){ + return new URL('../assets/logos/avantiwc.svg', import.meta.url); + } else if (operator.id === "koleje-dolnoslaskie"){ + return new URL('../assets/logos/kolejed.svg', import.meta.url); + } else if (operator.id === "trilex-express-die-landerbahn-gmbh-dlb"){ + return new URL('../assets/logos/trilex.png', import.meta.url); + } else if (operator.id === "polregio"){ + return new URL('../assets/logos/polregio.svg', import.meta.url); + } else if (operator.id === "bayerische-zugspitzbahn"){ + return new URL('../assets/logos/zugspitze.svg', import.meta.url); + } else if (operator.id === "rigi-bahnen"){ + return new URL('../assets/logos/rigi.svg', import.meta.url); + } else if (operator.id === "regionalverkehr-bern-solothurn"){ + return new URL('../assets/logos/rbs.svg', import.meta.url); + } else if (operator.id === "zentralbahn"){ + return new URL('../assets/logos/zb.svg', import.meta.url); + } else if (operator.id === "bls-ag"){ + return new URL('../assets/logos/bernmobil.svg', import.meta.url); + } else if (operator.id === "westbahn"){ + return new URL('../assets/logos/westbahn.svg', import.meta.url); + } else if (operator.id === "northern"){ + return new URL('../assets/logos/northern.svg', import.meta.url); + } else if (operator.id === "south-eastern"){ + return new URL('../assets/logos/southeastern.svg', import.meta.url); + } else if (operator.id === "hull-trains"){ + return new URL('../assets/logos/hulltrains.svg', import.meta.url); + } else if (operator.id === "schweizerische-bodensee-schiffahrtsgesellschaft"){ + return new URL('../assets/logos/bodenseech.png', import.meta.url); + } else if (operator.id === "bodensee-schiffsbetriebe"){ + return new URL('../assets/logos/bsb.svg', import.meta.url); + } else if (operator.id === "regiojet"){ + return new URL('../assets/logos/regiojet.svg', import.meta.url); + } else if (operator.id === "edzards-reisen"){ + return new URL('../assets/logos/edzards.svg', import.meta.url); + } else if (operator.id === "vlexx"){ + return new URL('../assets/logos/vlexx.png', import.meta.url); + } else if (operator.id === "nordwestbahn"){ + return new URL('../assets/logos/nordwestbahn.svg', import.meta.url); + } else if (operator.id === "caledonian-macbrayne-ferries"){ + return new URL('../assets/logos/caledonian-macbrayne.svg', import.meta.url); + } else if (operator.id === "caledonian-sleeper"){ + return new URL('../assets/logos/caledonian-sleeper.png', import.meta.url); + } else if (operator.id === "mecklenburgische-baderbahn-molli"){ + return new URL('../assets/logos/molli.svg', import.meta.url); + } else if (operator.id === "berliner-verkehrsbetriebe"){ + return new URL('../assets/logos/bvg_berlin.svg', import.meta.url); + } else { + console.log(operator.id); + return (null); + } + } +} +export default operatorfunctions; diff --git a/front/bahnui-front/src/lib/routes.js b/front/bahnui-front/src/lib/routes.js new file mode 100644 index 0000000..360bc5c --- /dev/null +++ b/front/bahnui-front/src/lib/routes.js @@ -0,0 +1,22 @@ +let routefunctions = { + getLineColors(line){ + if (!line){ + return (['black', 'white']); + } else if (line.productName === "STB"){ + return (['white', 'blue']); + } else if (line.productName === "S"){ + return (['white', 'green']); + } else if (line.productName === "RE" || line.productName === "RB"){ + return (['white', 'red']); + } else if (line.productName === "IC" || line.productName === "ICE"){ + return (['red', 'white']); + } else if (line.productName === "EC" || line.productName === "ECE"){ + return (['blue', 'white']); + } else if (line.productName === "MEX"){ + return (['black', 'yellow']); + } else { + return (['black', 'white']); + } + } +} +export default routefunctions; diff --git a/front/bahnui-front/src/lib/time.js b/front/bahnui-front/src/lib/time.js new file mode 100644 index 0000000..4d0053e --- /dev/null +++ b/front/bahnui-front/src/lib/time.js @@ -0,0 +1,55 @@ +const timecolors = [ + {r:147, g:147, b:147, h:0}, + {r:156, g:151, b:146, h:1}, + {r:166, g:155, b:145, h:2}, + {r:175, g:163, b:149, h:3}, + {r:201, g:177, b:153, h:4}, + {r:235, g:212, b:165, h:5}, + {r:249, g:230, b:176, h:6}, + {r:250, g:249, b:196, h:7}, + {r:248, g:255, b:208, h:8}, + {r:237, g:255, b:226, h:9}, + {r:239, g:255, b:242, h:10}, + {r:231, g:255, b:251, h:11}, + {r:220, g:249, b:255, h:12}, + {r:220, g:236, b:255, h:13}, + {r:224, g:219, b:254, h:14}, + {r:243, g:209, b:254, h:15}, + {r:247, g:190, b:236, h:16}, + {r:243, g:175, b:203, h:17}, + {r:234, g:163, b:183, h:18}, + {r:226, g:163, b:190, h:19}, + {r:206, g:160, b:200, h:20}, + {r:178, g:153, b:190, h:21}, + {r:159, g:152, b:178, h:22}, + {r:146, g:146, b:167, h:23}] + +let timefunctions = { + getTimeColor(string){ + let date = new Date(string); + let color1; + let color2; + let minutes; + + let i = 0; + color1 = timecolors[i]; + color2 = timecolors[i+1]; + while (color1.h < date.getHours() && i+1 < timecolors.length){ + i++; + color1 = timecolors[i]; + if (i+2 < timecolors.length) { + color2 = timecolors[i+1]; + } else { + color2 = timecolors[0]; + } + } + minutes = (date.getHours()-color1.h) * 60 + date.getMinutes(); + let maxMinutes = color2.h == 0 ? (24 - color1.h)*60 : (color2.h - color1.h)*60 + let r = (color2.r * minutes + color1.r * (maxMinutes-minutes))/maxMinutes; + let g = (color2.g * minutes + color1.g * (maxMinutes-minutes))/maxMinutes; + let b = (color2.r * minutes + color1.b * (maxMinutes-minutes))/maxMinutes; + let color = "rgb("+r+","+g+","+b+")" + return color; + } +} +export default timefunctions; \ No newline at end of file diff --git a/front/bahnui-front/src/main.js b/front/bahnui-front/src/main.js index 01433bc..9cf4b0d 100644 --- a/front/bahnui-front/src/main.js +++ b/front/bahnui-front/src/main.js @@ -1,4 +1,35 @@ import { createApp } from 'vue' import App from './App.vue' -createApp(App).mount('#app') + +// Vuetify +import 'vuetify/styles' +import { createVuetify } from 'vuetify' +import * as components from 'vuetify/components' +import * as directives from 'vuetify/directives' +import '@fortawesome/fontawesome-free/css/all.css' // Ensure your project is capable of handling css files +import { aliases, fa } from 'vuetify/iconsets/fa-svg' +import { library } from '@fortawesome/fontawesome-svg-core' +import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' +import { fas } from '@fortawesome/free-solid-svg-icons' +import { far } from '@fortawesome/free-regular-svg-icons' + +const app = createApp(App) + +app.component('font-awesome-icon', FontAwesomeIcon) // Register component globally +library.add(fas) // Include needed solid icons +library.add(far) // Include needed regular icons + +const vuetify = createVuetify({ + components, + directives, + icons: { + defaultSet: 'fa', + aliases, + sets: { + fa, + }, + }, +}) + +app.use(vuetify).mount('#app') diff --git a/front/package.json b/front/package.json new file mode 100644 index 0000000..6adc1cf --- /dev/null +++ b/front/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "vuetify": "^3.7.4" + } +}