Skip to content

Commit

Permalink
Item13077: more tweaks, brought back per-tab progress indicators (the…
Browse files Browse the repository at this point in the history
… global one is just too obscure)
  • Loading branch information
Comment committed Dec 7, 2014
1 parent 65cb864 commit 470095e
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 45 deletions.
7 changes: 5 additions & 2 deletions ConfigurePlugin/lib/Foswiki/Plugins/ConfigurePlugin.pm
Expand Up @@ -157,8 +157,11 @@ sub _JSONwrap {
my $response = &$method( $request->params(), $reporter );
use strict 'refs';
unless ($response) {
die join( "\n",
map { "$_->{level}: $_->{text}" } $reporter->messages() );

# Should never get here
die $method . " "
. join( "\n",
map { "$_->{level}: $_->{text}" } @{ $reporter->messages() } );
}
return $response;
}
Expand Down
Expand Up @@ -40,6 +40,16 @@ html body {
}

.whirly {
display:none;
width:16px;
height:16px;
margin-left: 0.5em;
background-image:url(loader-bars.gif);
background-repeat:no-repeat;
background-position:bottom left;
}

.ajax_whirly {
display:none;
width:16px;
height:16px;
Expand Down
Expand Up @@ -46,7 +46,7 @@ function _id_ify(id) {
function init_whirly() {
var $whirly, whirlyTimer;

$whirly = $(".whirly");
$whirly = $(".ajax_whirly");
$(document).ajaxSend(function() {
if (typeof(whirlyTimer) !== 'undefined') {
window.clearTimeout(whirlyTimer);
Expand All @@ -60,11 +60,20 @@ function _id_ify(id) {
whirlyTimer = window.setTimeout(function() {
$whirly.hide();
whirlyTimer = undefined;
}, 1000);
}, 5000);
});

}

function inline_whirly($site) {
var $whirly = $('<img class="whirly" style="display:inline">');
$site.append($whirly);
window.setTimeout(function() {
$whirly.remove();
}, 1000);
return $whirly;
}

// Find all modified values, and return key-values
function find_modified_values() {
var set = {}, handler;
Expand Down Expand Up @@ -107,10 +116,11 @@ function _id_ify(id) {
}

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

function RPC(method, message, params, report, $whirlyPlace) {
var rpcid, $w;
rpcid = _id_ify(message) + '_' + jsonRpc_reqnum++; // Get an id to uniquely identify the request
console.debug("Sending " + rpcid);
$w = inline_whirly($whirlyPlace);
$.jsonRpc(
json_rpc_url,
{
Expand All @@ -120,6 +130,7 @@ function _id_ify(id) {
params: params,
error: function(jsonResponse, textStatus, xhr) {
console.debug(rpcid + " failed");
$w.remove;
$.pnotify({
title: "Error",
text: jsonResponse.error.message,
Expand All @@ -133,6 +144,7 @@ function _id_ify(id) {
success: function(jsonResponse, textStatus, xhr) {
console.debug(rpcid + " OK");
report(jsonResponse.result);
$w.remove();
}
});
}
Expand Down Expand Up @@ -310,7 +322,8 @@ function _id_ify(id) {
RPC('check_current_value',
'Check: '+ handler.spec.keys,
params,
checker_reports );
checker_reports,
$node);
}

/*
Expand All @@ -327,12 +340,13 @@ function _id_ify(id) {
// Generate reports
var $div = $('<div class="message_block"></div>');
$div.html(TML.render_reports(results.messages));
$.each(results.changes, function(key, value) {
$div.append('<div class="changes">'
+ key + ' = ' + value
+ '</div>');

});
if (results.changes) {
$.each(results.changes, function(key, value) {
$div.append('<div class="changes">'
+ key + ' = ' + value
+ '</div>');
});
}
// Enable any carry-on buttons we find
$div.find('.wizard_button').each(function() {
var data = $(this).data('wizard');
Expand Down Expand Up @@ -365,7 +379,8 @@ function _id_ify(id) {
RPC('wizard',
'Call ' + data.method,
params,
function(result) { wizard_reports($node, result) });
function(result) { wizard_reports($node, result) },
$(this));
});
});
// Reflect changed values back to the input elements and
Expand Down Expand Up @@ -426,7 +441,7 @@ function _id_ify(id) {
}

// Delegate for calling wizards once auth info is available
function call_wizard($node, fb) {
function call_wizard($node, fb, $whirlyPlace) {
var handler = $node.data('value_handler'),
params = {
wizard: fb.wizard,
Expand All @@ -440,7 +455,8 @@ function _id_ify(id) {
RPC('wizard',
'Call ' + fb.method,
params,
function(result) { wizard_reports($node, result) });
function(result) { wizard_reports($node, result) },
$whirlyPlace);
}

/*
Expand Down Expand Up @@ -501,15 +517,15 @@ function _id_ify(id) {
$button.click(function() {
if (fb.auth == 1) {
auth_action = function() {
call_wizard($node, fb);
call_wizard($node, fb, $button);
};
$('#auth_note').html(spec.title);
$('#auth_prompt').dialog(
'option', 'title',
fb.label + ' requires authentication');
$('#auth_prompt').dialog("open");
} else {
call_wizard($node, fb);
call_wizard($node, fb, $button);
}
}).button();
$node.append($button);
Expand Down Expand Up @@ -616,8 +632,13 @@ function _id_ify(id) {

// Load the tab for a given section spec
function load_tab(spec, $panel) {
var $tab;

if ($panel.hasClass('spec_loaded'))
return;

$tab = $('#TAB' + _id_ify(spec.headline));

RPC('getspec',
'Load: ' + spec.headline,
{
Expand All @@ -631,15 +652,14 @@ function _id_ify(id) {
},
function(response) {
var $node = $('<div class="node"></div>'),
$tab, $report;
$report;

$panel.append($node);
$panel.addClass('spec_loaded');

// Clean off errors and warnings that were bubbled
// up to here from higher level deep checks. We will
// perform a deep check on this tab once it's open.
$tab = $('#TAB' + _id_ify(spec.headline));
$tab .removeClass('errors')
.removeClass('warnings');
// Duplicate the spec.entry here; it's the only way
Expand All @@ -654,12 +674,15 @@ function _id_ify(id) {
add_desc(spec, $node);

load_section_specs(response, $node); /*SMELL load_section_specs is not defined yet */

// Check all the keys under this node.
RPC('check_current_value',
'Check: ' + spec.headline,
{ keys : [ spec.headline ] },
checker_reports);
}
checker_reports,
$tab);
},
$tab
);
}

Expand Down Expand Up @@ -943,7 +966,8 @@ function _id_ify(id) {
params,
function(results) {
wizard_reports($root, results);
});
},
$(this));
};
$('#auth_note').html($("#webCheckAuthMessage").html());
$('#auth_prompt').dialog(
Expand Down Expand Up @@ -979,7 +1003,8 @@ function _id_ify(id) {
+ path.join(' > ')
+ '</div>');
}
});
},
$(this));
});

