mirror of
https://git.meshkee.com/cssd/cssd-front.git
synced 2026-10-10 20:43:18 +03:30
fix : display Dashboard admin and items fields
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
export default {
|
||||
metaInfo () {
|
||||
return {
|
||||
title: 'CSSD dashboard'
|
||||
title: 'CSSD Dashboard'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -32,6 +32,16 @@ import { ApiService, TokenService } from '@/services'
|
||||
// Sync store with router
|
||||
sync(store, router)
|
||||
|
||||
//vue filter for string
|
||||
Vue.filter('text_8_letter', function(value) {
|
||||
if (!value) return '';
|
||||
return value.slice(0, 8);
|
||||
});
|
||||
Vue.filter('text_20_letter', function(value) {
|
||||
if (!value) return '';
|
||||
return value.slice(0, 20);
|
||||
});
|
||||
|
||||
Vue.config.productionTip = false
|
||||
ApiService.setHeader();
|
||||
// Set the base URL of the API
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
import { TokenService } from '@/services'
|
||||
import store from '@/store';
|
||||
|
||||
const $hasRole = function (roles) {
|
||||
if (TokenService.getToken()) {
|
||||
roles = roles.split('|');
|
||||
for (const role of roles) {
|
||||
if (TokenService.getInfo().roles && Array.isArray(TokenService.getInfo().roles) && TokenService.getInfo().roles.includes(role)) {
|
||||
return true;
|
||||
if(TokenService.getInfo().roles){
|
||||
for (const role of roles) {
|
||||
if (Array.isArray(TokenService.getInfo().roles) && TokenService.getInfo().roles.includes(role)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else{
|
||||
const userRoles = store.state.roles || [];
|
||||
return userRoles.some(role => roles.includes(role));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -98,3 +98,23 @@ const ApiService = {
|
||||
|
||||
export default ApiService
|
||||
export { ApiService }
|
||||
|
||||
axios.interceptors.request.use(request => {
|
||||
console.log("🔵 API Request:", request.method.toUpperCase(), request.url);
|
||||
console.log("🔹 Headers:", request.headers);
|
||||
console.log("🔹 Data:", request.data);
|
||||
return request;
|
||||
}, error => {
|
||||
console.error("🔴 Request Error:", error);
|
||||
return Promise.reject(error);
|
||||
});
|
||||
|
||||
axios.interceptors.response.use(response => {
|
||||
console.log("🟢 API Response:", response.config.url);
|
||||
console.log("🟢 Status:", response.status);
|
||||
console.log("🟢 Data:", response.data);
|
||||
return response;
|
||||
}, error => {
|
||||
console.error("🔴 API Error:", error.response ? error.response.data : error);
|
||||
return Promise.reject(error);
|
||||
});
|
||||
@@ -9,7 +9,11 @@ export default {
|
||||
const response = await UserService.login(cell_number, password);
|
||||
commit('loginSuccess', response.data.access_token);
|
||||
// Redirect the user to the page he first tried to visit or to the home view
|
||||
router.push(router.history.current.query.redirect || '/');
|
||||
|
||||
const redirectPath = router.history.current.query.redirect || '/';
|
||||
if (router.currentRoute.path !== redirectPath) {
|
||||
router.push(redirectPath);
|
||||
}
|
||||
|
||||
dispatch('info', {}, {root : true});
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export default {
|
||||
user : {},
|
||||
roles : [],
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</material-card>
|
||||
|
||||
|
||||
<material-card v-if="$hasRole('Supervisor|Admin')" color="black" title="Supervisor" text="">
|
||||
<material-card v-if="$hasRole('Admin|Supervisor')" color="black" title="Supervisor" text="">
|
||||
<v-layout row wrap>
|
||||
<template v-for="(SupervisorCard, Key ) in SupervisorCards">
|
||||
<v-flex v-if="!SupervisorCard.role || $hasRole(SupervisorCard.role)" :class="[SupervisorCard.column, 'pa-2']"
|
||||
|
||||
+29
-23
@@ -4,27 +4,27 @@
|
||||
<material-card class color="black" title="All Items" text>
|
||||
<v-layout align-center wrap class="my-3 px-5">
|
||||
<v-flex xs12 md3 sm3 class="WM-FlexCenter">
|
||||
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"></v-icon>
|
||||
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"/>
|
||||
<v-text-field class="py-3 pr-3" v-model="filter.item_id" label="Item ID"
|
||||
color="black"></v-text-field>
|
||||
color="black"/>
|
||||
</v-flex>
|
||||
<v-flex xs12 md3 sm3 class="WM-FlexCenter pl-3">
|
||||
<v-icon class="fa fa-align-left mr-2 WM-Margin-B-8"></v-icon>
|
||||
<v-text-field class="py-3 pr-3" v-model="filter.name" label="Name" color="black"></v-text-field>
|
||||
<v-icon class="fa fa-align-left mr-2 WM-Margin-B-8"/>
|
||||
<v-text-field class="py-3 pr-3" v-model="filter.name" label="Name" color="black"/>
|
||||
</v-flex>
|
||||
<v-flex xs12 md3 sm3 class="WM-FlexCenter pl-3" v-if="$hasRole('Admin')">
|
||||
<v-icon class="fa fa-hospital-o mr-2 WM-Margin-B-8"></v-icon>
|
||||
<v-icon class="fa fa-hospital-o mr-2 WM-Margin-B-8"/>
|
||||
<v-autocomplete class="py-3 pr-3" v-model="filter.medical_center_id" item-text="name"
|
||||
item-value="id" label="Hospital" color="black" :items="medicalCenters"
|
||||
:clearable="true"></v-autocomplete>
|
||||
:clearable="true"/>
|
||||
</v-flex>
|
||||
<v-flex xs12 md3 sm3 class="WM-FlexCenter pl-3">
|
||||
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"></v-icon>
|
||||
<v-text-field class="py-3 pr-3" v-model="filter.size" label="Size" color="black"></v-text-field>
|
||||
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"/>
|
||||
<v-text-field class="py-3 pr-3" v-model="filter.size" label="Size" color="black"/>
|
||||
</v-flex>
|
||||
<v-flex xs12 md3 sm3 class="WM-FlexCenter pl3">
|
||||
<v-icon class="fa fa-align-left mr-2 WM-Margin-B-8"></v-icon>
|
||||
<v-text-field class="py-3 pr-3" v-model="filter.udi" label="UDI" color="black"></v-text-field>
|
||||
<v-icon class="fa fa-align-left mr-2 WM-Margin-B-8"/>
|
||||
<v-text-field class="py-3 pr-3" v-model="filter.udi" label="UDI" color="black"/>
|
||||
</v-flex>
|
||||
|
||||
</v-layout>
|
||||
@@ -35,7 +35,7 @@
|
||||
<span class="white--text CSSD-font">Filter</span>
|
||||
</v-btn>
|
||||
</v-flex>
|
||||
<v-spacer></v-spacer>
|
||||
<v-spacer/>
|
||||
<v-flex xs12 md2 sm2 class="text-xs-right">
|
||||
<router-link :to="{ name: 'AddItem' }">
|
||||
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black">
|
||||
@@ -46,7 +46,7 @@
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<v-layout class="px-4 my-3">
|
||||
<v-divider></v-divider>
|
||||
<v-divider/>
|
||||
</v-layout>
|
||||
<v-layout align-center wrap class="my-3 px-5">
|
||||
<v-flex md12>
|
||||
@@ -59,22 +59,23 @@
|
||||
<td class="title font-weight-light">{{ item.id }}</td>
|
||||
<!-- <td class="title font-weight-light">{{ item.unique_id }}</td> -->
|
||||
<td class="title font-weight-light">{{ item.name }}</td>
|
||||
<td class="title font-weight-light">{{ item.user ? item.user.name : '' }}</td>
|
||||
<td class="title font-weight-light">{{ (item.user && item.user.medical_center) ?
|
||||
item.user.medical_center.name : '' }}</td>
|
||||
<td class="title font-weight-light">{{ item.udi }}</td>
|
||||
<td class="title font-weight-light">{{ item.user ? item.user.name : '' | text_20_letter }}</td>
|
||||
<td class="title font-weight-light">{{ (item.user && item.user.medical_center) ? item.user.medical_center.name : '' }}</td>
|
||||
<td class="title font-weight-light">{{ item.udi | text_8_letter }}</td>
|
||||
<td class="title font-weight-light">{{ item.size }}</td>
|
||||
<td class="title font-weight-light">{{ item.status }}</td>
|
||||
<td class="text-xs-right FlexBtn Height-MD-60">
|
||||
<v-tooltip bottom open-on-hover v-if="$hasRole('Supervisor|Admin')">
|
||||
<v-tooltip bottom open-on-hover v-if="$hasRole('Admin|Supervisor')">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-btn
|
||||
:color="!['suspended', 'rejected'].includes(item.status) ? 'red' : 'green'"
|
||||
class="mr-2" @click="changeStatus(item)" v-bind="attrs" v-on="on">
|
||||
<v-icon class="white--text mr-1 caption">fas {{
|
||||
!['suspended', 'rejected'].includes(item.status) ? 'fa-close' :
|
||||
'fa-check' }}</v-icon>
|
||||
<span>{{ !['suspended', 'rejected'].includes(item.status) ? 'reject' :
|
||||
'approve' }}</span>
|
||||
<v-icon class="white--text mr-1 caption">
|
||||
fas {{!['suspended', 'rejected'].includes(item.status) ? 'fa-close' : 'fa-check' }}
|
||||
</v-icon>
|
||||
<span>
|
||||
{{ !['suspended', 'rejected'].includes(item.status) ? 'reject' : 'approve' }}
|
||||
</span>
|
||||
</v-btn>
|
||||
</template>
|
||||
<span>{{ !['suspended', 'rejected'].includes(item.status) ? 'reject' : 'approve'
|
||||
@@ -173,7 +174,7 @@ export default {
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
text: "User",
|
||||
text: "Owner",
|
||||
value: "User"
|
||||
},
|
||||
{
|
||||
@@ -191,6 +192,11 @@ export default {
|
||||
text: "Size",
|
||||
value: "size"
|
||||
},
|
||||
{
|
||||
sortable: false,
|
||||
text: "Status",
|
||||
value: "status"
|
||||
},
|
||||
{
|
||||
sortable: false,
|
||||
text: "Action",
|
||||
|
||||
Reference in New Issue
Block a user