diff --git a/src/sunstone/public/app/tabs/support-tab.js b/src/sunstone/public/app/tabs/support-tab.js index 34b5ff33d1..deed0a337d 100644 --- a/src/sunstone/public/app/tabs/support-tab.js +++ b/src/sunstone/public/app/tabs/support-tab.js @@ -16,6 +16,7 @@ define(function(require) { ]; var _panels = [ + require('./support-tab/panels/info') ]; var _formPanels = [ @@ -27,7 +28,7 @@ define(function(require) { resource: 'Support', title: TemplateTitle(), listHeader: ' Commercial Support Requests', - info_header: ' Commercial Support Request', + infoHeader: ' Commercial Support Request', subheader: TemplateSubheader(), buttons: Buttons, actions: Actions, diff --git a/src/sunstone/public/app/tabs/support-tab/actions.js b/src/sunstone/public/app/tabs/support-tab/actions.js index 8e476b28ff..d2e4b1575f 100644 --- a/src/sunstone/public/app/tabs/support-tab/actions.js +++ b/src/sunstone/public/app/tabs/support-tab/actions.js @@ -16,7 +16,13 @@ define(function(require) { SupportUtils.showSupportList(); $(".support_open_value").text(res.open_requests); $(".support_pending_value").text(res.pending_requests); - Sunstone.getDataTable(TAB_ID).updateView(req, res.REQUEST_POOL.REQUEST); + + var elements = []; + if(res.REQUEST_POOL.REQUEST){ + elements = res.REQUEST_POOL.REQUEST; + } + + Sunstone.getDataTable(TAB_ID).updateView(req, elements); }, error: function(request, error_json) { if (error_json.error.http_status=="401") { @@ -62,7 +68,7 @@ define(function(require) { $("a[href=back]", $("#support-tab")).trigger("click"); popFormDialog("create_support_request_form", $("#support-tab")); - $("a.refresh", $("#support-tab")).trigger("click"); + Sunstone.runAction("Support.refresh"); //addTemplateElement(request, response); //notifyCustom(tr("Request created"), " ID: " + response.VMTEMPLATE.ID, false) }, @@ -89,20 +95,20 @@ define(function(require) { function(context){}); } }, - + */ "Support.update" : { type: "single", call: OpenNebulaSupport.update, callback: function(request, response){ - $("a.refresh", $("#support-tab")).trigger("click"); - notifyMessage(tr("Comment added correctly")); + Sunstone.runAction("Support.refresh"); + Notifier.notifyMessage("Comment added correctly"); }, error: function(request, response){ - popFormDialog("create_template_form", $("#templates-tab")); - SupportUtils.showSupportConnect(); + Sunstone.runAction("Support.refresh"); + //Notifier.onError(request, response); + Notifier.notifyError("Comment failed to be added"); } }, - */ "Support.signout" : { type: "single", call: function() { diff --git a/src/sunstone/public/app/tabs/support-tab/panels/info.js b/src/sunstone/public/app/tabs/support-tab/panels/info.js new file mode 100644 index 0000000000..085acecd78 --- /dev/null +++ b/src/sunstone/public/app/tabs/support-tab/panels/info.js @@ -0,0 +1,94 @@ +define(function(require) { + /* + DEPENDENCIES + */ + + var Locale = require('utils/locale'); + var Sunstone = require('sunstone'); + + var TemplateInfo = require('hbs!./info/html'); + + /* + CONSTANTS + */ + + var TAB_ID = require('../tabId'); + var PANEL_ID = require('./info/panelId'); + var RESOURCE = "Support"; + var XML_ROOT = "REQUEST"; + + /* + CONSTRUCTOR + */ + + function Panel(info) { + this.title = "Info"; + this.icon = "fa-info-circle"; + + this.element = info[XML_ROOT]; + + return this; + } + + Panel.PANEL_ID = PANEL_ID; + Panel.prototype.html = _html; + Panel.prototype.setup = _setup; + + return Panel; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + var message; + if (this.element["status"] == "open") { + message = "This request is currently being processed by our staff"; + } else if (this.element["status"] == "pending") { + message = "This request is awaiting your response"; + } + + var comments = []; + if (this.element["comments"]) { + $.each(this.element["comments"], function(index, comment){ + var author = (comment["author_id"] == 21231023 ? "OpenNebula Support Team" : 'Me'); + + comments.push({ + title: ''+author+' - '+comment["created_at"]+'', + html_body: comment["html_body"] + }); + }); + } + + return TemplateInfo({ + 'element': this.element, + 'message': message, + 'comments': comments + }); + } + + function _setup(context) { + var that = this; + + $("#submit_support_comment").on("submit", function(){ + $("button[type=submit]", context).attr("disabled", "disabled"); + $("button[type=submit]", context).html(''); + + var request_id = that.element.id; + var request_json = { + "comment" : { + "value" : $(".comment", this).val() + }, + "solved" : $("#solved:checked", this).length > 0 ? true : false + }; + + Sunstone.runAction("Support.update", request_id, request_json); + return false; + }); + + $(".accordion_advanced_toggle", context).trigger("click"); + $("dl.right-info-tabs", context).hide(); + + return false; + } +}); diff --git a/src/sunstone/public/app/tabs/support-tab/panels/info/html.hbs b/src/sunstone/public/app/tabs/support-tab/panels/info/html.hbs new file mode 100644 index 0000000000..85206063bf --- /dev/null +++ b/src/sunstone/public/app/tabs/support-tab/panels/info/html.hbs @@ -0,0 +1,58 @@ +
+ {{{htmlDecode element.html_description}}} +
+Information | +|
---|---|
Requested | +{{element.created_at}} | +
Status | +{{element.status}} | +
{{message}} | +