123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- '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 ServiceabilityRenderingInfoImpl
- * @hideconstructor
- * @classdesc Render Service Implementation class
- */
- define(['../../../../api/impl/serviceability/nls/StringResources'], function (StringResources) {
- var ServiceabilityRenderingInfo = function () {
- function ServiceabilityRenderingInfo(logger) {
- _classCallCheck(this, ServiceabilityRenderingInfo);
- this._logger = logger;
- this._renderingInfo = undefined;
- }
- /**
- * @returns {RenderingInfo} the current rendering info object
- */
- ServiceabilityRenderingInfo.prototype.getCurrentRendering = function getCurrentRendering() {
- return this._renderingInfo;
- };
- /**
- * @param {RenderingInfo} renderingInfo the info of a rendersequence which is being executed
- */
- ServiceabilityRenderingInfo.prototype.setCurrentRendering = function setCurrentRendering(renderingInfo) {
- this._renderingInfo = renderingInfo;
- };
- /**
- * @returns {RenderingInfo} A RenderingInfo object represent the latest valid rendering info
- */
- ServiceabilityRenderingInfo.prototype.getLastRendering = function getLastRendering() {
- return this._lastRendering;
- };
- /**
- * @description set the latest valid rendering info object
- * @param {RenderingInfo} lastRendering An object of class RenderingInfo
- */
- ServiceabilityRenderingInfo.prototype.setLastRendering = function setLastRendering(lastRendering) {
- this._lastRendering = lastRendering;
- };
- ServiceabilityRenderingInfo.prototype.toJSON = function toJSON() {
- return {
- renderingInfo: {
- current: this._renderingInfo ? this._renderingInfo.toJSON() : {},
- last: this._lastRendering ? this._lastRendering.toJSON() : {}
- }
- };
- };
- /**
- * @description Returns a json which currently will be consumed by Serviceability feature
- * @returns a json represent the desired UI
- */
- ServiceabilityRenderingInfo.prototype.toUIJSON = function toUIJSON() {
- var request_durations = [],
- total_duration = void 0;
- if (this.getLastRendering() === undefined) {
- total_duration = this.getCurrentRendering().getDuration();
- var taskInfo = this.getCurrentRendering().getRenderSequenceWithData();
- if (taskInfo === undefined) {
- total_duration = total_duration + ' ' + StringResources.get('renderInProgress');
- } else {
- request_durations = taskInfo.getTaskInfo('data').getRequestDurations();
- total_duration = total_duration + ' ' + StringResources.get('renderInProgress');
- }
- } else {
- total_duration = this.getLastRendering().getDuration();
- var _taskInfo = this.getLastRendering().getRenderSequenceWithData();
- request_durations = _taskInfo.getTaskInfo('data').getRequestDurations();
- }
- var cellData = [[StringResources.get('liveWidgetTotalTime'), total_duration]];
- this._addRequestDurations(cellData, request_durations);
- return [{
- sectionName: StringResources.get('performanceSection'),
- sectionValues: [{
- fieldName: StringResources.get('durationField'),
- fieldValue: {
- cellValue: function cellValue(row, col) {
- return cellData[row][col];
- },
- columnLength: 2,
- rowLength: cellData.length
- },
- type: 'SimpleTable'
- }]
- }];
- };
- ServiceabilityRenderingInfo.prototype._addRequestDurations = function _addRequestDurations(cellData, requestDurations) {
- if (requestDurations.length === 0) {
- cellData.push([StringResources.get('singleQueryTime'), StringResources.get('infoNotAvailable')]);
- } else {
- requestDurations.forEach(function (duration, index) {
- var label = '';
- if (requestDurations.length === 1) {
- label = StringResources.get('singleQueryTime');
- } else {
- label = StringResources.get('multipleQueryTime', { name: index + 1 });
- }
- if (isNaN(duration)) {
- cellData.push([label, StringResources.get('infoNotAvailable')]);
- } else {
- cellData.push([label, duration]);
- }
- });
- }
- return cellData;
- };
- return ServiceabilityRenderingInfo;
- }();
- return ServiceabilityRenderingInfo;
- });
- //# sourceMappingURL=ServiceabilityRenderingInfo.js.map
|