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