diff --git a/.gitattributes b/.gitattributes index 967315d..42782b7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,6 @@ *.scss linguist-vendored *.js linguist-vendored CHANGELOG.md export-ignore + +/public/css/* -diff +/public/js/* -diff diff --git a/.gitignore b/.gitignore index 80c27a5..3de754b 100644 --- a/.gitignore +++ b/.gitignore @@ -57,7 +57,7 @@ fabric.properties # .idea/misc.xml # *.ipr storage/clockwork/ -public/css/ -public/js/ -public/fonts/ -public/webfonts/ +#public/css/ +#public/js/ +#public/fonts/ +#public/webfonts/ diff --git a/README.md b/README.md index fa66e05..e4f17b3 100644 --- a/README.md +++ b/README.md @@ -18,20 +18,9 @@ GeekBench 5 scores to do easier comparing and sorting. ## Project sponsor -[Cloud Five Limited](https://cloud-v.net/) for providing the hosting for demo installation. +Currently seeking a project sponsor -## 2.1.8 changes (20th October 2022): - -#### You can no longer use the form to submit YABS results -yabs.sh now has JSON formatted response and can POST the output directly from calling the script. - -With My idlers you can use your API key and the server id to directly POST the benchmark result - -`http://domain.com/api/yabs/tnSJLyhz/USERAPIKEYISHERE` - -Example yabs.sh call to POST the result - -`curl -sL yabs.sh | bash -s -- -s "http://domain.com/api/yabs/tnSJLyhz/USERAPIKEYISHERE"` +## 2.1.9 changes (2nd December 2022): ### NPM / Laravel mix now in use @@ -43,18 +32,15 @@ npm run prod #### Please run the following if updating from existing install: ```shell +php artisan migrate php artisan route:cache php artisan cache:clear ``` -* Added & implemented details footer blade component -* Added new index layout -* Updated domains, misc, reseller, seedboxes and shared use new index layout -* Updated validation for store and update -* Updated `updatePricing()` to not need `$as_usd` parameter -* Updated labels assigned insert -* Updated order/sort by methods for pricing related columns -* Removed add YABS button on servers index page +* Added & implemented NPM webpack +* Added compiled assets +* Added notes (Servers, shared, reseller, domains, DNS and IPs) +* Fixed create views default provider is no longer the former sponsor ## Requires @@ -78,6 +64,7 @@ php artisan cache:clear * Assign labels * Assign server type (KVM, OVZ, LXC & dedi) * Easy to edit values +* Assign notes ## Install @@ -120,6 +107,18 @@ Run with a single click on [PikaPods.com](https://www.pikapods.com/) [![PikaPods](https://www.pikapods.com/static/run-button.svg)](https://www.pikapods.com/pods?run=my-idlers) +## Adding a YABS benchmark + +yabs.sh now has JSON formatted response and can POST the output directly from calling the script. + +With My idlers you can use your API key and the server id to directly POST the benchmark result + +`https://yourdomain.com/api/yabs/SERVERID/USERAPIKEYISHERE` + +Example yabs.sh call to POST the result: + +`curl -sL yabs.sh | bash -s -- -s "https://yourdomain.com/api/yabs/SERVERID/USERAPIKEYISHERE"` + ## API endpoints For GET requests the header must have `Accept: application/json` and your API token (found at `/account`) diff --git a/app/Http/Controllers/NoteController.php b/app/Http/Controllers/NoteController.php new file mode 100644 index 0000000..038b84d --- /dev/null +++ b/app/Http/Controllers/NoteController.php @@ -0,0 +1,124 @@ +validate([ + 'service_id' => 'required|string|size:8', + 'note' => 'required|string', + ]); + + try { + $note_id = Str::random(8); + + $a = Note::create([ + 'id' => $note_id, + 'service_id' => $request->service_id, + 'note' => $request->note + ]); + + } catch (\Exception $e) { + + if ($e->getCode() === "23000") { + $message = "A note already exists for this service"; + } else { + $message = "Error inserting note"; + } + + return redirect()->route('notes.create') + ->withInput($request->input())->with('error', $message); + } + + Cache::forget('all_notes'); + + return redirect()->route('notes.index') + ->with('success', 'Note created successfully.'); + } + + public function edit(Note $note) + { + $note = Note::note($note->service_id); + $servers = Server::all(); + $shareds = Shared::all(); + $resellers = Reseller::all(); + $domains = Domains::all(); + $dns = DNS::all(); + $ips = IPs::all(); + + return view('notes.edit', compact(['note', 'servers', 'shareds', 'resellers', 'domains', 'dns', 'ips'])); + } + + public function update(Request $request, Note $note) + { + $request->validate([ + 'service_id' => 'required|string|size:8', + 'note' => 'required|string' + ]); + + $note->update([ + 'service_id' => $request->service_id, + 'note' => $request->note + ]); + + Cache::forget('all_notes'); + Cache::forget("note.$note->service_id"); + + return redirect()->route('notes.index') + ->with('success', 'Note was updated successfully.'); + } + + public function show(Note $note) + { + $note = Note::note($note->service_id); + return view('notes.show', compact(['note'])); + } + + public function destroy(Note $note) + { + if ($note->delete()) { + Cache::forget("all_notes"); + Cache::forget("note.$note->service_id"); + + return redirect()->route('notes.index') + ->with('success', 'Note was deleted successfully.'); + } + + return redirect()->route('notes.index') + ->with('error', 'Note was not deleted.'); + + } + +} diff --git a/app/Models/DNS.php b/app/Models/DNS.php index 6cb1df2..ac52e82 100644 --- a/app/Models/DNS.php +++ b/app/Models/DNS.php @@ -25,4 +25,10 @@ class DNS extends Model return DB::table('d_n_s')->count(); }); } + + public function note(): \Illuminate\Database\Eloquent\Relations\HasOne + { + return $this->hasOne(Note::class, 'service_id', 'id'); + } + } diff --git a/app/Models/Domains.php b/app/Models/Domains.php index 5172992..59127eb 100644 --- a/app/Models/Domains.php +++ b/app/Models/Domains.php @@ -56,4 +56,9 @@ class Domains extends Model return $this->hasMany(LabelsAssigned::class, 'service_id', 'id'); } + public function note(): \Illuminate\Database\Eloquent\Relations\HasOne + { + return $this->hasOne(Note::class, 'service_id', 'id'); + } + } diff --git a/app/Models/IPs.php b/app/Models/IPs.php index 1dbb5eb..c5beddb 100644 --- a/app/Models/IPs.php +++ b/app/Models/IPs.php @@ -47,4 +47,9 @@ class IPs extends Model }); } + public function note(): \Illuminate\Database\Eloquent\Relations\HasOne + { + return $this->hasOne(Note::class, 'service_id', 'id'); + } + } diff --git a/app/Models/Note.php b/app/Models/Note.php new file mode 100644 index 0000000..6ab7d6d --- /dev/null +++ b/app/Models/Note.php @@ -0,0 +1,66 @@ +addMonth(1), function () use ($service_id) { + return self::where('service_id', $service_id)->with(['server', 'shared', 'reseller', 'domain', 'dns', 'ip'])->first(); + }); + } + + public static function allNotes() + { + return Cache::remember("all_notes", now()->addMonth(1), function () { + return self::with(['server', 'shared', 'reseller', 'domain', 'dns', 'ip'])->orderBy('created_at', 'desc')->get(); + }); + } + + public function server(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Server::class, 'service_id', 'id'); + } + + public function shared(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Shared::class, 'service_id', 'id'); + } + + public function reseller(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Reseller::class, 'service_id', 'id'); + } + + public function domain(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Domains::class, 'service_id', 'id'); + } + + public function dns(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(DNS::class, 'service_id', 'id'); + } + + public function ip(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(IPs::class, 'service_id', 'id'); + } + +} diff --git a/app/Models/Reseller.php b/app/Models/Reseller.php index fb5c6c6..54c9d47 100644 --- a/app/Models/Reseller.php +++ b/app/Models/Reseller.php @@ -78,4 +78,9 @@ class Reseller extends Model return $this->hasMany(LabelsAssigned::class, 'service_id', 'id'); } + public function note(): \Illuminate\Database\Eloquent\Relations\HasOne + { + return $this->hasOne(Note::class, 'service_id', 'id'); + } + } diff --git a/app/Models/Server.php b/app/Models/Server.php index 16ad201..e424358 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -234,4 +234,9 @@ class Server extends Model return $this->hasMany(LabelsAssigned::class, 'service_id', 'id'); } + public function note(): \Illuminate\Database\Eloquent\Relations\HasOne + { + return $this->hasOne(Note::class, 'service_id', 'id'); + } + } diff --git a/app/Models/Shared.php b/app/Models/Shared.php index 3cca635..f26e86b 100644 --- a/app/Models/Shared.php +++ b/app/Models/Shared.php @@ -78,4 +78,9 @@ class Shared extends Model return $this->hasMany(LabelsAssigned::class, 'service_id', 'id'); } + public function note(): \Illuminate\Database\Eloquent\Relations\HasOne + { + return $this->hasOne(Note::class, 'service_id', 'id'); + } + } diff --git a/database/migrations/2022_12_02_000007_create_notes_table.php b/database/migrations/2022_12_02_000007_create_notes_table.php new file mode 100644 index 0000000..8dce8d7 --- /dev/null +++ b/database/migrations/2022_12_02_000007_create_notes_table.php @@ -0,0 +1,23 @@ +char('id', 8)->primary(); + $table->char('service_id', 8)->unique(); + $table->text('note'); + $table->timestamps(); + }); + } + + public function down() + { + Schema::dropIfExists('notes'); + } +}; diff --git a/public/css/app.css b/public/css/app.css index 36aae37..7a2263d 100644 Binary files a/public/css/app.css and b/public/css/app.css differ diff --git a/public/css/dark.css b/public/css/dark.css new file mode 100644 index 0000000..665d32d Binary files /dev/null and b/public/css/dark.css differ diff --git a/public/css/light.css b/public/css/light.css new file mode 100644 index 0000000..b0add7c Binary files /dev/null and b/public/css/light.css differ diff --git a/public/js/app.js b/public/js/app.js index 56c33b1..fc0b997 100644 Binary files a/public/js/app.js and b/public/js/app.js differ diff --git a/public/js/app.js.LICENSE.txt b/public/js/app.js.LICENSE.txt new file mode 100644 index 0000000..2c9b099 Binary files /dev/null and b/public/js/app.js.LICENSE.txt differ diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 2d60117..21c4155 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,4 +1,6 @@ { "/js/app.js": "/js/app.js", - "/css/app.css": "/css/app.css" + "/css/app.css": "/css/app.css", + "/css/dark.css": "/css/dark.css", + "/css/light.css": "/css/light.css" } diff --git a/resources/views/dns/show.blade.php b/resources/views/dns/show.blade.php index 57329e9..0d267e1 100644 --- a/resources/views/dns/show.blade.php +++ b/resources/views/dns/show.blade.php @@ -88,6 +88,12 @@ +
+ @if(isset($dns->note)) +

Note:

+

{{$dns->note->note}}

+ @endif +
diff --git a/resources/views/domains/create.blade.php b/resources/views/domains/create.blade.php index 821f7e9..728f319 100644 --- a/resources/views/domains/create.blade.php +++ b/resources/views/domains/create.blade.php @@ -52,7 +52,7 @@
- 10 + {{random_int(1,98)}}
diff --git a/resources/views/domains/show.blade.php b/resources/views/domains/show.blade.php index 883cc16..a4eda55 100644 --- a/resources/views/domains/show.blade.php +++ b/resources/views/domains/show.blade.php @@ -85,6 +85,12 @@
+
+ @if(isset($domain_info->note)) +

Note:

+

{{$domain_info->note->note}}

+ @endif +
{{ route('domains.index') }} diff --git a/resources/views/layouts/navigation.blade.php b/resources/views/layouts/navigation.blade.php index b7be5eb..871db2f 100644 --- a/resources/views/layouts/navigation.blade.php +++ b/resources/views/layouts/navigation.blade.php @@ -38,6 +38,7 @@
  • Providers
  • Seedboxes
  • YABS
  • +
  • Notes
  • Settings
  • Account
  • diff --git a/resources/views/notes/create.blade.php b/resources/views/notes/create.blade.php new file mode 100644 index 0000000..99f32d6 --- /dev/null +++ b/resources/views/notes/create.blade.php @@ -0,0 +1,67 @@ +@section("title", "Add a note") + + + {{ __('Create a note') }} + +
    + + + {{ route('notes.index') }} + Go back + + +
    + @csrf +
    +
    + +
    +
    +
    +

    This note is for:

    +
    +
    +
    Service
    +
    +
    +
    +
    +
    + Create note +
    +
    +
    +
    +
    +
    diff --git a/resources/views/notes/edit.blade.php b/resources/views/notes/edit.blade.php new file mode 100644 index 0000000..60f0196 --- /dev/null +++ b/resources/views/notes/edit.blade.php @@ -0,0 +1,74 @@ +@section("title", "Edit note") + + + {{ __('Edit note') }} + +
    + + + {{ route('notes.index') }} + Go back + + +
    + @csrf + @method('PUT') +
    +
    + +
    +
    +
    +

    This note is for:

    +
    +
    +
    Service
    +
    +
    +
    +
    +
    + Update note +
    +
    +
    +
    +
    +
    diff --git a/resources/views/notes/index.blade.php b/resources/views/notes/index.blade.php new file mode 100644 index 0000000..ba897e0 --- /dev/null +++ b/resources/views/notes/index.blade.php @@ -0,0 +1,90 @@ +@section('title', 'Notes') + + + {{ __('Notes') }} + +
    + + + Add a note + +
    + + + + + + + + + + + @if(!empty($notes[0])) + @foreach($notes as $n) + + + + + + + @endforeach + @else + + + + + + + @endif + +
    ServiceTypeNote PreviewActions
    + @if(!is_null($n->server)) + {{$n->server->hostname}} + @elseif(!is_null($n->shared)) + {{$n->shared->main_domain}} + @elseif(!is_null($n->reseller)) + {{$n->reseller->main_domain}} + @elseif(!is_null($n->domain)) + {{$n->domain->domain}}.{{$n->domain->extension}} + @elseif(!is_null($n->dns)) + {{$n->dns->dns_type}} {{$n->dns->hostname}} + @elseif(!is_null($n->ip)) + {{$n->ip->address}} + @endif + + @if(!is_null($n->server)) + SERVER + @elseif(!is_null($n->shared)) + SHARED + @elseif(!is_null($n->reseller)) + RESELLER + @elseif(!is_null($n->domain)) + DOMAIN + @elseif(!is_null($n->dns)) + DNS + @elseif(!is_null($n->ip)) + IP + @endif + {{strlen($n->note) > 80 ? substr($n->note,0,80)."…" : $n->note}} +
    + + + + + @csrf + @method('DELETE') + note}}"> +
    +
    No notes found.
    +
    +
    + +
    + + notes + +
    diff --git a/resources/views/notes/show.blade.php b/resources/views/notes/show.blade.php new file mode 100644 index 0000000..e1a1b69 --- /dev/null +++ b/resources/views/notes/show.blade.php @@ -0,0 +1,40 @@ +@section("title", "Note $note->id") + + + {{ __('Note') }} + +
    + +
    +
    +

    + @if(!is_null($note->server)) + {{$note->server->hostname}} (server) + @elseif(!is_null($note->shared)) + {{$note->shared->main_domain}} (shared) + @elseif(!is_null($note->reseller)) + {{$note->reseller->main_domain}} (reseller) + @elseif(!is_null($note->domain)) + {{$note->domain->domain}}.{{$note->domain->extension}} (domain) + @elseif(!is_null($note->dns)) + {{$note->dns->dns_type}} {{$note->dns->hostname}} (DNS) + @elseif(!is_null($note->ip)) + {{$note->ip->address}} (IP) + @endif +

    +
    +
    +
    +
    + {{$note->note}} +
    +
    + + {{ route('notes.index') }} + + + {{ route('notes.edit', $note->id) }} + +
    +
    +
    diff --git a/resources/views/reseller/create.blade.php b/resources/views/reseller/create.blade.php index 747a069..5b1a265 100644 --- a/resources/views/reseller/create.blade.php +++ b/resources/views/reseller/create.blade.php @@ -47,7 +47,7 @@
    - 10 + {{random_int(1,98)}}
    diff --git a/resources/views/reseller/show.blade.php b/resources/views/reseller/show.blade.php index 7f2b590..74e0a8d 100644 --- a/resources/views/reseller/show.blade.php +++ b/resources/views/reseller/show.blade.php @@ -133,6 +133,12 @@ FTP Limit {{$reseller->ftp_limit}} + @if(isset($reseller->note)) + + Note: + {{$reseller->note->note}} + + @endif diff --git a/resources/views/seedboxes/create.blade.php b/resources/views/seedboxes/create.blade.php index a54aa29..77c2978 100644 --- a/resources/views/seedboxes/create.blade.php +++ b/resources/views/seedboxes/create.blade.php @@ -45,7 +45,7 @@
    - 10 + {{random_int(1,98)}}
    diff --git a/resources/views/servers/create.blade.php b/resources/views/servers/create.blade.php index a8349e0..0e20a0a 100644 --- a/resources/views/servers/create.blade.php +++ b/resources/views/servers/create.blade.php @@ -110,7 +110,7 @@
    - 10 + {{random_int(1,98)}}
    diff --git a/resources/views/servers/show.blade.php b/resources/views/servers/show.blade.php index bb75ebd..e6afdf0 100644 --- a/resources/views/servers/show.blade.php +++ b/resources/views/servers/show.blade.php @@ -210,6 +210,10 @@ @endif

    curl -sL yabs.sh | bash -s -- -s "{{route('api.store-yabs', [$server_data->id, \Illuminate\Support\Facades\Auth::user()->api_token])}}"

    + @if(isset($server_data->note)) +

    Note:

    +

    {{$server_data->note->note}}

    + @endif
    diff --git a/resources/views/shared/create.blade.php b/resources/views/shared/create.blade.php index 906235b..06c0578 100644 --- a/resources/views/shared/create.blade.php +++ b/resources/views/shared/create.blade.php @@ -47,7 +47,7 @@
    - 10 + {{random_int(1,98)}}
    diff --git a/resources/views/shared/show.blade.php b/resources/views/shared/show.blade.php index c228262..f15f4ac 100644 --- a/resources/views/shared/show.blade.php +++ b/resources/views/shared/show.blade.php @@ -20,7 +20,7 @@
    -
    +
    @@ -97,7 +97,7 @@
    -
    +
    @@ -128,6 +128,12 @@ + @if(isset($shared->note)) + + + + + @endif
    FTP Limit {{$shared->ftp_limit}}
    Note:{{$shared->note->note}}
    diff --git a/routes/web.php b/routes/web.php index f8cbf3f..e02dbf0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -7,6 +7,7 @@ use App\Http\Controllers\IPsController; use App\Http\Controllers\LabelsController; use App\Http\Controllers\LocationsController; use App\Http\Controllers\MiscController; +use App\Http\Controllers\NoteController; use App\Http\Controllers\OsController; use App\Http\Controllers\ProvidersController; use App\Http\Controllers\ResellerController; @@ -64,6 +65,8 @@ Route::resource('shared', SharedController::class)->middleware(['auth']); Route::resource('yabs', YabsController::class)->middleware(['auth']); +Route::resource('notes', NoteController::class)->middleware(['auth']); + Route::get('yabs/{yab}/json', 'App\Http\Controllers\YabsController@yabsToJson')->middleware(['auth'])->name('yabs.json'); Route::get('yabs-compare-choose', 'App\Http\Controllers\YabsController@chooseYabsCompare')->middleware(['auth'])->name('yabs.compare-choose');