Remove EventModel in frontend
This commit is contained in:
@@ -2,7 +2,7 @@ import axios from "axios"
|
||||
|
||||
let BASE_URL = "http://localhost:3000/bands"
|
||||
|
||||
export async function getAllBands() {
|
||||
export async function fetchAllBands() {
|
||||
return await axios.get(BASE_URL)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export async function fetchConcerts() {
|
||||
return await axios.get(BASE_URL)
|
||||
}
|
||||
|
||||
export async function getConcert(id: number) {
|
||||
export async function fetchConcert(id: number) {
|
||||
if (id != undefined) {
|
||||
return await axios.get(BASE_URL + "/concert/" + id)
|
||||
} else {
|
||||
@@ -14,6 +14,19 @@ export async function getConcert(id: number) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns events with the most concerts
|
||||
*
|
||||
* @param nrOfConcerts Limit number of returned objects
|
||||
*
|
||||
* @returns Limited number of objects with the most concerts in it
|
||||
*/
|
||||
export async function fetchUpcomingConcerts(nrOfConcerts: number) {
|
||||
let url = BASE_URL + "?count=" + nrOfConcerts
|
||||
|
||||
return await axios.get(url)
|
||||
}
|
||||
|
||||
export async function searchConcert(searchTerm: string) {
|
||||
return await axios.get(BASE_URL + '/search?value=' + searchTerm)
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import axios from "axios"
|
||||
|
||||
const BASE_URL = "http://localhost:3000/events"
|
||||
|
||||
/**
|
||||
* Request all events in the database
|
||||
*
|
||||
* @param city Filter by name of city where the concert is
|
||||
* @param genre Filter by genre of the band
|
||||
*
|
||||
* @returns All events which fulfill the params
|
||||
*/
|
||||
export async function fetchEvents(city: string = "", genre: string = "") {
|
||||
let url = BASE_URL + "?"
|
||||
url += (city.length > 0) ? "city=" + city + "&" : ""
|
||||
url += (genre.length > 0) ? "genre=" + genre : ""
|
||||
|
||||
return await axios.get(url)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns events with the most concerts
|
||||
*
|
||||
* @param nrOfEvents Limit number of returned objects
|
||||
*
|
||||
* @returns Limited number of objects with the most concerts in it
|
||||
*/
|
||||
export async function getTopEvents(nrOfEvents: number) {
|
||||
let url = BASE_URL + "?sort=desc&count=" + nrOfEvents
|
||||
|
||||
return await axios.get(url)
|
||||
}
|
||||
|
||||
export async function searchEvent(searchTerm: string) {
|
||||
return await axios.get(BASE_URL + "/search?value=" + searchTerm)
|
||||
}
|
||||
@@ -7,11 +7,10 @@ export async function fetchAllLocations() {
|
||||
}
|
||||
|
||||
export async function getLocation(locationName: string) {
|
||||
console.log(locationName)
|
||||
return await axios.get(BASE_URL + "/location/" + locationName)
|
||||
}
|
||||
|
||||
export async function getTopLocations(nrOfLocations: number) {
|
||||
export async function fetchTopLocations(nrOfLocations: number) {
|
||||
let url = BASE_URL + "?sort=desc&count=" + nrOfLocations
|
||||
|
||||
return await axios.get(url)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BandModel } from "./bandModel";
|
||||
import { ConcertModel } from "./concertModel";
|
||||
import { GenreModel } from "./genreModel"
|
||||
|
||||
/**
|
||||
@@ -7,5 +8,5 @@ import { GenreModel } from "./genreModel"
|
||||
export class BandApiModel extends BandModel {
|
||||
genres: Array<GenreModel> = []
|
||||
rating: number = 0
|
||||
nrOfConcerts: number = 0
|
||||
concerts: Array<ConcertModel> = []
|
||||
}
|
||||
9
software/src/data/models/acts/concertDetailsApiModel.ts
Normal file
9
software/src/data/models/acts/concertDetailsApiModel.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { LocationDetailsApiModel } from "../locations/locationDetailsApiModel";
|
||||
import { BandModel } from "./bandModel";
|
||||
import { ConcertModel } from "./concertModel";
|
||||
|
||||
export class ConcertDetailsApiModel extends ConcertModel {
|
||||
location: LocationDetailsApiModel = new LocationDetailsApiModel()
|
||||
band: BandModel = new BandModel()
|
||||
|
||||
}
|
||||
35
software/src/data/stores/bandStore.ts
Normal file
35
software/src/data/stores/bandStore.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { BandApiModel } from "../models/acts/bandApiModel";
|
||||
import { fetchAllBands, getBand } from "../api/bandApi";
|
||||
import { BandDetailsApiModel } from "../models/acts/bandDetailsApiModel";
|
||||
|
||||
export const useBandStore = defineStore("bandStore", {
|
||||
state: () => ({
|
||||
bands: ref<Array<BandApiModel>>([]),
|
||||
band: ref<BandDetailsApiModel>(new BandDetailsApiModel()),
|
||||
fetchInProgress: ref(false)
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async getBands() {
|
||||
this.fetchInProgress = true
|
||||
|
||||
fetchAllBands()
|
||||
.then(result => {
|
||||
this.bands = result.data
|
||||
this.fetchInProgress = false
|
||||
})
|
||||
},
|
||||
|
||||
async getBand(name: string) {
|
||||
this.fetchInProgress = true
|
||||
|
||||
getBand(name)
|
||||
.then(result => {
|
||||
this.band = result.data
|
||||
this.fetchInProgress = false
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -9,6 +9,7 @@ import { ref } from "vue";
|
||||
import { SelectedSeatModel } from "../models/ordering/selectedSeatModel";
|
||||
import { calcPrice } from "@/scripts/concertScripts";
|
||||
import { BandModel } from "../models/acts/bandModel";
|
||||
import { ConcertModel } from "../models/acts/concertModel";
|
||||
|
||||
export const useBasketStore = defineStore('basketStore', {
|
||||
state: () => ({
|
||||
@@ -50,7 +51,7 @@ export const useBasketStore = defineStore('basketStore', {
|
||||
)
|
||||
},
|
||||
|
||||
moveSeatSelectionsToBasket(event, band: BandModel) {
|
||||
moveSeatSelectionsToBasket(concert: ConcertModel, band: BandModel) {
|
||||
// todo
|
||||
// for (let selectedSeat of this.selectedSeats) {
|
||||
// let itemInBasket: BasketItemModel = this.itemsInBasket.find((basketItem: BasketItemModel) => {
|
||||
|
||||
@@ -1,23 +1,48 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { ConcertApiModel } from "../models/acts/concertApiModel";
|
||||
import { useFeedbackStore } from "./feedbackStore";
|
||||
import { fetchConcerts } from "../api/concertApi";
|
||||
import { fetchConcert, fetchConcerts, fetchUpcomingConcerts } from "../api/concertApi";
|
||||
import { ConcertDetailsApiModel } from "../models/acts/concertDetailsApiModel";
|
||||
|
||||
export const useConcertStore = defineStore("concertStore", {
|
||||
state: () => ({
|
||||
concerts: ref<Array<ConcertApiModel>>([])
|
||||
concerts: ref<Array<ConcertApiModel>>([]),
|
||||
upcomingConcerts: ref<Array<ConcertApiModel>>([]),
|
||||
concert: ref<ConcertDetailsApiModel>(new ConcertDetailsApiModel()),
|
||||
fetchInProgress: ref(false)
|
||||
}),
|
||||
|
||||
actions: {
|
||||
/**
|
||||
* Download all concerts from server
|
||||
*/
|
||||
async getConcerts() {
|
||||
const feedbackStore = useFeedbackStore()
|
||||
feedbackStore.fetchDataFromServerInProgress = true
|
||||
this.fetchInProgress = true
|
||||
|
||||
await fetchConcerts()
|
||||
fetchConcerts()
|
||||
.then(result => {
|
||||
this.concerts = result.data
|
||||
feedbackStore.fetchDataFromServerInProgress = false
|
||||
this.fetchInProgress = false
|
||||
})
|
||||
},
|
||||
|
||||
async getConcert(id: number) {
|
||||
this.fetchInProgress = true
|
||||
|
||||
fetchConcert(id)
|
||||
.then(result => {
|
||||
this.concert = result.data
|
||||
this.fetchInProgress = false
|
||||
})
|
||||
},
|
||||
|
||||
async getUpcomingConcerts() {
|
||||
this.fetchInProgress = true
|
||||
|
||||
fetchUpcomingConcerts(4)
|
||||
.then(result => {
|
||||
this.upcomingConcerts = result.data
|
||||
this.fetchInProgress = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { useFeedbackStore } from "./feedbackStore";
|
||||
import { fetchAllLocations } from "../api/locationApi";
|
||||
import { fetchAllLocations, fetchTopLocations } from "../api/locationApi";
|
||||
import { LocationApiModel } from "../models/locations/locationApiModel";
|
||||
import { CityModel } from "../models/locations/cityModel";
|
||||
import { fetchAllCities } from "../api/cityApi";
|
||||
@@ -9,13 +8,17 @@ import { fetchAllCities } from "../api/cityApi";
|
||||
export const useLocationStore = defineStore("locationStore", {
|
||||
state: () => ({
|
||||
locations: ref<Array<LocationApiModel>>([]),
|
||||
cities: ref<Array<CityModel>>([])
|
||||
topLocations: ref<Array<LocationApiModel>>([]),
|
||||
cities: ref<Array<CityModel>>([]),
|
||||
fetchInProgress: ref(false)
|
||||
}),
|
||||
|
||||
actions: {
|
||||
/**
|
||||
* Download all cities/locations from server
|
||||
*/
|
||||
async getLocations() {
|
||||
const feedbackStore = useFeedbackStore()
|
||||
feedbackStore.fetchDataFromServerInProgress = true
|
||||
this.fetchInProgress = true
|
||||
|
||||
await fetchAllLocations()
|
||||
.then(result => {
|
||||
@@ -25,12 +28,29 @@ export const useLocationStore = defineStore("locationStore", {
|
||||
await fetchAllCities()
|
||||
.then(result => {
|
||||
this.cities = result.data
|
||||
feedbackStore.fetchDataFromServerInProgress = false
|
||||
this.fetchInProgress = false
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Get all locations in a specific city
|
||||
*
|
||||
* @param city City to filter for
|
||||
*
|
||||
* @returns Array of cities which are in the target city
|
||||
*/
|
||||
getLocationsByCity(city: string): Array<LocationApiModel> {
|
||||
return this.locations.filter(location => location.city.name == city)
|
||||
return this.locations.filter((location: LocationApiModel) => {
|
||||
return location.city.name == city
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
async getTopLocations() {
|
||||
await fetchTopLocations(8)
|
||||
.then(result => {
|
||||
this.topLocations = result.data
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -2,14 +2,14 @@ import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { searchBand } from "../api/bandApi";
|
||||
import { searchLocation } from "../api/locationApi";
|
||||
import { searchEvent } from "../api/eventApi";
|
||||
import { searchConcert } from "../api/concertApi";
|
||||
|
||||
export const useSearchStore = defineStore("searchStore", {
|
||||
state: () => ({
|
||||
searchTerm: ref(""),
|
||||
bands: ref(),
|
||||
locations: ref(),
|
||||
events: ref(),
|
||||
concerts: ref(),
|
||||
alreadySearched: ref(false),
|
||||
searchInProgress: ref(false)
|
||||
}),
|
||||
@@ -32,9 +32,9 @@ export const useSearchStore = defineStore("searchStore", {
|
||||
this.locations = result.data
|
||||
})
|
||||
|
||||
await searchEvent(this.searchTerm)
|
||||
await searchConcert(this.searchTerm)
|
||||
.then(result => {
|
||||
this.events = result.data
|
||||
this.concerts = result.data
|
||||
})
|
||||
|
||||
this.searchInProgress = false
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { fetchEvents } from "../api/eventApi";
|
||||
import { fetchAllCities } from "../api/cityApi";
|
||||
import { fetchAllGenres } from "../api/genreApi";
|
||||
import { useFeedbackStore } from "./feedbackStore";
|
||||
import { CityApiModel } from "../models/locations/cityApiModel";
|
||||
import { GenreApiModel } from "../models/acts/genreApiModel";
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export const useShoppingStore = defineStore("shoppingStore", {
|
||||
state: () => ({
|
||||
cities: ref<Array<CityApiModel>>([]),
|
||||
@@ -19,15 +21,6 @@ export const useShoppingStore = defineStore("shoppingStore", {
|
||||
async getEvents() {
|
||||
const feedbackStore = useFeedbackStore()
|
||||
feedbackStore.fetchDataFromServerInProgress = true
|
||||
|
||||
await fetchEvents(
|
||||
this.cityFilterName != null && this.cityFilterName != "undefined" && !this.cityFilterName.startsWith("<") ? this.cityFilterName : "",
|
||||
this.genreFilterName != null && this.genreFilterName != "undefined" && !this.genreFilterName.startsWith("<") ? this.genreFilterName : ""
|
||||
)
|
||||
.then(result => {
|
||||
this.events = result.data
|
||||
feedbackStore.fetchDataFromServerInProgress = false
|
||||
})
|
||||
},
|
||||
|
||||
async getCities() {
|
||||
|
||||
Reference in New Issue
Block a user