Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkregel committed Jul 11, 2024
1 parent 028a8b9 commit dc6e637
Show file tree
Hide file tree
Showing 17 changed files with 226 additions and 66 deletions.
22 changes: 21 additions & 1 deletion app/Http/Controllers/Spork/DevelopmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,28 @@ class DevelopmentController
{
public function index()
{
$path = base_path(request('path'));

return Inertia::render('Development/Index', [
// 'instances' => LaravelProgrammingStyle::instancesOf(CustomAction::class),
'title' => 'Settings',
'settings' => new class()
{
},
'files' => collect((new \Illuminate\Filesystem\Filesystem())->directories($path))
->map(fn ($directory) => [
'name' => basename($directory),
'file_path' => base64_encode($directory),
'is_directory' => true,
])
->concat(
collect((new \Illuminate\Filesystem\Filesystem())->files($path))
->map(fn (\SplFileInfo $file) => [
'name' => $file->getFilename(),
'file_path' => base64_encode($file->getPathname()),
'is_directory' => false,
])
),

]);
}
}
17 changes: 16 additions & 1 deletion app/Http/Controllers/Spork/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,29 @@ class SettingsController
{
public function __invoke()
{
$path = base_path(request('path'));

// settings are things that can be configured in between requests.
// They cannot be changed at run time, and might even require a restart of the servers.
return Inertia::render('Settings/Index', [
'title' => 'Settings',
'settings' => new class()
{
},
'notifications' => auth()->user()->notifications,
'files' => collect((new \Illuminate\Filesystem\Filesystem())->directories($path))
->map(fn ($directory) => [
'name' => basename($directory),
'file_path' => base64_encode($directory),
'is_directory' => true,
])
->concat(
collect((new \Illuminate\Filesystem\Filesystem())->files($path))
->map(fn (\SplFileInfo $file) => [
'name' => $file->getFilename(),
'file_path' => base64_encode($file->getPathname()),
'is_directory' => false,
])
),

]);
}
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Controllers/Spork/TagManagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ public function __invoke()
'accounts',
'domains',
'people',
'messages' => function ($q) {
$q->where('seen', false);
},
'messages',
])->withSum('transactions', 'amount')
->with(['conditions'])
->orderBy('type')
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function share(Request $request): array

