Skip to content

Commit 2b2628c

Browse files
committed
Basic gallery view and delete photos
1 parent df8dc60 commit 2b2628c

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

src/components/Gallery.vue

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,36 @@
22
<div>
33
<v-app id="inspire">
44
<sidebar></sidebar>
5-
<v-toolbar color="indigo" dark fixed app>
5+
<v-toolbar color="indigo" dark fixed app>
66
<v-toolbar-side-icon @click.stop="toggleSidebar()"></v-toolbar-side-icon>
77
<v-toolbar-title>Galleria</v-toolbar-title>
88
</v-toolbar>
9-
<v-content>Placeholder content</v-content>
9+
<v-content>
10+
Placeholder content {{ photos.length }}
11+
<v-layout>
12+
<v-flex xs12 sm8 offset-sm2>
13+
<v-card>
14+
<v-container grid-list-sm fluid>
15+
<v-layout row wrap>
16+
<v-flex v-for="n in photos.length - 1" :key="n" xs3 d-flex>
17+
<v-card flat tile class="d-flex">
18+
19+
<v-img :src="CBv1+'/photos/'+photos[n].name" aspect-ratio="1" class="grey lighten-2">
20+
<span> {{ photos[n].name }} </span>
21+
<span v-on:click="deletePhoto(photos[n].name)"> Elimina </span>
22+
<v-layout slot="placeholder" fill-height align-center justify-center ma-0>
23+
<v-progress-circular indeterminate color="grey lighten-5"></v-progress-circular>
24+
</v-layout>
25+
</v-img>
26+
</a>
27+
</v-card>
28+
</v-flex>
29+
</v-layout>
30+
</v-container>
31+
</v-card>
32+
</v-flex>
33+
</v-layout>
34+
</v-content>
1035
</v-app>
1136
</div>
1237
</template>
@@ -16,15 +41,43 @@ import sidebar from "../components/Sidebar"
1641
export default {
1742
components: { sidebar },
1843
name: 'HelloWorld',
44+
watch: {
45+
photosN: function() {
46+
this.l = this.photos.length
47+
}
48+
},
49+
mounted() {
50+
this.getPhotos()
51+
},
1952
methods: {
53+
getPhotos: function() {
54+
let axios = this.$axios
55+
let CBv1 = this.$data.CBv1
56+
axios.get(CBv1 + '/photos')
57+
.then(function(response) {
58+
this.$data.photos = response.data
59+
}.bind(this))
60+
},
61+
deletePhoto: function(name) {
62+
let axios = this.$axios
63+
let CBv1 = this.$data.CBv1
64+
axios.delete(CBv1 + '/photos/'+name)
65+
.then(function(response) {
66+
this.getPhotos()
67+
}.bind(this))
68+
},
2069
toggleSidebar: function() {
2170
let currentStatus = this.$store.getters.drawerStatus
2271
this.$store.commit('toggleDrawer', !currentStatus)
2372
}
2473
},
2574
data() {
2675
return {
76+
CB: process.env.CB_ENDPOINT + process.env.APIv2,
77+
CBv1: process.env.CB_ENDPOINT + process.env.APIv1,
78+
photos: [],
2779
drawer: null,
80+
l: null,
2881
};
2982
},
3083
};

0 commit comments

Comments
 (0)