diff --git a/app/Http/Controllers/Server/ServerController.php b/app/Http/Controllers/Server/ServerController.php
index bb20881a0..54a854289 100644
--- a/app/Http/Controllers/Server/ServerController.php
+++ b/app/Http/Controllers/Server/ServerController.php
@@ -29,6 +29,15 @@ class ServerController extends Controller
//
}
+ public function getJavascript(Request $request, $uuid, $file)
+ {
+ $server = Server::getByUUID($uuid);
+ return response()->view('server.js.' . $server->a_serviceFile . '.' . basename($file, '.js'), [
+ 'server' => $server,
+ 'node' => Node::find($server->node)
+ ])->header('Content-Type', 'application/javascript');
+ }
+
/**
* Renders server index page for specified server.
*
diff --git a/app/Http/Routes/ServerRoutes.php b/app/Http/Routes/ServerRoutes.php
index d7875837a..333bdacd6 100644
--- a/app/Http/Routes/ServerRoutes.php
+++ b/app/Http/Routes/ServerRoutes.php
@@ -41,6 +41,16 @@ class ServerRoutes {
'uses' => 'Server\ServerController@getAddFile'
]);
+ $router->post('files/directory-list', [
+ 'as' => 'server.files.directory-list',
+ 'uses' => 'Server\AjaxController@postDirectoryList'
+ ]);
+
+ $router->post('files/save', [
+ 'as' => 'server.files.save',
+ 'uses' => 'Server\AjaxController@postSaveFile'
+ ]);
+
// Assorted AJAX Routes
$router->group(['prefix' => 'ajax'], function ($server) use ($router) {
// Returns Server Status
@@ -52,15 +62,16 @@ class ServerRoutes {
$router->post('set-connection', [
'uses' => 'Server\AjaxController@postSetConnection'
]);
+ });
- // Assorted File Manager URLs
- $router->post('files/directory-list', [
- 'uses' => 'Server\AjaxController@postDirectoryList'
- ]);
+ // Assorted AJAX Routes
+ $router->group(['prefix' => 'js'], function ($server) use ($router) {
+ // Returns Server Status
+ $router->get('{file}', [
+ 'as' => 'server.js',
+ 'uses' => 'Server\ServerController@getJavascript'
+ ])->where('file', '.*');
- $router->post('files/save', [
- 'uses' => 'Server\AjaxController@postSaveFile'
- ]);
});
});
}
diff --git a/app/Models/Server.php b/app/Models/Server.php
index fee44d474..1075f1b86 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -112,7 +112,9 @@ class Server extends Model
return self::$serverUUIDInstance[$uuid];
}
- $query = self::where('uuidShort', $uuid)->where('active', 1);
+ $query = self::select('servers.*', 'services.file as a_serviceFile')
+ ->join('services', 'services.id', '=', 'servers.id')
+ ->where('uuidShort', $uuid)->where('active', 1);
if (self::$user->root_admin !== 1) {
$query->whereIn('servers.id', Subuser::accessServers());
@@ -120,6 +122,9 @@ class Server extends Model
$result = $query->first();
+ // @TODO: saving after calling this could end up resetting the daemon secret.
+ // We probably need to just allow access to self::getUserDaemonSecret() to
+ // get this result.
if(!is_null($result)) {
$result->daemonSecret = self::getUserDaemonSecret($result);
}
diff --git a/resources/views/server/files/edit.blade.php b/resources/views/server/files/edit.blade.php
index 78a66d1fb..bc412789b 100644
--- a/resources/views/server/files/edit.blade.php
+++ b/resources/views/server/files/edit.blade.php
@@ -69,7 +69,7 @@ $(document).ready(function () {
$('#save_file').append(' ').addClass('disabled');
$.ajax({
type: 'POST',
- url: '/server/{{ $server->uuidShort }}/ajax/files/save',
+ url: '{{ route('server.files.save', $server->uuidShort) }}',
headers: { 'X-CSRF-Token': '{{ csrf_token() }}' },
data: {
file: fileName,
diff --git a/resources/views/server/files/index.blade.php b/resources/views/server/files/index.blade.php
index e8bedc9ea..764bb2605 100644
--- a/resources/views/server/files/index.blade.php
+++ b/resources/views/server/files/index.blade.php
@@ -114,7 +114,7 @@
$.ajax({
type: 'POST',
- url: '/server/{{ $server->uuidShort }}/ajax/files/directory-list',
+ url: '{{ route('server.files.directory-list', $server->uuidShort) }}',
headers: { 'X-CSRF-Token': '{{ csrf_token() }}' },
data: { directory: urlDirectory }
}).done(function (data) {
diff --git a/resources/views/server/index.blade.php b/resources/views/server/index.blade.php
index 7e347f84a..610529ded 100644
--- a/resources/views/server/index.blade.php
+++ b/resources/views/server/index.blade.php
@@ -112,6 +112,9 @@
+@if($server->a_serviceFile === 'minecraft')
+
+@endif