return array_merge(parent::share($request), [
'navigation' => $navigation,
'current_navigation' => $navigation->where('current', true)->first(),
'current_navigation' => $navigation->flatten(1)->where('current', true)->first(),
'conversations' => auth()->check() ? Thread::query()
->with(['messages', 'messages.fromPerson', 'messages.toPerson'])
->whereHas('participants', function ($query) {
Expand Down
9 changes: 8 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use App\Services\News\NewsService;
use App\Services\Registrar\NamecheapService;
use App\Services\Weather\OpenWeatherService;
use App\Spork;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Filesystem\Filesystem;
Expand Down Expand Up @@ -86,6 +87,7 @@ public function register(): void
$this->app->bind(JiraServiceContract::class, JiraService::class);
$this->app->alias(Operator::class, 'operator');
$this->app->bind(PdfParserServiceContract::class, PdfParserService::class);
$this->app->singleton(Spork::class, fn () => new Spork());
}

/**
Expand All @@ -99,10 +101,15 @@ public function boot(): void

public function bootRoute(): void
{

Route::macro('domains', function (array $domains, $callback) {
foreach ($domains as $domain) {
Route::domain($domain)->group($callback)->name($domain);
Route::domain($domain)
->name($domain)
->group($callback);
}

return $this;
});

RateLimiter::for('api', function (Request $request) {
Expand Down
4 changes: 3 additions & 1 deletion app/Services/ConditionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public function navigation()
return $item;
});

return $navItems->filter(fn (Navigation $item) => $this->process($item));
return $navItems->filter(fn (Navigation $item) => $this->process($item))
->groupBy('group')
->sortKeys();
}

public function process(Conditionable $item, array $additionalValueData = [])
Expand Down
8 changes: 8 additions & 0 deletions app/Services/Finance/PlaidHttpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public function development(): self
return $this;
}

public function production(): self
{
$this->url = sprintf($this->baseUrl, 'production');
$this->new($this->url, []);

return $this;
}

public function auth($data): HttpService
{
$this->authBits = $data;
Expand Down
18 changes: 18 additions & 0 deletions app/Spork.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);

namespace App;

class Spork
{
protected array $navigation = [];

public function addNavigation(string $name, string $route, string $icon, array $options = []): array
{
return $this->navigation[] = array_merge([
'name' => $name,
'icon' => $icon,
'route' => url($route),
], $options);
}
}
2 changes: 1 addition & 1 deletion config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

'plaid' => [
'env' => env('PLAID_ENV', 'sandbox'),
'secret_key' => env('PLAID_DEVELOPMENT_SECRET', ''),
'secret_key' => env('PLAID_PRODUCTION_SECRET', ''),
'client_id' => env('PLAID_CLIENT_ID', ''),
'client_name' => env('APP_NAME'),
'language' => env('PLAID_LANGUAGE', 'en'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('navigations', function (Blueprint $table) {
$table->string('group')->index()->after('ugly_url');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('navigations', function (Blueprint $table) {
$table->dropColumn('group');
});
}
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"dayjs": "^1.11.9",
"dotenv": "^16.3.1",
"drawflow": "^0.0.59",
"highlight.js": "^11.10.0",
"mariadb": "^3.2.1",
"matrix-bot-sdk": "^0.7.0",
"matrix-js-sdk": "^29.1.0",
Expand All @@ -48,6 +49,7 @@
"prompts": "^2.4.2",
"pusher": "^5.1.3",
"sequelize": "^6.33.0",
"simple-code-editor": "^2.0.9",
"supertest": "^6.3.3",
"vue-draggable-next": "^2.2.1",
"vue-json-pretty": "^2.2.4",
Expand Down
19 changes: 10 additions & 9 deletions resources/js/Components/Spork/FileOrFolder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@
<span class="tracking-tight">{{ name }}</span>
</button>
<button v-else class="flex gap-1 items-center dark:hover:bg-stone-900/50 focus:bg-stone-900/50 focus:ring-2 focus:ring-blue-800"
:class="[
['artisan', 'composer', 'composer.phar', 'dev', 'sail', 'tests', 'public'].includes(name) ? 'text-green-600 dark:text-green-400' :'',
['composer.json', 'composer.lock'].includes(name) ? 'text-blue-500 dark:text-blue-300' :'',
['package.json', 'yarn.lock', 'package-lock.json',].includes(name) ? 'text-orange-600 dark:text-orange-400' :'',
!['artisan', 'composer', 'composer.phar', 'dev', 'sail', 'tests', 'public', 'composer.json', 'composer.lock', 'package.json', 'yarn.lock', 'package-lock.json',].includes(name) ? 'text-stone-700 dark:text-stone-100' :'',
]"
@dblclick="$emit('openFile', file)">
:class="[
['artisan', 'composer', 'composer.phar', 'dev', 'sail', 'tests', 'public'].includes(name) ? 'text-green-600 dark:text-green-400' :'',
['composer.json', 'composer.lock'].includes(name) ? 'text-blue-500 dark:text-blue-300' :'',
['package.json', 'yarn.lock', 'package-lock.json',].includes(name) ? 'text-orange-600 dark:text-orange-400' :'',
!['artisan', 'composer', 'composer.phar', 'dev', 'sail', 'tests', 'public', 'composer.json', 'composer.lock', 'package.json', 'yarn.lock', 'package-lock.json',].includes(name) ? 'text-stone-700 dark:text-stone-100' :'',
]"
@dblclick="$emit('openFile', file, name)"
>
<div class="w-4 h-4 flex-none"></div>

<svg class="w-4 h-4 flex-none" fill="none" stroke="currentColor" viewBox="0 0 24 24"
Expand All @@ -50,13 +51,13 @@
<span class="tracking-tight">{{ name }}</span>
</button>
<div v-if="folder && open">
<file-or-folder @openFile="$emit('openFile', fileThing)" v-for="fileThing in files" :key="fileThing.absolute" :file="fileThing">
<FileOrFolder v-for="fileThing in files" @openFile="(f) => $emit('openFile', f, file)" :key="fileThing.absolute" :file="fileThing">
<svg slot="icon" class="w-4 h-4 ml-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg">
<path v-if="fileThing.is_directory" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"></path>
<path v-else stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
</file-or-folder>
</FileOrFolder>
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions resources/js/Layouts/AppLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ const logout = () => {
</div>
<nav class="mt-8">
<div class="mt-6 w-full flex-1 space-y-1 px-2 flex flex-col">
<Link v-for="item in page.props.navigation" :key="item.name" :href="item?.href ?? '#'" :class="[item.current ? 'bg-slate-800 text-white' : 'text-slate-100 hover:bg-slate-800 hover:text-white', 'group flex w-full flex-wrap gap-2 rounded-md text-xs font-medium px-2 py-1.5 items-center justify-center xl:justify-start']" :aria-current="item.current ? 'page' : undefined">
<div v-for="(group, index) in page.props.navigation" class="mt-6 w-full flex-1 space-y-1 px-2 flex flex-col">
<div class="px-2 text-xs font-semibold text-stone-400 uppercase tracking-wider">{{ index }}</div>
<Link v-for="item in group" :key="item.name" :href="item?.href ?? '#'" :class="[item.current ? 'bg-slate-800 text-white' : 'text-slate-100 hover:bg-slate-800 hover:text-white', 'group flex w-full flex-wrap gap-2 rounded-md text-xs font-medium px-2 py-1.5 items-center justify-center xl:justify-start']" :aria-current="item.current ? 'page' : undefined">
<DynamicIcon :icon-name="item.icon" :active="item.current" :class="[item.current ? 'text-white' : 'text-slate-300 group-hover:text-white',
'xl:h-5 xl:w-5 w-6 h-6']" aria-hidden="true" />
<span class="text-base hidden xl:block">{{ item.name }}</span>
Expand Down Expand Up @@ -205,6 +206,5 @@ const logout = () => {
<audio id="notification-sound" src="/sounds/swiftly-610.ogg" preload="auto" type="audio/ogg" />
<audio id="success-sound" src="/sounds/i-did-it-message-tone.ogg" preload="auto" type="audio/ogg" />
<audio id="achievement-sound" src="/sounds/achievement-message-tone.ogg" preload="auto" type="audio/ogg" />
</div>
</template>
Loading

0 comments on commit dc6e637

Please sign in to comment.