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
+194
View File
@@ -0,0 +1,194 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-catalogs'}">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.catalog === '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>
<CInput
:class="validation.fa_title ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_title ? validation.fa_title.msg : null"
v-model="catalog.locale.fa.title"
/>
<CInput
:class="validation.en_title ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_title ? validation.en_title.msg : null"
v-model="catalog.locale.en.title"
/>
<div>
<el-checkbox v-model="catalog.showInFa" label="در نسخه فارسی سایت نمایش داده شود"/>
</div>
<div>
<el-checkbox v-model="catalog.showInEn" label="در نسخه انگلیسی سایت نمایش داده شود"/>
</div>
<el-divider></el-divider>
<p>فایل کاتلوگ:</p>
<input type="file" ref="file">
<p class="text-danger" v-if="validation.file">{{ validation.file.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<p>تصویر</p>
<img :src="catalog.cover" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="cover" @change="preview">
<p class="text-danger" v-if="validation.cover">{{ validation.cover.msg }}</p>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
import axiosUploadProcess from "@/mixins/axiosUploadProcess"
export default {
data() {
return {
catalog: null,
validation: {}
}
},
computed: {
title() {
return this.$route.params.image === 'new' ? 'افزودن کاتالوگ جدید' : 'ویرایش کاتالوگ'
}
},
mixins: [axiosUploadProcess],
methods: {
preview() {
this.catalog.cover = URL.createObjectURL(event.target.files[0])
},
post() {
this.validation = {}
if (!this.$refs.file.files[0]) {
return this.$message({
type: 'error',
message: 'فایل کاتالوگ اجباری میباشد'
})
}
if (!this.$refs.cover.files[0]) {
return this.$message({
type: 'error',
message: 'کاور اجباری میباشد'
})
}
const data = new FormData()
data.append('fa_title', this.catalog.locale.fa.title)
data.append('en_title', this.catalog.locale.en.title)
data.append('showInFa', this.catalog.showInFa)
data.append('showInEn', this.catalog.showInEn)
data.append('file', this.$refs.file.files[0])
data.append('cover', this.$refs.cover.files[0])
this.$axios.post(`/api/admin/catalog`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'کاتالوگ با موفقیت افزوده شد'
})
this.$router.push({name: 'admin-catalogs'})
})
.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_title', this.catalog.locale.fa.title)
data.append('en_title', this.catalog.locale.en.title)
data.append('showInFa', this.catalog.showInFa)
data.append('showInEn', this.catalog.showInEn)
if (this.$refs.file.files[0]) data.append('file', this.$refs.file.files[0])
if (this.$refs.cover.files[0]) data.append('cover', this.$refs.cover.files[0])
this.$axios.put(`/api/admin/catalog/${this.catalog._id}`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
this.$refs.cover.value = null
this.$refs.file.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 {
if (params.catalog !== 'new') {
const catalog = await $axios.get(`/api/public/catalog/${params.catalog}`)
return {
catalog: catalog.data
}
} else {
return {
catalog: {
locale: {
fa: {
title: ''
},
en: {
title: ''
}
},
file: '',
cover: '',
showInFa: true,
showInEn: false
}
}
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+143
View File
@@ -0,0 +1,143 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-catalogs-catalog',params: {catalog: '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="catalogs"
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.cover" alt="" style="width: 100%">
</template>
</el-table-column>
<el-table-column
prop="locale.fa.title"
label="عنوان فارسی"
width="">
</el-table-column>
<el-table-column
prop="locale.en.title"
label="عنوان انگلیسی"
width="">
</el-table-column>
<el-table-column
label="حالت نمایش"
width="">
<template slot-scope="scope">
<b class="text-success" v-if="scope.row.showInFa && scope.row.showInEn">فارسی و انگلیسی</b>
<b class="text-danger" v-if="!scope.row.showInFa && !scope.row.showInEn">نمایش داده نشود</b>
<b class="text-warning" v-if="!scope.row.showInEn && scope.row.showInFa">فارسی</b>
<b class="text-warning" v-if="!scope.row.showInFa && scope.row.showInEn">انگلیسی</b>
</template>
</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-catalogs-catalog',params: {catalog: 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: 'لیست',
catalogs: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/catalog/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'کاتالوگ با موفقیت حذف شد'
})
this.catalogs = this.catalogs.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 catalogs = await $axios.get(`/api/public/catalogs`)
return {
catalogs: catalogs.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>