OWL ITS + 탐지시스템(인터넷 진흥원)
minhee
2022-03-16 8fab2c64de2185fb905a9f63ff92c205cc8c75ca
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/**
 * Created by wisestone on 2019-02-07.
 */
'use strict';
 
define([
        'app',
        'angular'
    ],
    function (app, angular) {
        app.controller('issueAddTableConfigController', ['$scope', '$rootScope', '$log', '$resourceProvider', '$uibModalInstance', 'SweetAlert', '$timeout', 'IssueTableConfig', 'Issue', 'IssueTypeCustomField', '$q', '$filter', 'parameter',
            function ($scope, $rootScope, $log, $resourceProvider, $uibModalInstance, SweetAlert, $timeout, IssueTableConfig, Issue, IssueTypeCustomField, $q, $filter, parameter) {
 
                //  함수 모음
                $scope.fn = {
                    cancel : cancel,    //  팝업 창 닫기
                    formSubmit : formSubmit,    //  폼 전송
                    formCheck : formCheck,  //  폼 체크
                    getUsePartner : getUsePartner,
                    getCustomFields : getCustomFields,   //  사용자 정의 필드 목록을 가져온다.
                    getIssueAddTableConfigs : getIssueAddTableConfigs //  이슈 목록 테이블 설정 정보를 가져온다.
                };
 
                //  변수 모음
                $scope.vm = {
                    allIssue : parameter.allIssue,
                    issueTableConfigs : [{
                        name : $filter("translate")("issue.issueTitle"), // 이슈 제목
                        key : "ISSUE_TITLE",
                        width : "width-140-p",
                        position : 0,
                        display : true,
                        checkboxShow : false
                    }, {
                        name : $filter("translate")("common.priority"), // 우선순위
                        key : "PRIORITY",
                        width : "width-80-p",
                        position : 1,
                        display : true,
                        checkboxShow : true
                    }, {
                        name : $filter("translate")("common.importance"), // 중요도
                        key : "SEVERITY",
                        width : "width-80-p",
                        position : 2,
                        display : true,
                        checkboxShow : true
                    }, {
                        name : $filter("translate")("issue.issueType"), // 이슈 타입
                        key : "ISSUE_TYPE",
                        width : "width-140-p",
                        position : 3,
                        display : true,
                        checkboxShow : true
                    }, {
                        name : $filter("translate")("common.assigneeTeam"), // 담당부서
                        key : "ASSIGNEE_TEAM",
                        width : "width-100-p",
                        position : 4,
                        display : true,
                        checkboxShow : true
                    }, {
                        name : $filter("translate")("common.countDownIssue"), // 하위이슈 카운트
                        key : "COUNT_DOWN_ISSUE",
                        width : "width-100-p",
                        position : 5,
                        display : false,
                        checkboxShow : true
                    }, {
                        name : $filter("translate")("common.register"), // 등록자
                        key : "REGISTER",
                        width : "width-100-p",
                        position : 6,
                        display : false,
                        checkboxShow : true
                    }, {
                        name : $filter("translate")("common.period"), // 기간
                        key : "PERIOD",
                        width : "width-140-p",
                        position : 7,
                        display : false,
                        checkboxShow : true
                    }, {
                        name : $filter("translate")("common.lastChangeDate"), // 최근 변경일
                        key : "MODIFY_DATE",
                        width : "width-100-p",
                        position : 8,
                        display : false,
                        checkboxShow : true
                    }, {
                        name : $filter("translate")("common.registerDate"), // 등록일
                        key : "REGISTER_DATE",
                        width : "width-80-p",
                        position : 9,
                        display : false,
                        checkboxShow : true
                    }]
                };
 
 
                //  폼 전송
                function formCheck(formInvalid) {
                    if (formInvalid) {
                        return true;
                    }
 
                    return false;
                }
 
                //  폼 전송
                function formSubmit() {
                    $rootScope.spinner = true;
 
                    var content = {
                        issueTypeId : (function () {
                            var id = "";
                            if ($rootScope.allIssueList) {
                                id = -1;
                            } else {
                                id = $rootScope.getCurrentIssueTypeId();
                            }
                            return id;
                        })(),
                        issueTableConfigs : JSON.stringify($scope.vm.issueTableConfigs)
                    };
 
                    IssueTableConfig.add($resourceProvider.getContent(content,
                        $resourceProvider.getPageContent(0, 0))).then(function (result) {
 
                        if (result.data.message.status === "success") {
                            SweetAlert.success($filter("translate")("issue.completedSavingIssueTable"), $filter("translate")("issue.saveIssueTableSettingsInformation")); // "이슈 테이블 설정 저장 완료", "이슈 테이블 설정 정보가 저장되었습니다."
 
                            //swal.close();
                            $scope.fn.cancel();
                            //  변경된 이슈 테이블 정보를 이슈 목록 테이블에 갱신한다.
                            $rootScope.$broadcast("getIssueTableConfigs", {});
                        }
                        else {
                            SweetAlert.error($filter("translate")("issue.failedToSaveIssueTableSetting"), result.data.message.message); // 이슈 테이블 설정 저장 실패
                        }
                        $rootScope.spinner = false;
                    });
                }
 
 
                //  팝업 창 닫기
                function cancel() {
                    $rootScope.$broadcast("closeLayer");    //  팝업이 열리고 나서 js-multi, js-single 등에서 body 이벤트가 날아가는 현상 수정
                    $uibModalInstance.dismiss('cancel');
                    $(document).unbind("keydown");  //  단축키 이벤트 제거
                }
 
                //  이슈유형 별 파트너 목록
                function getUsePartner() {
                    var deferred = $q.defer();
                    $scope.vm.partners = [];
 
                    Issue.findPartners($resourceProvider.getContent({issueTypeId : $rootScope.getCurrentIssueTypeId()},
                        $resourceProvider.getPageContent(0, 1))).then(function (result) {
                        if (result.data.message.status === "success") {
                            $scope.vm.partnerVos = result.data.data;
                        }
                        else {
                            SweetAlert.swal($filter("translate")("issue.failedToPartnerListLookup"), result.data.message.message, "error"); // 파트너 목록 조회 실패
                        }
                        deferred.resolve(result.data.data);
                    });
                    return deferred.promise;
                }
 
                //  사용자 정의 필드 목록을 가져온다.
                function getCustomFields() {
                    var deferred = $q.defer();
 
                    IssueTypeCustomField.findByIssueType($resourceProvider.getContent({issueTypeId : $rootScope.getCurrentIssueTypeId()},
                        $resourceProvider.getPageContent(0, 1000))).then(function (result) {
                        if (result.data.message.status !== "success") {
                            SweetAlert.error($filter("translate")("issue.failedToUserDefinedFieldListLookup"), result.data.message.message); // 사용자 정의 필드 목록 조회 실패
                        }
 
                        deferred.resolve(result.data.data);
                    });
 
                    return deferred.promise;
                }
 
                var content = {
                    //delValue : $scope.vm.issueTableConfigs.splice(12,1),
                    issueTableConfigs : JSON.stringify($scope.vm.issueTableConfigs),
                    issueTypeId : (function () {
                        var id = "";
                        if ($rootScope.allIssueList) {
                            id = -1;
                        } else {
                            id = $rootScope.getCurrentIssueTypeId();
                        }
                        return id;
                    })()
                };
                //  이슈 목록 테이블 설정 정보를 가져온다.
                function getIssueAddTableConfigs() {
                    var deferred = $q.defer();
 
                    IssueTableConfig.detail($resourceProvider.getContent(content,
                        $resourceProvider.getPageContent(0, 1000))).then(function (result) {
                        if (result.data.message.status !== "success") {
                            SweetAlert.error($filter("translate")("issue.failedToIssueTableColumnLookup"), result.data.message.message); // 이슈 테이블 컬럼 조회 실패
                        }
 
                        // for (var i = 0; i < result.data.name; i++) {
                        //     if (result.data.name === '') {
                        //         result.splice(i,1);
                        //         i--;
                        //     }
                        // }
 
                        deferred.resolve(result.data.data);
                    });
 
                    return deferred.promise;
                }
 
                //  파트너를 조회한 후 표시할 이슈 테이블 컬럼을 준비한다.
                $scope.fn.getUsePartner().then(function (result) {
                    let count = 10;
                    angular.forEach(result, function (partner) {
                        $scope.vm.issueTableConfigs.push({
                            name : partner.name,
                            key : (function () {
                                var key = "";
                                if (partner.name === "업체") {
                                    key = "COMPANY";
                                } else if(partner.name === "ISP") {
                                    key = "ISP";
                                } else {
                                    key = "HOSTING";
                                }
                                return key;
                            })(),
                            width : "width-100-p",
                            display : false,
                            checkboxShow : true,
                            position : count
                        });
                        count ++;
                    });
                    //  사용자 정의 필드를 조회한 후 표시할 이슈 테이블 컬럼을 준비한다.
                    $scope.fn.getCustomFields().then(function (result) {
                        angular.forEach(result, function (customField) {
                            $scope.vm.issueTableConfigs.push({
                                name : customField.name,
                                key : "CUSTOM_FIELD_" + customField.id,
                                width : "width-100-p",
                                display : false,
                                checkboxShow : true,
                                position : count
                            });
                            count++;
                        });
 
                        //  이슈 목록 테이블 설정 정보를 가져온다.
                        $scope.fn.getIssueAddTableConfigs().then(function (issueTableConfigs) {
                            if ($rootScope.isDefined(issueTableConfigs)) {
                                $rootScope.spinner = true;
 
                                var saveTableConfigs = JSON.parse(issueTableConfigs);
 
                                angular.forEach(saveTableConfigs, function (saveTableConfig) {
 
                                    for (var count in $scope.vm.issueTableConfigs) {
                                        var issueTableConfig = $scope.vm.issueTableConfigs[count];
 
                                        if (issueTableConfig.key === saveTableConfig.key) {
                                            issueTableConfig.display = saveTableConfig.display;
                                            issueTableConfig.width = saveTableConfig.width;
                                            issueTableConfig.position = parseInt(saveTableConfig.position);
                                            break;
                                        }
                                    }
                                });
 
                                $rootScope.spinner = false;
                            }
                        });
                    })
                });
 
            }]);
    });