diff options
author | daita <maxence@pontapreta.net> | 2016-09-21 18:53:04 +0300 |
---|---|---|
committer | daita <maxence@pontapreta.net> | 2016-09-21 18:53:04 +0300 |
commit | e18204607103baf4ce8ee73b9d48906521b101ae (patch) | |
tree | 0a7a5c5ca8f8bf46a34b747ba5e0566cb5f12deb | |
parent | 819bf290bef79dcdfcd60dd5faaebdf86a078a10 (diff) |
Live settings
-rw-r--r-- | js/settings.admin.js | 14 | ||||
-rw-r--r-- | lib/Controller/SettingsController.php | 11 | ||||
-rw-r--r-- | lib/Service/ConfigService.php | 25 | ||||
-rw-r--r-- | templates/settings.admin.php | 32 |
4 files changed, 70 insertions, 12 deletions
diff --git a/js/settings.admin.js b/js/settings.admin.js index 88fd239..3aa4422 100644 --- a/js/settings.admin.js +++ b/js/settings.admin.js @@ -30,8 +30,10 @@ $(document) save : function() { $('#nextant_apply').attr('disabled', true); - $('#solr_url').prop('disable', true); - $('#solr_core').prop('disable', true); + $('#solr_url').attr('disabled', true); + $('#solr_core').attr('disabled', true); + $('#solr_live_extract').attr('disabled', true); + $('#solr_live_docupdate').attr('disabled', true); nextantSettings.test('ping'); }, @@ -45,6 +47,8 @@ $(document) var data = { solr_url : $('#solr_url').val(), solr_core : $('#solr_core').val(), + live_extract : $('#solr_live_extract').prop('checked'), + live_docupdate : $('#solr_live_docupdate').prop('checked'), command : command } @@ -153,8 +157,10 @@ $(document) }, reset : function() { - $('#solr_url').prop('disable', false); - $('#solr_core').prop('disable', false); + $('#solr_url').attr('disabled', false); + $('#solr_core').attr('disabled', false); + $('#solr_live_extract').attr('disabled', false); + $('#solr_live_docupdate').attr('disabled', false); $('#nextant_apply').attr('disabled', false); } } diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 30894a3..964ad88 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -71,12 +71,14 @@ class SettingsController extends Controller 'current_docs' => $documentsCount, 'solr_url' => $this->configService->getAppValue('solr_url'), 'solr_core' => $this->configService->getAppValue('solr_core'), + 'live_extract' => $this->configService->getAppValue('live_extract'), + 'live_docupdate' => $this->configService->getAppValue('live_docupdate'), 'solr_lock' => $this->configService->getAppValue('solr_lock') ]; return new TemplateResponse($this->appName, 'settings.admin', $params, 'blank'); } - public function setSettings($solr_url, $solr_core, $command) + public function setSettings($solr_url, $solr_core, $live_extract, $live_docupdate, $command) { $this->solr_url = $solr_url; $this->solr_core = $solr_core; @@ -124,7 +126,7 @@ class SettingsController extends Controller break; case 'save': - $result = $this->save($message); + $result = $this->save($live_extract, $live_docupdate, $message); break; } } @@ -236,11 +238,14 @@ class SettingsController extends Controller return false; } - private function save(&$message) + private function save($live_extract, $live_docupdate, &$message) { + $this->miscService->log('__' . (($live_extract) ? '1' : '0') . ' _ ' . (($live_docupdate) ? '1' : '0')); if (! is_null($this->solr_url) && ! is_null($this->solr_core)) { $this->configService->setAppValue('solr_url', $this->solr_url); $this->configService->setAppValue('solr_core', $this->solr_core); + $this->configService->setAppValue('live_extract', (($live_extract) ? '1' : '0')); + $this->configService->setAppValue('live_docupdate', (($live_docupdate) ? '1' : '0')); $this->configService->setAppValue('configured', '1'); $message = "Your configuration has been saved"; diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index 5658438..3f68a0b 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -31,11 +31,17 @@ use OCP\IConfig; class ConfigService { + const ACTION_LIVE_EXTRACT = 'live_extract'; + + const ACTION_LIVE_DOCUPDATE = 'live_docupdate'; + private $defaults = [ 'configured' => '1', 'needed_index' => '1', 'solr_url' => 'http://127.0.0.1:8983/solr/', 'solr_core' => 'nextant', + 'live_extract' => '1', + 'live_docupdate' => '1', 'solr_lock' => 0 ]; @@ -79,6 +85,25 @@ class ConfigService } /** + * return if config allow to perform action + * + * @param string $action + * @return boolean + */ + public function shoudIContinue($action) + { + switch ($action) { + case self::ACTION_LIVE_EXTRACT: + return ($this->getAppValue($action) == '1'); + + case self::ACTION_LIVE_DOCUPDATE: + if ($this->getAppValue(self::ACTION_LIVE_EXTRACT) != '1') + return false; + return ($this->getAppValue($action) == '1'); + } + } + + /** * generate an array to pass config to Solarium * * @return array diff --git a/templates/settings.admin.php b/templates/settings.admin.php index 38b2a4d..c409935 100644 --- a/templates/settings.admin.php +++ b/templates/settings.admin.php @@ -32,8 +32,8 @@ script('nextant', 'settings.admin'); <tr> <td colspan="2"><em><?php p($l->t('Specify the URL of your Solr servlet, and the name of the core to use.')); ?> <br />If you do not have a Solr servlet running, you can <a - href="https://github.com/daita/nextant/wiki" target="_blank">find few guides on how - to install one on the Wiki</a></em></td> + href="https://github.com/daita/nextant/wiki" target="_blank">find + few guides on how to install one on the Wiki</a></em></td> </tr> <tr> <td> </td> @@ -48,15 +48,36 @@ if ($_['configured'] == '1') { <td><?php ($_['current_docs'] == false) ? p('Solr Servlet is down') : p($_['current_docs']); ?></td> </tr> <?php } ?> + <tr> + <td style="text-align: right;"><label> + <?php p($l->t('Live Extract :')) ?> </label></td> + <td><input type="checkbox" name="solr_live_extract" + id="solr_live_extract" value="1" + <?php if ($_['live_extract'] == '1') { p('CHECKED'); } ?> + style="margin: 10px;"> (<a + href="https://github.com/daita/nextant/wiki/Extracting-&-Live-Update" + target="_blank">help</a>)</td> + </tr> + <tr> - <td style="text-align: right;"><label for="solr_url"> + <td style="text-align: right;"><label> + <?php p($l->t('Live Document Update :')) ?> </label></td> + <td><input type="checkbox" name="solr_live_docupdate" + id="solr_live_docupdate" value="1" + <?php if ($_['live_docupdate'] == '1') { p('CHECKED'); } ?> + style="margin: 10px;"></td> + </tr> + + <tr> + <td style="text-align: right;"><label> <?php p($l->t('Address of your Solr Servlet :')) ?> </label></td> <td><input type="text" name="solr_url" id="solr_url" value="<?php p($_['solr_url'])?>" style="width: 360px;"></td> </tr> + <tr> - <td style="text-align: right;"><label for="solr_core"><?php p($l->t('Core :')) ?> </label></td> - <td><input type="text" name="solr_core" id="solr_core" + <td style="text-align: right;"><label><?php p($l->t('Core :')) ?> </label></td> + <td><input type="text" id="solr_core" value="<?php p($_['solr_core'])?>" style="width: 360px;"></td> </tr> @@ -66,6 +87,7 @@ if ($_['configured'] == '1') { <button type="button" id="nextant_apply" style="width: 370px"><?php p($l->t('Test and Save')) ?></button> </td> </tr> + <tr style="height: 40px;"> <td colspan="2" style="text-align: center; width: 550px;"><span id="nextant-admin-msg" class="msg"></span></td> |