From 9a196ee07913ea7249c524ffdcd9cd790b9fff59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 16 Jun 2015 12:58:03 +0200 Subject: [PATCH] Feature #3748: Support tab --- src/sunstone/public/app/app.js | 3 +- src/sunstone/public/app/tabs/support-tab.js | 93 ++++++++++++ .../public/app/tabs/support-tab/actions.js | 138 ++++++++++++++++++ .../public/app/tabs/support-tab/buttons.js | 32 ++++ .../public/app/tabs/support-tab/datatable.js | 73 +++++++++ .../public/app/tabs/support-tab/subheader.hbs | 68 +++++++++ .../public/app/tabs/support-tab/tabId.js | 3 + .../public/app/tabs/support-tab/title.hbs | 14 ++ .../app/tabs/support-tab/utils/common.js | 44 ++++++ 9 files changed, 467 insertions(+), 1 deletion(-) create mode 100644 src/sunstone/public/app/tabs/support-tab.js create mode 100644 src/sunstone/public/app/tabs/support-tab/actions.js create mode 100644 src/sunstone/public/app/tabs/support-tab/buttons.js create mode 100644 src/sunstone/public/app/tabs/support-tab/datatable.js create mode 100644 src/sunstone/public/app/tabs/support-tab/subheader.hbs create mode 100644 src/sunstone/public/app/tabs/support-tab/tabId.js create mode 100644 src/sunstone/public/app/tabs/support-tab/title.hbs create mode 100644 src/sunstone/public/app/tabs/support-tab/utils/common.js diff --git a/src/sunstone/public/app/app.js b/src/sunstone/public/app/app.js index e981abc6f5..435b854058 100644 --- a/src/sunstone/public/app/app.js +++ b/src/sunstone/public/app/app.js @@ -30,7 +30,8 @@ define(function(require) { require('tabs/oneflow-dashboard'), require('tabs/oneflow-services-tab'), require('tabs/oneflow-templates-tab'), - require('tabs/settings-tab') + require('tabs/settings-tab'), + require('tabs/support-tab') ]; var _commonDialogs = [ diff --git a/src/sunstone/public/app/tabs/support-tab.js b/src/sunstone/public/app/tabs/support-tab.js new file mode 100644 index 0000000000..34b5ff33d1 --- /dev/null +++ b/src/sunstone/public/app/tabs/support-tab.js @@ -0,0 +1,93 @@ +define(function(require) { + var Buttons = require('./support-tab/buttons'); + var Actions = require('./support-tab/actions'); + var Table = require('./support-tab/datatable'); + var Notifier = require('utils/notifier'); + var SupportUtils = require('./support-tab/utils/common'); + var Sunstone = require('sunstone'); + + var TemplateTitle = require('hbs!./support-tab/title'); + var TemplateSubheader = require('hbs!./support-tab/subheader'); + + var TAB_ID = require('./support-tab/tabId'); + var DATATABLE_ID = "dataTableSupport"; + + var _dialogs = [ + ]; + + var _panels = [ + ]; + + var _formPanels = [ + //require('./support-tab/form-panels/create') + ]; + + var Tab = { + tabId: TAB_ID, + resource: 'Support', + title: TemplateTitle(), + listHeader: ' Commercial Support Requests', + info_header: ' Commercial Support Request', + subheader: TemplateSubheader(), + buttons: Buttons, + actions: Actions, + dataTable: new Table(DATATABLE_ID, {actions: true, info: true, oneSelection: true}), + panels: _panels, + formPanels: _formPanels, + dialogs: _dialogs, + setup: _setup + }; + + return Tab; + + function _setup(context) { + + SupportUtils.showSupportConnect(); + SupportUtils.startIntervalRefresh(); + + $(".support_button").on("click", function(){ + $("#li_support-tab > a").trigger("click"); + $(".create_dialog_button", "#support-tab").trigger("click"); + return false; + }); + + $("#support_credentials_form", context).on("submit", function(){ + $(".submit_support_credentials_button", context).attr("disabled", "disabled"); + $(".submit_support_credentials_button", context).html(''); + + var data = { + email : $("#support_email", this).val(), + password : $("#support_password", this).val() + }; + + $.ajax({ + url: 'support/credentials', + type: "POST", + dataType: "text", + data: JSON.stringify(data), + success: function(){ + $(".submit_support_credentials_button", context).removeAttr("disabled"); + $(".submit_support_credentials_button", context).html('Sign in'); + + Sunstone.runAction("Support.refresh"); + + SupportUtils.showSupportList(); + SupportUtils.startIntervalRefresh(); + }, + error: function(response){ + if (response.status=="401") { + Notifier.notifyError("Support credentials are incorrect"); + } else { + Notifier.notifyError(response.responseText); + } + + $(".submit_support_credentials_button", context).removeAttr("disabled"); + $(".submit_support_credentials_button", context).html('Sign in'); + } + }); + + return false; + }); + } + +}); diff --git a/src/sunstone/public/app/tabs/support-tab/actions.js b/src/sunstone/public/app/tabs/support-tab/actions.js new file mode 100644 index 0000000000..8e476b28ff --- /dev/null +++ b/src/sunstone/public/app/tabs/support-tab/actions.js @@ -0,0 +1,138 @@ +define(function(require) { + var Sunstone = require('sunstone'); + var Notifier = require('utils/notifier'); + var OpenNebulaSupport = require('opennebula/support'); + var SupportUtils = require('./utils/common'); + + var RESOURCE = "Support"; + var TAB_ID = require('./tabId'); + //var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId'); + + var _actions = { + "Support.list" : { + type: "list", + call: OpenNebulaSupport.list, + callback: function(req, list, res){ + 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); + }, + error: function(request, error_json) { + if (error_json.error.http_status=="401") { + SupportUtils.stopIntervalRefresh(); + } + + SupportUtils.showSupportConnect(); + } + }, + "Support.refresh" : { + type: "custom", + call: function() { + var tab = $('#' + TAB_ID); + if (Sunstone.rightInfoVisible(tab)) { + Sunstone.runAction(RESOURCE+".show", Sunstone.rightInfoResourceId(tab)); + } else { + Sunstone.getDataTable(TAB_ID).waitingNodes(); + Sunstone.runAction(RESOURCE+".list", {force: true}); + } + }, + error: function(request, error_json) { + SupportUtils.showSupportConnect(); + } + }, + "Support.show" : { + type: "single", + call: OpenNebulaSupport.show, + callback: function(request, response) { + //Sunstone.getDataTable(TAB_ID).updateElement(request, response); + if (Sunstone.rightInfoVisible($('#'+TAB_ID))) { + Sunstone.insertPanels(TAB_ID, response); + } + }, + error: function(request, error_json) { + SupportUtils.showSupportConnect(); + } + }, + /*TODO + "Support.create" : { + type: "create", + call: OpenNebulaSupport.create, + callback: function(request, response){ + $("a[href=back]", $("#support-tab")).trigger("click"); + popFormDialog("create_support_request_form", $("#support-tab")); + + $("a.refresh", $("#support-tab")).trigger("click"); + //addTemplateElement(request, response); + //notifyCustom(tr("Request created"), " ID: " + response.VMTEMPLATE.ID, false) + }, + error: function(request, error_json){ + popFormDialog("create_support_request_form", $("#support-tab")); + if (error_json.error.http_status=="403") { + notifyError(error_json.error.message); + } else { + $("a[href=back]", $("#support-tab")).trigger("click"); + SupportUtils.showSupportConnect(); + } + } + + }, + + "Support.create_dialog" : { + type: "custom", + call: function(){ + Sunstone.popUpFormPanel( + "create_support_request_form", + "support-tab", + "create", + false, + function(context){}); + } + }, + + "Support.update" : { + type: "single", + call: OpenNebulaSupport.update, + callback: function(request, response){ + $("a.refresh", $("#support-tab")).trigger("click"); + notifyMessage(tr("Comment added correctly")); + }, + error: function(request, response){ + popFormDialog("create_template_form", $("#templates-tab")); + SupportUtils.showSupportConnect(); + } + }, + */ + "Support.signout" : { + type: "single", + call: function() { + $.ajax({ + url: 'support/credentials', + type: "DELETE", + dataType: "text", + success: function(){ + SupportUtils.showSupportConnect(); + Sunstone.runAction("Support.refresh"); + }, + error: function(response){ + if (response.status=="401") { + Notifier.notifyError("Support credentials are incorrect"); + } else { + Notifier.notifyError(response.responseText); + } + } + }); + } + }, +/* TODO + "Support.upload" : { + type: "single", + call: function() { + $upload_support_file.foundation("reveal", "open"); + } + } +*/ + }; + + return _actions; +}); \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/support-tab/buttons.js b/src/sunstone/public/app/tabs/support-tab/buttons.js new file mode 100644 index 0000000000..ff453b6ebc --- /dev/null +++ b/src/sunstone/public/app/tabs/support-tab/buttons.js @@ -0,0 +1,32 @@ +define(function(require) { + var Locale = require('utils/locale'); + + var Buttons = { + "Support.refresh" : { + type: "action", + layout: "refresh", + text: '', + alwaysActive: true + }, + "Support.upload" : { + type: "action", + layout: "main", + text: ' '+Locale.tr("Upload a file"), + custom_classes: "only-right-info" + }, + "Support.signout" : { + type: "action", + layout: "main", + text: '', + tip: "Sign out of Commercial Support", + alwaysActive: true + }, + "Support.create_dialog" : { + type: "create_dialog", + layout: "create", + text: "Submit a Request" + } + }; + + return Buttons; +}); \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/support-tab/datatable.js b/src/sunstone/public/app/tabs/support-tab/datatable.js new file mode 100644 index 0000000000..6727415a8d --- /dev/null +++ b/src/sunstone/public/app/tabs/support-tab/datatable.js @@ -0,0 +1,73 @@ +define(function(require) { + /* + DEPENDENCIES + */ + + var TabDataTable = require('utils/tab-datatable'); + var SunstoneConfig = require('sunstone-config'); + var Locale = require('utils/locale'); + + /* + CONSTANTS + */ + + var RESOURCE = "Support"; + var XML_ROOT = "REQUEST"; + var TAB_NAME = require('./tabId'); + + /* + CONSTRUCTOR + */ + + function Table(dataTableId, conf) { + this.conf = conf || {}; + this.tabId = TAB_NAME; + this.dataTableId = dataTableId; + this.resource = RESOURCE; + this.xmlRoot = XML_ROOT; + + this.dataTableOptions = { + "bAutoWidth": false, + "bSortClasses" : false, + "bDeferRender": true, + "aoColumnDefs": [ + {"bSortable": false, "aTargets": ["check"]}, + {"sWidth": "35px", "aTargets": [0]}, + {"bVisible": true, "aTargets": SunstoneConfig.tabTableColumns(TAB_NAME)}, + {"bVisible": false, "aTargets": ['_all']} + ] + }; + + this.columns = [ + "ID", + "Subject", + "Requested", + "Status" + ]; + + + TabDataTable.call(this); + } + + Table.prototype = Object.create(TabDataTable.prototype); + Table.prototype.constructor = Table; + Table.prototype.elementArray = _elementArray; + + return Table; + + /* + FUNCTION DEFINITIONS + */ + + function _elementArray(element) { + return [ + '', + element.id, + element.subject, + element.created_at, + element.status + ]; + } +}); diff --git a/src/sunstone/public/app/tabs/support-tab/subheader.hbs b/src/sunstone/public/app/tabs/support-tab/subheader.hbs new file mode 100644 index 0000000000..e1cce970cb --- /dev/null +++ b/src/sunstone/public/app/tabs/support-tab/subheader.hbs @@ -0,0 +1,68 @@ +
+
+

