SessionLoggingController.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. /*
  3. * Licensed Materials - Property of IBM
  4. *
  5. * IBM Cognos Products: admin
  6. *
  7. * (C) Copyright IBM Corp. 2017
  8. *
  9. * US Government Users Restricted Rights - Use, duplication or disclosure
  10. * restricted by GSA ADP Schedule Contract with IBM Corp.
  11. */
  12. define(['underscore', 'bi/glass/app/plugins/MenuActionInterface', 'bi/admin/nls/StringResource'], function (_, MenuActionInterface, StringResource) {
  13. 'use strict';
  14. var SessionLoggingController = MenuActionInterface.extend({
  15. onSelectItem: function onSelectItem(context) {
  16. var id = context.target.itemId;
  17. var idTokens = id.split('.');
  18. var key = idTokens[idTokens.length - 1];
  19. if (key === "sessionLoggingButton") {
  20. var mySessionSlideOut;
  21. var options = context.target.plugin.itemSpec.items[context.target.specItemIndex].options;
  22. options.launchPoint = context.target.plugin.getButtonElement();
  23. options.label = StringResource.get('sessionLoggingTitle');
  24. options.onHide = function () {
  25. mySessionSlideOut.contentView.hide();
  26. }.bind(this);
  27. options.width = '400px';
  28. mySessionSlideOut = context.glassContext.appController.showSlideOut(options);
  29. }
  30. },
  31. onOpen: function onOpen(context) {
  32. var ajaxService = context.glassContext.services.ajax;
  33. var url = 'v1/configuration/keys/GlugService.enableSessionLogging';
  34. var promise = ajaxService.ajax({
  35. 'type': 'GET',
  36. 'url': url
  37. });
  38. return Promise.resolve().then(function () {
  39. return promise.then(function (data) {
  40. this.isVisible = _.values(data)[0];
  41. ;
  42. }.bind(this));
  43. }.bind(this));
  44. },
  45. isItemVisible: function isItemVisible(context) {
  46. if (!_.isUndefined(this.isVisible)) {
  47. if (this.isVisible === "true") {
  48. return true;
  49. } else {
  50. return false;
  51. }
  52. }
  53. }
  54. });
  55. return SessionLoggingController;
  56. });