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
+156
View File
@@ -0,0 +1,156 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-blog-categories'}">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.category === '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>
<CForm>
<CRow>
<CCol sm="12">
<CInput
:class="validation.fa_title ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_title ? validation.fa_title.msg : null"
v-model="blogCategory.locale.fa.title"
/>
<CInput
:class="validation.fa_description ? 'err' : null"
label="توضیح فارسی"
:description="validation.fa_description ? validation.fa_description.msg : null"
v-model="blogCategory.locale.fa.description"
/>
<el-divider></el-divider>
<CInput
:class="validation.en_title ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_title ? validation.en_title.msg : null"
v-model="blogCategory.locale.en.title"
/>
<CInput
:class="validation.en_description ? 'err' : null"
label="توضیح انگلیسی"
:description="validation.en_description ? validation.en_description.msg : null"
v-model="blogCategory.locale.en.description"
/>
</CCol>
</CRow>
</CForm>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
export default {
data() {
return {
blogCategory: null,
validation: {}
}
},
computed: {
title() {
return this.$route.params.category === 'new' ? 'افزودن دسته بندی' : 'مشاهده دسته بندی'
}
},
methods: {
post() {
this.validation = {}
const data = {
fa_title: this.blogCategory.locale.fa.title,
en_title: this.blogCategory.locale.en.title,
fa_description: this.blogCategory.locale.fa.description,
en_description: this.blogCategory.locale.en.description
}
this.$axios.post(`/api/admin/blogCategory`, data)
.then(response => {
this.$message({
type: 'success',
message: 'دسته بندی با موفقیت ایجاد شد.'
})
this.$router.push({name: 'admin-blog-categories'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
},
update() {
this.validation = {}
const data = {
fa_title: this.blogCategory.locale.fa.title,
en_title: this.blogCategory.locale.en.title,
fa_description: this.blogCategory.locale.fa.description,
en_description: this.blogCategory.locale.en.description
}
this.$axios.put(`/api/admin/blogCategory/${this.blogCategory._id}`, data)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
if (params.category !== 'new') {
const blogCategory = await $axios.get(`/api/admin/blogCategory/${params.category}`)
return {
blogCategory: blogCategory.data
}
} else {
return {
blogCategory: {
locale: {
fa: {
title: '',
description: ''
},
en: {
title: '',
description: ''
}
}
}
}
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+120
View File
@@ -0,0 +1,120 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-blog-categories-category',params:{category: 'new'}}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<el-table
:data="blogCategories"
style="width: 100%">
<el-table-column
type="index"
label="#">
</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="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-blog-categories-category',params: {category: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست دسته بندی ها',
list_title: 'لیست',
blogCategories: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/blogCategory/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'دسته بندی با موفقیت حذف شد'
})
this.blogCategories = this.blogCategories.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 blogCategories = await $axios.get(`/api/public/blogCategories`)
return {
blogCategories: blogCategories.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>