96
96
request_build_response_handler.clearProgressUI = function() {
97
97
destroy_temporary_spinner();
99
request_build_response_handler.showError = function(header, error_msgs) {
100
if (header === null) {
101
if (error_msgs === null) {
102
header = "An error occurred, please contact an " +
105
header = "The following errors occurred:";
108
var error_html = header;
109
if (error_msgs !== null) {
110
error_html += "<ul>";
111
if (typeof(error_msgs) === "string"){
112
error_msgs = [error_msgs];
114
Y.each(error_msgs, function(error_msg){
115
error_html += "<li>" + error_msg.replace(/<([^>]+)>/g,'') +
118
error_html += "</ul><p/>";
120
request_build_overlay.error_node.set('innerHTML', error_html);
99
request_build_response_handler.showError = function(errormessage) {
100
display_errors(null, errormessage);
250
var get_new_builds_message = function(build_html, current_builds) {
252
if (build_html === null) {
255
nr_new = display_build_records(build_html, current_builds);
257
return Y.Lang.substitute(MANY_BUILDS_MESSAGE, {nr_new: nr_new});
259
return ONE_BUILD_MESSAGE;
262
var get_info_header = function(new_builds_message, pending_build_info) {
263
var info_header = Y.Node.create('<div></div>')
264
.addClass('popup-build-informational');
265
if (new_builds_message !== null) {
266
info_header.append(Y.Node.create('<p></p>')
267
.set('text', new_builds_message));
269
if (pending_build_info !== null) {
270
info_header.append(Y.Node.create('<p></p>')
271
.set('text', pending_build_info));
273
if (info_header.getContent.hasChildNodes()) {
271
280
* The form submit function
286
295
headers: {'Accept': 'application/json; application/xhtml'},
288
failure: request_build_response_handler.getErrorHandler(
289
function(handler, id, response) {
292
error_header_text = "",
293
build_info, build_html, error_info,
294
nr_new, new_builds_message, field_name;
295
if( response.status >= 500 ) {
296
// There's some error content we need to display.
298
response.status + ' ' + response.statusText];
300
// The response will be a json data object containing
301
// info about what builds there are, informational
302
// text about any builds already pending, plus any
303
// errors. The FormOverlay infrastructure only
304
// supports displaying errors so we will construct
305
// our own HTML where the informational text will be
306
// appropriately displayed.
307
build_info = Y.JSON.parse(response.responseText);
309
// The result of rendering the +builds view
310
build_html = build_info.builds;
311
// Any builds already pending (informational only)
312
pending_build_info = build_info.already_pending;
313
// Other more critical errors
314
error_info = build_info.errors;
316
if (build_html !== null) {
317
nr_new = display_build_records(
318
build_html, current_builds);
319
new_builds_message = ONE_BUILD_MESSAGE;
326
error_header_text = new_builds_message;
328
if (pending_build_info !== null) {
329
if (error_header_text !== "" ) {
330
error_header_text += "<p/>" +
333
error_header_text = pending_build_info;
336
for (field_name in error_info) {
337
if (error_info.hasOwnProperty(field_name)) {
338
errors.push(error_info[field_name]);
341
if (error_header_text !== "") {
343
"<p><div class='popup-build-informational'>"
344
+ error_header_text + "</p></div>";
345
if (Y.Object.size(errors)>0) {
347
"<p/>" + "There were also some errors:";
350
error_header = "There were some errors:";
353
handler.showError(error_header, errors);
297
failure: request_build_response_handler.getFailureHandler(),
355
298
success: request_build_response_handler.getSuccessHandler(
356
299
function(handler, id, response) {
302
error_header_text = "",
303
build_info, build_html, error_info,
304
nr_new, info_header, field_name;
305
content_type = response.getResponseHeader('Content-type');
306
if( content_type !== 'application/json' ) {
307
// We got the HTML for the builds back, we're done.
357
308
request_build_overlay.hide();
358
309
display_build_records(
359
310
response.responseText, current_builds);
312
// The response will be a json data object containing
313
// info about what builds there are, informational
314
// text about any builds already pending, plus any
315
// errors. The FormOverlay infrastructure only
316
// supports displaying errors so we will construct
317
// our own HTML where the informational text will be
318
// appropriately displayed.
319
build_info = Y.JSON.parse(response.responseText);
321
// The result of rendering the +builds view
322
build_html = build_info.builds;
323
// Any builds already pending (informational only)
324
pending_build_info = build_info.already_pending;
325
// Other more critical errors
326
error_info = build_info.errors;
328
info_header = get_info_header(
329
get_new_builds_message(
330
build_html, current_builds),
333
for (field_name in error_info) {
334
if (error_info.hasOwnProperty(field_name)) {
335
errors.push(error_info[field_name]);
338
error_container = Y.Node.create('<div></div>')
339
if (info_header !== null) {
340
error_container.append(info_header);
341
if (errors.length > 0) {
342
error_container.append(
343
Y.Node.create('<p></p>')
346
"There were also some errors:"));
350
'text', "There were some errors:");
352
display_errors(error_container, errors);
363
357
id: request_build_overlay.form_node,
405
399
"label[for^='field.distroseries.']");
402
var display_errors = function(container, error_msgs) {
403
var errors_list, header;
404
if (container === null) {
405
if (error_msgs === null) {
406
header = "An error occurred, please contact an administrator.";
408
header = "The following errors occurred:";
410
container = Y.Node.create('<div></div>')
411
.set('text', header);
413
if (error_msgs !== null) {
414
errors_list = Y.Node.create('<ul></ul>');
415
if (Y.Lang.isString(error_msgs)){
416
error_msgs = [error_msgs];
418
Y.each(error_msgs, function(error_msg){
419
errors_list.append(Y.Node.create('<li></li>')
420
.set('text', error_msg));
422
container.append(errors_list);
424
request_build_overlay.error_node.setContent(container);
409
428
* Callback used to enable/disable distro series selection when a different
410
429
* ppa is selected.