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
+276
View File
@@ -0,0 +1,276 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-blog-posts'}">برگشت به صفحه قبل</CButton>
<CButton size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="12">
<CCard>
<CCardBody>
<CForm>
<CRow>
<CCol sm="12">
<p>دسته بندی</p>
<el-select v-model="blogPost.category" filterable :class="validation.category? 'err' : null">
<el-option v-for="item in blogCategories" :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>
<el-divider></el-divider>
</CCol>
<div>
<el-checkbox v-model="blogPost.published" label="پست منتشر شود"/>
</div>
</CRow>
</CForm>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<h4>فارسی</h4>
<el-divider></el-divider>
<CInput
:class="validation.fa_title ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_title ? validation.fa_title.msg : null"
v-model="blogPost.locale.fa.title"
/>
<CTextarea
:class="validation.fa_short_description ? 'err' : null"
label="توضیح کوتاه فارسی"
:description="validation.fa_short_description ? validation.fa_short_description.msg : null"
v-model="blogPost.locale.fa.short_description"
/>
<CInput
:class="validation.fa_last_section_image_title ? 'err' : null"
label="عنوان روی تصویر بخش آخر"
:description="validation.fa_last_section_image_title ? validation.fa_last_section_image_title.msg : null"
v-model="blogPost.locale.fa.last_section_image_title"
/>
<CTextarea
:class="validation.fa_last_section_image_description ? 'err' : null"
label="توضیحات روی تصویر بخش آخر"
:description="validation.fa_last_section_image_description ? validation.fa_last_section_image_description.msg : null"
v-model="blogPost.locale.fa.last_section_image_description"
/>
<CInput
:class="validation.fa_last_section_title ? 'err' : null"
label="عنوان زیر تصویر بخش آخر"
:description="validation.fa_last_section_title ? validation.fa_last_section_title.msg : null"
v-model="blogPost.locale.fa.last_section_title"
/>
<CTextarea
:class="validation.fa_last_section_description ? 'err' : null"
label="توضیحات زیر تصویر بخش آخر"
:description="validation.fa_last_section_description ? validation.fa_last_section_description.msg : null"
v-model="blogPost.locale.fa.last_section_description"
/>
<client-only>
<p>توضیحات فارسی</p>
<ckeditor v-model="blogPost.locale.fa.description" :config="editorConfigFa"></ckeditor>
<p class="text-danger" v-if="validation.fa_description">{{ validation.fa_description.msg }}</p>
</client-only>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<h4>انگلیسی</h4>
<el-divider></el-divider>
<CInput
:class="validation.en_title ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_title ? validation.en_title.msg : null"
v-model="blogPost.locale.en.title"
/>
<CTextarea
:class="validation.en_short_description ? 'err' : null"
label="توضیح کوتاه انگلیسی"
:description="validation.en_short_description ? validation.en_short_description.msg : null"
v-model="blogPost.locale.en.short_description"
/>
<CInput
:class="validation.en_last_section_image_title ? 'err' : null"
label="عنوان روی تصویر بخش آخر"
:description="validation.en_last_section_image_title ? validation.en_last_section_image_title.msg : null"
v-model="blogPost.locale.en.last_section_image_title"
/>
<CTextarea
:class="validation.en_last_section_image_description ? 'err' : null"
label="توضیحات روی تصویر بخش آخر"
:description="validation.en_last_section_image_description ? validation.en_last_section_image_description.msg : null"
v-model="blogPost.locale.en.last_section_image_description"
/>
<CInput
:class="validation.en_last_section_title ? 'err' : null"
label="عنوان زیر تصویر بخش آخر"
:description="validation.en_last_section_title ? validation.en_last_section_title.msg : null"
v-model="blogPost.locale.en.last_section_title"
/>
<CTextarea
:class="validation.en_last_section_description ? 'err' : null"
label="توضیحات زیر تصویر بخش آخر"
:description="validation.en_last_section_description ? validation.en_last_section_description.msg : null"
v-model="blogPost.locale.en.last_section_description"
/>
<client-only>
<p>توضیحات انگلیسی</p>
<ckeditor v-model="blogPost.locale.en.description" :config="editorConfigEn"></ckeditor>
<p class="text-danger" v-if="validation.en_description">{{ validation.en_description.msg }}</p>
</client-only>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<p>کاور</p>
<img :src="blogPost.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>
<CCol lg="6">
<CCard>
<CCardBody>
<p>تصویر بخش آخر</p>
<img :src="blogPost.last_section_image" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="last_section_image" @change="preview2">
<p class="text-danger" v-if="validation.last_section_image">{{ validation.last_section_image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="12">
<CCard>
<CCardBody>
<p>آپلود ویدیو</p>
<input type="file" ref="video" placeholder="انتخاب فایل ویدیو"/>
<p class="text-danger" v-if="validation.last_section_image">{{ validation.last_section_image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="12" v-if="blogPost.video">
<CCard>
<CCardBody>
<video class="mt-3" width="100%" height="400" muted controls
:src="blogPost.video"></video>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
import axiosUploadProcess from "@/mixins/axiosUploadProcess"
export default {
data() {
return {
title: 'مشاهده پست',
blogPost: null,
blogCategories: null,
editorConfigFa: {
language: 'en',
extraPlugins: ['bidi', 'justify']
},
editorConfigEn: {
language: 'en',
extraPlugins: ['bidi', 'justify']
},
validation: {}
}
},
mixins: [axiosUploadProcess],
methods: {
preview() {
this.blogPost.cover = URL.createObjectURL(event.target.files[0])
},
preview2() {
this.blogPost.last_section_image = URL.createObjectURL(event.target.files[0])
},
update() {
this.validation = {}
const data = new FormData()
data.append('fa_title', this.blogPost?.locale?.fa?.title || '')
data.append('en_title', this.blogPost?.locale?.en?.title || '')
data.append('fa_description', this.blogPost?.locale?.fa?.description || '')
data.append('en_description', this.blogPost?.locale?.en?.description || '')
data.append('fa_short_description', this.blogPost?.locale?.fa?.short_description || '')
data.append('en_short_description', this.blogPost?.locale?.en?.short_description || '')
data.append('fa_last_section_image_title', this.blogPost?.locale?.fa?.last_section_image_title || '')
data.append('en_last_section_image_title', this.blogPost?.locale?.en?.last_section_image_title || '')
data.append('fa_last_section_image_description', this.blogPost?.locale?.fa?.last_section_image_description || '')
data.append('en_last_section_image_description', this.blogPost?.locale?.en?.last_section_image_description || '')
data.append('fa_last_section_title', this.blogPost?.locale?.fa?.last_section_title || '')
data.append('en_last_section_title', this.blogPost?.locale?.en?.last_section_title || '')
data.append('fa_last_section_description', this.blogPost?.locale?.fa?.last_section_description || '')
data.append('en_last_section_description', this.blogPost?.locale?.en?.last_section_description || '')
data.append('category', this.blogPost.category)
data.append('published', this.blogPost.published)
console.log(this.$refs)
if (this.$refs.cover.files[0]) data.append('cover', this.$refs.cover.files[0])
if (this.$refs.last_section_image.files[0]) data.append('last_section_image', this.$refs.last_section_image.files[0])
if (this.$refs?.video?.files[0]) data.append('video', this.$refs?.video?.files[0])
this.$axios.put(`/api/admin/blogPost/${this.blogPost._id}`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
this.$refs.cover.value = null
this.$refs.last_section_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 blogCategories = await $axios.get(`/api/public/blogCategories`)
const blogPost = await $axios.get(`/api/public/blogPost/${params.post}?noCategory=true`)
return {
blogCategories: blogCategories.data,
blogPost: blogPost.data
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+141
View File
@@ -0,0 +1,141 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-blog-posts-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="blogPosts"
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
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="وضعیت انتشار پست"
>
<template slot-scope="scope">
<span class="text-success" v-if="scope.row.published">منتشر شده</span>
<span class="text-danger" v-else>منتشر نشده</span>
</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-blog-posts-post',params: {post: 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: 'لیست',
blogPosts: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/blogPost/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'پست با موفقیت حذف شد'
})
this.blogPosts = this.blogPosts.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 blogPosts = await $axios.get(`/api/public/blogPosts?getAll=true`)
return {
blogPosts: blogPosts.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>
+114
View File
@@ -0,0 +1,114 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-blog-posts'}">برگشت به صفحه قبل</CButton>
<CButton size="sm" color="success" class="mr-1" @click="post">افزودن</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="fa_title"
/>
<CInput
:class="validation.en_title ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_title ? validation.en_title.msg : null"
v-model="en_title"
/>
</CCol>
</CRow>
</CForm>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<p>کاور</p>
<img :src="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 {
title: 'افزودن پست',
fa_title: '',
en_title: '',
cover: '',
blogCategories: null,
editorConfig: {
language: 'en',
extraPlugins: ['bidi', 'justify']
},
validation: {}
}
},
mixins: [axiosUploadProcess],
methods: {
preview() {
this.cover = URL.createObjectURL(event.target.files[0])
},
post() {
this.validation = {}
const data = new FormData()
data.append('fa_title', this.fa_title)
data.append('en_title', this.en_title)
data.append('cover', this.$refs.cover.files[0])
this.$axios.post(`/api/admin/blogPost`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'پست با موفقیت ایجاد شد.'
})
this.$router.push({name: 'admin-blog-posts-post', params: {post: response.data._id}})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
return this.$message({
type: 'warning',
message: 'پارامتر ها رو بررسی و دوباره تلاش کنید'
})
} else console.log(err.response.data)
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin'
}
</script>