Add description field to nodes (#1065)

This commit is contained in:
Stan 2018-03-26 20:57:24 +02:00 committed by Dane Everitt
parent 56478d81da
commit f1a76ec7fd
5 changed files with 65 additions and 11 deletions

View File

@ -63,6 +63,7 @@ class Node extends Model implements CleansAttributes, ValidableContract
'disk_overallocate', 'upload_size', 'disk_overallocate', 'upload_size',
'daemonSecret', 'daemonBase', 'daemonSecret', 'daemonBase',
'daemonSFTP', 'daemonListen', 'daemonSFTP', 'daemonListen',
'description',
]; ];
/** /**
@ -99,6 +100,7 @@ class Node extends Model implements CleansAttributes, ValidableContract
*/ */
protected static $dataIntegrityRules = [ protected static $dataIntegrityRules = [
'name' => 'regex:/^([\w .-]{1,100})$/', 'name' => 'regex:/^([\w .-]{1,100})$/',
'description' => 'string',
'location_id' => 'exists:locations,id', 'location_id' => 'exists:locations,id',
'public' => 'boolean', 'public' => 'boolean',
'fqdn' => 'string', 'fqdn' => 'string',
@ -226,4 +228,5 @@ class Node extends Model implements CleansAttributes, ValidableContract
{ {
return $this->hasMany(Allocation::class); return $this->hasMany(Allocation::class);
} }
}
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddDescriptionToNodes extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('nodes', function (Blueprint $table) {
$table->text('description')->after('name');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('nodes', function (Blueprint $table) {
$table->dropColumn('description');
});
}
}

View File

@ -32,15 +32,15 @@
<input type="text" name="name" id="pName" class="form-control" value="{{ old('name') }}"/> <input type="text" name="name" id="pName" class="form-control" value="{{ old('name') }}"/>
<p class="text-muted small">Character limits: <code>a-zA-Z0-9_.-</code> and <code>[Space]</code> (min 1, max 100 characters).</p> <p class="text-muted small">Character limits: <code>a-zA-Z0-9_.-</code> and <code>[Space]</code> (min 1, max 100 characters).</p>
</div> </div>
<div class="form-group">
<label for="pDescription" class="form-label">Description</label>
<textarea name="description" id="pDescription" rows="4" class="form-control">{{ old('description') }}</textarea>
</div>
<div class="form-group"> <div class="form-group">
<label for="pLocationId" class="form-label">Location</label> <label for="pLocationId" class="form-label">Location</label>
<select name="location_id" id="pLocationId"> <select name="location_id" id="pLocationId">
@foreach($locations as $location) @foreach($locations as $location)
@if($location->id == old('location_id')) <option value="{{ $location->id }}" {{ $location->id != old('location_id') ?: 'selected' }}>{{ $location->short }}</option>
<option value="{{ $location->id }}" selected>{{ $location->short }}</option>
@else
<option value="{{ $location->id }}">{{ $location->short }}</option>
@endif
@endforeach @endforeach
</select> </select>
</div> </div>
@ -177,4 +177,4 @@
<script> <script>
$('#pLocationId').select2(); $('#pLocationId').select2();
</script> </script>
@endsection @endsection

View File

@ -58,6 +58,18 @@
</div> </div>
</div> </div>
</div> </div>
@if ($node->description)
<div class="col-xs-12">
<div class="box box-default">
<div class="box-header with-border">
Description
</div>
<div class="box-body table-responsive">
<pre>{{ $node->description }}</pre>
</div>
</div>
</div>
@endif
<div class="col-xs-12"> <div class="col-xs-12">
<div class="box box-danger"> <div class="box box-danger">
<div class="box-header with-border"> <div class="box-header with-border">
@ -146,4 +158,4 @@
}); });
})(); })();
</script> </script>
@endsection @endsection

View File

@ -48,6 +48,12 @@
<p class="text-muted"><small>Character limits: <code>a-zA-Z0-9_.-</code> and <code>[Space]</code> (min 1, max 100 characters).</small></p> <p class="text-muted"><small>Character limits: <code>a-zA-Z0-9_.-</code> and <code>[Space]</code> (min 1, max 100 characters).</small></p>
</div> </div>
</div> </div>
<div class="form-group col-xs-12">
<label for="description" class="control-label">Description</label>
<div>
<textarea name="description" id="description" rows="4" class="form-control">{{ $node->description }}</textarea>
</div>
</div>
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label for="name" class="control-label">Location</label> <label for="name" class="control-label">Location</label>
<div> <div>
@ -71,8 +77,8 @@
<input type="text" autocomplete="off" name="fqdn" class="form-control" value="{{ old('fqdn', $node->fqdn) }}" /> <input type="text" autocomplete="off" name="fqdn" class="form-control" value="{{ old('fqdn', $node->fqdn) }}" />
</div> </div>
<p class="text-muted"><small>Please enter domain name (e.g <code>node.example.com</code>) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node. <p class="text-muted"><small>Please enter domain name (e.g <code>node.example.com</code>) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node.
<a tabindex="0" data-toggle="popover" data-trigger="focus" title="Why do I need a FQDN?" data-content="In order to secure communications between your server and this node we use SSL. We cannot generate a SSL certificate for IP Addresses, and as such you will need to provide a FQDN.">Why?</a> <a tabindex="0" data-toggle="popover" data-trigger="focus" title="Why do I need a FQDN?" data-content="In order to secure communications between your server and this node we use SSL. We cannot generate a SSL certificate for IP Addresses, and as such you will need to provide a FQDN.">Why?</a>
</small></p> </small></p>
</div> </div>
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label class="form-label"><span class="label label-warning"><i class="fa fa-power-off"></i></span> Communicate Over SSL</label> <label class="form-label"><span class="label label-warning"><i class="fa fa-power-off"></i></span> Communicate Over SSL</label>
@ -222,4 +228,4 @@
}); });
$('select[name="location_id"]').select2(); $('select[name="location_id"]').select2();
</script> </script>
@endsection @endsection