Skip to content

Commit 8999ccd

Browse files
Merge branch 'main' of https://github.com/laravelwebdev/simpede into main
2 parents ee76b71 + 80ec74d commit 8999ccd

File tree

3 files changed

+23
-30
lines changed

3 files changed

+23
-30
lines changed

app/Helpers/GoogleDriveQuota.php

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,38 @@ class GoogleDriveQuota
88
{
99
public static function getQuota(): array
1010
{
11-
$clientId = config('app.google.client_id');
11+
$clientId = config('app.google.client_id');
1212
$clientSecret = config('app.google.client_secret');
1313
$refreshToken = config('app.google.refresh_token');
1414

15-
// Step 1: Refresh token -> Access token
15+
$used = 0;
16+
$total = 0;
17+
1618
$response = Http::asForm()->post('https://oauth2.googleapis.com/token', [
17-
'client_id' => $clientId,
19+
'client_id' => $clientId,
1820
'client_secret' => $clientSecret,
1921
'refresh_token' => $refreshToken,
20-
'grant_type' => 'refresh_token',
22+
'grant_type' => 'refresh_token',
2123
]);
2224

23-
if ($response->failed()) {
24-
return [
25-
'used_gb' => null,
26-
'total_gb' => null,
27-
'error' => $response->json(),
28-
];
29-
}
30-
31-
$accessToken = $response->json()['access_token'];
32-
33-
// Step 2: Get storage info
34-
$about = Http::withToken($accessToken)
35-
->get('https://www.googleapis.com/drive/v3/about?fields=storageQuota')
36-
->json();
25+
if ($response->ok()) {
26+
$accessToken = $response->json()['access_token'] ?? null;
27+
if ($accessToken) {
28+
$about = Http::withToken($accessToken)
29+
->get('https://www.googleapis.com/drive/v3/about?fields=storageQuota')
30+
->json();
3731

38-
$limit = $about['storageQuota']['limit'] ?? 0;
39-
$usage = $about['storageQuota']['usage'] ?? 0;
32+
$limit = $about['storageQuota']['limit'] ?? 0;
33+
$usage = $about['storageQuota']['usage'] ?? 0;
4034

41-
// Convert bytes to GB
42-
$limitGb = $limit ? round($limit / (1024 ** 3), 2) : 0;
43-
$usageGb = $usage ? round($usage / (1024 ** 3), 2) : 0;
35+
$total = $limit ? round($limit / (1024 ** 3), 2) : 0;
36+
$used = $usage ? round($usage / (1024 ** 3), 2) : 0;
37+
}
38+
}
4439

4540
return [
46-
'used' => $usageGb,
47-
'total' => $limitGb,
41+
'used' => $used,
42+
'total' => $total,
4843
];
4944
}
5045
}
51-
52-

app/Nova/Metrics/ServerResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function calculate(NovaRequest $request): PartitionResult
4646
$quota = GoogleDriveQuota::getQuota();
4747

4848
$value = $quota['used']; // dalam GB
49-
$total = $quota['total']; // dalam GB
49+
$total = $quota['total']; // dalam GB
5050
} else {
5151
$command = $this->type === 'inode'
5252
? ['du', '--inodes', '-s']

lang/vendor/nova/id.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
"Dark": "Gelap",
132132
"Dashboard": "Dasbor",
133133
"December": "Desember",
134-
"Decrease": "Mengurangi",
134+
"Decrease": "Menurun",
135135
"Delete": "Hapus",
136136
"Delete all notifications": "Hapus semua notifikasi",
137137
"Delete File": "Hapus Berkas",
@@ -213,7 +213,7 @@
213213
"ID": "ID",
214214
"If you did not request a password reset, no further action is required.": "Jika Anda tidak meminta pengaturan ulang kata sandi, tidak ada tindakan lebih lanjut yang diperlukan.",
215215
"Impersonate": "Menyamar",
216-
"Increase": "Tambah",
216+
"Increase": "Meningkat",
217217
"India": "India",
218218
"Indonesia": "Indonesia",
219219
"Iran, Islamic Republic Of": "Republik Islam Iran",

0 commit comments

Comments
 (0)