Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
Admin form validation added.
Browse files Browse the repository at this point in the history
  • Loading branch information
parautenbach committed Mar 1, 2014
1 parent 5988510 commit 73183b2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ public CallbackObject(HipChatRoomNotification notification, String roomId) {

private class HipChatRoomNotificationCallback implements Callback {

// TODO: Record notify status
// TODO: Record and test notify status
ArrayList<CallbackObject> callbacks;
Object waitObject;

Expand Down
4 changes: 3 additions & 1 deletion src/resources/buildServerResources/adminSettings.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ limitations under the License.
</td>
</tr>
<tr>
<th><label for="apiUrl">API token: <l:star /></label></th>
<th>
<label for="apiToken">API token: <l:star /></label>
</th>
<td>
<forms:textField name="apiToken" value="${apiToken}" />
<span class="smallNote">A user OAuth token.</span>
Expand Down
52 changes: 35 additions & 17 deletions src/resources/buildServerResources/js/hipChatAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ limitations under the License.

var HipChatProject = {
save : function() {
BS.ajaxRequest($('hipChatProjectForm').action, {
parameters : 'project=1' +
'&roomId=' + $('roomId').value +
'&notify=' + $('notify').checked +
'&projectId=' + $('projectId').value,
BS.ajaxRequest($("hipChatProjectForm").action, {
parameters : "project=1" +
"&roomId=" + $("roomId").value +
"&notify=" + $("notify").checked +
"&projectId=" + $("projectId").value,
onComplete : function(transport) {
if (transport.responseXML) {
BS.XMLResponse.processErrors(transport.responseXML, {
Expand All @@ -37,13 +37,27 @@ var HipChatProject = {
};

var HipChatAdmin = {
validate : function() {
var apiUrl = document.forms["hipChatForm"]["apiUrl"].value;
var apiToken = document.forms["hipChatForm"]["apiToken"].value;
if (apiUrl == null || apiUrl == "" || apiToken == null || apiToken == "") {
alert("You must specify a value for both the API URL and token.");
return false;
}
return true;
},

save : function() {
BS.ajaxRequest($('hipChatForm').action, {
parameters : 'edit=1' +
'&apiUrl=' + $('apiUrl').value +
'&apiToken=' + $('apiToken').value +
'&defaultRoomId=' + $('defaultRoomId').value +
'&notify=' + $('notify').checked,
if (!HipChatAdmin.validate()) {
return false;
}

BS.ajaxRequest($("hipChatForm").action, {
parameters : "edit=1" +
"&apiUrl=" + $("apiUrl").value +
"&apiToken=" + $("apiToken").value +
"&defaultRoomId=" + $("defaultRoomId").value +
"&notify=" + $("notify").checked,
onComplete : function(transport) {
if (transport.responseXML) {
BS.XMLResponse.processErrors(transport.responseXML, {
Expand All @@ -59,19 +73,23 @@ var HipChatAdmin = {
},

testConnection : function() {
if (!HipChatAdmin.validate()) {
return false;
}

jQuery.ajax(
{
url: $('hipChatForm').action,
url: $("hipChatForm").action,
data: {
test: 1,
apiUrl: $('apiUrl').value,
apiToken: $('apiToken').value
apiUrl: $("apiUrl").value,
apiToken: $("apiToken").value
},
type: 'GET'
type: "GET"
}).done(function() {
alert('Connection successful!');
alert("Connection successful!");
}).fail(function() {
alert('Connection failed!')
alert("Connection failed!")
});
return false;
}
Expand Down

0 comments on commit 73183b2

Please sign in to comment.