|
|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
|
|
|
Lib::loadClass('RouteBase');
|
|
|
+Lib::loadClass('UI');
|
|
|
|
|
|
class Route_Install extends RouteBase {
|
|
|
|
|
|
@@ -14,10 +15,10 @@ class Route_Install extends RouteBase {
|
|
|
}
|
|
|
|
|
|
public function defaultAction() {
|
|
|
- SE_Layout::gora();
|
|
|
- SE_Layout::menu();
|
|
|
+ UI::gora();
|
|
|
+ UI::menu();
|
|
|
$this->menu();
|
|
|
- SE_Layout::dol();
|
|
|
+ UI::dol();
|
|
|
}
|
|
|
|
|
|
private function menu() {
|
|
|
@@ -29,7 +30,7 @@ class Route_Install extends RouteBase {
|
|
|
<input type="hidden" name="_route" value="Install" />
|
|
|
<input type="hidden" name="_task" value="createApp" />
|
|
|
<label>Przygotuj kod źródłowy do aktualizacji na serwerze klienta:</label>
|
|
|
- <select class="form-control" name="licence_id">
|
|
|
+ <select id="servers_list" class="form-control" name="licence_id">
|
|
|
<?php foreach ($serversList as $srv) : ?>
|
|
|
<option value="<?php echo $srv->ID; ?>">[<?php echo $srv->ID; ?>] <?php echo $srv->domain; ?></option>
|
|
|
<?php endforeach; ?>
|
|
|
@@ -37,6 +38,7 @@ class Route_Install extends RouteBase {
|
|
|
<button type="submit" id="fldSbmtBtn" class="btn btn-primary" autocomplete="off">
|
|
|
Generuj
|
|
|
</button>
|
|
|
+ <div id="servers_list_react"></div>
|
|
|
</form>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -49,6 +51,57 @@ jQuery(document).ready(function () {
|
|
|
});
|
|
|
</script>
|
|
|
<?php
|
|
|
+ echo UI::h('script', ['src'=>"static/vendor.js", 'type'=>"text/javascript"]);
|
|
|
+ // echo UI::h('script', ['src'=>"https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.js", 'type'=>"text/javascript"]);
|
|
|
+ // echo UI::h('script', ['src'=>"https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.js", 'type'=>"text/javascript"]);
|
|
|
+ // echo UI::h('script', ['src'=>"https://cdnjs.cloudflare.com/ajax/libs/react-bootstrap-typeahead/0.10.4/react-bootstrap-typeahead.js", 'type'=>"text/javascript"]);
|
|
|
+
|
|
|
+ $jsonServersList = array_values(array_map(
|
|
|
+ function ($srv) {
|
|
|
+ return [
|
|
|
+ 'id' => $srv->ID,
|
|
|
+ 'label' => "{$srv->domain} [{$srv->ID}]"
|
|
|
+ ];
|
|
|
+ },
|
|
|
+ $serversList
|
|
|
+ ));
|
|
|
+ echo UI::h('script', ['type'=>"text/javascript"], "
|
|
|
+ (function(global){
|
|
|
+ if (!global.p5VendorJs) { console.warn('Brak p5VendorJs'); return; }
|
|
|
+ if (!global.p5VendorJs.React) { console.warn('Brak p5VendorJs.React'); return; }
|
|
|
+ if (!global.p5VendorJs.ReactDOM) { console.warn('Brak p5VendorJs.ReactDOM'); return; }
|
|
|
+ if (!global.p5VendorJs.Typeahead) { console.warn('Brak p5VendorJs.Typeahead'); return; }
|
|
|
+ const React = global.p5VendorJs.React;
|
|
|
+ const ReactDOM = global.p5VendorJs.ReactDOM;
|
|
|
+ const Typeahead = global.p5VendorJs.Typeahead;
|
|
|
+ var options = ".json_encode($jsonServersList).";
|
|
|
+ var selected = [];
|
|
|
+ var onInputChange = function (query) {
|
|
|
+ // console.log('onInputChange:: query', query);
|
|
|
+ }
|
|
|
+ var onChange = function (value) {
|
|
|
+ // console.log('onChange:: value', value);
|
|
|
+ if (value.length > 0) {
|
|
|
+ var id = value[0]['id'];
|
|
|
+ if (id > 0) {
|
|
|
+ document.getElementById('servers_list').value = id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ReactDOM.render(
|
|
|
+ React.createElement(Typeahead, {
|
|
|
+ options: options,
|
|
|
+ emptyLabel: 'Brak danych',
|
|
|
+ placeholder: 'Wybierz serwer',
|
|
|
+ selected: selected,
|
|
|
+ // onInputChange: onInputChange,
|
|
|
+ onChange: onChange,
|
|
|
+ }, null),
|
|
|
+ document.getElementById('servers_list_react')
|
|
|
+ );
|
|
|
+ })(window);
|
|
|
+ ");
|
|
|
}
|
|
|
|
|
|
public function createAppAction() {
|
|
|
@@ -56,8 +109,8 @@ jQuery(document).ready(function () {
|
|
|
$args = array();
|
|
|
$args['licence_id'] = V::get('licence_id', 0, $_REQUEST, 'int');
|
|
|
|
|
|
- SE_Layout::gora();
|
|
|
- SE_Layout::menu();
|
|
|
+ UI::gora();
|
|
|
+ UI::menu();
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
|
|
|
try {
|
|
|
@@ -126,31 +179,25 @@ jQuery(document).ready(function () {
|
|
|
$this->_endWithException($e);
|
|
|
}
|
|
|
echo '</div>';// .container
|
|
|
-?>
|
|
|
-<div class="alert alert-success">
|
|
|
- <strong>Gotowe</strong> Aplikacja znajduje się w katalogu <?php echo $appLicenceInfo->installFolderName; ?>
|
|
|
-</div>
|
|
|
-<?php
|
|
|
+ UI::alert('success', "<strong>Gotowe</strong> Aplikacja znajduje się w katalogu {$appLicenceInfo->installFolderName}");
|
|
|
}
|
|
|
- SE_Layout::dol();
|
|
|
+ UI::dol();
|
|
|
}
|
|
|
|
|
|
public function gitResetHardAction() {
|
|
|
session_write_close();
|
|
|
$args = array();
|
|
|
$args['licence_id'] = V::get('licence_id', 0, $_REQUEST, 'int');
|
|
|
- SE_Layout::gora();
|
|
|
- SE_Layout::menu();
|
|
|
+ UI::gora();
|
|
|
+ UI::menu();
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
-
|
|
|
try {
|
|
|
$appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
$this->_gitResetHard($appLicenceInfo);
|
|
|
} catch (Exception $e) {
|
|
|
$this->_endWithException($e);
|
|
|
}
|
|
|
-
|
|
|
- SE_Layout::dol();
|
|
|
+ UI::dol();
|
|
|
}
|
|
|
|
|
|
public function _gitResetHard($appLicenceInfo) {
|
|
|
@@ -158,7 +205,6 @@ jQuery(document).ready(function () {
|
|
|
if (empty($appLicenceInfo->domains)) throw new Exception("Domains not found");
|
|
|
$installPath = $appLicenceInfo->installPath;
|
|
|
if (empty($installPath)) throw new Exception("Install path not found");
|
|
|
-
|
|
|
$cmds = array();
|
|
|
$cmds[] = "cd {$installPath} && git reset --hard";
|
|
|
$cmds[] = "cd {$installPath} && git pull";
|
|
|
@@ -174,18 +220,16 @@ jQuery(document).ready(function () {
|
|
|
session_write_close();
|
|
|
$args = array();
|
|
|
$args['licence_id'] = V::get('licence_id', 0, $_REQUEST, 'int');
|
|
|
- SE_Layout::gora();
|
|
|
- SE_Layout::menu();
|
|
|
+ UI::gora();
|
|
|
+ UI::menu();
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
-
|
|
|
try {
|
|
|
$appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
$this->_encodeSource($appLicenceInfo);
|
|
|
} catch (Exception $e) {
|
|
|
$this->_endWithException($e);
|
|
|
}
|
|
|
-
|
|
|
- SE_Layout::dol();
|
|
|
+ UI::dol();
|
|
|
}
|
|
|
|
|
|
public function _encodeSource($appLicenceInfo) {
|
|
|
@@ -423,15 +467,14 @@ jQuery(document).ready(function () {
|
|
|
}
|
|
|
|
|
|
public function _endWithException($e) {
|
|
|
-?>
|
|
|
-<div class="container">
|
|
|
- <div class="alert alert-danger">
|
|
|
- #<?php echo $e->getLine(); ?>: <?php echo $e->getMessage(); ?>
|
|
|
- </div>
|
|
|
- <p>Wróć do <a href="index.php?_route=Install">menu</a></p>
|
|
|
-</div>
|
|
|
-<?php
|
|
|
- SE_Layout::dol();
|
|
|
+ echo UI::h('div', ['class'=>"container"], [
|
|
|
+ UI::h('div', ['class' => "alert alert-danger"], "#" . $e->getLine() . ": " . $e->getMessage()),
|
|
|
+ UI::h('p', [], [
|
|
|
+ "Wróć do ",
|
|
|
+ UI::h('a', ['href'=>"index.php?_route=Install"], "menu")
|
|
|
+ ])
|
|
|
+ ]);
|
|
|
+ UI::dol();
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
@@ -439,21 +482,18 @@ jQuery(document).ready(function () {
|
|
|
session_write_close();
|
|
|
$args = array();
|
|
|
$args['licence_id'] = V::get('licence_id', 0, $_REQUEST, 'int');
|
|
|
- SE_Layout::gora();
|
|
|
- //SE_Layout::menu();
|
|
|
+ UI::gora();
|
|
|
+ //UI::menu();
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
-
|
|
|
try {
|
|
|
$appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
$this->_sendToRemoteTestDir($appLicenceInfo);
|
|
|
-?>
|
|
|
- Test online: <a target="_blank" href="https://<?php echo $appLicenceInfo->mainServer; ?>/se.encrypted.upgrade/">https://<?php echo $appLicenceInfo->mainServer; ?>/se.encrypted.upgrade/</a>
|
|
|
-<?php
|
|
|
+ echo "Test online: ";
|
|
|
+ echo UI::h('a', ['target'=>"_blank", 'href'=>"https://{$appLicenceInfo->mainServer}/se.encrypted.upgrade/"], "https://{$appLicenceInfo->mainServer}/se.encrypted.upgrade/");
|
|
|
} catch (Exception $e) {
|
|
|
$this->_endWithException($e);
|
|
|
}
|
|
|
-
|
|
|
- SE_Layout::dol();
|
|
|
+ UI::dol();
|
|
|
}
|
|
|
|
|
|
public function _fetchRemoteHomeDir($appLicenceInfo) {
|
|
|
@@ -520,21 +560,18 @@ ssh {$sshArgs} {$sshHostUsr} 'ln -s ~/se.encrypted.upgrade/SE /Library/Server/We
|
|
|
session_write_close();
|
|
|
$args = array();
|
|
|
$args['licence_id'] = V::get('licence_id', 0, $_REQUEST, 'int');
|
|
|
- SE_Layout::gora();
|
|
|
- //SE_Layout::menu();
|
|
|
+ UI::gora();
|
|
|
+ //UI::menu();
|
|
|
//$this->menu($args['licence_id']);// TODO: GO BACK BTN
|
|
|
-
|
|
|
try {
|
|
|
$appLicenceInfo = $this->getAppLicenceInfo($args['licence_id']);
|
|
|
$this->_upgradeRemoteFromTestDir($appLicenceInfo);
|
|
|
-?>
|
|
|
- Test online: <a target="_blank" href="https://<?php echo $appLicenceInfo->mainServer; ?>/SE/">https://<?php echo $appLicenceInfo->mainServer; ?>/SE/</a>
|
|
|
-<?php
|
|
|
+ echo "Test online: ";
|
|
|
+ echo UI::h('a', ['target'=>"_blank", 'href'=>"https://{$appLicenceInfo->mainServer}/SE/"], "https://{$appLicenceInfo->mainServer}/SE/");
|
|
|
} catch (Exception $e) {
|
|
|
$this->_endWithException($e);
|
|
|
}
|
|
|
-
|
|
|
- SE_Layout::dol();
|
|
|
+ UI::dol();
|
|
|
}
|
|
|
|
|
|
public function _upgradeRemoteFromTestDir($appLicenceInfo) {
|