Gps User Page
This commit is contained in:
@@ -316,6 +316,66 @@
|
||||
:exact="false"
|
||||
/>
|
||||
</CSidebarNavDropdown>
|
||||
|
||||
<CSidebarNavDropdown
|
||||
v-if="hasPermission('gps')"
|
||||
:show="getDropdownState('adminS_GpsM_Dropdown')"
|
||||
name="مدیریت پنل جی پی اس"
|
||||
:font-icon="getDropdownState('adminS_GpsM_Dropdown') ? `fas fa-folder-open`:`fas fa-folder` "
|
||||
@update:show="val => setDropdownState('adminS_GpsM_Dropdown', val)"
|
||||
>
|
||||
<CSidebarNavItem
|
||||
v-if="hasPermission('gps')"
|
||||
name="کاربران"
|
||||
:to="{ name: 'admin-gps-users', query: { type: 'all' } }"
|
||||
font-icon="fal fa-user"
|
||||
:exact="false"
|
||||
/>
|
||||
<CSidebarNavItem
|
||||
v-if="hasPermission('gps')"
|
||||
name="درخواست های دسترسی"
|
||||
:to="{ name: 'admin-gps-users', query: { type: 'req' } }"
|
||||
font-icon="fal fa-user"
|
||||
:exact="false"
|
||||
:badge="pendingUsers ? { text: pendingUsers, color: 'danger' } : null"
|
||||
/>
|
||||
<CSidebarNavItem
|
||||
v-if="hasPermission('gps')"
|
||||
name="دستگاه ها"
|
||||
:to="{ name: 'admin-admins-admin', params: { admin: 'new' } }"
|
||||
font-icon="fal fa-microchip"
|
||||
:exact="false"
|
||||
/>
|
||||
<CSidebarNavItem
|
||||
v-if="hasPermission('gps')"
|
||||
name="دستگاه های ثبت شده"
|
||||
:to="{ name: 'admin-admins-admin', params: { admin: 'new' } }"
|
||||
font-icon="fal fa-map"
|
||||
:exact="false"
|
||||
/>
|
||||
<CSidebarNavItem
|
||||
v-if="hasPermission('gps')"
|
||||
name="درخواست های برداشت"
|
||||
:to="{ name: 'admin-admins-admin', params: { admin: 'new' } }"
|
||||
font-icon="fal fa-credit-card"
|
||||
:exact="false"
|
||||
/>
|
||||
<CSidebarNavItem
|
||||
v-if="hasPermission('gps')"
|
||||
name="جوایز"
|
||||
:to="{ name: 'admin-admins-admin', params: { admin: 'new' } }"
|
||||
font-icon="fal fa-gift"
|
||||
:exact="false"
|
||||
/>
|
||||
<CSidebarNavItem
|
||||
v-if="hasPermission('gps')"
|
||||
name="درخواست های جوایز"
|
||||
:to="{ name: 'admin-admins-admin', params: { admin: 'new' } }"
|
||||
font-icon="fal fa-trophy"
|
||||
:exact="false"
|
||||
/>
|
||||
</CSidebarNavDropdown>
|
||||
|
||||
</CSidebarNav>
|
||||
<!-- sidebar content -->
|
||||
|
||||
@@ -345,7 +405,11 @@ export default {
|
||||
newOldPieceRequests: state => state.admin.newOldPieceRequests,
|
||||
newBufferRequests: state => state.admin.newBufferRequests,
|
||||
newGuaranteeReports: state => state.admin.newGuaranteeReports,
|
||||
newComplaintReports: state => state.admin.newComplaintReports
|
||||
newComplaintReports: state => state.admin.newComplaintReports,
|
||||
newWithdrawRequest: state => state.admin.newWithdrawRequest,
|
||||
pendingUsers: state => state.admin.pendingUsers,
|
||||
newAwardRequest: state => state.admin.newAwardRequest,
|
||||
newInstallDeviceRequest: state => state.admin.newInstallDeviceRequest
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog title="اطلاعات کاربر" :visible.sync="centerDialogVisible" width="40%" center>
|
||||
<el-descriptions title="" direction="vertical" :column="4" border>
|
||||
|
||||
<el-descriptions-item label="نام و نام خانودگی">{{ user.first_name +" "+ user.last_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="شماره همراه">{{ user.mobile_number }}</el-descriptions-item>
|
||||
<el-descriptions-item label="استان" >{{ user.province_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="شهر">{{ user.city_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="کد ملی ">{{ user.national_code }}</el-descriptions-item>
|
||||
<el-descriptions-item label="نام فروشگاه">{{ user.shopName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="شماره ثابت">{{ user.cell_number }}</el-descriptions-item>
|
||||
<el-descriptions-item label="تاریخ تولد">{{ user.birthDate }}</el-descriptions-item>
|
||||
<el-descriptions-item label="آدرس">{{ user.address }}</el-descriptions-item>
|
||||
|
||||
</el-descriptions>
|
||||
<CCardBody>
|
||||
<el-table :data="user.cardBank" style="width: 100%">
|
||||
<el-table-column type="index" label="#"> </el-table-column>
|
||||
<el-table-column prop="holderName" label="نام صاحب کارت" width="200px"> </el-table-column>
|
||||
<el-table-column prop="PAN" label="شماره حساب" width="200px"> </el-table-column>
|
||||
<el-table-column prop="IBAN" label="شماره شبا" width=""> </el-table-column>
|
||||
</el-table>
|
||||
</CCardBody>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="centerDialogVisible = false">{{
|
||||
$route.query?.type == 'req' ? 'Cancel' : 'Close'
|
||||
}}</el-button>
|
||||
<el-button v-if="$route.query?.type == 'req'" type="primary" @click="confirmUser(user._id)">Confirm</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
<CustomSubHeader>
|
||||
<CBreadcrumb class="border-0 mb-0"> کاربران جی پی اس </CBreadcrumb>
|
||||
</CustomSubHeader>
|
||||
<CCard>
|
||||
<CCardHeader>
|
||||
<slot name="header">
|
||||
<CIcon name="cil-grid" />
|
||||
کاربران
|
||||
</slot>
|
||||
</CCardHeader>
|
||||
|
||||
<CCardBody>
|
||||
<el-table :data="users" style="width: 100%">
|
||||
<el-table-column type="index" label="#"> </el-table-column>
|
||||
|
||||
<el-table-column prop="first_name" label="نام" width="200px"> </el-table-column>
|
||||
<el-table-column prop="last_name" label="نام خانوادگی" width="200px"> </el-table-column>
|
||||
|
||||
<el-table-column prop="national_code" label="کدملی" width=""> </el-table-column>
|
||||
|
||||
<el-table-column prop="mobile_number" label="شماره همراه" width=""> </el-table-column>
|
||||
|
||||
<el-table-column label="وضعیت" width="">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.active" type="success">فعال</el-tag>
|
||||
<el-tag v-else type="danger">غیر فعال</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="نمایش" width="110" align="center">
|
||||
<template slot-scope="scope">
|
||||
<CButton :key="scope.row._id" color="info" variant="outline" @click="showUserDialog(scope.row._id)">
|
||||
<i class="fal fa-eye"></i>
|
||||
</CButton>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'AdminGpsUsersList',
|
||||
layout: 'admin',
|
||||
async asyncData({ $axios, error, query }) {
|
||||
try {
|
||||
let users
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if (query?.type == 'req') {
|
||||
users = await $axios.get('/api/admin/gps/users/pending')
|
||||
} else {
|
||||
users = await $axios.get('/api/admin/gps/users')
|
||||
}
|
||||
return {
|
||||
users: users.data
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
users: [],
|
||||
centerDialogVisible: false,
|
||||
user: {}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
config() {
|
||||
return this.$config
|
||||
},
|
||||
usersTypeList() {
|
||||
return this.$route.query?.type
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
async usersTypeList(newVal, oldVal) {
|
||||
try {
|
||||
let users
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if (this.$route.query?.type == 'req') {
|
||||
users = await this.$axios.get('/api/admin/gps/users/pending')
|
||||
} else {
|
||||
users = await this.$axios.get('/api/admin/gps/users')
|
||||
}
|
||||
|
||||
this.users = users.data
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async showUserDialog(id) {
|
||||
const {data}= await this.$axios.get(`/api/admin/gps/users/${id}`)
|
||||
this.user = data
|
||||
this.centerDialogVisible = true
|
||||
},
|
||||
async confirmUser(id){
|
||||
try {
|
||||
await this.$axios.patch(`/api/admin/gps/users/${id}/true`)
|
||||
this.$nuxt.refresh()
|
||||
this.centerDialogVisible = false
|
||||
} catch (err) {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: err.response.data.message
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -65,7 +65,7 @@ module.exports.getAllNotifs = async socket => {
|
||||
const newGuaranteeReports = allData[7]
|
||||
const newComplaintReports = allData[8]
|
||||
const newWithdrawRequest = allData[9]
|
||||
const newGpsRequest = allData[10]
|
||||
const pendingUsers = allData[10]
|
||||
const newAwardRequest = allData[11]
|
||||
const newInstallDeviceRequest = allData[12]
|
||||
|
||||
@@ -81,7 +81,7 @@ module.exports.getAllNotifs = async socket => {
|
||||
newGuaranteeReports,
|
||||
newComplaintReports,
|
||||
newWithdrawRequest,
|
||||
newGpsRequest,
|
||||
pendingUsers,
|
||||
newAwardRequest,
|
||||
newInstallDeviceRequest
|
||||
})
|
||||
|
||||
@@ -369,10 +369,13 @@ module.exports.getCurrent = async (req, res) => {
|
||||
}
|
||||
|
||||
module.exports.getUsersForAdmin = async (req, res) => {
|
||||
const user = await User.find({}).sort({ active: 1, created_at: -1 }).select('-password -token -otp -seenByAdmin')
|
||||
const user = await User.find({}).sort({ active: 1, created_at: -1 }).select('-password -token -otp -seenByAdmin -cardBank')
|
||||
res.status(200).json(user)
|
||||
}
|
||||
module.exports.getPendingUsersForAdmin = async (req, res) => {
|
||||
const user = await User.find({active:false}).sort({ active: 1, created_at: -1 }).select('-password -token -otp -seenByAdmin -cardBank')
|
||||
res.status(200).json(user)
|
||||
}
|
||||
|
||||
module.exports.getUserForAdmin = async (req, res) => {
|
||||
const user = await User.findById(req.params.id).select('-password -token -otp -seenByAdmin')
|
||||
if (!user) {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ const inHostUrl = 'mongodb://root:KPTt76tImNBBMm4Kor8QA9gB@asan-service:27017/as
|
||||
const outHostUrl = 'mongodb://root:KPTt76tImNBBMm4Kor8QA9gB@hotaka.liara.cloud:33794/asanserv_database?authSource=admin'
|
||||
const init = ()=>{
|
||||
try {
|
||||
mongoose.connect(inHostUrl, {
|
||||
mongoose.connect(outHostUrl, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
useFindAndModify: false,
|
||||
|
||||
@@ -42,6 +42,7 @@ const userGPS = require('../controllers/GPS.User')
|
||||
/// /////////////// User
|
||||
|
||||
router.get('/gps/users',hasPermission('gps'), userGPS.getUsersForAdmin)
|
||||
router.get('/gps/users/pending',hasPermission('gps'), userGPS.getPendingUsersForAdmin)
|
||||
router.get('/gps/users/:id',hasPermission('gps'), userGPS.getUserForAdmin)
|
||||
|
||||
router.patch('/gps/users/:id/:status',hasPermission('gps'), userGPS.activeUser)
|
||||
|
||||
Reference in New Issue
Block a user