The Support Subscription provides expert integration and production support on supported platforms and include:

+
    +
  • Problem diagnosis, resolution and bug fixing
  • +
  • Solving unexpected problems when using, installing or configuring the software
  • +
  • Guidance about tuning for optimal and scalable performance in your environment
  • +
  • Answering “how to” questions related to standard and intended product usage
  • +
  • Offering hints about how to go around missing features
  • +
  • Answering questions about product adaptation and integration
  • +
+

For more info on support subcriptions, click here

+
+
+
+ Commercial Support +
+
+ + +
+
+ + +
+
+ +
+
+

or

+
+ +
+
+
+
+
+
+

Additional Help Resources

+
+
+
+ +
+

This tab can be disabled in the sunstone views configuration files

\ No newline at end of file diff --git a/src/sunstone/public/app/tabs/support-tab/tabId.js b/src/sunstone/public/app/tabs/support-tab/tabId.js new file mode 100644 index 0000000000..3ff81a183a --- /dev/null +++ b/src/sunstone/public/app/tabs/support-tab/tabId.js @@ -0,0 +1,3 @@ +define(function(require) { + return 'support-tab'; +}); diff --git a/src/sunstone/public/app/tabs/support-tab/title.hbs b/src/sunstone/public/app/tabs/support-tab/title.hbs new file mode 100644 index 0000000000..8064e48680 --- /dev/null +++ b/src/sunstone/public/app/tabs/support-tab/title.hbs @@ -0,0 +1,14 @@ + Support +
+ + \ No newline at end of file diff --git a/src/sunstone/public/app/tabs/support-tab/utils/common.js b/src/sunstone/public/app/tabs/support-tab/utils/common.js new file mode 100644 index 0000000000..731a423101 --- /dev/null +++ b/src/sunstone/public/app/tabs/support-tab/utils/common.js @@ -0,0 +1,44 @@ +define(function(require) { + /* + Common functions for the support tab + */ + + var Sunstone = require('sunstone'); + + var TAB_ID = require('../tabId'); + + var support_interval_function; + + function _show_support_connect() { + $(".support_info").hide(); + $("#"+Sunstone.getDataTable(TAB_ID).dataTableId+"Container", "#"+TAB_ID).hide(); + $(".support_connect").show(); + $(".actions_row", "#"+TAB_ID).hide(); + } + + function _show_support_list() { + $(".support_info").show(); + $(".support_connect").hide(); + $(".actions_row", "#"+TAB_ID).show(); + $("#"+Sunstone.getDataTable(TAB_ID).dataTableId+"Container", "#"+TAB_ID).show(); + } + + function _startIntervalRefresh() { + Sunstone.runAction('Support.list'); + + support_interval_function = setInterval(function(){ + Sunstone.runAction('Support.list'); + }, Sunstone.TOP_INTERVAL); + } + + function _stopIntervalRefresh() { + clearInterval(support_interval_function); + } + + return { + 'showSupportConnect': _show_support_connect, + 'showSupportList': _show_support_list, + 'startIntervalRefresh': _startIntervalRefresh, + 'stopIntervalRefresh': _stopIntervalRefresh, + }; +}); \ No newline at end of file