-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
source now working on the previous missing results
- Loading branch information
Showing
20 changed files
with
359 additions
and
37 deletions.
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
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
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,34 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Http\Resources\DocumentResource; | ||
use App\Http\Resources\DocumentResourceWithPaginate; | ||
use App\Models\Collection; | ||
use Illuminate\Http\Request; | ||
|
||
class DocumentController extends Controller | ||
{ | ||
public function index(Collection $collection) { | ||
|
||
$filter = request()->get('filter'); | ||
|
||
if ($filter) { | ||
$documents = $collection->documents() | ||
->where('status', '=', $filter)->paginate(100); | ||
} else { | ||
$documents = $collection->documents()->paginate(100); | ||
} | ||
|
||
return response()->json([ | ||
'documents' => new DocumentResourceWithPaginate($documents), | ||
]); | ||
} | ||
|
||
public function status(Collection $collection) { | ||
|
||
return response()->json([ | ||
'documents' => DocumentResource::collection($collection->documents), | ||
]); | ||
} | ||
} |
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,39 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\ResourceCollection; | ||
|
||
class DocumentResourceWithPaginate extends ResourceCollection | ||
{ | ||
/** | ||
* Transform the resource collection into an array. | ||
* | ||
* @return array<int|string, mixed> | ||
*/ | ||
public function toArray(Request $request): array | ||
{ | ||
return [ | ||
'data' => DocumentResource::collection($this), | ||
'meta' => [ | ||
'current_page' => $this->currentPage(), | ||
'from' => $this->firstItem(), | ||
'last_page' => $this->lastPage(), | ||
'per_page' => $this->perPage(), | ||
'to' => $this->lastItem(), | ||
'total' => $this->total(), | ||
], | ||
'links' => [ | ||
'first' => route('collections.documents.index', [ | ||
'collection' => request()->collection->id, | ||
'filter' => request()->filter, | ||
'page' => 1, | ||
]), | ||
'last' => $this->url($this->lastPage()), | ||
'prev' => $this->previousPageUrl(), | ||
'next' => $this->nextPageUrl(), | ||
], | ||
]; | ||
} | ||
} |
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
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
71 changes: 71 additions & 0 deletions
71
resources/js/Pages/Collection/Components/DocumentStatus.vue
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,71 @@ | ||
<script setup> | ||
import {computed, onMounted, onUnmounted, ref} from "vue"; | ||
import {router} from "@inertiajs/vue3"; | ||
const props = defineProps({ | ||
collection: Array | ||
}) | ||
const notCompleteCount = computed(() => { | ||
return documents.value.filter(document => document.status !== 'Complete').length; | ||
}) | ||
const completeCount = computed(() => { | ||
return documents.value.filter(document => document.status === 'Complete').length; | ||
}) | ||
const totalCount = computed(() => { | ||
return documents.value.length; | ||
}) | ||
const percentComplete = computed(() => { | ||
return Math.round((completeCount.value / totalCount.value) * 100); | ||
}) | ||
const documents = ref([]); | ||
const getDocuments = () => { | ||
axios.get(route('collections.documents.status', { | ||
collection: props.collection.id | ||
})).then(response => { | ||
documents.value = response.data.documents; | ||
}).catch(error => { | ||
console.log(error) | ||
}) | ||
} | ||
onUnmounted(() => { | ||
Echo.leave(`collection.${props.collection.id}`); | ||
}); | ||
onMounted(() => { | ||
Echo.private(`collection.${props.collection.id}`) | ||
.listen('.status', (e) => { | ||
let message = e.message; | ||
if (message === 'Document Processed' || message === 'processing') { | ||
getDocuments(); | ||
} | ||
}); | ||
getDocuments(); | ||
}) | ||
</script> | ||
|
||
<template> | ||
|
||
<div v-show="documents.length > 0" v-auto-animate> | ||
<div class="flex justify-start gap-2 items-center text-sm border border-secondary p-2 rounded-md"> | ||
<div>Total: {{totalCount}}</div> | ||
<div>Complete: {{completeCount}}</div> | ||
<div>Not Complete: {{notCompleteCount}}</div> | ||
<div class="radial-progress text-xs text-secondary" | ||
|
||
:style="`--value:${percentComplete}; --size:3rem; `" role="progressbar">{{percentComplete}}%</div> | ||
</div> | ||
</div> | ||
|
||
</template> | ||
|
||
<style scoped> | ||
</style> |
Oops, something went wrong.