<commit_before>/*********************************************************************************
 * Copyright 2019 Cognizant Technology Solutions
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.  You may obtain a copy
 * of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations under
 * the License.
 *******************************************************************************/

import { Component, OnInit, Inject, ViewChild } from '@angular/core';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA, MatPaginator, MatTableDataSource } from '@angular/material';
import { RestCallHandlerService } from '@insights/common/rest-call-handler.service';
import { HealthCheckService } from './healthcheck.service';
import { TitleCasePipe } from '@angular/common';


@Component({
  selector: 'healthcheck-show-details-dialog',
  templateUrl: './healthcheck-show-details-dialog.html',
  styleUrls: ['./healthcheck-show-details-dialog.css']
})
export class ShowDetailsDialog implements OnInit {
  showContent: boolean;
  showThrobber: boolean = false;
  checkResponseData: boolean;
  pathName: string;
  detailType: string;
  columnLength: number;
  resultsLength: number = 6;
  agentDetailedNode = [];
  agentDetailedDatasource = new MatTableDataSource([]);
  headerArrayDisplay = [];
  masterHeader = new Map<String, String>();
  finalHeaderToShow = new Map<String, String>();
  @ViewChild(MatPaginator) paginator: MatPaginator;
  headerSet = new Set();

  constructor(public dialogRef: MatDialogRef<ShowDetailsDialog>,
    @Inject(MAT_DIALOG_DATA) public data: any,
    private restCallHandlerService: RestCallHandlerService,
    private healthCheckService: HealthCheckService, private titlecase: TitleCasePipe) {
    this.fillMasterHeaderData();
  }

  ngOnInit() {
    this.loadDetailsDialogInfo();
    this.detailType = this.data.detailType;
  }

  ngAfterViewInit() {
    this.agentDetailedDatasource.paginator = this.paginator;
  }

  fillMasterHeaderData() {
    this.masterHeader.set("execId", "Execution ID");
    this.masterHeader.set("inSightsTimeX", "Execution Time ("+this.data.timeZone+")");
    this.masterHeader.set("status", "Status");
    this.masterHeader.set("message", "Message");
  }

  loadDetailsDialogInfo(): void {
    this.showThrobber = true;
    this.showContent = !this.showThrobber;
    this.checkResponseData = true;
    this.healthCheckService.loadHealthConfigurations(this.data.toolName, this.data.categoryName, this.data.agentId)
      .then((data) => {
        this.showThrobber = false;
        this.showContent = !this.showThrobber;
        var dataArray = data.data.nodes;
        if (dataArray != undefined) {
          this.pathName = this.data.pathName;
          if (dataArray.length === 0 && this.data.detailType != "Platform Service") {
            this.checkResponseData = false;
          }
          for (var key in dataArray) {
            var dataNodes = dataArray[key];
            for (var node in dataNodes) {
              if (node == "propertyMap") {
                var obj = dataNodes[node];

                if (typeof obj["status"] !== "undefined") {
                  obj["status"] = this.titlecase.transform(obj["status"]);
                }
                if (typeof obj["message"] !== "undefined") {
                  obj["message"] = obj["message"].slice(0, 100);<commit_msg>#166284383 "Helath-check Showdetails code change"<commit_after>/*********************************************************************************
 * Copyright 2019 Cognizant Technology Solutions
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.  You may obtain a copy
 * of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations under
 * the License.
 *******************************************************************************/

import { Component, OnInit, Inject, ViewChild } from '@angular/core';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA, MatPaginator, MatTableDataSource } from '@angular/material';
import { RestCallHandlerService } from '@insights/common/rest-call-handler.service';
import { HealthCheckService } from './healthcheck.service';
import { TitleCasePipe } from '@angular/common';
import { DatePipe } from '@angular/common';


@Component({
  selector: 'healthcheck-show-details-dialog',
  templateUrl: './healthcheck-show-details-dialog.html',
  styleUrls: ['./healthcheck-show-details-dialog.css']
})
export class ShowDetailsDialog implements OnInit {
  showContent: boolean;
  showThrobber: boolean = false;
  checkResponseData: boolean;
  pathName: string;
  detailType: string;
  columnLength: number;
  resultsLength: number = 6;
  agentDetailedNode = [];
  agentDetailedDatasource = new MatTableDataSource([]);
  headerArrayDisplay = [];
  date:any;
  masterHeader = new Map<String, String>();
  finalHeaderToShow = new Map<String, String>();
  @ViewChild(MatPaginator) paginator: MatPaginator;
  headerSet = new Set();

  constructor(public dialogRef: MatDialogRef<ShowDetailsDialog>,
    @Inject(MAT_DIALOG_DATA) public data: any,
    private restCallHandlerService: RestCallHandlerService,
    private healthCheckService: HealthCheckService, private titlecase: TitleCasePipe, public datePipe: DatePipe) {
    this.fillMasterHeaderData();
  }

  ngOnInit() {
    this.loadDetailsDialogInfo();
    this.detailType = this.data.detailType;
  }

  ngAfterViewInit() {
    this.agentDetailedDatasource.paginator = this.paginator;
  }

  fillMasterHeaderData() {
    this.masterHeader.set("execId", "Execution ID");
    this.masterHeader.set("inSightsTimeX", "Execution Time ("+this.data.timeZone+")");
    this.masterHeader.set("status", "Status");
    this.masterHeader.set("message", "Message");
  }

  loadDetailsDialogInfo(): void {
    this.showThrobber = true;
    this.showContent = !this.showThrobber;
    this.checkResponseData = true;
    this.healthCheckService.loadHealthConfigurations(this.data.toolName, this.data.categoryName, this.data.agentId)
      .then((data) => {
        this.showThrobber = false;
        this.showContent = !this.showThrobber;
        var dataArray = data.data.nodes;
        if (dataArray != undefined) {
          this.pathName = this.data.pathName;
          if (dataArray.length === 0 && this.data.detailType != "Platform Service") {
            this.checkResponseData = false;
          }
          for (var key in dataArray) {
            var dataNodes = dataArray[key];
            for (var node in dataNodes) {
              if (node == "propertyMap") {
                var obj = dataNodes[node];
                this.date = new Date();
                if (typeof obj["inSightsTimeX"] !== "undefined") {
                  obj["inSightsTimeX"] = this.datePipe.transform(this.date, 'yyyy-MM-dd HH:mm:ss');
                }
                if (typeof obj["status"] !== "undefined") {
                  obj["status"] = this.titlecase.transform(obj["status"]);
                }
                if (typeof obj["message"] !== "undefined") {
                  obj["message"] = obj["message"].slice(0, 100);
{'fraction_non_alphanumeric': 0.15497636386865976, 'fraction_numerical': 0.004727226268046505, 'mean_word_length': 3.6429418742586, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7397396', 'n_tokens_mistral': 2186, 'n_tokens_neox': 2118, 'n_words': 538}