update:add ci cd files ==> do not edit those file

This commit is contained in:
mahyargdz
2024-10-10 21:49:00 +03:30
parent 6fe34708a2
commit 8cf0492c87
464 changed files with 79533 additions and 0 deletions
+182
View File
@@ -0,0 +1,182 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-gallery'}">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.image === 'new'" size="sm" color="success" class="mr-1" @click="post">افزودن</CButton>
<CButton v-else size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="6">
<CCard>
<CCardBody>
<div>
<p>دسته بندی</p>
<el-select v-model="image.category" filterable :disabled="image.noCategory" :class="validation.category? 'err' : null">
<el-option v-for="item in galleryCategories" :label="item.locale.fa.title" :value="item._id" :key="item._id"/>
</el-select>
<p class="text-danger" v-if="validation.category">{{ validation.category.msg }}</p>
</div>
<div class="mt-3">
<el-checkbox v-model="image.noCategory" label="بدون دسته بندی"/>
</div>
<el-divider></el-divider>
<CInput
:class="validation.fa_caption ? 'err' : null"
label="کپشن فارسی"
:description="validation.fa_caption ? validation.fa_caption.msg : null"
v-model="image.locale.fa.caption"
/>
<CInput
:class="validation.en_caption ? 'err' : null"
label="کپشن انگلیسی"
:description="validation.en_caption ? validation.en_caption.msg : null"
v-model="image.locale.en.caption"
/>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<p>تصویر</p>
<img :src="image.image" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="image" @change="preview">
<p class="text-danger" v-if="validation.image">{{ validation.image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
import axiosUploadProcess from "@/mixins/axiosUploadProcess"
export default {
data() {
return {
galleryCategories: null,
image: null,
validation: {}
}
},
computed: {
title() {
return this.$route.params.image === 'new' ? 'افزودن تصویر جدید' : 'ویرایش تصویر'
}
},
mixins: [axiosUploadProcess],
methods: {
preview() {
this.image.image = URL.createObjectURL(event.target.files[0])
},
post() {
this.validation = {}
const data = new FormData()
data.append('fa_caption', this.image.locale.fa.caption)
data.append('en_caption', this.image.locale.en.caption)
data.append('category', this.image.category)
data.append('noCategory', this.image.noCategory)
data.append('image', this.$refs.image.files[0])
this.$axios.post(`/api/admin/gallery`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'تصویر با موفقیت افزوده شد'
})
this.$router.push({name: 'admin-gallery'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
this.$message({
type: 'error',
message: 'پارامتر هارو بررسی کنید'
})
} else console.log(err.response.data)
})
},
update() {
this.validation = {}
const data = new FormData()
data.append('fa_caption', this.image.locale.fa.caption)
data.append('en_caption', this.image.locale.en.caption)
data.append('category', this.image.category)
data.append('noCategory', this.image.noCategory)
if (this.$refs.image.files[0]) data.append('image', this.$refs.image.files[0])
this.$axios.put(`/api/admin/gallery/${this.image._id}`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
this.$refs.image.value = null
this.$nuxt.refresh()
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
this.$message({
type: 'error',
message: 'پارامتر هارو بررسی کنید'
})
} else console.log(err.response.data)
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
const galleryCategories = await $axios.get(`/api/public/galleryCategories`)
if (params.image !== 'new') {
const image = await $axios.get(`/api/public/galleryImage/${params.image}`)
return {
galleryCategories: galleryCategories.data,
image: image.data
}
} else {
return {
galleryCategories: galleryCategories.data,
image: {
locale: {
fa: {
caption: ''
},
en: {
caption: ''
}
},
image: '',
category: '',
noCategory: false
}
}
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+142
View File
@@ -0,0 +1,142 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-gallery-image',params: {image: 'new'}}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<CRow>
<CCol>
<el-table
:data="galleryImages"
style="width: 100%">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
label="عکس"
width="200">
<template slot-scope="scope">
<img :src="scope.row.thumb" alt="" style="width: 100%">
</template>
</el-table-column>
<el-table-column
label="دسته بندی"
width="">
<template slot-scope="scope">
<span v-if="!scope.row.noCategory">{{ scope.row.category.locale.fa.title }}</span>
<span v-else class="text-danger">بدون دسته بندی</span>
</template>
</el-table-column>
<el-table-column
prop="locale.fa.caption"
label="کپشن فارسی"
width="">
</el-table-column>
<el-table-column
prop="locale.en.caption"
label="کپشن انگلیسی"
width="">
</el-table-column>
<el-table-column
label="ویرایش"
width="110"
align="center">
<template slot-scope="scope">
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
<i class="far fa-trash-alt"></i>
</CButton>
<CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-gallery-image',params: {image: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCol>
</CRow>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست تصاویر گالری',
list_title: 'لیست',
galleryImages: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/gallery/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'تصویر با موفقیت حذف شد'
})
this.galleryImages = this.galleryImages.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const galleryImages = await $axios.get(`/api/public/gallery`)
return {
galleryImages: galleryImages.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>