Skip to content
Snippets Groups Projects
Commit 3696f10e authored by Tibo's avatar Tibo
Browse files

create basic rack view

parent 29e69eb3
No related branches found
No related tags found
No related merge requests found
Pipeline #13827 passed
...@@ -21,7 +21,9 @@ class ServerController extends Controller ...@@ -21,7 +21,9 @@ class ServerController extends Controller
return [ return [
'name' => 'required|string|regex:/^[a-zA-Z0-9\s\-\.]+$/|max:255', 'name' => 'required|string|regex:/^[a-zA-Z0-9\s\-\.]+$/|max:255',
"organization_id" => Rule::in(Auth::user()->organizations->modelKeys()), "organization_id" => Rule::in(Auth::user()->organizations->modelKeys()),
"description" => 'nullable|string']; "description" => 'nullable|string',
"size" => "nullable|int|min:0|max:48",
"position" => "nullable|int|min:0|max:48"];
} }
/** /**
...@@ -90,6 +92,8 @@ class ServerController extends Controller ...@@ -90,6 +92,8 @@ class ServerController extends Controller
$server->name = $request->name; $server->name = $request->name;
$server->organization_id = $request->organization_id; $server->organization_id = $request->organization_id;
$server->description = $request->description; $server->description = $request->description;
$server->size = $request->size;
$server->position = $request->position;
$server->save(); $server->save();
return redirect(action("ServerController@show", ["server" => $server])); return redirect(action("ServerController@show", ["server" => $server]));
......
...@@ -17,6 +17,8 @@ use Illuminate\Support\Collection; ...@@ -17,6 +17,8 @@ use Illuminate\Support\Collection;
* @property \Illuminate\Support\Carbon|null $updated_at * @property \Illuminate\Support\Carbon|null $updated_at
* @property string $name * @property string $name
* @property string $description * @property string $description
* @property int $size rack size, expressed in "U"
* @property int $position position in rack, expressed in "U", starting from the bottom
* @property string $token * @property string $token
* @property string $read_token * @property string $read_token
* @property \App\Organization $organization * @property \App\Organization $organization
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ServersAddRackInformation extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('servers', function (Blueprint $table) {
// expressed in "U"
$table->unsignedInteger("size")->default(0);
// expressed in "U", starting from the bottom
$table->unsignedInteger("position")->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('servers', function (Blueprint $table) {
$table->dropColumn("size");
$table->dropColumn("position");
});
}
}
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
@section('content') @section('content')
<style> <style>
div.rack {
position: relative;
width: 100%;
border: 1px solid rgba(0, 0, 0, 0.1);
}
div.server { div.server {
position: absolute; position: absolute;
width: 100%; width: 100%;
...@@ -15,30 +21,54 @@ ...@@ -15,30 +21,54 @@
border: 1px solid rgba(0, 0, 0, 0.1); border: 1px solid rgba(0, 0, 0, 0.1);
} }
div.1u { div.size-1u {
height: 2rem; height: 2rem;
} }
div.2u { div.size-2u {
height: 4rem; height: 4rem;
} }
div.size-48u {
height: 96rem
}
div.slot {
position: absolute;
width: 100%;
height: 2rem;
padding: 0.2rem;
display: flex;
flex-direction: column;
word-wrap: break-word;
background-color: rgba(0, 0, 0, 0.01);
border: 1px solid rgba(0, 0, 0, 0.05);
}
</style> </style>
<div class="container"> <div class="container">
<div class="rack size-48u">
<h1>{{ $organization->name }}</h1> @for ($i = 0; $i < 48; $i++)
<div class="slot" style="bottom: {{ 2*$i }}rem"></div>
<div style="position: relative; width: 100%; height: 96rem"> @endfor
<div class="server 1u"
style="bottom: 2rem;">
Server 02
</div>
<div class="server 1u" @foreach ($organization->servers as $server)
style="bottom: 0rem;"> @if ($server->size == 0)
Server 01 @continue
@endif
<div class="server size-{{ $server->size }}u"
style="bottom: {{ 2*$server->position }}rem;">
<p>
<a href="{{ $server->getUrlAttribute() }}"
class="text-decoration-none">
{{ $server->name }}
</a>
{!! $server->status()->badge() !!}
</p>
</div> </div>
@endforeach
</div> </div>
</div> </div>
......
...@@ -28,6 +28,11 @@ ...@@ -28,6 +28,11 @@
"organization" => $organization]) }}"> "organization" => $organization]) }}">
<i class="fas fa-redo-alt"></i> Reset dashboard token <i class="fas fa-redo-alt"></i> Reset dashboard token
</a> </a>
<a class="btn btn-primary btn-sm"
href="{{ action("OrganizationController@rack", ["organization" => $organization]) }}">
<i class="fas fa-server"></i> Rack view
</a>
</p> </p>
<table class="table table-striped my-5"> <table class="table table-striped my-5">
......
...@@ -68,6 +68,48 @@ ...@@ -68,6 +68,48 @@
</span> </span>
@endif @endif
</div> </div>
<div class="form-group">
<label for="size">Form factor</label>
<div class="input-group">
<input id="size"
type="number" min="0" max="48" step="1"
class="form-control{{ $errors->has('size') ? ' is-invalid' : '' }}"
name="size"
value="{{ old('size', $server->size) }}">
<div class="input-group-append">
<div class="input-group-text">u</div>
</div>
</div>
@if ($errors->has('size'))
<span class="invalid-feedback">
<strong>{{ $errors->first('size') }}</strong>
</span>
@endif
</div>
<div class="form-group">
<label for="position">Position (from bottom)</label>
<div class="input-group">
<input id="position"
type="number" min="0" max="48" step="1"
class="form-control{{ $errors->has('position') ? ' is-invalid' : '' }}"
name="position"
value="{{ old('position', $server->position) }}">
<div class="input-group-append">
<div class="input-group-text">u</div>
</div>
</div>
@if ($errors->has('position'))
<span class="invalid-feedback">
<strong>{{ $errors->first('position') }}</strong>
</span>
@endif
</div>
<div class="form-group"> <div class="form-group">
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment