bug 5190: Integrated update cert command with the new UI

This commit is contained in:
will 2010-11-02 18:12:35 -07:00
parent 33fc23d903
commit 410d423a5e
3 changed files with 56 additions and 9 deletions

View File

@ -96,7 +96,7 @@
<li>
<label>Certificate:</label>
<textarea class="text" name="update_cert" id="update_cert" style="height: 300px; width: 400px" />
<div id="update_cert_errormsg" class="dialog_formcontent_errormsg" style="display:none;" ></div>
<div id="update_cert_errormsg" class="dialog_formcontent_errormsg" style="display:none; width:300px" ></div>
</li>
</ol>
</form>

View File

@ -1527,7 +1527,7 @@ function validateNumber(label, field, errMsgField, min, max, isOptional) {
return isValid;
}
function validateString(label, field, errMsgField, isOptional) {
function validateString(label, field, errMsgField, isOptional, maxLength) {
var isValid = true;
var errMsg = "";
var value = field.val();
@ -1535,8 +1535,8 @@ function validateString(label, field, errMsgField, isOptional) {
errMsg = label + " is a required value. ";
isValid = false;
}
else if (value!=null && value.length >= 255) {
errMsg = label + " must be less than 255 characters";
else if (value!=null && value.length >= maxLength) {
errMsg = label + " must be less than " + maxLength + " characters";
isValid = false;
}
else if(value!=null && value.indexOf('"')!=-1) {

View File

@ -295,7 +295,7 @@ function afterLoadResourceJSP($midmenuItem1) {
initAddZoneButton($("#midmenu_add_link"));
initUpdateConsoleCertButton($("#midmenu_add2_link"));
initDialog("dialog_add_zone");
initDialog("dialog_update_cert", 550);
initDialog("dialog_update_cert", 450);
}
function initUpdateConsoleCertButton($midMenuAddLink2) {
@ -308,15 +308,62 @@ function initUpdateConsoleCertButton($midMenuAddLink2) {
.dialog('option', 'buttons', {
"Add": function() {
var $thisDialog = $(this);
var isValid = true;
isValid &= validateString("SSL Certificate", $thisDialog.find("#update_cert"), $thisDialog.find("#update_cert_errormsg"), false, 4096);
if (!isValid) return;
$spinningWheel = $thisDialog.find("#spinning_wheel").show();
$thisDialog.dialog("close");
var cert = trim($thisDialog.find("#update_cert").val());
$.ajax({
data: createURL("command=uploadCustomCertificate&certificate="+encodeURIComponent(cert)),
dataType: "json",
success: function(json) {
var jobId = json.uploadcustomcertificateresponse.jobid;
var timerKey = "asyncJob_" + jobId;
$("body").everyTime(
5000,
timerKey,
function() {
$.ajax({
data: createURL("command=queryAsyncJobResult&jobId="+jobId),
dataType: "json",
success: function(json) {
var result = json.queryasyncjobresultresponse;
if (result.jobstatus == 0) {
return; //Job has not completed
} else {
$("body").stopTime(timerKey);
$spinningWheel.hide();
if (result.jobstatus == 1) { // Succeeded
$thisDialog.dialog("close");
// TODO: Add a confirmation message
} else if (result.jobstatus == 2) { // Failed
var errorMsg = result.jobresult.uploadcustomcertificateresponse.errortext;
$thisDialog.find("#info_container").text(errorMsg).show();
}
}
},
error: function(XMLHttpResponse) {
$("body").stopTime(timerKey);
handleErrorInDialog(XMLHttpResponse, $thisDialog);
}
});
},
0
);
},
error: function(XMLHttpResponse) {
handleErrorInDialog(XMLHttpResponse, $thisDialog);
}
});
},
"Cancel": function() {
var $thisDialog = $(this);
$thisDialog.dialog("close");
}
}).dialog("open");
return false;
});
@ -348,7 +395,7 @@ function initAddZoneButton($midmenuAddLink1) {
if (!isValid)
return;
$thisDialog.find("#spinning_wheel").show()
$thisDialog.find("#spinning_wheel").show();
var moreCriteria = [];