OWL ITS + 탐지시스템(인터넷 진흥원)
src/main/webapp/scripts/app/issue/issueAdd.controller.js
@@ -33,11 +33,15 @@
                    getIssueTypeCustomFields : getIssueTypeCustomFields,    //  이슈 유형에 연결된 사용자 정의 필드 목록 가져오기
                    removeUploadFile : removeUploadFile,    //  업로드하려는 특정 파일을 삭제
                    removeManager : removeManager,  //  담당자 삭제
                    removeDepartment : removeDepartment,  //  담당부서 삭제
                    setIssueTypeTemplate : setIssueTypeTemplate,    //  이슈 유형 템플릿 적용하기
                    startExecute : startExecute //  컨트롤 로딩시 처음으로 시작되는 함수
                    startExecute : startExecute, //  컨트롤 로딩시 처음으로 시작되는 함수
                    containsPartner : containsPartner,
                    getPartners : getPartners
                };
                $scope.vm = {
                    partnerVos : "",
                    form : {
                        title : "",    //  제목
                        description : "",   //  내용
@@ -54,31 +58,33 @@
                        attachedFiles : [], //  섬머노트로 파일 업로드를 할 경우 서버에서 pk를 따고 issue id와 연동 작업이 필요하다.
                        startCompleteDateRange : "", //  시작일 ~ 종료일
                        detectingDateRange : "", //  탐지일
                        issueCustomFields : []  //  이슈에서 사용되는 사용자 정의 필드
                        issueCustomFields : [],  //  이슈에서 사용되는 사용자 정의 필드
                        requiredDatas : []  // 사용자 정의 필드 필수 데이터 체크
                    },
                    infiniteAdd : false,    //  연속 생성
                    projectName : "",   //  프로젝트 명 검색
                    userName : "",  //  사용자 검색
                    departmentName : "",  // 부서명 검색
                    companyId : -1, // 부서 ID
                    companyName : "",   // 업체명 검색
                    companyManager : "",   // 업체 담당자
                    companyTel : "",  // 업체 전화번호
                    companyEmail : "",  // 업체 이메일
                    companyMemo : "",  // 업체 비고
                    ispId : -1, // ISP ID
                    ispName : "", // ISP 명
                    ispCode : "", // ISP 코드
                    ispManager : "", // ISP 담당자
                    ispTel : "", // ISP 전화번호
                    ispEmail : "", // ISP 이메일
                    ispMemo : "", // ISP 비고
                    hostingId : -1, // 호스팅 ID
                    hostingName : "", // 호스팅명 검색
                    hostingManager : "", // 호스팅 담당자
                    hostingTel : "", // 호스팅 전화번호
                    hostingEmail : "", // 호스팅 이메일
                    hostingMemo : "", // 호스팅 비고
                    companyId : -1,
                    ispId : -1,
                    hostingId : -1,
                    hostingMemo :"", // 호스팅 비고
                    autoCompletePage : {
                        user : {
                            page : 0,
@@ -115,6 +121,18 @@
                    fileTableConfigs : [],   //  파일 업로드 정보 테이블
                };
                // 연관 일감 관련
                $scope.vm.relationIssueTypes =
                    [
                        { id: 0, name: $filter("translate")("issue.relationIssueType1") },
                        { id: 1, name: $filter("translate")("issue.relationIssueType2") },
                        { id: 2, name: $filter("translate")("issue.relationIssueType3") },
                        { id: 3, name: $filter("translate")("issue.relationIssueType4") },
                        { id: 4, name: $filter("translate")("issue.relationIssueType5") },
                        { id: 5, name: $filter("translate")("issue.relationIssueType6") }
                    ];
                $scope.vm.relationIssueType = $scope.vm.relationIssueTypes[0];
                angular.extend(this, $controller('autoCompleteController', {$scope : $scope, $injector : $injector}));
                function getStartProjectListCallback(result){
@@ -127,14 +145,20 @@
                //  프로젝트가 변경되면 담당자 초기화
                $scope.$watch("vm.form.projects", function (newValue, oldValue) {
                    if (angular.isDefined(newValue)) {
                        if (newValue.length < 1) {
                            $scope.vm.form.users = [];
                        } else {
                            //  이슈 유형에 연결된 사용자 정의 필드 가져오기
                            $scope.fn.getIssueTypeCustomFields();
                        }
                        //  이슈 유형에 연결된 사용자 정의 필드 가져오기
                        $scope.fn.getIssueTypeCustomFields();
                    }
                });
                $scope.$watch("vm.form.issueTypeId", function (newValue, oldValue) {
                    $scope.vm.partnerVos = $scope.fn.getPartners();
                });
                //  섬머노트 이미지 업로드
@@ -293,6 +317,11 @@
                    $scope.vm.form.departments.splice(index, 1);
                }
                // 담당부서 삭제
                function removeDepartment(index) {
                    $scope.vm.form.departments.splice(index, 1);
                }
                //  업로드 파일 삭제
                function removeUploadFile(index) {
                    $scope.vm.form.files.splice(index, 1);
@@ -300,6 +329,21 @@
                    angular.forEach($scope.vm.form.files, function (file, index) {
                        file.index = index;
                    });
                }
                // 업체/ISP/호스팅 이름이 포함 여부 확인
                function containsPartner(name) {
                    var result = false;
                    if ($scope.vm.partnerVos != null) {
                        $scope.vm.partnerVos.forEach(function (partnerVo) {
                            if (name === partnerVo.name) {
                                result = true;
                            }
                        });
                    }
                    return result;
                }
                //  담당자 autocomplete page 업데이트트
@@ -343,6 +387,7 @@
                // 업체정보 결과 값 Event 처리(set)
                $scope.$on("companyFieldEvent", function (event, result) {
                    $scope.vm.companyId = result[0].id;
                    $scope.vm.companyName = result[0].name;
                    $scope.vm.companyManager = result[0].manager;
                    $scope.vm.companyTel = result[0].tel;
                    $scope.vm.companyEmail = result[0].email;
@@ -353,6 +398,7 @@
                // ISP정보 결과 값 Event 처리(set)
                $scope.$on("ispFieldEvent", function (event, result) {
                    $scope.vm.ispId = result[0].id;
                    $scope.vm.ispName = result[0].name;
                    $scope.vm.ispCode = result[0].code;
                    $scope.vm.ispManager = result[0].manager;
                    $scope.vm.ispTel = result[0].tel;
@@ -363,6 +409,7 @@
                // 호스팅정보 결과 값 Event 처리(set)
                $scope.$on("hostingFieldEvent", function (event, result) {
                    $scope.vm.hostingId = result[0].id;
                    $scope.vm.hostingName = result[0].name;
                    $scope.vm.hostingCode = result[0].code;
                    $scope.vm.hostingManager = result[0].manager;
                    $scope.vm.hostingTel = result[0].tel;
@@ -377,6 +424,7 @@
                    var content = {
                        title : $rootScope.preventXss($scope.vm.form.title),    //  제목
                        description : $rootScope.preventXss($scope.vm.form.description),   //  내용
                        projectId : (function () {   //  프로젝트 아이디
                            var projectId = "";
@@ -386,9 +434,11 @@
                            return projectId;
                        })(),
                        issueTypeId : $scope.vm.form.issueTypeId,   //  이슈 유형 아이디
                        priorityId : $scope.vm.form.priorityId,    //  우선순위 아이디
                        severityId : $scope.vm.form.severityId,    //  중요도 아이디
                        companyId : (function () {   //  업체 아이디
                            var companyId = -1;
                            if ($scope.vm.form.issueCompanyFields.length > 0) {
@@ -444,9 +494,6 @@
                            return attachedFileIds;
                        })(),
                        startCompleteDateRange : $scope.vm.form.startCompleteDateRange,
                        detectingDateRange : $scope.vm.form.detectingDateRange,
                        issueCompanyFields : (function () {
                            var issueCompanyFields = [];
@@ -509,6 +556,33 @@
                            return issueHostingFields;
                        })(),
                        startCompleteDateRange : $scope.vm.form.startCompleteDateRange,
                        detectingDateRange : $scope.vm.form.detectingDateRange,
                        requiredDatas : (function () {    //  사용자 정의 필드 필수 데이터 체크
                            var requiredDatas = [];
                            angular.forEach($scope.vm.form.requiredDatas, function (issueCustomField) {
                                var useValues = [];
                                if (angular.isArray(issueCustomField.useValues)) {
                                    angular.forEach(issueCustomField.useValues, function (useValue) {
                                        useValues.push(useValue.value);
                                    });
                                }
                                else {
                                    useValues.push(issueCustomField.useValues);
                                }
                                //  useValues 를 배열로 변환한다.
                                var temp = angular.copy(issueCustomField);
                                temp.useValues = useValues;
                                issueCustomFields.push(temp);
                            });
                            return issueCustomFields;
                        })(),
                        issueCustomFields : (function () {    //  이슈에서 사용되는 사용자 정의 필드
                            var issueCustomFields = [];
@@ -543,27 +617,27 @@
                        },
                        fileFormDataName : "file"
                    }).then(function (result) {
                            if (result.data.message.status === "success") {
                                //  연속 등록 체크시 이동하지 않음.
                                if ($scope.vm.infiniteAdd) {
                                    $scope.fn.infiniteAddForm();
                                }
                                else {
                                    $scope.fn.cancel();
                                    if ($state.current.name !== "issues.list") {
                                        $state.go("issues.list");
                                    }
                                }
                                $rootScope.$broadcast("getIssueList", {});
                        if (result.data.message.status === "success") {
                            //  연속 등록 체크시 이동하지 않음.
                            if ($scope.vm.infiniteAdd) {
                                $scope.fn.infiniteAddForm();
                            }
                            else {
                                SweetAlert.error($filter("translate")("issue.failedIssueRegistration"), result.data.message.message); // 이슈 등록 실패
                                $scope.fn.cancel();
                                if ($state.current.name !== "issues.list" || $state.current.name === "issues.list") {
                                    $state.go("issues.list");
                                }
                            }
                            $rootScope.spinner = false;
                        });
                            $rootScope.$broadcast("getIssueList", {});
                        }
                        else {
                            SweetAlert.error($filter("translate")("issue.failedIssueRegistration"), result.data.message.message); // 이슈 등록 실패
                        }
                        $rootScope.spinner = false;
                    });
                }
                //  팝업 창 닫기
@@ -637,6 +711,7 @@
                //  이슈 유형에 연결된 사용자 정의 필드
                function getIssueTypeCustomFields() {
                    $scope.vm.form.issueCustomFields = [];
                    $scope.vm.form.requiredDatas = [];
                    //  이슈 타입 아이디나 프로젝트 아이디가 없으면 통신을 하지 않는다.
                    if (!$rootScope.isDefined($scope.vm.form.issueTypeId) || $scope.vm.form.projects.length < 1) {
                        return;
@@ -651,9 +726,17 @@
                        if (result.data.message.status === "success") {
                            $scope.vm.form.issueCustomFields = [];
                            $scope.vm.form.requiredDatas = [];
                            angular.forEach(result.data.data, function (issueTypeCustomField) {
                                switch (issueTypeCustomField.customFieldVo.customFieldType) {
                                    case "INPUT" :
                                    case "NUMBER" :
                                    case "DATETIME" :
                                    case "IP_ADDRESS" :
                                    case "EMAIL" :
                                    case "SITE" :
                                    case "TEL" :
                                        issueTypeCustomField.useValues = issueTypeCustomField.customFieldVo.defaultValue;
                                        break;
                                    case "SINGLE_SELECT" :
@@ -672,8 +755,10 @@
                                        });
                                        break;
                                }
                                $scope.vm.form.issueCustomFields.push(issueTypeCustomField);
                                if(issueTypeCustomField.customFieldVo.requiredData === "Y") {
                                    $scope.vm.form.requiredDatas.push(issueTypeCustomField.customFieldVo.requiredData);
                                }
                            });
                        }
                        else {
@@ -726,27 +811,48 @@
                    }
                }
                function getPartners() {
                    if($scope.vm.form.issueTypeId === ""){
                        $scope.vm.form.issueTypeId = $rootScope.issueTypeMenu.id
                    }
                    var content = {
                        issueTypeId : $scope.vm.form.issueTypeId,
                    };
                    Issue.findPartners($resourceProvider.getContent(
                        content,
                        $resourceProvider.getPageContent(0, 1))).then(function (result) {
                        if (result.data.message.status === "success") {
                            $scope.vm.partnerVos = result.data.data;
                        }
                    });
                }
                //  최초 실행
                function startExecute() {
                    var promises = {
                        getIssueTypes : $scope.fn.getIssueTypes(),
                        getPriorities : $scope.fn.getPriorities(),
                        getSeverities : $scope.fn.getSeverities()
                        getSeverities : $scope.fn.getSeverities(),
                        getPartners : $scope.fn.getPartners()
                    };
                    $q.all(promises).then(function (results) {
                        // 현재 프로젝트 설정
                        if ($rootScope.workProject != null && $rootScope.workProject.id > -1) {
                            $scope.vm.projectName = $rootScope.workProject.name;
                            $scope.fn.projects = [];
                            $scope.fn.projects.push($rootScope.workProject);
                            $scope.fn.getProjectList($scope.vm.projectName, $scope.vm.form.projects, $scope.vm.autoCompletePage.project.page, getStartProjectListCallback);
                            $scope.vm.form.projects = [];
                            $scope.vm.form.projects.push($rootScope.workProject);
                        }
                        // 현재 이슈타입 유형 설정
                        var id = $rootScope.getCurrentIssueTypeId();
                        if (id != null) {
                            $scope.vm.form.issueTypeId = id.toString();
                        }
                        $log.debug("promises 결과 ", results);
                    });
                }
                $scope.fn.startExecute();
            }]);
    });
    });