mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
Check if the zendesk_api gem is installed
This commit is contained in:
parent
df4b85fc9c
commit
8e3d43efdb
@ -50,7 +50,6 @@ var support_actions = {
|
||||
type: "list",
|
||||
call: OpenNebula.Support.list,
|
||||
callback: function(req, list, res){
|
||||
console.log(list)
|
||||
$(".support_info").show();
|
||||
$(".support_connect").hide();
|
||||
$(".actions_row", "#support-tab").show();
|
||||
@ -376,7 +375,6 @@ function updateSupportInfo(request, response){
|
||||
|
||||
if (response["REQUEST"]["comments"]) {
|
||||
$.each(response["REQUEST"]["comments"], function(index, comment){
|
||||
console.log(comment)
|
||||
html += generateAdvancedSection({
|
||||
title: '<span style="width: 100%;">' + (comment["author_id"] == 21231023 ? "OpenNebula Support Team" : "Me") + ' <span style="color: #999;"> - '+ comment["created_at"] + '</span></span>',
|
||||
html_id: 'advanced_comment_' + response["REQUEST"]["id"] + index,
|
||||
@ -509,12 +507,14 @@ $(document).ready(function(){
|
||||
dataType: "json",
|
||||
data: JSON.stringify(data),
|
||||
success: function(){
|
||||
console.log("success")
|
||||
$("#support-tabrefresh_buttons > a").trigger("click");
|
||||
},
|
||||
error: function(response){
|
||||
console.log("error")
|
||||
if (response.status=="401") {
|
||||
notifyError("Support credentials are incorrect")
|
||||
} else {
|
||||
notifyError(response.responseText)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -14,7 +14,14 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'zendesk_api'
|
||||
begin
|
||||
require 'zendesk_api'
|
||||
rescue LoadError
|
||||
STDERR.puts "[OpenNebula Support] Missing zendesk_api gem"
|
||||
ZENDESK_API_GEM = false
|
||||
else
|
||||
ZENDESK_API_GEM = true
|
||||
end
|
||||
|
||||
helpers do
|
||||
def zendesk_client
|
||||
@ -98,9 +105,17 @@ helpers do
|
||||
|
||||
return one_zrequest
|
||||
end
|
||||
|
||||
def check_zendesk_api_gem
|
||||
if !ZENDESK_API_GEM
|
||||
error 500, "zendesk_api gem missing, it requires ruby >= 1.9.3"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
get '/support/request' do
|
||||
check_zendesk_api_gem
|
||||
|
||||
zrequests = zendesk_client.requests({:status => "open,pending"})
|
||||
|
||||
open_requests = 0
|
||||
@ -128,6 +143,8 @@ get '/support/request' do
|
||||
end
|
||||
|
||||
get '/support/request/:id' do
|
||||
check_zendesk_api_gem
|
||||
|
||||
zrequest = zendesk_client.requests.find(:id => params[:id])
|
||||
# TODO check error
|
||||
one_zrequest = {
|
||||
@ -138,9 +155,9 @@ get '/support/request/:id' do
|
||||
end
|
||||
|
||||
post '/support/request' do
|
||||
check_zendesk_api_gem
|
||||
|
||||
body_hash = JSON.parse(@request_body)
|
||||
pp body_hash
|
||||
STDOUT.flush
|
||||
zrequest = zendesk_client.requests.create({
|
||||
:subject => body_hash['subject'],
|
||||
:comment => { :value => body_hash['description'] },
|
||||
@ -154,6 +171,8 @@ post '/support/request' do
|
||||
end
|
||||
|
||||
post '/support/request/:id/action' do
|
||||
check_zendesk_api_gem
|
||||
|
||||
body_hash = JSON.parse(@request_body)
|
||||
if body_hash["action"]["params"]['comment']
|
||||
comment_value = body_hash["action"]["params"]['comment']['value']
|
||||
@ -178,6 +197,8 @@ end
|
||||
|
||||
|
||||
post '/support/credentials' do
|
||||
check_zendesk_api_gem
|
||||
|
||||
body_hash = JSON.parse(@request_body)
|
||||
if body_hash["email"].nil? || body_hash["password"].nil?
|
||||
error 401, "Zendesk credentials not provided"
|
||||
|
Loading…
Reference in New Issue
Block a user