Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rss feed, expiring domain list, and recent job batches to dashboard #5

Merged
merged 18 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ $ ./bin/sail up -d
```
(On Mac or Linux)


# What does it do? Features?
- [x] Syncing domains from Namecheap
- [x] Syncing servers from Laravel Forge
Expand Down Expand Up @@ -44,3 +43,7 @@ $ ./bin/sail up -d
- [ ] List events from all projects
- [ ] List budget usage -- if applicable.
- [ ] Domain Purchasing and Renewals

## Screenshots

![screenshot-dashboard-2024-02-25.png](/resources/screenshots/screenshot-dashboard-2024-02-25.png)
2 changes: 1 addition & 1 deletion app/Actions/Jetstream/AddTeamMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AddTeamMember implements AddsTeamMembers
/**
* Add a new team member to the given team.
*/
public function add(User $user, Team $team, string $email, string $role = null): void
public function add(User $user, Team $team, string $email, ?string $role = null): void
{
Gate::forUser($user)->authorize('addTeamMember', $team);

Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Jetstream/InviteTeamMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InviteTeamMember implements InvitesTeamMembers
/**
* Invite a new team member to the given team.
*/
public function invite(User $user, Team $team, string $email, string $role = null): void
public function invite(User $user, Team $team, string $email, ?string $role = null): void
{
Gate::forUser($user)->authorize('addTeamMember', $team);

Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Spork/CustomAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class CustomAction
public function __construct(
public string $name = 'Set Namecheap DNS',
public string $slug = 'custom-action',
public ?string $models = null,
public array $models = [],
) {
}
}
54 changes: 54 additions & 0 deletions app/Actions/Spork/Domains/AddDomainToCloudflareAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);

namespace App\Actions\Spork\Domains;

use App\Actions\Spork\CustomAction;
use App\Contracts\ActionInterface;
use App\Models\Credential;
use App\Models\Domain;
use App\Services\Factories\DomainServiceFactory;
use App\Services\Factories\RegistrarServiceFactory;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Http\Request;

class AddDomainToCloudflareAction extends CustomAction implements ActionInterface
{
public function __construct($name = 'Add domain to cloudflare', $slug = 'add-domain-to-cloudflare')
{
parent::__construct($name, $slug, models: [Domain::class]);
}

public function __invoke(Dispatcher $dispatcher, Request $request)
{
$request->validate([
'items' => 'required|array',
]);
$credentials = $request->user()->credentials()->get();

$domains = Domain::query()
->with('credential')
->whereIn('credential_id', $credentials->pluck('id'))
->whereIn('id', $request->input('items'))
->get();

$cloudflare = Credential::query()
->where('user_id', $request->user()->id)
->where('service', 'cloudflare')
->where('type', Credential::TYPE_DOMAIN)
->first();

$registrarFactory = new RegistrarServiceFactory;
$domainFactory = new DomainServiceFactory;
$cloudflareService = $domainFactory->make($cloudflare);

foreach ($domains as $domain) {

$cfDns = $cloudflareService->createDomain($domain->name);
$registrarService = $registrarFactory->make($domain->credential);

$registrarService->updateDomainNs($domain->name, $cfDns);
}
}
}
33 changes: 0 additions & 33 deletions app/Actions/Spork/Domains/SyncNamecheapDnsAction.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Actions/Spork/SyncDataFromCredential.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SyncDataFromCredential extends CustomAction
{
public function __construct($name = 'Sync Data From Credential', $slug = 'sync-data-from-credential')
{
parent::__construct($name, $slug, models: Credential::class);
parent::__construct($name, $slug, models: [Credential::class]);
}

public function __invoke(Dispatcher $dispatcher, Request $request)
Expand Down
33 changes: 0 additions & 33 deletions app/Console/Commands/Generate.php

This file was deleted.

203 changes: 203 additions & 0 deletions app/Console/Commands/LibraryMetaDataScan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Jobs\BuildMetaDataFile;
use Closure;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;

class LibraryMetaDataScan extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:library-meta-data-scan';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Execute the console command.
*/
public function handle()
{
// ...$filesystem->directories('/media/Downloads'),
$supportedTypes = [
// Audio
'mp3',
'flac',
'm3u',
'm4a',
'ogg',
// ebooks
'pdf',
'epub',
//video
'mp4',
'mkv',
'm4v',
'm2ts',
'part',
'mkv.part',
// sub titles
'ts',
'srt',
// metadata
'cue',
'xml',
// playlist
'm3u8',
// db
'json',
'sqlite',
'sqlite3',
'ini',

// checksums
'sfv',
'checksum',

// audiotracks
'mka',
];
$blacklistedTypes = [
'gif',
'png',
'jpg',
'jpeg',
'nfo',
'gif',
'mobileconfig',
'xci',
'html',
'log',
'svg',
'txt',
'url',
'exe',
'db',
'metathumb',
'iso',
'lnk',
'md',
'About_album',
'pls',
'accurip',
'mid',
'auCDtect',
'opus',
'hosts',
'last_time',
'sbk',
'yml',
'db-shm',
'db-wal',
'zip',
'yaml',
'pem',
'txz',
'1',
'mbp',
'env',
'config',
'key',
'js',
'INFO',
'css',
'psd',
'pspimage',
'sqlite3-shm',
'sqlite3-wal',
'gz',
'phar',
'LICENSE',
'lock',
'dist',
'web',
'php',
'composer',
'console',
'sh',
'jsonlint',
'php-cs-fixer',
'php-parse',
'phpstan',
'phpunit',
'satis',
'validate-json',
'var-dump-server',
'Dockerfile',
'conf',
'ico',
'map',
'eot',
'ttf',
'woff',
'woff2',
'twig',
'meta',
'PORTING_INFO',
'compile',
'bat',
'stub',
'scss',
'rst',
'diff',
'phpt',
'template',
'y',
'asc',
'neon',
'xsd',
'tpl',
'base64',
'xlf',
'CHANGELOG',
'secret',
'public',
'planet',
'port',
'peer',
];

$this->recursivelyFindFiles('/media/Shows', $supportedTypes, $blacklistedTypes, function (\SplFileInfo $file, $err, $out) {
});
}

protected function recursivelyFindFiles(string $directory, array &$supportedTypes, array &$blacklistedTypes, Closure $callback)
{
$this->warn(' Found: '.$directory);
$files = (new Filesystem)->files($directory);

// Build a list of supported file types.
// Interactively when
/** @var \SplFileInfo $file */
foreach ($files as $file) {
$name = $file->getBasename();
$split = explode('.', $name);
$extension = end($split);
$path = $file->getPathname();

if (in_array($extension, $blacklistedTypes)) {
continue;
}

dispatch(new BuildMetaDataFile($path));
}

$directories = (new Filesystem)->directories($directory);

foreach ($directories as $directory) {
$this->recursivelyFindFiles($directory, $supportedTypes, $blacklistedTypes, $callback);
}
}
}
Loading
Loading