-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de60fd2
commit c9d399d
Showing
6 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Resources\ImportResource; | ||
use App\Models\Import; | ||
use Illuminate\Http\Request; | ||
|
||
class ImportController extends Controller | ||
{ | ||
public function index(Request $request) | ||
{ | ||
/** @var ApiKey $apiKey */ | ||
$apiKey = $request->get('apiKey'); | ||
|
||
$imports = Import::query() | ||
->where('space_id', $apiKey->user->spaces()->first()->id) | ||
->latest() | ||
->get(); | ||
|
||
return ImportResource::collection($imports); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class ImportResource extends JsonResource | ||
{ | ||
/** @var Import $resource */ | ||
public $resource; | ||
|
||
public function toArray(Request $request): array | ||
{ | ||
return [ | ||
'name' => $this->resource->name, | ||
'status' => $this->resource->status, | ||
'created_at' => $this->resource->created_at, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script setup> | ||
import { ref } from 'vue'; | ||
import Navigation from '../../components/Navigation.vue'; | ||
const imports = ref([]); | ||
const fetchImports = () => { | ||
fetch('/api/imports', { headers: { 'api-key': localStorage.getItem('api_key') } }) | ||
.then(response => response.json()) | ||
.then(data => { | ||
imports.value = data; | ||
}); | ||
}; | ||
fetchImports(); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<Navigation /> | ||
<div class="max-w-3xl mx-auto my-10 space-y-10"> | ||
<div v-for="_import in imports"> | ||
<div class="py-4 px-5 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg"> | ||
<div class="text-sm">{{ _import.name }}</div> | ||
<div class="mt-2 text-xs text-gray-500">Uploaded {{ new Intl.RelativeTimeFormat('en', { numeric: 'auto' }).format(Math.round((new Date(_import.created_at) - new Date()) / 86400000), 'day') }}</div> | ||
<div class="mt-4 flex items-center space-x-2"> | ||
<div class="text-xs" :class="_import.status >= 0 ? 'text-green-600' : 'text-grey-500'">1. Upload</div> | ||
<div class="w-4 h-px" :class="_import.status >= 1 ? 'bg-green-600' : 'bg-black'"></div> | ||
<div class="text-xs" :class="_import.status >= 1 ? 'text-green-600' : 'text-grey-500'">2. Define columns</div> | ||
<div class="w-4 h-px" :class="_import.status >= 2 ? 'bg-green-600' : 'bg-black'"></div> | ||
<div class="text-xs" :class="_import.status >= 2 ? 'text-green-600' : 'text-grey-500'">3. Import</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters