update:add ci cd files ==> do not edit those file
This commit is contained in:
@@ -0,0 +1,213 @@
|
||||
<template>
|
||||
<div>
|
||||
<CustomSubHeader>
|
||||
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
|
||||
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-slider'}">برگشت به صفحه قبل</CButton>
|
||||
<CButton v-if="$route.params.slide === '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>-->
|
||||
<!-- <h4 class="mt-5">فارسی</h4>-->
|
||||
<!-- <el-divider></el-divider>-->
|
||||
<!-- <CInput-->
|
||||
<!-- :class="validation.fa_name ? 'err' : null"-->
|
||||
<!-- label="نام فارسی"-->
|
||||
<!-- :description="validation.fa_name ? validation.fa_name.msg : null"-->
|
||||
<!-- v-model="slide.locale.fa.name"-->
|
||||
<!-- />-->
|
||||
<!-- <CInput-->
|
||||
<!-- :class="validation.fa_position ? 'err' : null"-->
|
||||
<!-- label="سمت فارسی"-->
|
||||
<!-- :description="validation.fa_position ? validation.fa_position.msg : null"-->
|
||||
<!-- v-model="slide.locale.fa.position"-->
|
||||
<!-- />-->
|
||||
<!-- <CTextarea-->
|
||||
<!-- :class="validation.fa_slide ? 'err' : null"-->
|
||||
<!-- label="کامنت فارسی"-->
|
||||
<!-- :description="validation.fa_slide ? validation.fa_slide.msg : null"-->
|
||||
<!-- v-model="slide.locale.fa.slide"-->
|
||||
<!-- />-->
|
||||
|
||||
|
||||
<!-- <h4 class="mt-5">انگلیسی</h4>-->
|
||||
<!-- <el-divider></el-divider>-->
|
||||
<!-- <CInput-->
|
||||
<!-- :class="validation.en_name ? 'err' : null"-->
|
||||
<!-- label="نام انگلیسی"-->
|
||||
<!-- :description="validation.en_name ? validation.en_name.msg : null"-->
|
||||
<!-- v-model="slide.locale.en.name"-->
|
||||
<!-- />-->
|
||||
<!-- <CInput-->
|
||||
<!-- :class="validation.en_position ? 'err' : null"-->
|
||||
<!-- label="سمت انگلیسی"-->
|
||||
<!-- :description="validation.en_position ? validation.en_position.msg : null"-->
|
||||
<!-- v-model="slide.locale.en.position"-->
|
||||
<!-- />-->
|
||||
<!-- <CTextarea-->
|
||||
<!-- :class="validation.en_slide ? 'err' : null"-->
|
||||
<!-- label="کامنت انگلیسی"-->
|
||||
<!-- :description="validation.en_slide ? validation.en_slide.msg : null"-->
|
||||
<!-- v-model="slide.locale.en.slide"-->
|
||||
<!-- />-->
|
||||
|
||||
<!-- </CForm>-->
|
||||
<!-- </CCardBody>-->
|
||||
<!-- </CCard>-->
|
||||
<!-- </CCol>-->
|
||||
<CCol sm="12">
|
||||
<CCard>
|
||||
<CCardBody>
|
||||
<el-switch style="direction: ltr" v-model="slide.isImage" active-text="عکس" inactive-text="ویدیو" inactive-color="#ff4949"></el-switch>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
</CCol>
|
||||
<CCol v-if="slide.isImage" lg="6">
|
||||
<CCard>
|
||||
<CCardBody>
|
||||
<h2>عکس</h2>
|
||||
<el-divider></el-divider>
|
||||
<img :src="slide.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>
|
||||
<CCol v-else lg="6">
|
||||
<CCard>
|
||||
<CCardBody>
|
||||
<h2>ویدیو</h2>
|
||||
<el-divider></el-divider>
|
||||
<video :src="slide.video" style="width: 100%;max-width: 600px;" controls muted autoplay></video>
|
||||
<input type="file" ref="video" @change="preview2">
|
||||
<p class="text-danger" v-if="validation.video">{{ validation.video.msg }}</p>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
</CCol>
|
||||
</CRow>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axiosUploadProcess from "~/mixins/axiosUploadProcess"
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
slide: null,
|
||||
validation: {}
|
||||
}
|
||||
},
|
||||
mixins: [axiosUploadProcess],
|
||||
computed: {
|
||||
title() {
|
||||
return this.$route.params.slide === 'new' ? 'افزودن اسلاید جدید' : 'مشاهده اطلاعات اسلاید'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
preview() {
|
||||
this.slide.image = URL.createObjectURL(event.target.files[0])
|
||||
},
|
||||
preview2() {
|
||||
this.slide.video = URL.createObjectURL(event.target.files[0])
|
||||
},
|
||||
post() {
|
||||
this.validation = {}
|
||||
|
||||
const data = new FormData()
|
||||
data.append('isImage', this.slide.isImage)
|
||||
|
||||
if (this.slide.isImage) data.append('image', this.$refs.image.files[0])
|
||||
else data.append('video', this.$refs.video.files[0])
|
||||
|
||||
this.$axios.post(`/api/admin/slide`, data, this.axiosConfig)
|
||||
.then(response => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: 'اسلاید با موفقیت ایجاد شد.'
|
||||
})
|
||||
this.$router.push({name: 'admin-slider'})
|
||||
})
|
||||
.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)
|
||||
})
|
||||
},
|
||||
// update() {
|
||||
// this.validation = {}
|
||||
// const data = new FormData()
|
||||
// data.append('fa_name', this.slide.locale.fa.name)
|
||||
// data.append('en_name', this.slide.locale.en.name)
|
||||
//
|
||||
// data.append('fa_position', this.slide.locale.fa.position)
|
||||
// data.append('en_position', this.slide.locale.en.position)
|
||||
//
|
||||
// data.append('fa_slide', this.slide.locale.fa.slide)
|
||||
// data.append('en_slide', this.slide.locale.en.slide)
|
||||
//
|
||||
// if (this.$refs.image.files[0]) data.append('image', this.$refs.image.files[0])
|
||||
//
|
||||
// this.$axios.put(`/api/admin/slide/${this.slide._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
|
||||
// else console.log(err.response.data)
|
||||
// })
|
||||
// }
|
||||
},
|
||||
head() {
|
||||
return {
|
||||
title: this.title
|
||||
}
|
||||
},
|
||||
layout: 'admin',
|
||||
async asyncData({$axios, params, error}) {
|
||||
try {
|
||||
if (params.slide !== 'new') {
|
||||
const slide = await $axios.get(`/api/public/slide/${params.slide}`)
|
||||
return {
|
||||
slide: slide.data
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
slide: {
|
||||
isImage: true,
|
||||
image: '',
|
||||
video: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
error({status: 404, message: 'page not found'})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<div>
|
||||
<CustomSubHeader>
|
||||
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
|
||||
<CButton size="sm" color="success" :to="{name: 'admin-slider-slide',params:{slide: '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="slides"
|
||||
style="width: 100%">
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="#">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="مدیا"
|
||||
width="250">
|
||||
<template slot-scope="scope">
|
||||
<img v-if="scope.row.isImage" :src="scope.row.image" alt="" style="width: 100%;">
|
||||
<video v-else :src="scope.row.video" style="width: 100%;" controls muted></video>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="نوع"
|
||||
width="">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.isImage">عکس</span>
|
||||
<span 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-slider-slide',params: {slide: 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: 'لیست',
|
||||
slides: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
remove(id) {
|
||||
this.$confirm('این مورد حذف شود؟', 'هشدار', {
|
||||
confirmButtonText: 'بله',
|
||||
cancelButtonText: 'لغو',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
this.$axios.delete(`/api/admin/slide/${id}`)
|
||||
.then(res => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: 'مورد با موفقیت حذف شد'
|
||||
})
|
||||
this.slides = this.slides.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 slides = await $axios.get(`/api/public/slides`)
|
||||
|
||||
return {
|
||||
slides: slides.data
|
||||
}
|
||||
} catch (e) {
|
||||
error({status: 500, message: 'there is a problem here'})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user