$('#showExpert').button({disabled: true});
Expand Down Expand Up @@ -1016,7 +1041,8 @@ function _id_ify(id) {
});
$('#saveButton').button('disable');
}
});
},
$(this));
};
var changed = ':<ul>';
if ($('#bootstrap_warning').length) {
Expand Down Expand Up @@ -1068,8 +1094,10 @@ function _id_ify(id) {
RPC('check_current_value',
'Check all',
{ keys : [] },
checker_reports);
});
checker_reports,
$(".ajax_whirly"));
},
$(".ajax_whirly"));
});

$(window).on('beforeunload', function() {
Expand Down
2 changes: 1 addition & 1 deletion ConfigurePlugin/templates/configure.tmpl
Expand Up @@ -52,7 +52,7 @@ configure.js script.
an admin (see 'Security and Authentication'), or you might lock yourself out
from this interface.
</div>
<div class="whirly"></div>
<div class="ajax_whirly"></div>
</div>
<div id="root" class="main">
</div>
Expand Down
5 changes: 0 additions & 5 deletions core/lib/Foswiki/Configure/Checkers/OCTAL.pm
Expand Up @@ -30,11 +30,6 @@ sub check_current_value {
$val = 0;
}

if ( $val !~ /^\s*[0-7]*\s*$/ ) {
$reporter->ERROR("Number format error");
return;
}

my $check = $this->{item}->{CHECK}->[0];
if ($check) {
if ( defined $check->{min} ) {
Expand Down
7 changes: 0 additions & 7 deletions core/lib/Foswiki/Configure/Checkers/PERL.pm
Expand Up @@ -19,13 +19,6 @@ sub check_current_value {
return;
}

eval $value;
if ($@) {
$reporter->ERROR( 'Not a valid PERL value: '
. Foswiki::Configure::Reporter::stripStacktrace($@) );
return;
}

_check_for_null( $value, $reporter );
}

Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/Checkers/STRING.pm
Expand Up @@ -24,7 +24,7 @@ sub check_current_value {
my ( $this, $reporter ) = @_;

my $value = $this->{item}->getExpandedValue();
if ( !defined $value || $value eq '' ) {
if ( !defined $value ) {
my $check = $this->{item}->{CHECK}->[0];
unless ( $check && $check->{nullok}[0] ) {
$reporter->ERROR("Must be non-empty");
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/LoadSpec.pm
Expand Up @@ -606,7 +606,7 @@ sub addCfgValuesToSpec {
# UIs
my $value = eval "\$cfg->$spec->{keys}";
ASSERT( !$@ ) if DEBUG;
$spec->{current_value} = $value;
$spec->{current_value} = $spec->encodeValue($value);
}

# Don't do this; it's not the case that the default value
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/Query.pm
Expand Up @@ -305,7 +305,7 @@ sub check_current_value {
# Apply "set" values to $Foswiki::cfg
eval { _getSetParams( $params, $root, $frep ); };
if ( $frep->has_level('errors') ) {
return undef;
return [ { reports => $frep->messages() } ];
}

# Because we're running in a plugin, we already have LocalSite.cfg
Expand Down
9 changes: 8 additions & 1 deletion core/lib/Foswiki/Configure/Wizards/Save.pm
Expand Up @@ -222,7 +222,14 @@ sub save {
my $spec = $root->getValueObject($k);
my $value = $v;
if ($spec) {
$value = $spec->decodeValue($value);
eval { $value = $spec->decodeValue($value) };
if ($@) {
$reporter->ERROR(
"SAVE ABORTED: Could not interpret new value for $k: "
. Foswiki::Configure::Reporter::stripStackTrace(
$@) );
return undef;
}
}
if ( defined $value ) {
eval "\$Foswiki::cfg$k=\$value";
Expand Down

0 comments on commit 470095e

Please sign in to comment.