OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2022-01-07 ad7e60c5d5a090160c6b9be63c02a75a6c369b91
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
/**
 * Created by jeong on 2018-01-28.
 */
'use strict';
 
define([
        'app'
    ],
    function (app) {
        app.controller('userDetailController', ['$scope', '$rootScope', '$log', '$resourceProvider', '$tableProvider', 'IssueHistory', '$uibModal', 'SweetAlert', '$filter', 'User',
            function ($scope, $rootScope, $log, $resourceProvider, $tableProvider, IssueHistory, $uibModal, SweetAlert, $filter, User) {
 
                //  함수
                $scope.fn = {
                    getMyInfo : getMyInfo,   //나의 정보 조회(등급, 담당부서)
                    getIssueHistoryList : getIssueHistoryList,    //  이슈 기록 정보 조회
                    modify : modify, //  사용자 수정
                    changeSearchPeriod : changeSearchPeriod,    //  이력 조회 검색 조건 변경
                    modifyPassword : modifyPassword //  비밀번호 변경
                };
 
                $scope.vm = {
                    viewer : {},
                    search : {
                        searchPeriod : "LAST_SEVEN_DAYS",
                        startEndDateRange : "" //  이슈 기록 조회 날짜
                    },
                    issueHistoryVos : [],   //  이슈 기록 정보
                    issueHistoryDates : [], //  이슈 기록 정보 날짜
                    myLevel : "",
                    myDepartments : [],
                    phone : ""
                };
 
                //  직접 입력에서 날짜 선택시 이슈 기록 정보 조회
                $scope.$watch("vm.search.startEndDateRange", function (newValue) {
                    if ($rootScope.isDefined(newValue)) {
                        $scope.fn.getIssueHistoryList();
                    }
                });
 
                //  사용자 수정
                function modify(id) {
                    $uibModal.open({
                        templateUrl : 'views/user/userModify.html',
                        size : "md",
                        controller : "userModifyController",
                        backdrop : 'static',
                        resolve : {
                            parameter : function () {
                                return {
                                    id : id
                                };
                            }
                        }
                    });
                }
 
                //  사용자 비밀번호 변경
                function modifyPassword(id) {
                    $uibModal.open({
                        templateUrl : 'views/user/userModifyPassword.html',
                        size : "md",
                        controller : "userModifyPasswordController",
                        backdrop : 'static',
                        resolve : {
                            parameter : function () {
                                return {
                                    id : id
                                };
                            }
                        }
                    });
                }
 
                //  나의 정보 조회(등급, 담당부서)
                function getMyInfo() {
 
                    User.findMyLevelAndDepartment($resourceProvider.getContent(
                        $resourceProvider.getPageContent(0, 0))).then(function (result) {
 
                        if (result.data.message.status === "success") {
                            $scope.vm.myLevel = result.data.data.levelName;
                            $scope.vm.myDepartments = result.data.data.departmentName;
                            // 전화번호 하이픈 추가하여 조회
                            $scope.vm.phone = $rootScope.user.phone;
                            let hyphen = $scope.vm.phone.trim();
                            let phone = hyphen.replace(/(^02.{0}|^01.{1}|[0-9]{3})([0-9]+)([0-9]{4})/,"$1-$2-$3");
                            $rootScope.user.phone = phone;
                        }
                        else {
                            SweetAlert.swal($filter("translate")("users.failedToRetrieveIssueHistory"), result.data.message.message, "error"); // "이슈 기록 정보 조회 실패"
                        }
                    });
                }
 
                //  이슈 기록 정보 조회
                function getIssueHistoryList() {
                    var content = {
                        searchPeriod : $scope.vm.search.searchPeriod,
                        searchStartDate : "",
                        searchEndDate : ""
                    };
 
                    if ($rootScope.isDefined($scope.vm.search.startEndDateRange)) {
                        var startEndDateRange = $scope.vm.search.startEndDateRange.split("~");
                        content.searchStartDate = startEndDateRange[0].trim();
                        content.searchEndDate = startEndDateRange[1].trim();
                    }
 
                    IssueHistory.find($resourceProvider.getContent(content,
                        $resourceProvider.getPageContent(0, 0))).then(function (result) {
 
                        if (result.data.message.status === "success") {
                            $scope.vm.issueHistoryDates = Object.keys(result.data.data.issueHistoryGroups);    //  기록 날짜 수집
 
                            $scope.vm.issueHistoryDates.sort(function (a, b) {
                                var c = new Date(a);
                                var d = new Date(b);
                                return d - c;
                            });
 
                            $scope.vm.issueHistoryVos = result.data.data.issueHistoryGroups;   //  이슈 기록 정보
                        }
                        else {
                            SweetAlert.swal($filter("translate")("users.failedToRetrieveIssueHistory"), result.data.message.message, "error"); // "이슈 기록 정보 조회 실패"
                        }
                    });
                }
 
                //  이력 조회 검색 조건 변경
                function changeSearchPeriod() {
                    switch ($scope.vm.search.searchPeriod) {
                        case "CUSTOM_INPUT" :
                            $scope.vm.search.startEndDateRange = "";
                            break;
                        default :
                            $scope.vm.search.startEndDateRange = "";
                            $scope.fn.getIssueHistoryList();
                    }
                }
 
 
                //  이슈 기록 정보 조회
                $scope.fn.getIssueHistoryList();
                $scope.fn.getMyInfo();
            }
        ]);
    }
);