Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaita <maxence@pontapreta.net>2016-09-30 18:52:33 +0300
committerdaita <maxence@pontapreta.net>2016-09-30 18:52:33 +0300
commitdedc683a40b6a16f10a947b83266f39ce0cb17c7 (patch)
tree605b384066b0ae0d3a9a0556185ba4f802cfa9df
parent366ee59c10be7068384141d36a203b21a6cf2b61 (diff)
interactive admin UI
-rw-r--r--appinfo/routes.php21
-rw-r--r--css/admin.css7
-rw-r--r--js/settings.admin.js74
-rw-r--r--lib/Controller/SettingsController.php44
-rw-r--r--lib/Service/ConfigService.php1
-rw-r--r--templates/settings.admin.php77
6 files changed, 144 insertions, 80 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index c7c3938..893dfb9 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -31,12 +31,23 @@ return [
'verb' => 'POST'
],
[
- 'name' => 'settings#forceIndex',
- 'url' => 'ajax/settings/forceindex.php',
- 'verb' => 'POST'
- ]
+ 'name' => 'settings#setOption',
+ 'url' => 'ajax/settings/option.php',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'settings#forceIndex',
+ 'url' => 'ajax/settings/forceindex.php',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'settings#updateSubOptions',
+ 'url' => 'ajax/settings/updateSubOptions.php',
+ 'verb' => 'POST'
+ ]
]
-];
+]
+;
/*
* This route is now useless. It was used with navigate.js + SearchController
diff --git a/css/admin.css b/css/admin.css
index 5a629c4..bc090b5 100644
--- a/css/admin.css
+++ b/css/admin.css
@@ -20,4 +20,11 @@ DIV.nextant_display_text {
left: 40px;
position: absolute;
font-style: italic;
+}
+
+TD.nextant_admin_left {
+ width: 250px;
+ text-align: right;
+ font-weight: bold;
+ padding-right: 15px;
} \ No newline at end of file
diff --git a/js/settings.admin.js b/js/settings.admin.js
index f078c3b..87e2dec 100644
--- a/js/settings.admin.js
+++ b/js/settings.admin.js
@@ -30,6 +30,62 @@ $(document)
init : function() {
nextantSettings.statusclearall(true);
+ nextantSettings.checksuboptions(true);
+ },
+
+ checksuboptions : function(instant) {
+ $.post(OC.filePath('nextant', 'ajax/settings',
+ 'updateSubOptions.php'), {
+ instant : instant
+ }, nextantSettings.updatesuboptions);
+ },
+
+ updatesuboptions : function(response) {
+ var delay = 600;
+ if (response.instant == 'true')
+ delay = 0;
+
+ if (response.configured == 1) {
+ $("#nextant_suboptions :input").attr(
+ "disabled", false);
+ $('#nextant_help_link').unbind('click');
+ $('#nextant_suboptions').fadeTo(delay, 1);
+ } else {
+ $("#nextant_suboptions :input").attr(
+ "disabled", true);
+ $('#nextant_help_link').bind('click',
+ function(e) {
+ e.preventDefault();
+ })
+ $('#nextant_suboptions').fadeTo(delay, 0.4);
+ }
+
+ $('#solr_live_extract').prop('checked',
+ (response.live_extract == 1));
+ $('#solr_live_docupdate').prop('checked',
+ (response.live_docupdate == 1));
+
+ if (response.last_index > 0)
+ $('#solr_last_index').text(
+ response.last_index_format);
+ else
+ $('#solr_last_index').text('never');
+
+ if (response.configured == 0) {
+ $('#solr_current_docs').text(
+ 'Nextant is not configured yet');
+ $('#nextant_force_index').hide(delay);
+ } else if (response.solr_ping == 'false')
+ $('#solr_current_docs').text(
+ 'Solr Core is down');
+ else {
+ $('#nextant_force_index').show(delay);
+ if (response.current_docs > 0)
+ $('#solr_current_docs').text(
+ response.current_docs);
+ else
+ $('#solr_current_docs').text('none');
+ }
},
statusclearall : function(instant) {
@@ -79,8 +135,6 @@ $(document)
$('#nextant_apply').attr('disabled', 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');
},
@@ -95,10 +149,6 @@ $(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
}
@@ -142,24 +192,24 @@ $(document)
'#save',
'All test went fine. Saving your configuration',
0);
+ nextantSettings.checksuboptions(false);
break;
}
$.post(OC.filePath('nextant', 'ajax/settings',
'admin.php'), data,
nextantSettings.tested_standby);
-
},
tested_standby : function(response) {
- // setTimeout(function() {
- nextantSettings.tested(response);
- // }, 200);
+ // setTimeout(function() {
+ nextantSettings.tested(response);
+ // }, 200);
},
tested : function(response) {
nextantSettings.status('#' + response.command,
- response.data.message,
+ response.message,
(response.status == 'success') ? 1 : 2);
switch (response.command) {
@@ -215,8 +265,6 @@ $(document)
reset : function() {
$('#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 fb58f98..677352d 100644
--- a/lib/Controller/SettingsController.php
+++ b/lib/Controller/SettingsController.php
@@ -64,29 +64,43 @@ class SettingsController extends Controller
*/
public function index()
{
- $documentsCount = $this->solrAdmin->count($error);
-
$params = [
+ 'solr_url' => $this->configService->getAppValue('solr_url'),
+ 'solr_core' => $this->configService->getAppValue('solr_core')
+ ];
+
+ return new TemplateResponse($this->appName, 'settings.admin', $params, 'blank');
+ }
+
+ public function forceIndex()
+ {
+ $this->configService->needIndex(true);
+ }
+
+ public function updateSubOptions($instant)
+ {
+ $response = array(
+ 'instant' => $instant,
'configured' => $this->configService->getAppValue('configured'),
- 'current_docs' => $documentsCount,
+ 'ping' => $this->solrAdmin->ping($error),
+ 'current_docs' => $this->solrAdmin->count($error),
'last_index' => $this->configService->getAppValue('last_index'),
+ 'last_index_format' => date('r', $this->configService->getAppValue('last_index')),
'needed_index' => $this->configService->getAppValue('needed_index'),
- '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');
+ return $response;
}
- public function forceIndex()
+ public function setOption($option, $value)
{
- $this->configService->needIndex(true);
+ $this->configService->setAppValue($option, $value);
}
- public function setSettings($solr_url, $solr_core, $live_extract, $live_docupdate, $command)
+ public function setSettings($solr_url, $solr_core, $command)
{
$this->solr_url = $solr_url;
$this->solr_core = $solr_core;
@@ -134,7 +148,7 @@ class SettingsController extends Controller
break;
case 'save':
- $result = $this->save($live_extract, $live_docupdate, $message);
+ $result = $this->save($message);
break;
}
}
@@ -142,9 +156,7 @@ class SettingsController extends Controller
$response = array(
'command' => $command,
'status' => $result ? 'success' : 'failure',
- 'data' => array(
- 'message' => $message
- )
+ 'message' => $message
);
return $response;
@@ -246,13 +258,11 @@ class SettingsController extends Controller
return false;
}
- private function save($live_extract, $live_docupdate, &$message)
+ private function save(&$message)
{
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 8f5d996..b8fe1d6 100644
--- a/lib/Service/ConfigService.php
+++ b/lib/Service/ConfigService.php
@@ -42,6 +42,7 @@ class ConfigService
'solr_core' => 'nextant',
'live_extract' => '1',
'live_docupdate' => '0',
+ 'last_index' => 0,
'solr_lock' => 0
];
diff --git a/templates/settings.admin.php b/templates/settings.admin.php
index bcea9be..2cd6b3c 100644
--- a/templates/settings.admin.php
+++ b/templates/settings.admin.php
@@ -44,14 +44,14 @@ style('nextant', 'admin');
<td>&nbsp;</td>
</tr>
<tr>
- <td style="text-align: right;"><label>
- <?php p($l->t('Address of your Solr Servlet :')) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></td>
+ <td class="nextant_admin_left">
+ <?php p($l->t('Address of your Solr Servlet :')) ?></td>
<td><input type="text" name="solr_url" id="solr_url"
value="<?php p($_['solr_url'])?>" style="width: 250px;"></td>
</tr>
<tr>
- <td style="text-align: right;"><label><?php p($l->t('Core :')) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></td>
+ <td class="nextant_admin_left"><?php p($l->t('Core :')) ?></td>
<td><input type="text" id="solr_core"
value="<?php p($_['solr_core'])?>" style="width: 250px;"></td>
</tr>
@@ -62,6 +62,8 @@ style('nextant', 'admin');
<button type="button" id="nextant_apply" style="width: 270px"><?php p($l->t('Test and Save')) ?></button>
</td>
</tr>
+ </table>
+ <table id="nextant_suboptions">
<tr>
<td>&nbsp;</td>
</tr>
@@ -70,66 +72,51 @@ style('nextant', 'admin');
id="nextant-admin-msg" class="msg"></span></td>
</tr>
-->
- <?php
-if ($_['configured'] == '1') {
- ?>
-
<tr style="height: 30px;">
- <td style="text-align: right;"><label>
- <?php p($l->t('Live Extract :')) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></td>
+ <td class="nextant_admin_left">
+ <?php p($l->t('Live Extract :')); ?>
+ </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
+ id="solr_live_extract" value="1" style="margin: 10px;"> (<a
+ id="nextant_help_link"
href="https://github.com/daita/nextant/wiki/Extracting-&-Live-Update"
target="_blank">help</a>)</td>
</tr>
<tr style="height: 30px;">
- <td style="text-align: right;"><label>
- <?php p($l->t('Live Document Update :')) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></td>
+ <td class="nextant_admin_left">
+ <?php p($l->t('Live Document Update :')) ?></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>
+ id="solr_live_docupdate" value="1" style="margin: 10px;"></td>
</tr>
- <tr style="height: 20px;">
- <td style="width: 250px; text-align: right;"><label>
- <?php p($l->t('Last index:')) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></td>
- <td><?php
-
- if ($_['last_index'] > 0) {
- p(date('r', $_['last_index']));
- ?></td>
+ <tr style="height: 30px;">
+ <td class="nextant_admin_left">
+ <?php p($l->t('Last index :')) ?></td>
+ <td><div id="solr_last_index"></div></td>
</tr>
- <tr style="height: 20px;">
- <td style="width: 250px; text-align: right;"><label>
- <?php p($l->t('Number of documents :')) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></td>
- <td><?php ($_['current_docs'] === false) ? p('Solr Servlet is down') : p($_['current_docs']); ?></td>
+ <tr style="height: 30px;">
+ <td class="nextant_admin_left">
+ <?php p($l->t('Number of documents :')) ?></td>
+ <td><div id="solr_current_docs"></div></td>
</tr>
- <tr>
+ <tr style="height: 30px;">
<td></td>
- <td><?php
- if ($_['needed_index'] == 0) {
- ?>
- <button type="button" id="nextant_force_index"
+ <td>
+ <button type="button" id="nextant_force_index"
style="width: 270px"><?php p($l->t('Force re-index')) ?></button>
- <?php
- } else
- if ($_['needed_index'] == 2) {
- ?> <b>execute <i>./occ nextant:index</i></b> <?php
- } else
- p('index scheduled');
- } else
- p('never');
- ?></td>
+<?php
+// if ($_['needed_index'] == 2) {
+// <b>execute <i>./occ nextant:index</i></b>
+// } else
+// p('index scheduled');
+?></td>
</tr>
- <?php } ?>
-
+
+
</table>
</td>
<td style="padding-left: 40px;">