Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/resources/views/admin/servers/view/database.blade.php
7461 views
1
@extends('layouts.admin')
2
3
@section('title')
4
Server — {{ $server->name }}: Databases
5
@endsection
6
7
@section('content-header')
8
<h1>{{ $server->name }}<small>Manage server databases.</small></h1>
9
<ol class="breadcrumb">
10
<li><a href="{{ route('admin.index') }}">Admin</a></li>
11
<li><a href="{{ route('admin.servers') }}">Servers</a></li>
12
<li><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></li>
13
<li class="active">Databases</li>
14
</ol>
15
@endsection
16
17
@section('content')
18
@include('admin.servers.partials.navigation')
19
<div class="row">
20
<div class="col-sm-7">
21
<div class="alert alert-info">
22
Database passwords can be viewed when <a href="/server/{{ $server->uuidShort }}/databases">visiting this server</a> on the front-end.
23
</div>
24
<div class="box box-primary">
25
<div class="box-header with-border">
26
<h3 class="box-title">Active Databases</h3>
27
</div>
28
<div class="box-body table-responsible no-padding">
29
<table class="table table-hover">
30
<tr>
31
<th>Database</th>
32
<th>Username</th>
33
<th>Connections From</th>
34
<th>Host</th>
35
<th>Max Connections</th>
36
<th></th>
37
</tr>
38
@foreach($server->databases as $database)
39
<tr>
40
<td>{{ $database->database }}</td>
41
<td>{{ $database->username }}</td>
42
<td>{{ $database->remote }}</td>
43
<td><code>{{ $database->host->host }}:{{ $database->host->port }}</code></td>
44
@if($database->max_connections != null)
45
<td>{{ $database->max_connections }}</td>
46
@else
47
<td>Unlimited</td>
48
@endif
49
<td class="text-center">
50
<button data-action="reset-password" data-id="{{ $database->id }}" class="btn btn-xs btn-primary"><i class="fa fa-refresh"></i></button>
51
<button data-action="remove" data-id="{{ $database->id }}" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></button>
52
</td>
53
</tr>
54
@endforeach
55
</table>
56
</div>
57
</div>
58
</div>
59
<div class="col-sm-5">
60
<div class="box box-success">
61
<div class="box-header with-border">
62
<h3 class="box-title">Create New Database</h3>
63
</div>
64
<form action="{{ route('admin.servers.view.database', $server->id) }}" method="POST">
65
<div class="box-body">
66
<div class="form-group">
67
<label for="pDatabaseHostId" class="control-label">Database Host</label>
68
<select id="pDatabaseHostId" name="database_host_id" class="form-control">
69
@foreach($hosts as $host)
70
<option value="{{ $host->id }}">{{ $host->name }}</option>
71
@endforeach
72
</select>
73
<p class="text-muted small">Select the host database server that this database should be created on.</p>
74
</div>
75
<div class="form-group">
76
<label for="pDatabaseName" class="control-label">Database</label>
77
<div class="input-group">
78
<span class="input-group-addon">s{{ $server->id }}_</span>
79
<input id="pDatabaseName" type="text" name="database" class="form-control" placeholder="database" />
80
</div>
81
</div>
82
<div class="form-group">
83
<label for="pRemote" class="control-label">Connections</label>
84
<input id="pRemote" type="text" name="remote" class="form-control" value="%" />
85
<p class="text-muted small">This should reflect the IP address that connections are allowed from. Uses standard MySQL notation. If unsure leave as <code>%</code>.</p>
86
</div>
87
<div class="form-group">
88
<label for="pmax_connections" class="control-label">Concurrent Connections</label>
89
<input id="pmax_connections" type="text" name="max_connections" class="form-control"/>
90
<p class="text-muted small">This should reflect the max number of concurrent connections from this user to the database. Leave empty for unlimited.</p>
91
</div>
92
</div>
93
<div class="box-footer">
94
{!! csrf_field() !!}
95
<p class="text-muted small no-margin">A username and password for this database will be randomly generated after form submission.</p>
96
<input type="submit" class="btn btn-sm btn-success pull-right" value="Create Database" />
97
</div>
98
</form>
99
</div>
100
</div>
101
</div>
102
@endsection
103
104
@section('footer-scripts')
105
@parent
106
<script>
107
$('#pDatabaseHost').select2();
108
$('[data-action="remove"]').click(function (event) {
109
event.preventDefault();
110
var self = $(this);
111
swal({
112
title: '',
113
type: 'warning',
114
text: 'Are you sure that you want to delete this database? There is no going back, all data will immediately be removed.',
115
showCancelButton: true,
116
confirmButtonText: 'Delete',
117
confirmButtonColor: '#d9534f',
118
closeOnConfirm: false,
119
showLoaderOnConfirm: true,
120
}, function () {
121
$.ajax({
122
method: 'DELETE',
123
url: '/admin/servers/view/{{ $server->id }}/database/' + self.data('id') + '/delete',
124
headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') },
125
}).done(function () {
126
self.parent().parent().slideUp();
127
swal.close();
128
}).fail(function (jqXHR) {
129
console.error(jqXHR);
130
swal({
131
type: 'error',
132
title: 'Whoops!',
133
text: (typeof jqXHR.responseJSON.error !== 'undefined') ? jqXHR.responseJSON.error : 'An error occurred while processing this request.'
134
});
135
});
136
});
137
});
138
$('[data-action="reset-password"]').click(function (e) {
139
e.preventDefault();
140
var block = $(this);
141
$(this).addClass('disabled').find('i').addClass('fa-spin');
142
$.ajax({
143
type: 'PATCH',
144
url: '/admin/servers/view/{{ $server->id }}/database',
145
headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') },
146
data: { database: $(this).data('id') },
147
}).done(function (data) {
148
swal({
149
type: 'success',
150
title: '',
151
text: 'The password for this database has been reset.',
152
});
153
}).fail(function(jqXHR, textStatus, errorThrown) {
154
console.error(jqXHR);
155
var error = 'An error occurred while trying to process this request.';
156
if (typeof jqXHR.responseJSON !== 'undefined' && typeof jqXHR.responseJSON.error !== 'undefined') {
157
error = jqXHR.responseJSON.error;
158
}
159
swal({
160
type: 'error',
161
title: 'Whoops!',
162
text: error
163
});
164
}).always(function () {
165
block.removeClass('disabled').find('i').removeClass('fa-spin');
166
});
167
});
168
</script>
169
@endsection
170
171