<commit_before>﻿///<reference path="../references.ts" />

module SupportCenter {
    "use strict";

    export interface IDetectorViewScope extends ng.IScope {
        loading: string;
        chartoptions: any;
        chartdata: any;
        info: any;
        responsemetadata: any;
        wiki: string;
        solution: string;
        additionaldata: any;
        metricsets: DiagnosticMetricSet[];
        selectedworker: string;
        detectorsource: string;
        abnormaltimeperiod: AbnormalTimePeriod;
    }

    export class DetectorViewCtrl {
        public static $inject: string[] = ["DetectorsService", "$stateParams", "$window", "FeedbackService", "$mdToast", "$timeout"];
        public showDetailedView: boolean = true;
        public detectorFeedbackOption: number = -1;
        private nameElement: any;
        private detectorName: string;
        public api: any;
        public isLoading: boolean;

        constructor(private DetectorsService: IDetectorsService, private $stateParams: IStateParams, private $window: angular.IWindowService, private FeedbackService: IFeedbackService, private $mdToast: angular.material.IToastService, private $timeout: ng.ITimeoutService) {
            this.isLoading = true;
            this.nameElement = document.getElementById('name');
            let self = this;
            this.$timeout(function () {
                self.detectorName = self.nameElement.innerText;

                if (angular.isDefined(FeedbackService.detectorsFeedbackList[self.detectorName])) {
                    self.detectorFeedbackOption = FeedbackService.detectorsFeedbackList[self.detectorName];
                }
            }, 3000);

            // This is a hack because the chart was loading incorrectly because of some problem with material I believe. 
            // TODO: revisit this experience. 
            this.$timeout(function () {
                self.isLoading = false;
            }, 1);

            
        }

        isDetailedGraphEnabled(detectorName: string) {
            for (var i = 0; i < DetectorViewHelper.DetailedGraphEnabledDetectors.length; i++) {
                if (detectorName.indexOf(DetectorViewHelper.DetailedGraphEnabledDetectors[i].name)) {
                    return true;
                }
            }
            return false;
        }

        sendDetectorFeedback(detectorName: string, feedbackOption: number) {

            if (this.detectorFeedbackOption === -1) {
                this.detectorFeedbackOption = feedbackOption;
                let self = this;
                this.FeedbackService.sendDetectorFeedback(detectorName, feedbackOption).then(function (answer) {
                    if (angular.isDefined(answer) && answer === true) {
                        self.$mdToast.showSimple("Feedback submitted successfully.Thank you !!");
                        self.FeedbackService.detectorsFeedbackList[detectorName] = feedbackOption;
                    }<commit_msg>Fixing bug where detail graph showing everywhere<commit_after>﻿///<reference path="../references.ts" />

module SupportCenter {
    "use strict";

    export interface IDetectorViewScope extends ng.IScope {
        loading: string;
        chartoptions: any;
        chartdata: any;
        info: any;
        responsemetadata: any;
        wiki: string;
        solution: string;
        additionaldata: any;
        metricsets: DiagnosticMetricSet[];
        selectedworker: string;
        detectorsource: string;
        abnormaltimeperiod: AbnormalTimePeriod;
    }

    export class DetectorViewCtrl {
        public static $inject: string[] = ["DetectorsService", "$stateParams", "$window", "FeedbackService", "$mdToast", "$timeout"];
        public showDetailedView: boolean = true;
        public detectorFeedbackOption: number = -1;
        private nameElement: any;
        private detectorName: string;
        public api: any;
        public isLoading: boolean;

        constructor(private DetectorsService: IDetectorsService, private $stateParams: IStateParams, private $window: angular.IWindowService, private FeedbackService: IFeedbackService, private $mdToast: angular.material.IToastService, private $timeout: ng.ITimeoutService) {
            this.isLoading = true;
            this.nameElement = document.getElementById('name');
            let self = this;
            this.$timeout(function () {
                self.detectorName = self.nameElement.innerText;

                if (angular.isDefined(FeedbackService.detectorsFeedbackList[self.detectorName])) {
                    self.detectorFeedbackOption = FeedbackService.detectorsFeedbackList[self.detectorName];
                }
            }, 3000);

            // This is a hack because the chart was loading incorrectly because of some problem with material I believe. 
            // TODO: revisit this experience. 
            this.$timeout(function () {
                self.isLoading = false;
            }, 1);

            
        }

        isDetailedGraphEnabled(detectorName: string) {
            for (var i = 0; i < DetectorViewHelper.DetailedGraphEnabledDetectors.length; i++) {
                if (detectorName.indexOf(DetectorViewHelper.DetailedGraphEnabledDetectors[i].name) >= 0) {
                    return true;
                }
            }
            return false;
        }

        sendDetectorFeedback(detectorName: string, feedbackOption: number) {

            if (this.detectorFeedbackOption === -1) {
                this.detectorFeedbackOption = feedbackOption;
                let self = this;
                this.FeedbackService.sendDetectorFeedback(detectorName, feedbackOption).then(function (answer) {
                    if (angular.isDefined(answer) && answer === true) {
                        self.$mdToast.showSimple("Feedback submitted successfully.Thank you !!");
                        self.FeedbackService.detectorsFeedbackList[detectorName] = feedbackOption;
                    }
{'fraction_non_alphanumeric': 0.09115191986644407, 'fraction_numerical': 0.0028380634390651085, 'mean_word_length': 2.2227003765465305, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5442987', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1449, 'n_words': 341}