|
7 | 7 | @section('content') |
8 | 8 | <div class="col-md-9"> |
9 | 9 | <ul class="breadcrumb"> |
10 | | - <li><a href="/admin">Admin Control</a></li> |
11 | | - <li><a href="/admin/servers">Servers</a></li> |
| 10 | + <li><a href="/admin">Admin Control</a></li> |
| 11 | + <li><a href="/admin/servers">Servers</a></li> |
12 | 12 | <li class="active">Create New Server</li> |
13 | | - </ul> |
| 13 | + </ul> |
14 | 14 | <h3>Create New Server</h3><hr /> |
15 | 15 | <form action="#" method="POST"> |
16 | 16 | <div class="well"> |
|
19 | 19 | <label for="server_name" class="control-label">Server Name</label> |
20 | 20 | <div> |
21 | 21 | <input type="text" autocomplete="off" name="server_name" class="form-control" /> |
22 | | - <p class="text-muted" style="margin: 0 0 -10.5px;"><small><em>Character limits: <code>a-zA-Z0-9_-</code> and <code>[Space]</code> (max 35 characters)</em></small></p> |
| 22 | + <p class="text-muted"><small><em>Character limits: <code>a-zA-Z0-9_-</code> and <code>[Space]</code> (max 35 characters)</em></small></p> |
23 | 23 | </div> |
24 | 24 | </div> |
25 | 25 | <div class="form-group col-md-6"> |
|
33 | 33 | <div id="load_settings"> |
34 | 34 | <div class="well"> |
35 | 35 | <div class="row"> |
36 | | - <div class="ajax_loading_box" style="display:none;"><i class="fa fa-refresh fa-spin" id="position_me"></i></div> |
| 36 | + <div class="ajax_loading_box" style="display:none;"><i class="fa fa-refresh fa-spin ajax_loading_position"></i></div> |
37 | 37 | <div class="form-group col-md-6"> |
38 | 38 | <label for="location" class="control-label">Server Location</label> |
39 | 39 | <div> |
|
43 | 43 | <option value="{{ $location->id }}">{{ $location->long }} ({{ $location->short }})</option> |
44 | 44 | @endforeach |
45 | 45 | </select> |
| 46 | + <p class="text-muted"><small>The location in which this server will be deployed.</small></p> |
46 | 47 | </div> |
47 | 48 | </div> |
48 | 49 | <div class="form-group col-md-6 hidden"> |
|
51 | 52 | <select name="node" id="getNode" class="form-control"> |
52 | 53 | <option></option> |
53 | 54 | </select> |
| 55 | + <p class="text-muted"><small>The node which this server will be deployed to.</small></p> |
54 | 56 | </div> |
55 | 57 | </div> |
56 | 58 | </div> |
|
61 | 63 | <select name="node" id="getIP" class="form-control"> |
62 | 64 | <option></option> |
63 | 65 | </select> |
| 66 | + <p class="text-muted"><small>Select the main IP that this server will be listening on. You can assign additional open IPs and ports below.</small></p> |
64 | 67 | </div> |
65 | 68 | </div> |
66 | 69 | <div class="form-group col-md-6 hidden"> |
67 | 70 | <label for="location" class="control-label">Server Port</label> |
68 | 71 | <div> |
69 | 72 | <select name="node" id="getPort" class="form-control"></select> |
| 73 | + <p class="text-muted"><small>Select the main port that this server will be listening on.</small></p> |
| 74 | + </div> |
| 75 | + </div> |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + <div class="well"> |
| 80 | + <div class="row"> |
| 81 | + <div class="form-group col-md-3 col-xs-6"> |
| 82 | + <label for="memory" class="control-label">Memory</label> |
| 83 | + <div class="input-group"> |
| 84 | + <input type="text" name="memory" class="form-control" /> |
| 85 | + <span class="input-group-addon">MB</span> |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + <div class="form-group col-md-3 col-xs-6"> |
| 89 | + <label for="disk" class="control-label">Disk Space</label> |
| 90 | + <div class="input-group"> |
| 91 | + <input type="text" name="disk" class="form-control" /> |
| 92 | + <span class="input-group-addon">MB</span> |
| 93 | + </div> |
| 94 | + </div> |
| 95 | + <div class="form-group col-md-3 col-xs-6"> |
| 96 | + <label for="cpu" class="control-label">CPU Limit</label> |
| 97 | + <div class="input-group"> |
| 98 | + <input type="text" name="cpu" value="0" class="form-control" /> |
| 99 | + <span class="input-group-addon">%</span> |
| 100 | + </div> |
| 101 | + </div> |
| 102 | + <div class="form-group col-md-3 col-xs-6"> |
| 103 | + <label for="io" class="control-label">Block I/O</label> |
| 104 | + <div class="input-group"> |
| 105 | + <input type="text" name="io" value="500" class="form-control" /> |
| 106 | + <span class="input-group-addon">I/O</span> |
| 107 | + </div> |
| 108 | + </div> |
| 109 | + </div> |
| 110 | + <div class="row"> |
| 111 | + <div class="col-md-12"> |
| 112 | + <p class="text-muted"><small>If you do not want to limit CPU usage set the value to <code>0</code>. To determine a value, take the number <em>physical</em> cores and multiply it by 100. For example, on a quad core system <code>(4 * 100 = 400)</code> there is <code>400%</code> available. To limit a server to using half of a single core, you would set the value to <code>50</code>. To allow a server to use up to two physical cores, set the value to <code>200</code>. BlockIO should be a value between <code>10</code> and <code>1000</code>. Please see <a href="https://docs.docker.com/reference/run/#block-io-bandwidth-blkio-constraint" target="_blank">this documentation</a> for more information about it.</small><p> |
| 113 | + </div> |
| 114 | + </div> |
| 115 | + </div> |
| 116 | + <div class="row"> |
| 117 | + <div class="col-md-6" id="load_services"> |
| 118 | + <div class="well"> |
| 119 | + <div class="row"> |
| 120 | + <div class="ajax_loading_box" style="display:none;"><i class="fa fa-refresh fa-spin ajax_loading_position"></i></div> |
| 121 | + <div class="form-group col-md-12"> |
| 122 | + <label for="service" class="control-label">Service Type</label> |
| 123 | + <div> |
| 124 | + <select name="node" id="getService" class="form-control"> |
| 125 | + <option></option> |
| 126 | + @foreach($services as $service) |
| 127 | + <option value="{{ $service->id }}">{{ $service->name }}</option> |
| 128 | + @endforeach |
| 129 | + </select> |
| 130 | + <p class="text-muted"><small>Select the type of service that this server will be running.</small></p> |
| 131 | + </div> |
| 132 | + </div> |
| 133 | + <div class="form-group col-md-12 hidden"> |
| 134 | + <label for="service_option" class="control-label">Service Option</label> |
| 135 | + <div> |
| 136 | + <select name="node" id="getOption" class="form-control"> |
| 137 | + <option></option> |
| 138 | + </select> |
| 139 | + <p class="text-muted"><small>Select the type of service that this server will be running.</small></p> |
| 140 | + </div> |
| 141 | + </div> |
| 142 | + </div> |
| 143 | + </div> |
| 144 | + </div> |
| 145 | + <div class="col-md-6"> |
| 146 | + <div class="well"> |
| 147 | + <div class="row"> |
| 148 | + <div class="form-group col-md-12"> |
| 149 | + <label for="use_custom_image" class="control-label">Use Custom Docker Image</label> |
| 150 | + <div class="input-group"> |
| 151 | + <span class="input-group-addon"> |
| 152 | + <input type="checkbox" name="use_custom_image" /> |
| 153 | + </span> |
| 154 | + <input type="text" class="form-control" name="custom_image_name" disabled /> |
| 155 | + </div> |
| 156 | + <p class="text-muted"><small>If you would like to use a custom docker image for this server please enter it here. Most users can ignore this option.</small></p> |
70 | 157 | </div> |
71 | 158 | </div> |
72 | 159 | </div> |
|
76 | 163 | </div> |
77 | 164 | <script> |
78 | 165 | $(document).ready(function () { |
| 166 | +
|
| 167 | + $('input[name="use_custom_image"]').change(function () { |
| 168 | + $('input[name="custom_image_name"]').val('').prop('disabled', !($(this).is(':checked'))); |
| 169 | + }); |
| 170 | +
|
79 | 171 | var nodeData = null; |
80 | 172 | var currentLocation = null; |
81 | 173 | var currentNode = null; |
| 174 | + var currentService = null; |
82 | 175 | $('#getLocation').on('change', function (event) { |
83 | 176 |
|
84 | 177 | if ($('#getLocation').val() === '' || $('#getLocation').val() === currentLocation) { |
|
93 | 186 | $('#getIP').html('<option></option>').parent().parent().addClass('hidden'); |
94 | 187 | $('#getPort').html('').parent().parent().addClass('hidden'); |
95 | 188 |
|
96 | | - handleLoader(true); |
| 189 | + handleLoader('#load_settings', true); |
97 | 190 |
|
98 | 191 | $.ajax({ |
99 | 192 | method: 'POST', |
|
105 | 198 | location: $('#getLocation').val() |
106 | 199 | } |
107 | 200 | }).done(function (data) { |
108 | | - var data = $.parseJSON(data); |
| 201 | + //var data = $.parseJSON(data); |
109 | 202 | $.each(data, function (i, item) { |
110 | 203 | var isPublic = (item.public !== 1) ? '(Private Node)' : ''; |
111 | 204 | $('#getNode').append('<option value="' + item.id + '">' + item.name + ' ' + isPublic + '</option>'); |
112 | 205 | }); |
113 | 206 | $('#getNode').parent().parent().removeClass('hidden') |
114 | 207 | }).fail(function (jqXHR) { |
115 | 208 | alert('An error occured while attempting to load a list of nodes in this location.'); |
| 209 | + currentLocation = null; |
116 | 210 | console.log(jqXHR); |
117 | 211 | }).always(function () { |
118 | | - handleLoader(); |
| 212 | + handleLoader('#load_settings'); |
119 | 213 | }) |
120 | 214 | }); |
121 | 215 | $('#getNode').on('change', function (event) { |
|
130 | 224 | $('#getIP').html('<option></option>').parent().parent().addClass('hidden'); |
131 | 225 | $('#getPort').html('').parent().parent().addClass('hidden'); |
132 | 226 |
|
133 | | - handleLoader(true); |
| 227 | + handleLoader('#load_settings', true); |
134 | 228 |
|
135 | 229 | $.ajax({ |
136 | 230 | method: 'POST', |
|
148 | 242 | }); |
149 | 243 | $('#getIP').parent().parent().removeClass('hidden'); |
150 | 244 | }).fail(function (jqXHR) { |
| 245 | + alert('An error occured while attempting to get IPs and Ports avaliable on this node.'); |
| 246 | + currentNode = null; |
151 | 247 | console.log(jqXHR); |
152 | 248 | }).always(function () { |
153 | | - handleLoader(); |
| 249 | + handleLoader('#load_settings'); |
154 | 250 | }); |
155 | 251 |
|
156 | 252 | }); |
| 253 | +
|
157 | 254 | $('#getIP').on('change', function (event) { |
158 | 255 |
|
159 | 256 | if ($('#getIP').val() === '') { |
|
170 | 267 |
|
171 | 268 | }); |
172 | 269 |
|
| 270 | + $('#getService').on('change', function (event) { |
| 271 | +
|
| 272 | + if ($('#getService').val() === '' || $('#getService').val() === currentService) { |
| 273 | + return; |
| 274 | + } |
| 275 | +
|
| 276 | + currentService = $('#getService').val(); |
| 277 | + handleLoader('#load_services', true); |
| 278 | +
|
| 279 | + $.ajax({ |
| 280 | + method: 'POST', |
| 281 | + url: '/admin/ajax/new/server/service-options', |
| 282 | + headers: { |
| 283 | + 'X-CSRF-TOKEN': '{{ csrf_token() }}' |
| 284 | + }, |
| 285 | + data: { |
| 286 | + service: $('#getService').val() |
| 287 | + } |
| 288 | + }).done(function (data) { |
| 289 | + $.each(data, function (i, option) { |
| 290 | + $('#getOption').append('<option value="' + option.id + '">' + option.name + '</option>'); |
| 291 | + }); |
| 292 | + $('#getOption').parent().parent().removeClass('hidden'); |
| 293 | + }).fail(function (jqXHR) { |
| 294 | + alert('An error occured while attempting to list options for this service.'); |
| 295 | + currentService = null; |
| 296 | + console.log(jqXHR); |
| 297 | + }).always(function () { |
| 298 | + handleLoader('#load_services'); |
| 299 | + }); |
| 300 | +
|
| 301 | + }); |
| 302 | +
|
173 | 303 | // Show Loading Animation |
174 | | - function handleLoader (show) { |
| 304 | + function handleLoader (element, show) { |
| 305 | +
|
| 306 | + var spinner = $(element).find('.ajax_loading_position'); |
| 307 | + var popover = $(element).find('.ajax_loading_box'); |
175 | 308 |
|
176 | 309 | // Show Animation |
177 | | - if (show === true){ |
178 | | - var height = $('#load_settings').height(); |
179 | | - var width = $('#load_settings').width(); |
| 310 | + if (typeof show !== 'undefined') { |
| 311 | + var height = $(element).height(); |
| 312 | + var width = $(element).width(); |
180 | 313 | var center_height = (height / 2) - 16; |
181 | 314 | var center_width = (width / 2) - 16; |
182 | | - $('#position_me').css({ |
| 315 | + spinner.css({ |
183 | 316 | 'top': center_height, |
184 | 317 | 'left': center_width, |
185 | 318 | 'font-size': '32px' |
186 | 319 | }); |
187 | | - $(".ajax_loading_box").css({ |
| 320 | + popover.css({ |
188 | 321 | 'height': height, |
189 | 322 | 'margin': '-20px 0 0 -5px', |
190 | 323 | 'width': width |
191 | 324 | }).fadeIn(); |
192 | 325 | } else { |
193 | | - $('.ajax_loading_box').fadeOut(100); |
| 326 | + popover.hide(); |
194 | 327 | } |
195 | 328 |
|
196 | 329 | } |
|
0 commit comments