diff --git a/app/Http/Controllers/CollectionController.php b/app/Http/Controllers/CollectionController.php index e92c7bb4..fc7d4beb 100644 --- a/app/Http/Controllers/CollectionController.php +++ b/app/Http/Controllers/CollectionController.php @@ -45,6 +45,26 @@ public function store() return to_route('collections.show', $collection); } + public function update(Collection $collection) + { + + $validated = request()->validate([ + 'name' => 'required', + 'description' => 'required', + 'driver' => 'required', + 'embedding_driver' => 'required', + ]); + + $collection->update($validated); + /** + * Make and then reditect to the view page + */ + request()->session()->flash('flash.banner', 'Collection updated successfully!'); + + return to_route('collections.show', $collection); + } + + public function show(Collection $collection) { $chatResource = $collection->chats()->where('user_id', auth()->user()->id) diff --git a/resources/js/Components/Labels.vue b/resources/js/Components/Labels.vue new file mode 100644 index 00000000..d4eadb30 --- /dev/null +++ b/resources/js/Components/Labels.vue @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/resources/js/Pages/Collection/Components/EmbeddingType.vue b/resources/js/Pages/Collection/Components/EmbeddingType.vue index f8239bb6..2c3f97e4 100644 --- a/resources/js/Pages/Collection/Components/EmbeddingType.vue +++ b/resources/js/Pages/Collection/Components/EmbeddingType.vue @@ -55,8 +55,15 @@ { active: false, key: "mock", title: 'Gemini', description: 'This will work with the Gemini Api', current: false }, { active: true, key: "mock", title: 'Claude using Vonage', description: 'This will work with the Claude Api', current: false }, ] - - const selected = ref(publishingOptions[0]) + const props = defineProps({ + default: { + type: String, + default: 'mock' + } + }) + + const selected = ref(publishingOptions + .find(option => option.key === props.default) || publishingOptions[0]) watch(selected, (value) => { console.log("emit " , value) diff --git a/resources/js/Pages/Collection/Components/LlmType.vue b/resources/js/Pages/Collection/Components/LlmType.vue index e990ea47..d81e4fe1 100644 --- a/resources/js/Pages/Collection/Components/LlmType.vue +++ b/resources/js/Pages/Collection/Components/LlmType.vue @@ -55,8 +55,16 @@ { active: false, key: "mock", title: 'Gemini', description: 'This will work with the Gemini Api', current: false }, ] + + const props = defineProps({ + default: { + type: String, + default: 'mock' + } + }) - const selected = ref(publishingOptions[0]) + const selected = ref(publishingOptions + .find(option => option.key === props.default) || publishingOptions[0]) watch(selected, (value) => { console.log("emit " , value) diff --git a/resources/js/Pages/Collection/Components/ResourceForm.vue b/resources/js/Pages/Collection/Components/ResourceForm.vue index fc87b515..4092a2be 100644 --- a/resources/js/Pages/Collection/Components/ResourceForm.vue +++ b/resources/js/Pages/Collection/Components/ResourceForm.vue @@ -13,11 +13,16 @@
Choose the system to Interact with the data
- +
Choose the system to Embed the data
- +
diff --git a/resources/js/Pages/Collection/Edit.vue b/resources/js/Pages/Collection/Edit.vue new file mode 100644 index 00000000..1299d819 --- /dev/null +++ b/resources/js/Pages/Collection/Edit.vue @@ -0,0 +1,100 @@ + + + + \ No newline at end of file diff --git a/resources/js/Pages/Collection/Index.vue b/resources/js/Pages/Collection/Index.vue index 7bf153f7..c4c39a42 100644 --- a/resources/js/Pages/Collection/Index.vue +++ b/resources/js/Pages/Collection/Index.vue @@ -4,6 +4,7 @@ import Welcome from '@/Components/Welcome.vue'; import PrimaryButton from '@/Components/PrimaryButton.vue'; import SecondaryButton from '@/Components/SecondaryButton.vue'; import CreateCollection from './Create.vue'; +import EditCollection from './Edit.vue'; import { ref } from 'vue'; import PrimaryButtonLink from '@/Components/PrimaryButtonLink.vue'; @@ -17,10 +18,23 @@ const props = defineProps({ const showCreateCollection = ref(false); +const showEditCollection = ref(false); + +const collectionToEdit = ref({}); + const closeCreateCollectionSlideOut = () => { showCreateCollection.value = false; }; +const showEditCollectionSlideOut = (collection) => { + collectionToEdit.value = collection; + showEditCollection.value = true; +}; +const closeEditCollectionSlideOut = () => { + collectionToEdit.value = {}; + showEditCollection.value = false; +}; + @@ -55,7 +69,10 @@ const closeCreateCollectionSlideOut = () => { -
+
{{ collectionItem.name }} @@ -81,10 +98,16 @@ const closeCreateCollectionSlideOut = () => {
-
+
view + + + Edit +
@@ -96,5 +119,8 @@ const closeCreateCollectionSlideOut = () => {
+ diff --git a/resources/js/Pages/Collection/Show.vue b/resources/js/Pages/Collection/Show.vue index 0f7cc833..83384a2f 100644 --- a/resources/js/Pages/Collection/Show.vue +++ b/resources/js/Pages/Collection/Show.vue @@ -3,11 +3,14 @@ import AppLayout from '@/Layouts/AppLayout.vue'; import Welcome from '@/Components/Welcome.vue'; import SecondaryLink from '@/Components/SecondaryLink.vue'; import PrimaryButton from '@/Components/PrimaryButton.vue'; +import SecondaryButton from '@/Components/SecondaryButton.vue'; import { computed, onMounted, ref } from 'vue'; +import EditCollection from './Edit.vue'; import { useDropzone } from "vue3-dropzone"; import { router, useForm, Link } from '@inertiajs/vue3'; import FileUploader from './Components/FileUploader.vue'; +import Label from '@/Components/Labels.vue'; import CreateChat from './Components/CreateChat.vue'; import { ChatBubbleLeftIcon } from '@heroicons/vue/24/outline'; @@ -24,6 +27,15 @@ const props = defineProps({ }, }); +const showEditCollection = ref(false); + +const showEditCollectionSlideOut = () => { + showEditCollection.value = true; +}; +const closeEditCollectionSlideOut = () => { + showEditCollection.value = false; +}; + onMounted(() => { Echo.private(`collection.${props.collection.data.id}`) @@ -57,7 +69,8 @@ onMounted(() => {

{{ collection.data.name }}

- +
@@ -69,11 +82,29 @@ onMounted(() => { })"> Continue Chatting +
+ Edit +
+

{{ collection.data.description }}

+
+ + +
@@ -159,5 +190,8 @@ onMounted(() => { + diff --git a/routes/web.php b/routes/web.php index a79e4ba9..792bbd4f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -35,6 +35,7 @@ Route::controller(CollectionController::class)->group(function () { Route::get('/collections', 'index')->name('collections.index'); Route::post('/collections', 'store')->name('collections.store'); + Route::put('/collections/{collection}', 'update')->name('collections.update'); Route::get('/collections/{collection}', 'show')->name('collections.show'); Route::any('/collections/{collection}/upload', 'filesUpload')->name('collections.upload'); }); diff --git a/tests/Feature/Http/Controllers/CollectionControllerTest.php b/tests/Feature/Http/Controllers/CollectionControllerTest.php index c99ef50a..9c685671 100644 --- a/tests/Feature/Http/Controllers/CollectionControllerTest.php +++ b/tests/Feature/Http/Controllers/CollectionControllerTest.php @@ -53,6 +53,27 @@ public function test_store(): void } + public function test_update(): void + { + $user = $this->createUserWithCurrentTeam(); + $this->actingAs($user); + $collection = Collection::factory()->create([ + 'team_id' => $user->currentTeam->id, + ]); + + $this->assertDatabaseCount('collections', 1); + $response = $this->put(route('collections.update', $collection), [ + 'name' => 'Test', + 'driver' => 'mock', + 'embedding_driver' => DriversEnum::Claude->value, + 'description' => 'Test Description', + ])->assertStatus(302); + $this->assertDatabaseCount('collections', 1); + + $this->assertEquals(DriversEnum::Claude, $collection->refresh()->embedding_driver); + + } + public function test_file_upload() { Queue::fake();