Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkregel committed Dec 24, 2024
1 parent 9689192 commit 7ef9b28
Show file tree
Hide file tree
Showing 25 changed files with 530 additions and 411 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Spork/ManageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function show($model)

unset($paginator['data']);

return Inertia::render('Manage/Index', [
return Inertia::render('Manage/List', [
'title' => 'CRUD '.Str::ucfirst(str_replace('_', ' ', Str::ascii($table, 'en'))),
'description' => $description,
'singular' => Str::singular($table),
Expand Down
13 changes: 11 additions & 2 deletions app/Http/Controllers/Spork/ProjectsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Http\Controllers\Spork;

use App\Http\Controllers\Controller;
use App\Http\Requests\StoreProjectRequest;
use App\Models\Project;
use App\Models\Research;
use App\Models\Task;
Expand All @@ -18,8 +19,7 @@ public function index()
{
$model = \App\Models\Project::class;
/** @var \Illuminate\Pagination\LengthAwarePaginator $paginator */
$paginator = $model::query()
->where('team_id', auth()->user()->current_team_id)
$paginator = auth()->user()->personalProjects()
->paginate(request('limit', 15), ['*'], 'page', request('page', 1));

$data = $paginator->items();
Expand Down Expand Up @@ -172,4 +172,13 @@ public function create()
'description' => $description,
]);
}

public function store(StoreProjectRequest $request)
{
$project = new Project;
$project->forceFill($request->all());
$project->save();

return redirect()->route('projects.show', $project);
}
}
6 changes: 4 additions & 2 deletions app/Http/Requests/StoreProjectRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class StoreProjectRequest extends FormRequest
*/
public function authorize(): bool
{
return false;
return true;
}

/**
Expand All @@ -24,7 +24,9 @@ public function authorize(): bool
public function rules(): array
{
return [
//
'name' => 'required',
'settings' => 'json|nullable',
'user_id' => 'required|exists:users,id',
];
}
}
5 changes: 1 addition & 4 deletions app/Jobs/SyncMailboxIfCredentialsAreSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ public function handle(ImapFactoryService $imapFactory): void
$trackedMessage->save();
}
}

info('Processed '.$i.'/'.count($messages));
}

info('Finished syncing mailbox');
}

protected function getPersonFromEmail(array $message)
Expand Down Expand Up @@ -150,7 +148,6 @@ protected function getPersonToEmail(array $message)

if (empty($person)) {
$person = Person::first();
info('This thing from email: '.$fromEmail);

$person->update([
'emails' => array_values(array_unique(array_merge($person->emails, [strtolower($fromEmail)]))),
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function casts(): array

public function getIsUserAttribute()
{
return auth()->id() === $this->from_person;
return auth()->user()?->person()?->id === $this->from_person;
}

public function credential(): BelongsTo
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public function credentials(): MorphToMany
);
}

public function team(): BelongsTo
public function user(): BelongsTo
{
return $this->belongsTo(Team::class);
return $this->belongsTo(User::class);
}

public function deployments(): HasMany
Expand Down
5 changes: 5 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Fortify\TwoFactorAuthenticatable;
Expand Down Expand Up @@ -88,6 +89,10 @@ protected function casts(): array
'email_verified_at' => 'datetime',
];
}
public function personalProjects(): HasMany
{
return $this->hasMany(Project::class);
}

public function getActivitylogOptions(): LogOptions
{
Expand Down
2 changes: 1 addition & 1 deletion app/Repositories/MatrixClientSyncRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ protected function processMemberEvent($id, mixed $event)
$thread->update(['origin_server_ts' => Carbon::createFromFormat('U', round($event['origin_server_ts']/ 1000))]);
}

if (empty($person->photo_url)) {
if (empty($person->photo_url) && !empty($event['content']['avatar_url'])) {
try {
$person->photo_url = $this->downloadMedia($credential, $event['content']['avatar_url']);
$person->save();
Expand Down
2 changes: 1 addition & 1 deletion database/factories/ProjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function definition(): array
{
return [
'name' => $this->faker->name(),
'team_id' => Team::factory(),
'user_id' => User::factory(),
];
}
}
126 changes: 126 additions & 0 deletions database/migrations/2024_12_21_114749_moar_indexes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::table('articles', function (Blueprint $table) {
$table->index([
'last_modified',
'author_id',
'author_type',
]);
$table->index('headline');
});
Schema::table('domains', function (Blueprint $table) {
$table->index([
'credential_id',
'expires_at',
]);
});
Schema::table('accounts', function (Blueprint $table) {
$table->index([
'credential_id',
'type',
]);
});

Schema::table('transactions', function (Blueprint $table) {
$table->index([
'account_id',
'date',
]);
});

Schema::table('people', function (Blueprint $table) {
$table->index(['user_id', 'name']);
$table->index('identifiers');
});
Schema::table('roles', function (Blueprint $table) {
$table->index('name');
});
Schema::table('permissions', function (Blueprint $table) {
$table->index('name');
});
Schema::table('role_has_permissions', function (Blueprint $table) {
$table->index(['role_id', 'permission_id']);
});
Schema::table('model_has_permissions', function (Blueprint $table) {
$table->index(['model_id', 'model_type', 'permission_id']);
});
Schema::table('model_has_roles', function (Blueprint $table) {
$table->index(['model_id', 'model_type', 'role_id']);
});
Schema::table('emails', function (Blueprint $table) {
$table->index(['credential_id', 'sent_at']);
});
}

public function down(): void
{

Schema::table('articles', function (Blueprint $table) {
$table->dropIndex([
'last_modified',
'author_id',
'author_type',
]);
$table->dropIndex('headline');
});
Schema::table('domains', function (Blueprint $table) {
$table->dropIndex([
'credential_id',
'expires_at',
]);
});
Schema::table('accounts', function (Blueprint $table) {
$table->dropIndex([
'credential_id',
'type',
]);
});

Schema::table('transactions', function (Blueprint $table) {
$table->dropIndex([
'account_id',
'date',
]);
});

Schema::table('thread_participants', function (Blueprint $table) {
$table->dropIndex([
'thread_id',
'person_id',
]);
});
Schema::table('threads', function (Blueprint $table) {
$table->dropIndex('thread_id');
});
Schema::table('people', function (Blueprint $table) {
$table->dropIndex(['user_id', 'name']);
$table->dropIndex('identities');
});
Schema::table('roles', function (Blueprint $table) {
$table->dropIndex('name');
});
Schema::table('permissions', function (Blueprint $table) {
$table->dropIndex('name');
});
Schema::table('role_has_permissions', function (Blueprint $table) {
$table->dropIndex(['role_id', 'permission_id']);
});
Schema::table('model_has_permissions', function (Blueprint $table) {
$table->dropIndex(['model_id', 'model_type', 'permission_id']);
});
Schema::table('model_has_roles', function (Blueprint $table) {
$table->dropIndex(['model_id', 'model_type', 'role_id']);
});
Schema::table('emails', function (Blueprint $table) {
$table->dropIndex(['credential_id', 'sent_at']);
});
}
};
34 changes: 34 additions & 0 deletions resources/js/Components/NotificationBody.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script setup>
import { computed } from 'vue'
import { NewspaperIcon } from "@heroicons/vue/20/solid";
import moment from "moment-timezone";
const { notification } = defineProps({
notification: Object
})
const notificationText = computed(() => {
return notification.text
})
const date = computed(() => {
return moment(notification.created_at).format("YYYY-MM-DD")
})
</script>

<template>
<div v-if="notification.type === 'App\\Notifications\\Daily\\SummaryNotification'">
<div class="p-4">
<NewspaperIcon class="h-6 w-6 text-gray-400" />
</div>
<div class="py-2">
Your summary notification for {{ date }} is ready!
</div>
</div>
<pre v-else>{{ notification }}</pre>
</template>

<style scoped>
</style>
19 changes: 3 additions & 16 deletions resources/js/Layouts/AppLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
import { ChevronDownIcon, MagnifyingGlassIcon } from '@heroicons/vue/20/solid'
import DynamicIcon from "@/Components/DynamicIcon.vue";
import Search from "@/Components/Spork/Molecules/Search.vue";
import NotificationBody from "@/Components/NotificationBody.vue";
const page = usePage()
defineProps({
title: String,
Expand Down Expand Up @@ -171,22 +172,8 @@ const logout = () => {
<transition enter-active-class="transition ease-out duration-100" enter-from-class="transform opacity-0 scale-95" enter-to-class="transform opacity-100 scale-100" leave-active-class="transition ease-in duration-75" leave-from-class="transform opacity-100 scale-100" leave-to-class="transform opacity-0 scale-95">
<MenuItems class="absolute right-0 z-0 mt-2.5 w-96 origin-top-right rounded-md bg-white dark:bg-stone-800 py-2 shadow-lg ring-1 ring-stone-900/5 focus:outline-none">
<MenuItem class="flex items-start px-2">
<template>
<div class="flex-shrink-0">
<DynamicIcon icon-name="CheckCircleIcon" class="h-6 w-6 text-green-400 dark:text-green-300" aria-hidden="true" />
</div>
<div class="ml-3 w-0 flex-1 pt-0.5">
<p class="text-sm font-medium text-gray-900 dark:text-gray-50">Successfully saved!</p>
<p class="mt-1 text-sm text-gray-500 dark:text-gray-300">Anyone with a link can now view this file.</p>
</div>
<div class="ml-4 flex flex-shrink-0">
<button type="button" @click="show = false" class="inline-flex rounded-md bg-white text-gray-400 dark:text-gray-300 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
<span class="sr-only">Close</span>
<XMarkIcon class="h-5 w-5" aria-hidden="true" />
</button>
</div>
</template>
<MenuItem class="flex items-start px-2" v-for="notification in page.props.notifications" :key="notification">
<NotificationBody :notification="notification" />
</MenuItem>
</MenuItems>
</transition>
Expand Down
Loading

0 comments on commit 7ef9b28

Please sign in to comment.