|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Satis\BuildContext; |
|
6
|
|
|
use App\Satis\ConfigManager; |
|
7
|
|
|
use App\Satis\Context\PrivateRepository; |
|
8
|
|
|
use App\Satis\Context\PublicRepository; |
|
9
|
|
|
use App\Satis\Model\ControlPanelConfig; |
|
10
|
|
|
use Illuminate\Contracts\Filesystem\FileNotFoundException; |
|
11
|
|
|
use Illuminate\Http\Request; |
|
12
|
|
|
use JMS\Serializer\Serializer; |
|
13
|
|
|
use Exception; |
|
14
|
|
|
use Response; |
|
15
|
|
|
use Illuminate\Routing\Controller as BaseController; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @author Lukas Homza <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class Controller extends BaseController { |
|
21
|
|
|
/** |
|
22
|
|
|
* @param \App\Satis\ConfigManager $configManager |
|
23
|
|
|
* @param \App\Satis\BuildContext $buildContext |
|
24
|
|
|
* @param \Illuminate\Http\Request $request |
|
25
|
|
|
*/ |
|
26
|
|
|
protected function build(ConfigManager $configManager, BuildContext $buildContext, Request $request) { |
|
27
|
|
|
if($request->ajax()) { |
|
28
|
|
|
$buildContext->setItemName($request->get('what')); |
|
29
|
|
|
|
|
30
|
|
|
$configManager->setDisableBuild(true) |
|
31
|
|
|
->save(); |
|
32
|
|
|
|
|
33
|
|
|
$configManager->setDisableBuild(false) |
|
34
|
|
|
->forceBuild($buildContext); |
|
35
|
|
|
|
|
36
|
|
|
Response::json() |
|
37
|
|
|
->send(); |
|
38
|
|
|
} else { |
|
39
|
|
|
Response::json() |
|
40
|
|
|
->setStatusCode(404) |
|
41
|
|
|
->send(); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param \JMS\Serializer\Serializer $serializer |
|
47
|
|
|
* @param \App\Satis\Model\ControlPanelConfig $controlPanelConfig |
|
48
|
|
|
* @param \App\Satis\ConfigManager $configManager |
|
49
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
|
50
|
|
|
*/ |
|
51
|
|
|
public function index(Serializer $serializer, ControlPanelConfig $controlPanelConfig, |
|
52
|
|
|
ConfigManager $configManager |
|
53
|
|
|
) { |
|
54
|
|
|
|
|
55
|
|
|
try { |
|
56
|
|
|
$controlPanelConfig |
|
57
|
|
|
->setConfig($configManager->getDefinition()) |
|
58
|
|
|
->setRepositoryTypes(config('satis.repository_types')) |
|
59
|
|
|
->isLoaded(true); |
|
60
|
|
|
} catch(Exception $e) { |
|
61
|
|
|
$message = $e->getMessage(); |
|
62
|
|
|
if($e instanceof FileNotFoundException) { |
|
63
|
|
|
$message = trans('satis.not_found'); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
$controlPanelConfig |
|
67
|
|
|
->setMessage($message) |
|
68
|
|
|
->isLoaded(false); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
$controlPanelConfig->setNodeServer(config('satis.node')); |
|
72
|
|
|
$controlPanelConfig->isLocked($configManager->isBuilding()); |
|
73
|
|
|
|
|
74
|
|
|
return view('index', [ |
|
75
|
|
|
'satis' => $serializer->serialize($controlPanelConfig, 'json'), |
|
76
|
|
|
'webpackDevServer' => config('satis.webpack_dev_server'), |
|
77
|
|
|
'nodeServer' => config('satis.node.host') . ':' . config('satis.node.port') |
|
78
|
|
|
]); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param \App\Satis\ConfigManager $configManager |
|
83
|
|
|
* @param \Illuminate\Http\Request $request |
|
84
|
|
|
*/ |
|
85
|
|
|
public function buildPrivate(ConfigManager $configManager, Request $request) { |
|
86
|
|
|
$this->build($configManager, new PrivateRepository(), $request); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param \App\Satis\ConfigManager $configManager |
|
91
|
|
|
* @param \Illuminate\Http\Request $request |
|
92
|
|
|
*/ |
|
93
|
|
|
public function buildPublic(ConfigManager $configManager, Request $request) { |
|
94
|
|
|
$this->build($configManager, new PublicRepository(), $request); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|