Skip to content

Commit

Permalink
Item12952: add search function, EXPERT tabs, improve texts
Browse files Browse the repository at this point in the history
  • Loading branch information
crawford committed Sep 23, 2014
1 parent 386a65a commit dd0b86d
Show file tree
Hide file tree
Showing 10 changed files with 226 additions and 66 deletions.
32 changes: 30 additions & 2 deletions ConfigurePlugin/lib/Foswiki/Plugins/ConfigurePlugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ sub initPlugin {

# Register each of the RPC methods with JsonRpcContrib
foreach my $method (
qw(getcfg getspec check_current_value changecfg deletecfg purgecfg wizard)
qw(getcfg getspec search check_current_value changecfg deletecfg purgecfg wizard)
)
{
Foswiki::Contrib::JsonRpcContrib::registerMethod( 'configure', $method,
Expand Down Expand Up @@ -293,6 +293,32 @@ sub getcfg {

=pod
---+++ =search=
Search headlines and keys for a fragment of text. Return the path(s) to
the item(s) matched in an array or arrays, where each entry is a single
path.
=cut

sub search {
my $params = shift;
my $root = _loadSpec();

return () unless $params->{search};

my %found;
foreach my $find ( $root->search( $params->{search} ) ) {
my @path = $find->getPath();
$found{ join( '>', @path ) } = \@path;
}
my $finds = [ map { $found{$_} } sort keys %found ];

return $finds;
}

=pod
---+++ =getspec=
Use a search to find a configuration item spec
Expand Down Expand Up @@ -586,11 +612,13 @@ sub check_current_value {
}
) if $reporter->has($level);
}
my @path = $spec->getPath();
pop(@path); # remove keys
push(
@report,
{
keys => $k,
path => [ $spec->getSectionPath() ],
path => [@path],
reports => \@reps
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ div.information {
background-image: url("info-icon.png") !important;
}

.expert {
display: block;
div.expert {
background-image: url(expert.png);
padding-left: 60px !important;
background-position: left 45%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function _id_ify(id) {
}

// Make an RPC call
function RPC(method, message, params, report, $node) {
function RPC(method, message, params, report) {
var rpcid = _id_ify(message) + '_' + jsonRpc_reqnum++; // Get an id to uniquely identify the request

console.debug("Sending " + rpcid);
Expand Down Expand Up @@ -286,8 +286,7 @@ function _id_ify(id) {
RPC('check_current_value',
'Check: '+ handler.spec.keys,
params,
checker_reports,
$node, 'check' );
checker_reports );
}

/*
Expand Down Expand Up @@ -387,8 +386,7 @@ function _id_ify(id) {
RPC('wizard',
'Call ' + fb.method,
params,
function(result) { wizard_reports($node, result) },
$node, 'check');
function(result) { wizard_reports($node, result) });
}

/*
Expand Down Expand Up @@ -535,7 +533,7 @@ function _id_ify(id) {
check_current_value($node);
}).button({
icons: {
primary: "undo-icon"
primary: "ui-icon-arrowreturn-1-w"
},
text: false
}).hide();
Expand Down Expand Up @@ -607,10 +605,8 @@ function _id_ify(id) {
RPC('check_current_value',
'Check: ' + spec.headline,
{ keys : [ spec.headline ] },
checker_reports,
$panel, 'check');
},
$panel, 'load'
checker_reports);
}
);
}

Expand Down Expand Up @@ -787,13 +783,19 @@ function _id_ify(id) {
$.each(entries, function(index, entry) {
if (entry.typename == "SECTION" && !created[entry.headline]) {
created[entry.headline] = true;
var $li = $('<li><a href="' +
// This URL could be anything; we're going to
// cancel it in the beforeLoad, below.
json_rpc_url +
'"><span class="tab" id="' +
'TAB' + _id_ify(entry.headline) + '">' +
entry.headline + '</span></a></li>');
var $li = $('<li><a href="'
// This URL could be anything; we're going to
// cancel it in the beforeLoad, below.
+ json_rpc_url
+ '"><span class="tab" id="'
+ 'TAB' + _id_ify(entry.headline) + '">'
+ entry.headline
+ '</span></a></li>');
if (entry.EXPERT && entry.EXPERT == 1) {
$li.addClass('expert');
if ($('#showExpert').attr('checked') !== 'checked')
$li.addClass('hidden_expert');
}
$li.data('spec.entry', entry);
if ($children === null) {
$children = $('<div></div>');
Expand Down Expand Up @@ -888,15 +890,45 @@ function _id_ify(id) {
params,
function(results) {
wizard_reports($root, results);
},
$root, 'check');
});
};
$('#auth_note').html($("#webCheckAuthMessage").html());
$('#auth_prompt').dialog(
'option', 'title', 'Webserver authentication');
$('#auth_prompt').dialog("open");
});

$('#closeSearchButton').button().click(function() {
$('#searchResults').hide();
});
$('#searchResults').hide();
$('#searchButton').button(
{
icons: {
primary: "ui-icon-search"
},
text: false
}).click(function() {
var search = $('#searchInput').val();
var $node = $('#searchResults');
$node.find('.path').remove();
$node.prepend('<div>Search for: ' + search + '</div>');
$('#searchResults').show();
RPC('search',
'Search: ' + search,
{
search: search
},
function(response) {
for (var i = 0; i < response.length; i++) {
var path = response[i];
$node.append('<div class="path">'
+ path.join(' > ')
+ '</div>');
}
});
});

$('#showExpert').button({disabled: true});

$('#saveButton').button({disabled: !bs}).click(function() {
Expand Down Expand Up @@ -930,8 +962,7 @@ function _id_ify(id) {
});
$('#saveButton').button('disable');
}
},
$root, 'load');
});
};
var changed = ':<ul>';
if ($('#bootstrap_warning').length) {
Expand Down Expand Up @@ -983,10 +1014,8 @@ function _id_ify(id) {
RPC('check_current_value',
'Check all',
{ keys : [] },
checker_reports,
$root, 'check' );
},
$root, 'load');
checker_reports);
});
});
/*
Expand Down
5 changes: 5 additions & 0 deletions ConfigurePlugin/templates/configure.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ configure.js script.
<div class="header clearfix">
<img class="logo" src="%PUBURLPATH%/%SYSTEMWEB%/ConfigurePlugin/foswiki-logo.png" alt="Foswiki configure"/>
<div class="top_level_buttons">
<input type="text" width="30" id="searchInput" title="Enter a string to search for"/>
<button id="searchButton" title="Search in titles and keys">Search</button>
<button id="webCheckButton">Study Web Server</button>
<input id="showExpert" type="checkbox"><label for="showExpert">Show expert options</label>
<button id="saveButton">Save</button>
</div>
<div id="searchResults">
<button id="closeSearchButton">Close</button>
</div>
<div id="bootstrap_warning" class="foswikiAlert">
<strong>Warning</strong> Foswiki is running in 'bootstrap' mode, which means
that there is no existing configuration (LocalSite.cfg is missing or is
Expand Down
Loading

0 comments on commit dd0b86d

Please sign in to comment.