-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved existing dashboard functionality and implemented deploy scri…
…pt view/edit per client
- Loading branch information
Showing
14 changed files
with
531 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/Http/Controllers/Front/Ajax/ClientScriptController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace KgBot\LaravelDeploy\Http\Controllers\Front\Ajax; | ||
|
||
use Illuminate\Http\Request; | ||
use KgBot\LaravelDeploy\Http\Controllers\BaseController; | ||
use KgBot\LaravelDeploy\Models\Client; | ||
use League\Flysystem\FileNotFoundException; | ||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; | ||
|
||
class ClientScriptController extends BaseController | ||
{ | ||
public function fetch( Client $client ) | ||
{ | ||
$filepath = base_path( DIRECTORY_SEPARATOR . $client->script_source ); | ||
|
||
if ( file_exists( $filepath ) ) { | ||
|
||
$content = file_get_contents( $filepath ); | ||
|
||
return response()->json( compact( 'content' ) ); | ||
|
||
} else { | ||
|
||
throw new FileNotFoundException( 'We can\'t find deploy script defined for this client' ); | ||
} | ||
} | ||
|
||
public function save( Client $client, Request $request ) | ||
{ | ||
if ( $request->has( 'content' ) && $content = $request->get( 'content' ) ) { | ||
|
||
$filepath = base_path( DIRECTORY_SEPARATOR . $client->script_source ); | ||
|
||
if ( file_exists( $filepath ) ) { | ||
|
||
file_put_contents( $filepath, $content ); | ||
|
||
return response()->json( 'success' ); | ||
|
||
} else { | ||
|
||
throw new FileNotFoundException( 'We can\'t find deploy script defined for this client' ); | ||
} | ||
|
||
} else { | ||
|
||
throw new BadRequestHttpException( 'Parameter content is required.' ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.