Skip to content

Commit

Permalink
feat(admin): add repair photos gallery button on admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
trollepierre committed Dec 27, 2021
1 parent 16b804f commit 89ddf84
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions front/components/ArticleCard/ArticleCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
@click="updateChapter"/>
<input class="chapter-input" v-model="chapterToRepair"/>
</form>
<app-button
:disabled="isUpdatePhotosClicked"
class="app-button"
:text="$t('repairPhotos')"
@click="updatePhotos"/>
<app-button
:disabled="isUpdateClicked"
class="app-button"
Expand Down Expand Up @@ -67,6 +72,7 @@
import AppButton from '@/components/AppButton/AppButton'
import articlesApi from '../../services/api/articles'
import chaptersApi from '../../services/api/chapters'
import photosApi from '../../services/api/photos'
import notificationsService from '../../services/services/notifications'
import translationsService from '../../services/services/translations'
Expand All @@ -82,6 +88,7 @@
return {
isUpdateClicked: false,
isUpdateChapterClicked: false,
isUpdatePhotosClicked: false,
isDeleteClicked: false,
chapterToRepair: '0',
}
Expand Down Expand Up @@ -133,6 +140,19 @@
})
},
updatePhotos() {
this.disableUpdatePhotosButton()
notificationsService.information(this.$t('syncLaunched'))
photosApi.update(this.article.dropboxId)
.then(() => {
notificationsService.information(this.$t('syncDone'))
})
.then(() => this.goToArticle())
.catch(err => {
notificationsService.error(`${this.$t('syncError')} ${err}`)
})
},
disableUpdateButton() {
this.isUpdateClicked = true
},
Expand All @@ -141,6 +161,10 @@
this.isUpdateChapterClicked = true
},
disableUpdatePhotosButton() {
this.isUpdatePhotosClicked = true
},
deleteArticle() {
this.disableDeleteButton()
notificationsService.information(this.$t('deleteLaunched'))
Expand Down Expand Up @@ -168,6 +192,7 @@
fr: {
repairArticle: 'Réparer l’article',
repairChapter: 'Réparer le chapitre',
repairPhotos: 'Réparer la galerie photo',
deleteArticle: 'Supprimer l’article',
goToArticle: 'Voir l’article',
viewGallery: 'Voir les photos',
Expand All @@ -181,6 +206,7 @@
en: {
repairArticle: 'Repair the article',
repairChapter: 'Repair the chapter',
repairPhotos: 'Repair the image gallery',
deleteArticle: 'Delete the article',
goToArticle: 'Read the article',
viewGallery: 'Discover the pictures',
Expand Down
4 changes: 4 additions & 0 deletions front/services/api/photos.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const PhotosApi = {
fetch(id) {
return apiService.get(`articles/${id}/photos`)
},

update(id) {
return apiService.put(`admin/articles/${id}/photos`)
},
}

export default PhotosApi

0 comments on commit 89ddf84

Please sign in to comment.