Skip to content

Commit

Permalink
add collection index and collection add
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Mar 25, 2024
1 parent b29b51b commit dee8d03
Show file tree
Hide file tree
Showing 22 changed files with 449 additions and 115 deletions.
5 changes: 1 addition & 4 deletions .env.github
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:zR66Rx/bzt2/cu0BK92ijOXxCpGxoPCVgFEdHxZQa+k=
APP_DEBUG=true
APP_URL=http://localhost
APP_URL=http://larachain.test

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
Expand Down Expand Up @@ -63,8 +63,5 @@ MAPBOX_TOKEN="foobar"
[email protected]
ADMIN_ONE_PASSWORD=makeagoodone

[email protected]
ADMIN_TWO_PASSWORD=makeagoodone

## Fake key
OPENAI_API_KEY=sk-m8ox9NVgboSLRCr5VA5RT3BXbkFJzP1QGUedbQxGmmuAQWRT
14 changes: 5 additions & 9 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v3
Expand All @@ -54,16 +54,12 @@ jobs:
- name: Install Composer dependencies
run: |
composer config http-basic.packages.craftable.pro "${{ secrets.CRAFTABLE_PRO_EMAIL }}" "${{ secrets.CRAFTABLE_PRO_LICENCE_KEY }}"
composer install --no-interaction --prefer-dist
composer install --no-progress --prefer-dist --optimize-autoloader
- name: Prepare the application
- name: Setup application
run: |
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
- name: Clear Config
run: php artisan config:clear

cp .env.github .env
php artisan storage:link
- name: PHP Code Style (phpcs)
run: |
Expand Down
44 changes: 44 additions & 0 deletions app/Http/Controllers/CollectionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace App\Http\Controllers;

use App\Http\Resources\CollectionResource;
use App\Models\Collection;
use Illuminate\Http\Request;

class CollectionController extends Controller
{

public function index() {

return inertia("Collection/Index", [
'collections' => CollectionResource::collection(Collection::query()
->where("team_id", auth()->user()->current_team_id)
->get())
]);
}

public function store() {

$validated = request()->validate([
'name' => 'required',
'description' => 'required',
]);

$validated['team_id'] = auth()->user()->current_team_id;

$collection = Collection::create($validated);
/**
* Make and then reditect to the view page
*/
request()->session()->flash("flash.banner", "Collection created successfully!");

return to_route('collections.show', $collection);
}

public function show(Collection $collection) {
return inertia("Collection/Show", [
'collection' => new CollectionResource($collection)
]);
}
}
1 change: 1 addition & 0 deletions app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function version(Request $request): ?string
public function share(Request $request): array
{
return array_merge(parent::share($request), [
'app_name' => config("app.name"),
'features' => Feature::all(),
]);
}
Expand Down
19 changes: 19 additions & 0 deletions app/Http/Resources/CollectionResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class CollectionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return parent::toArray($request);
}
}
5 changes: 5 additions & 0 deletions app/Jobs/ProcessFileJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public function __construct(public Document $document)
*/
public function handle(): void
{
/**
* @TODO
* Make a test. I am keeping this simple to just run the batch
* but if it does more needs a test
*/
//This will trigger a batch job chain that will do the following for all the document pages
// it will save this on a Collections Watchers so we can see it in the UI.
//1) Chunk up the data
Expand Down
4 changes: 2 additions & 2 deletions app/Providers/JetstreamServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ protected function configurePermissions(): void
'delete',
])->description('Administrator users can perform any action.');

Jetstream::role('editor', 'Editor', [
Jetstream::role('member', 'Member', [
'read',
'create',
'update',
])->description('Editor users have the ability to read, create, and update.');
])->description('Member users have the ability to read, create, and update.');
}
}
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
|
*/

'name' => env('APP_NAME', 'Laravel'),
'name' => env('APP_NAME', 'Ai Hub'),

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config/jetstream.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

