lab6 vue
This commit is contained in:
parent
e54fbdb7b7
commit
e5ec216e5b
@ -243,7 +243,7 @@ export default {
|
||||
data() {
|
||||
return{
|
||||
albums: [],
|
||||
URL: "http://localhost:8080/",
|
||||
URL: "http://localhost:8080/api/1.0/",
|
||||
album: new Album(),
|
||||
songs: [],
|
||||
artists: [],
|
||||
@ -255,9 +255,17 @@ export default {
|
||||
getAllInfo: new Object() ,
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
if (localStorage.getItem("token") == null) {
|
||||
this.$router.push("/login");
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getArtistsInAlbum(id){
|
||||
axios.get(this.URL + `album/${id}/getAllArtists`)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + `album/${id}/getAllArtists`)
|
||||
.then(response => {
|
||||
this.artistsInAlbum = response.data;
|
||||
console.log(response.data);
|
||||
@ -267,7 +275,10 @@ export default {
|
||||
});
|
||||
},
|
||||
getArtistsInAlbum(id){
|
||||
axios.get(this.URL + `album/${id}/getAllArtists`)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + `album/${id}/getAllArtists`)
|
||||
.then(response => {
|
||||
this.artistsInAlbum = response.data;
|
||||
console.log(response.data);
|
||||
@ -277,7 +288,10 @@ export default {
|
||||
});
|
||||
},
|
||||
getAlbums(){
|
||||
axios.get(this.URL + "album")
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + "album")
|
||||
.then(response => {
|
||||
this.albums = response.data;
|
||||
console.log(response.data);
|
||||
@ -288,7 +302,10 @@ export default {
|
||||
},
|
||||
addAlbum(album){
|
||||
console.log(this.album);
|
||||
axios.post(this.URL + "album", album)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).post(this.URL + "album", album)
|
||||
.then(() => {
|
||||
this.getAlbums();
|
||||
this.closeModal();
|
||||
@ -298,13 +315,19 @@ export default {
|
||||
});
|
||||
},
|
||||
deleteAlbum(id){
|
||||
axios.delete(this.URL + `album/${id}`)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).delete(this.URL + `album/${id}`)
|
||||
.then(() =>{
|
||||
this.getAlbums();
|
||||
})
|
||||
},
|
||||
editAlbum(album){
|
||||
axios.put(this.URL + `album/${album.id}`, album)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).put(this.URL + `album/${album.id}`, album)
|
||||
.then(() =>{
|
||||
const index = this.albums.findIndex((s) => s.id === album.id);
|
||||
if (index !== -1) {
|
||||
@ -330,7 +353,10 @@ export default {
|
||||
},
|
||||
getSongsFromAlbum(albumId){
|
||||
this.selectedSongs = [];
|
||||
axios.get(this.URL + `album/${albumId}/songs`)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + `album/${albumId}/songs`)
|
||||
.then(response => {
|
||||
this.songs = response.data;
|
||||
console.log(response.data);
|
||||
@ -359,7 +385,10 @@ export default {
|
||||
document.getElementById("ModalForAddSongs").style.display = "none";
|
||||
},
|
||||
saveSongs(id) {
|
||||
axios.post(this.URL + `album/${id}/addSongs`, this.selectedSongs)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).post(this.URL + `album/${id}/addSongs`, this.selectedSongs)
|
||||
.then(() => {
|
||||
this.getSongsFromAlbum(id);
|
||||
this.CloseModalForAddSongs();
|
||||
@ -370,7 +399,10 @@ export default {
|
||||
});
|
||||
},
|
||||
getSongsFromUndefinedAlbum(){
|
||||
axios.get(this.URL + `album/getSongsUndefined`)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + `album/getSongsUndefined`)
|
||||
.then(response => {
|
||||
this.songs = response.data;
|
||||
console.log(response.data);
|
||||
@ -380,7 +412,10 @@ export default {
|
||||
});
|
||||
},
|
||||
deleteSongFromAlbum(id){
|
||||
axios.delete(this.URL + `album/deleteSongFromAlbum/${id}`)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).delete(this.URL + `album/deleteSongFromAlbum/${id}`)
|
||||
.then(() =>{
|
||||
this.getSongsFromAlbum();
|
||||
})
|
||||
@ -411,7 +446,10 @@ export default {
|
||||
this.selectedArtists = [...this.open];
|
||||
},
|
||||
addArtistToAlbum(id, list) {
|
||||
axios
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}})
|
||||
.post(this.URL + `album/${id}/addArtistToAlbum`, list)
|
||||
.then(() => {
|
||||
this.closeModalForAddArtists();
|
||||
@ -423,7 +461,10 @@ export default {
|
||||
});
|
||||
},
|
||||
getArtists(){
|
||||
axios.get(this.URL + "artist")
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + "artist")
|
||||
.then(response => {
|
||||
this.artists = response.data;
|
||||
console.log(response.data);
|
||||
|
@ -66,13 +66,21 @@ export default {
|
||||
data() {
|
||||
return{
|
||||
artists: [],
|
||||
URL: "http://localhost:8080/",
|
||||
URL: "http://localhost:8080/api/1.0/",
|
||||
artist: new Artist(),
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
if (localStorage.getItem("token") == null) {
|
||||
this.$router.push("/login");
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getArtists(){
|
||||
axios.get(this.URL + "artist")
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + "artist")
|
||||
.then(response => {
|
||||
this.artists = response.data;
|
||||
})
|
||||
@ -82,7 +90,10 @@ export default {
|
||||
},
|
||||
addArtist(artist){
|
||||
console.log(artist);
|
||||
axios.post(this.URL + "artist", artist)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).post(this.URL + "artist", artist)
|
||||
.then(() => {
|
||||
this.getArtists();
|
||||
this.closeModal();
|
||||
@ -92,13 +103,19 @@ export default {
|
||||
});
|
||||
},
|
||||
deleteArtist(id){
|
||||
axios.delete(this.URL + `artist/${id}`)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).delete(this.URL + `artist/${id}`)
|
||||
.then(() =>{
|
||||
this.getArtists();
|
||||
})
|
||||
},
|
||||
editArtist(artist){
|
||||
axios.put(this.URL + `artist/${artist.id}`, artist)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).put(this.URL + `artist/${artist.id}`, artist)
|
||||
.then(() =>{
|
||||
const index = this.artists.findIndex((s) => s.id === artist.id);
|
||||
if (index !== -1) {
|
||||
|
@ -47,7 +47,7 @@ export default {
|
||||
name: 'example',
|
||||
data() {
|
||||
return {
|
||||
URL: "http://localhost:8080/",
|
||||
URL: "http://localhost:8080/api/1.0/",
|
||||
name: undefined,
|
||||
albums: [],
|
||||
songs: [],
|
||||
@ -55,13 +55,21 @@ export default {
|
||||
searchResult: new Object(),
|
||||
};
|
||||
},
|
||||
beforeCreate() {
|
||||
if (localStorage.getItem("token") == null) {
|
||||
this.$router.push("/login");
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onInput(event) {
|
||||
this.name = event.target.value;
|
||||
},
|
||||
getByName(name){
|
||||
console.log(name);
|
||||
axios.get(this.URL + `find/get/${name}`)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + `find/get/${name}`)
|
||||
.then(response => {
|
||||
this.searchResult = response.data;
|
||||
console.log(response.data);
|
||||
|
@ -74,7 +74,7 @@ export default {
|
||||
return{
|
||||
songs: [],
|
||||
albums: [],
|
||||
URL: "http://localhost:8080/",
|
||||
URL: "http://localhost:8080/api/1.0/",
|
||||
song: new Song(),
|
||||
editedSong: new Song(),
|
||||
}
|
||||
@ -86,7 +86,12 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
getSongs(){
|
||||
axios.get(this.URL + "song")
|
||||
axios
|
||||
.create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}})
|
||||
.get(this.URL + "song")
|
||||
.then(response => {
|
||||
this.songs = response.data;
|
||||
console.log(response.data);
|
||||
@ -96,7 +101,10 @@ export default {
|
||||
});
|
||||
},
|
||||
getAlbums() {
|
||||
axios.get(this.URL + "song/albums")
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(this.URL + "song/albums")
|
||||
.then(response => {
|
||||
this.albums = response.data;
|
||||
console.log(response.data);
|
||||
@ -109,7 +117,10 @@ export default {
|
||||
console.log(song);
|
||||
song.album = null;
|
||||
console.log(song);
|
||||
axios
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}})
|
||||
.post(this.URL + "song", song)
|
||||
.then(() => {
|
||||
this.getSongs();
|
||||
@ -120,7 +131,10 @@ export default {
|
||||
});
|
||||
},
|
||||
deleteSong(id){
|
||||
axios.delete(this.URL + `song/${id}`)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).delete(this.URL + `song/${id}`)
|
||||
.then(() =>{
|
||||
this.getSongs();
|
||||
})
|
||||
@ -140,7 +154,10 @@ export default {
|
||||
document.getElementById("editModal").style.display = "none";
|
||||
},
|
||||
editSong(song) {
|
||||
axios.put(this.URL + `song/${song.id}`, song)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).put(this.URL + `song/${song.id}`, song)
|
||||
.then(() => {
|
||||
const index = this.songs.findIndex((s) => s.id === song.id);
|
||||
if (index !== -1) {
|
||||
|
@ -24,6 +24,11 @@ export default {
|
||||
users: []
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
if (localStorage.getItem("token") == null) {
|
||||
this.$router.push("/login");
|
||||
}
|
||||
},
|
||||
created(){
|
||||
const getTokenForHeader = function () {
|
||||
return "Bearer " + localStorage.getItem("token");
|
||||
@ -34,7 +39,10 @@ export default {
|
||||
"Authorization": getTokenForHeader(),
|
||||
}
|
||||
};
|
||||
axios.get(`http://localhost:8080`, requestParams)
|
||||
axios .create({
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem("token")
|
||||
}}).get(`http://localhost:8080`, requestParams)
|
||||
.then(response => {
|
||||
this.users = response.data;
|
||||
})
|
||||
|
@ -18,6 +18,7 @@ const routes = [
|
||||
{ path: "/login", component: login},
|
||||
{ path: "/registration", component: registration},
|
||||
{ path: "/error", component: error, meta: { requiresAuth: true }},
|
||||
{ path: "/", component: songs, meta: { requiresAuth: true }},
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
|
@ -17,7 +17,7 @@ public class Album {
|
||||
private String albumName;
|
||||
|
||||
@JsonManagedReference
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "album")
|
||||
@OneToMany(cascade = CascadeType.MERGE, mappedBy = "album")
|
||||
private List<Song> songs;
|
||||
|
||||
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
|
Loading…
x
Reference in New Issue
Block a user