update cache and UI
This commit is contained in:
parent
d2f5273703
commit
7622e7a95b
|
|
@ -72,6 +72,7 @@ class LeaveManagementController extends Controller
|
|||
'users.id as user_id',
|
||||
'users.name as user_name',
|
||||
'users.email',
|
||||
'users.avatar',
|
||||
'users.created_at as user_created_at',
|
||||
'users.permission',
|
||||
'users.updated_at as user_updated_at',
|
||||
|
|
@ -92,6 +93,7 @@ class LeaveManagementController extends Controller
|
|||
'id' => $item->user_id,
|
||||
'name' => $item->user_name,
|
||||
'email' => $item->email,
|
||||
'avatar' => $item->avatar,
|
||||
'created_at' => $item->user_created_at,
|
||||
'permission' => $item->permission,
|
||||
'updated_at' => $item->user_updated_at,
|
||||
|
|
|
|||
|
|
@ -33,24 +33,24 @@ class TimekeepingController extends Controller
|
|||
$cacheData = CurrentMonthTimekeeping::getCacheCurrentMonthTimekeeping();
|
||||
if ($cacheData) {
|
||||
$cacheData->data = json_decode($cacheData->data, true);
|
||||
return response()->json(['status' => true, 'data' => $cacheData->data, 'working_days' => $cacheData->working_days, 'message' => 'Get from cache']);
|
||||
return response()->json(['status' => true, 'data' => $this->appendUsersInformation($cacheData->data), 'working_days' => $cacheData->working_days, 'message' => 'Get from cache']);
|
||||
} else {
|
||||
$result = $this->analyzeCurrentMonthTimeKeepingData($currentMonth, $currentYear);
|
||||
if ($data) {
|
||||
$data->update(['data' => json_encode($result)]);
|
||||
return response()->json(['status' => true, 'data' => $result, 'message' => 'Get from analyzeCurrentMonthTimeKeepingData + update record']);
|
||||
return response()->json(['status' => true, 'data' => $this->appendUsersInformation($result), 'message' => 'Get from analyzeCurrentMonthTimeKeepingData + update record']);
|
||||
}
|
||||
MonthlyTimekeeping::create(['month' => $currentMonth, 'year' => $currentYear, 'working_days' => $currentDate->daysInMonth, 'data' => json_encode($result)]);
|
||||
return response()->json(['status' => true, 'data' => $result, 'message' => 'Get from analyzeCurrentMonthTimeKeepingData + create record']);
|
||||
return response()->json(['status' => true, 'data' => $this->appendUsersInformation($result), 'message' => 'Get from analyzeCurrentMonthTimeKeepingData + create record']);
|
||||
}
|
||||
} else {
|
||||
if ($data) {
|
||||
$data['data'] = json_decode($data['data']);
|
||||
return response()->json(['status' => true, 'data' => $data['data'], 'working_days' => $data['working_days'], 'message' => 'Get from DB']);
|
||||
return response()->json(['status' => true, 'data' => $this->appendUsersInformation($data['data']), 'working_days' => $data['working_days'], 'message' => 'Get from DB']);
|
||||
} else {
|
||||
$result = $this->analyzeCurrentMonthTimeKeepingData($request->month, $request->year);
|
||||
MonthlyTimekeeping::create(['month' => $request->month, 'year' => $request->year, 'working_days' => Carbon::create((int)$request->year, (int)$request->month)->daysInMonth, 'data' => json_encode($result)]);
|
||||
return response()->json(['status' => true, 'data' => $result, 'message' => 'Get from analyzeCurrentMonthTimeKeepingData']);
|
||||
return response()->json(['status' => true, 'data' => $this->appendUsersInformation($result), 'message' => 'Get from analyzeCurrentMonthTimeKeepingData']);
|
||||
}
|
||||
}
|
||||
return response()->json(['status' => false, 'mewssage' => 'Get data failed!']);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ class UserController extends Controller
|
|||
'url' => 'https://ms.prology.net'
|
||||
];
|
||||
|
||||
if (env('APP_ENV') == 'prod' || env('APP_ENV') == 'production') {
|
||||
$gitea = Http::withHeaders([
|
||||
'Authorization' => 'token ' . env('GITEA_ADMIN_TOKEN'),
|
||||
'Accept' => 'application/json',
|
||||
|
|
@ -93,6 +94,9 @@ class UserController extends Controller
|
|||
$zulip_data['url'] = 'https://zulip.ipsupply.com.au';
|
||||
|
||||
return response()->json(['data' => ['user' => $user_res, 'gitea' => $gitea_res, 'zulip' => $zulip_data], 'status' => true, 'message' => 'Create successful']);
|
||||
} else {
|
||||
return response()->json(['data' => ['user' => $user_res, 'gitea' => "dev", 'zulip' => "dev"], 'status' => true, 'message' => 'Create successful']);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(['status' => false, 'message' => 'Process fail']);
|
||||
|
|
@ -123,7 +127,7 @@ class UserController extends Controller
|
|||
if ($user) {
|
||||
if (!$user->qrcode) {
|
||||
// Generate the QR code and save it to storage
|
||||
QrCode::size(500)->margin(2)->generate($qrCodeContent, Storage::path('public/'.$filePath));
|
||||
QrCode::size(500)->margin(2)->generate($qrCodeContent, Storage::path('public/' . $filePath));
|
||||
// Update the user's record with the QR code file path
|
||||
$user->qrcode = $filePath;
|
||||
$user->save();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\Traits;
|
|||
|
||||
use App\Helper\Cache\CurrentMonthTimekeeping;
|
||||
use App\Models\Notes;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
|
@ -100,7 +101,7 @@ trait AnalyzeData
|
|||
}
|
||||
}
|
||||
|
||||
$result[] = ['user' => $admin, 'history' => $user_data];
|
||||
$result[] = ['user' => $admin->id, 'history' => $user_data];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
@ -119,4 +120,19 @@ trait AnalyzeData
|
|||
CurrentMonthTimekeeping::cleanCacheCurrentMonthTimekeeping();
|
||||
return;
|
||||
}
|
||||
|
||||
public function appendUsersInformation($results)
|
||||
{
|
||||
$users = User::all();
|
||||
$data = [];
|
||||
foreach($users as $user){
|
||||
foreach($results as $result){
|
||||
$result = (array)$result;
|
||||
if($result['user'] === $user->id){
|
||||
$data[] = ['user'=> $user, 'history' => $result['history']];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ const data = [
|
|||
label: 'Organization Settings',
|
||||
icon: IconSettings,
|
||||
group: 'admin',
|
||||
permissions: 'admin',
|
||||
},
|
||||
// { link: '/jira', label: 'Jira', icon: IconSubtask },
|
||||
// { link: '/custom-theme', label: 'Custom Theme', icon: IconBrush },
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { getLeaveManagement, updateNoteLeave } from '@/api/Admin'
|
|||
import { update } from '@/rtk/helpers/CRUD'
|
||||
import { get } from '@/rtk/helpers/apiService'
|
||||
import {
|
||||
Avatar,
|
||||
Box,
|
||||
Button,
|
||||
Drawer,
|
||||
|
|
@ -30,6 +31,7 @@ interface User {
|
|||
email_verified_at: string | null
|
||||
permission: string
|
||||
remember_token: string | null
|
||||
avatar: string
|
||||
created_at: string | null
|
||||
updated_at: string | null
|
||||
}
|
||||
|
|
@ -458,7 +460,13 @@ const LeaveManagement = () => {
|
|||
<Table.Td ta={'center'}>{index + 1}</Table.Td>
|
||||
<Table.Td>
|
||||
<Tooltip multiline label={user.user.name}>
|
||||
<div>{user.user.name}</div>
|
||||
<div style={{display:'flex', alignItems:'center'}}><Avatar size={'md'} mr={'md'} src={import.meta.env.VITE_BACKEND_URL.includes('local')
|
||||
? import.meta.env.VITE_BACKEND_URL +
|
||||
'storage/' +
|
||||
user.user.avatar
|
||||
: import.meta.env.VITE_BACKEND_URL +
|
||||
'image/storage/' +
|
||||
user.user.avatar}/>{user.user.name}</div>
|
||||
</Tooltip>
|
||||
</Table.Td>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
import { update, Xdelete } from '@/rtk/helpers/CRUD'
|
||||
import { get } from '@/rtk/helpers/apiService'
|
||||
import {
|
||||
Avatar,
|
||||
Box,
|
||||
Button,
|
||||
Drawer,
|
||||
|
|
@ -43,6 +44,7 @@ interface User {
|
|||
email_verified_at: string | null
|
||||
permission: string
|
||||
remember_token: string | null
|
||||
avatar: string
|
||||
created_at: string | null
|
||||
updated_at: string | null
|
||||
}
|
||||
|
|
@ -864,7 +866,13 @@ const Timekeeping = () => {
|
|||
// offset={{ mainAxis: 5, crossAxis: 0 }}
|
||||
label={showTooltipAllNote(user)}
|
||||
>
|
||||
<div>{user.user.name}</div>
|
||||
<div style={{display:'flex', alignItems:'center'}}><Avatar size={'md'} mr={'md'} src={import.meta.env.VITE_BACKEND_URL.includes('local')
|
||||
? import.meta.env.VITE_BACKEND_URL +
|
||||
'storage/' +
|
||||
user.user.avatar
|
||||
: import.meta.env.VITE_BACKEND_URL +
|
||||
'image/storage/' +
|
||||
user.user.avatar}/>{user.user.name}</div>
|
||||
</Tooltip>
|
||||
</Table.Td>
|
||||
<Table.Td ta={'center'}>{totalDays}</Table.Td>
|
||||
|
|
|
|||
Loading…
Reference in New Issue