'features' => [
// Features::termsAndPrivacyPolicy(),
// Features::profilePhotos(),
Features::profilePhotos(),
// Features::api(),
Features::teams(['invitations' => true]),
Features::accountDeletion(),
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_STORE" value="array"/>
<env name="DB_CONNECTION" value="pgsql"/>
<env name="DB_DATABASE" value="testing"/>
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="MAIL_MAILER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<!-- this is a fake token! -->
<env name="OPENAI_API_KEY" value="sk-m8ox9NVgboSLRCr5VA5RT3BXbkFJzP1QGUedbQxGmmuAQWRT"/>
<env name="DB_DATABASE" value="testing"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="OPENAI_MOCK" value="true"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
</phpunit>
15 changes: 15 additions & 0 deletions resources/js/Components/PrimaryButtonLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script setup>
import { Link } from '@inertiajs/vue3';
defineProps({
href: {
type: String,
default: "#",
},
});
</script>

<template>
<Link :href="href" class="inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 focus:bg-gray-700 active:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition ease-in-out duration-150">
<slot />
</Link>
</template>
23 changes: 23 additions & 0 deletions resources/js/Components/TextArea.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script setup>
import { onMounted, ref } from 'vue';
defineProps({
modelValue: String,
});
defineEmits(['update:modelValue']);
const input = ref(null);
</script>

<template>
<textarea
ref="input"
class="border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 rounded-md shadow-sm"
:value="modelValue"
@input="$emit('update:modelValue', $event.target.value)"
>
</textarea>
</template>
98 changes: 12 additions & 86 deletions resources/js/Components/Welcome.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<script setup>
import ApplicationLogo from '@/Components/ApplicationLogo.vue';
import { usePage } from '@inertiajs/vue3';
const people = [
{ name: 'Lindsay Walton', title: 'Front-end Developer', email: '[email protected]', role: 'Member' },
// More people...
]
</script>

<template>
Expand All @@ -8,97 +17,14 @@ import ApplicationLogo from '@/Components/ApplicationLogo.vue';
<ApplicationLogo class="block h-12 w-auto" />

<h1 class="mt-8 text-2xl font-medium text-gray-900">
Welcome to your Jetstream application!
Welcome to {{ usePage().props.app_name }}, where your data transformation journey begins! Dive into a seamless experience of managing and analyzing your data with precision and ease.
</h1>

<p class="mt-6 text-gray-500 leading-relaxed">
Laravel Jetstream provides a beautiful, robust starting point for your next Laravel application. Laravel is designed
to help you build your application using a development environment that is simple, powerful, and enjoyable. We believe
you should love expressing your creativity through programming, so we have spent time carefully crafting the Laravel
ecosystem to be a breath of fresh air. We hope you love it.
Get started by creating a new 'Collection'—your first step towards organizing diverse data sources like PDFs, website data, and more, into a cohesive unit. Each 'Collection' serves as a centralized hub for your team's data, making it easier to collaborate, analyze, and derive actionable insights. Simply select or switch your team from the menu, and create or access your Collections to embark on a streamlined data management journey. Ready to unlock the full potential of your data? Let's create your first Collection and set the foundation for unparalleled team collaboration and insight discovery.
</p>
</div>

<div class="bg-gray-200 bg-opacity-25 grid grid-cols-1 md:grid-cols-2 gap-6 lg:gap-8 p-6 lg:p-8">
<div>
<div class="flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" class="w-6 h-6 stroke-gray-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25" />
</svg>
<h2 class="ms-3 text-xl font-semibold text-gray-900">
<a href="https://laravel.com/docs">Documentation</a>
</h2>
</div>

<p class="mt-4 text-gray-500 text-sm leading-relaxed">
Laravel has wonderful documentation covering every aspect of the framework. Whether you're new to the framework or have previous experience, we recommend reading all of the documentation from beginning to end.
</p>

<p class="mt-4 text-sm">
<a href="https://laravel.com/docs" class="inline-flex items-center font-semibold text-indigo-700">
Explore the documentation

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="ms-1 w-5 h-5 fill-indigo-500">
<path fill-rule="evenodd" d="M5 10a.75.75 0 01.75-.75h6.638L10.23 7.29a.75.75 0 111.04-1.08l3.5 3.25a.75.75 0 010 1.08l-3.5 3.25a.75.75 0 11-1.04-1.08l2.158-1.96H5.75A.75.75 0 015 10z" clip-rule="evenodd" />
</svg>
</a>
</p>
</div>

<div>
<div class="flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" class="w-6 h-6 stroke-gray-400">
<path stroke-linecap="round" d="M15.75 10.5l4.72-4.72a.75.75 0 011.28.53v11.38a.75.75 0 01-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25h-9A2.25 2.25 0 002.25 7.5v9a2.25 2.25 0 002.25 2.25z" />
</svg>
<h2 class="ms-3 text-xl font-semibold text-gray-900">
<a href="https://laracasts.com">Laracasts</a>
</h2>
</div>

<p class="mt-4 text-gray-500 text-sm leading-relaxed">
Laracasts offers thousands of video tutorials on Laravel, PHP, and JavaScript development. Check them out, see for yourself, and massively level up your development skills in the process.
</p>

<p class="mt-4 text-sm">
<a href="https://laracasts.com" class="inline-flex items-center font-semibold text-indigo-700">
Start watching Laracasts

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="ms-1 w-5 h-5 fill-indigo-500">
<path fill-rule="evenodd" d="M5 10a.75.75 0 01.75-.75h6.638L10.23 7.29a.75.75 0 111.04-1.08l3.5 3.25a.75.75 0 010 1.08l-3.5 3.25a.75.75 0 11-1.04-1.08l2.158-1.96H5.75A.75.75 0 015 10z" clip-rule="evenodd" />
</svg>
</a>
</p>
</div>

<div>
<div class="flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" class="w-6 h-6 stroke-gray-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z" />
</svg>
<h2 class="ms-3 text-xl font-semibold text-gray-900">
<a href="https://tailwindcss.com/">Tailwind</a>
</h2>
</div>

<p class="mt-4 text-gray-500 text-sm leading-relaxed">
Laravel Jetstream is built with Tailwind, an amazing utility first CSS framework that doesn't get in your way. You'll be amazed how easily you can build and maintain fresh, modern designs with this wonderful framework at your fingertips.
</p>
</div>

<div>
<div class="flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" class="w-6 h-6 stroke-gray-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.5 10.5V6.75a4.5 4.5 0 10-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 002.25-2.25v-6.75a2.25 2.25 0 00-2.25-2.25H6.75a2.25 2.25 0 00-2.25 2.25v6.75a2.25 2.25 0 002.25 2.25z" />
</svg>
<h2 class="ms-3 text-xl font-semibold text-gray-900">
Authentication
</h2>
</div>

<p class="mt-4 text-gray-500 text-sm leading-relaxed">
Authentication and registration views are included with Laravel Jetstream, as well as support for user email verification and resetting forgotten passwords. So, you're free to get started with what matters most: building your application.
</p>
</div>
</div>

</div>
</template>
29 changes: 29 additions & 0 deletions resources/js/Pages/Collection/Components/ResourceForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<div class="grid grid-cols-6 gap-4">

<div class="col-span-6 sm:col-span-6">
<InputLabel value="Name" />
<TextInput v-model="modelValue.name" type="text" class="mt-1 block w-full" />
<InputError :message="modelValue.errors.name" class="mt-2" />
</div>
<div class="col-span-6 sm:col-span-6">
<InputLabel value="Description (ai will use this to help understand the data)" />
<TextArea v-model="modelValue.description" type="text" class="mt-1 block w-full" />
<InputError :message="modelValue.errors.description" class="mt-2" />
</div>

</div>
</template>

<script setup>
import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue';
import TextInput from '@/Components/TextInput.vue';
import TextArea from '@/Components/TextArea.vue';
const props = defineProps({
modelValue: Object,
});
</script>
Loading

0 comments on commit dee8d03

Please sign in to comment.