OWL ITS + 탐지시스템(인터넷 진흥원)
jhjang
2021-10-14 b74776268dd3eb2bc57744928d6f7150ffcd4ec2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/**
 * Created by wisestone on 2018-11-02.
 */
'use strict';
 
define(['app', 'saveSvgAsPng'],
    function (app, saveSvgAsPng) {
        app.directive('issueCompleteWidget', ['$log', '$rootScope', '$resourceProvider', 'Widget', 'SweetAlert', 'Workspace', '$filter',
            function ($log, $rootScope, $resourceProvider, Widget, SweetAlert, Workspace, $filter) {
                return {
                    restrict : 'E',
                    scope : {
                        issueCompleteWidget : '=',
                    },
                    replace : true,
                    templateUrl : '../custom_components/widget/issue-complete-widget/issue-complete-widget.html',
                    controller : function ($scope, $element, $attrs) {
 
                        //  함수 모음
                        $scope.fn = {
                            findIssueCompleteWidget : findIssueCompleteWidget,  //  전체 이슈 처리 현황 조회
                            downloadImage : downloadImage,   //  이미지 다운로드
                        };
 
                        //  변수 모음
                        $scope.vm = {
                            options : {
                                chart : {
                                    type : 'discreteBarChart',
                                    height : 220,
                                    margin : {
                                        top : 20,
                                        right : 20,
                                        bottom : 20,
                                        left : 55
                                    },
                                    x : function (d) {
                                        return d.modifyDate;
                                    },
                                    y : function (d) {
                                        return d.issueCount;
                                    },
                                    yDomain : [0, 5],
                                    showValues : true,
                                    valueFormat : function (d) {
                                        return d;
                                    },
                                    duration : 100,
                                    xAxis : {
                                        axisLabel : ''
                                    },
                                    yAxis : {
                                        axisLabel : '',
                                        axisLabelDistance : 10,
                                        tickFormat : function (d) {
                                            return d3.format(',.0f')(d);
                                        }
                                    }
                                }
                            },
                            data : [
                                {
                                    key : "",
                                    values : []
                                }
                            ],
                            search : {
                                searchPeriod : "LAST_SEVEN_DAYS"
                            }
                        };
 
                        //  전체 이슈 처리 현황 정보가 변경될때 감지한다.
                        $scope.$watch("issueCompleteWidget", function (newValue) {
                            if ($rootScope.isDefined(newValue)) {
                                var maxCount = 5;
 
                                angular.forEach(newValue.issueCompleteCountList, function (value) {
                                    if (maxCount < value.issueCount) {
                                        maxCount = value.issueCount;
                                    }
                                });
 
                                $scope.vm.options = {
                                    chart : {
                                        type : 'discreteBarChart',
                                            height : 220,
                                            margin : {
                                            top : 20,
                                                right : 20,
                                                bottom : 20,
                                                left : 55
                                        },
                                        x : function (d) {
                                            return d.modifyDate;
                                        },
                                        y : function (d) {
                                            return d.issueCount;
                                        },
                                        yDomain : [0, maxCount],
                                            showValues : true,
                                            valueFormat : function (d) {
                                            return d;
                                        },
                                        duration : 100,
                                            xAxis : {
                                            axisLabel : ''
                                        },
                                        yAxis : {
                                            axisLabel : '',
                                                axisLabelDistance : 10,
                                                tickFormat : function (d) {
                                                return d3.format(',.0f')(d);
                                            }
                                        }
                                    }
                                };
 
                                $scope.vm.data[0].values = newValue.issueCompleteCountList;
 
                            }
                        });
 
                        //  전체 이슈 처리현황 목록 조회
                        function findIssueCompleteWidget() {
                            Widget.findIssueComplete($resourceProvider.getContent($scope.vm.search,
                                $resourceProvider.getPageContent(0, 0))).then(function (result) {
 
                                if (result.data.message.status === "success") {
                                    $scope.issueCompleteWidget = result.data.issueCompleteWidget;
                                }
                                else {
                                    SweetAlert.error($filter("translate")("dashboard.failedToTotalIssueHandling"), result.data.message.message); // 전체 이슈 처리현황 실패
                                }
                            });
                        }
 
                        //  이미지 다운로드
                        function downloadImage() {
                            if ((navigator.userAgent.indexOf('MSIE') > 0 || navigator.userAgent.indexOf('Trident') > 0)) {
                                SweetAlert.warning($filter("translate")("dashboard.notSupportedImageDownload"), $filter("translate")("dashboard.ieNotSupportedImageDownload")); // 이미지 다운로드 미지원, IE 에서는 이미지 다운로드를 지원하지 않습니다.
                                return;
                            }
                            //  업무 공간에서 해당 사용자가 활성 상태 인지 확인 후 이미지 다운로드를 실행한다.
                            Workspace.checkUseWorkspace($resourceProvider.getContent({},
                                $resourceProvider.getPageContent(0, 0))).then(function (result) {
 
                                if (result.data.message.status === "success") {
                                    saveSvgAsPng.saveSvgAsPng($($element).find("svg")[0], $filter("translate")("dashboard.overallIssueHandlingStatusPNG"), { canvg : null, backgroundColor: '#f1f1f1' }); // 전체 이슈 처리 현황.png
                                }
                                else {
                                    //  웹 소켓 연결이 안되어 있을 경우에는 직접 alert 를 표시한다.
                                    if ($rootScope.getObjectKeys($rootScope.users) < 1) {
                                        SweetAlert.error($filter("translate")("dashboard.excludeWorkspaceParticipation"), result.data.message.message); // 업무 공간 참여 제외
                                    }
                                }
                            });
                        }
                    }
                    ,
                    link : function (scope, element, attrs) {
 
                    }
                };
            }])
    });