123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Licensed Materials - Property of IBM
- * IBM Business Analytics (C) Copyright IBM Corp. 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- /**
- * @class ContentServiceabilityImpl
- * @hideconstructor
- * @classdesc Widget Service Implementation class
- */
- define(['../../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../../../api/DashboardAPI', '../ContentInfoAPI', './ContentInfoImpl', '../../../../features/dashboard/dashboardServiceability/view/ServiceabilityContent', 'react', 'react-dom'], function (APIFactory, DashboardAPI, ContentInfoApi, ContentInfoImpl, ServiceabilityContent, React, ReactDOM) {
- var ContentServiceabilityImpl = function () {
- function ContentServiceabilityImpl(options) {
- _classCallCheck(this, ContentServiceabilityImpl);
- this.getDashboardAPI = function () {
- return options.dashboardAPI;
- };
- this.getContentAPI = function () {
- return options.content;
- };
- var logger = options.dashboardAPI.getService(DashboardAPI.GLOBAL_SERVICES.LOGGER);
- this.getLogger = function () {
- return logger;
- };
- this._contentInfo = APIFactory.createAPI(new ContentInfoImpl(this.getContentAPI(), this.getLogger()), [ContentInfoApi]);
- this._contentInfo.setData('generalInfo', {});
- this._isInfoVisible = false;
- }
- ContentServiceabilityImpl.prototype.getContentInfo = function getContentInfo() {
- return this._contentInfo;
- };
- ContentServiceabilityImpl.prototype.isInfoVisible = function isInfoVisible() {
- return this._isInfoVisible;
- };
- /**
- * @description Currently we only fetch and process the info of Performance section.
- * But it should be more generic.
- * @todo `showInfo` will have an argument to indicate what sections we're going to display so
- * that we don't have to hardcode 'Performance'. Then, we fetch the sections and process them.
- */
- ContentServiceabilityImpl.prototype._fetchUIJSON = function _fetchUIJSON() {
- var UIJson = this._contentInfo.toUIJSON().filter(function (section) {
- return section.sectionName === 'Performance';
- });
- UIJson.forEach(function (section) {
- section.sectionName = '';
- section.sectionValues.forEach(function (field) {
- field.fieldName = '';
- });
- });
- return UIJson;
- };
- ContentServiceabilityImpl.prototype.showInfo = function showInfo() {
- this._isInfoVisible = true;
- var contentViewDOM = this.getContentAPI().getFeature('ContentViewDOM');
- if (contentViewDOM) {
- var overlayID = 's12yOverlay_' + this.getContentAPI().getId();
- var contentNode = contentViewDOM.getNode();
- var overlayNode = contentNode.querySelector('#' + overlayID);
- if (!overlayNode) {
- overlayNode = document.createElement('div');
- overlayNode.id = overlayID;
- overlayNode.className = 's12yOverlay';
- contentNode.appendChild(overlayNode);
- var UIJson = this._fetchUIJSON();
- var infoNode = React.createElement(
- React.Fragment,
- null,
- React.createElement('div', { className: 's12yOverlayBackground' }),
- React.createElement(ServiceabilityContent, {
- widgetInfo: this._contentInfo,
- dashboardApi: this.getDashboardAPI(),
- UISpec: UIJson,
- showButtons: false
- })
- );
- ReactDOM.render(infoNode, overlayNode);
- }
- } else {
- this.getLogger().warn('cannot find ContentViewDOM feature');
- }
- };
- ContentServiceabilityImpl.prototype.hideInfo = function hideInfo() {
- this._isInfoVisible = false;
- var contentViewDOM = this.getContentAPI().getFeature('ContentViewDOM');
- if (contentViewDOM) {
- var overlayID = 's12yOverlay_' + this.getContentAPI().getId();
- var contentNode = contentViewDOM.getNode();
- var overlayNode = contentNode.querySelector('#' + overlayID);
- if (overlayNode) {
- ReactDOM.unmountComponentAtNode(overlayNode);
- contentNode.removeChild(overlayNode);
- }
- } else {
- this.getLogger().warn('cannot find ContentViewDOM feature');
- }
- };
- return ContentServiceabilityImpl;
- }();
- return ContentServiceabilityImpl;
- });
- //# sourceMappingURL=ContentServiceabilityImpl.js.map
|