| | |
| | | 'app', 'angular' |
| | | ], |
| | | function (app, angular) { |
| | | app.controller('apiSettingController', ['$scope', '$rootScope', '$log', '$resourceProvider','$uibModal', 'SweetAlert', '$timeout', '$filter', '$injector', '$controller', 'Api', 'Priority', 'Severity', 'IssueType', |
| | | function ($scope, $rootScope, $log, $resourceProvider, $uibModal, SweetAlert, $timeout, $filter, $injector, $controller, Api, Priority, Severity, IssueType) { |
| | | app.controller('apiSettingController', ['$scope', '$rootScope', '$log', '$resourceProvider','$uibModal', 'SweetAlert', |
| | | '$timeout', '$filter', '$injector', '$controller', 'Api', 'Priority', 'Severity', 'IssueType', 'IssueTypeCustomField', |
| | | 'IssueStatus', '$q', |
| | | function ($scope, $rootScope, $log, $resourceProvider, $uibModal, SweetAlert, |
| | | $timeout, $filter, $injector, $controller, Api, Priority, Severity, IssueType, IssueTypeCustomField, |
| | | IssueStatus, $q) { |
| | | |
| | | $scope.fn = { |
| | | changeTab : changeTab, |
| | | getIssueTypeCallback : getIssueTypeCallback, |
| | | getProjectListCallback : getProjectListCallback, |
| | | formSubmit : formSubmit, |
| | | formSubmitColumnSetting : formSubmitColumnSetting, |
| | | formCheck : formCheck, |
| | | initForm : initForm, |
| | | getPriorities : getPriorities, |
| | | getSeverities : getSeverities, |
| | | start : start, |
| | | onChangeColumnSetting : onChangeColumnSetting, |
| | | onChangeEndIssueStatus : onChangeEndIssueStatus, |
| | | getIssueTypes : getIssueTypes, |
| | | onChangeIssueType : onChangeIssueType, |
| | | reset : reset, |
| | | resetOverlap : resetOverlap, |
| | | formSubmitOverlap : formSubmitOverlap, |
| | | removeCustomField : removeCustomField, |
| | | getOverlapList : getOverlapList, |
| | | onChangeIssueTypeOverlap : onChangeIssueTypeOverlap |
| | | onChangeIssueTypeOverlap : onChangeIssueTypeOverlap, |
| | | getIssueTypeCustomFields : getIssueTypeCustomFields, |
| | | getCurrentIssueTypeVo : getCurrentIssueTypeVo, |
| | | getIssueStatuses : getIssueStatuses, |
| | | onChangeIssueTypeSpec : onChangeIssueTypeSpec, |
| | | createRequestModifyJson : createRequestModifyJson, |
| | | createRequestAddJson : createRequestAddJson, |
| | | createCustomFields : createCustomFields, |
| | | getProjects : getProjects, |
| | | formSubmitCompleteIssueStatus : formSubmitCompleteIssueStatus, |
| | | loadPage : loadPage, |
| | | resetCompleteIssueStatus : resetCompleteIssueStatus, |
| | | findIssueList : findIssueList, |
| | | onChangeProject : onChangeProject, |
| | | setApiIssueTypeStatus : setApiIssueTypeStatus |
| | | }; |
| | | |
| | | $scope.vm = { |
| | | tab : "API_COL_SETTING", |
| | | tab : "", |
| | | issueTypes : [], |
| | | issueStatuses : [], |
| | | completeIssueStatuses : [], |
| | | severities : [], |
| | | priorities : [], |
| | | projects : [], |
| | | sampleJsonAdd : "", |
| | | sampleJsonModify : "", |
| | | // projects : [], |
| | | form : { |
| | | issueCustomFields : [], |
| | | issueApiDefault : { |
| | | title : "", |
| | | description : "", |
| | |
| | | // totalPage : 0 |
| | | // } |
| | | }, |
| | | completeIssueStatusId : "", |
| | | issueTypeId : "", |
| | | issueTypeName : "", |
| | | |
| | | issueStatusId : "", |
| | | issueStatusName : "", |
| | | |
| | | customFieldName : "", |
| | | issueTypeData : null // 이슈 유형 객체 |
| | | |
| | | projectId : "", |
| | | projectName : "", |
| | | }; |
| | | |
| | | angular.extend(this, $controller('autoCompleteController', {$scope : $scope, $injector : $injector})); |
| | |
| | | |
| | | function reset() { |
| | | $scope.fn.initForm(); |
| | | $scope.fn.formSubmit(); |
| | | $scope.fn.formSubmitColumnSetting(); |
| | | } |
| | | |
| | | // 자동종료 설정 초기화 |
| | | function resetCompleteIssueStatus() { |
| | | $scope.vm.completeIssueStatusId = ""; |
| | | } |
| | | |
| | | // 하위 이슈 처리 기준 항목 초기화(중복처리할 항목) |
| | | function resetOverlap() { |
| | | $scope.vm.form.customFieldIds = []; |
| | | $scope.fn.form.formSubmitOverlap(); |
| | |
| | | Api.findApiOverlap($resourceProvider.getContent( |
| | | conditions, $resourceProvider.getPageContent(0, 1000))).then(function (result) { |
| | | if (result.data.message.status === "success") { |
| | | |
| | | let customFieldApiOverlaps = result.data.data; |
| | | $scope.vm.form.customFields = []; |
| | | let customFieldApiOverlaps = result.data.data; |
| | | |
| | | customFieldApiOverlaps.forEach(function (customFieldApiOverlap) { |
| | | $scope.vm.form.customFields.push(customFieldApiOverlap.customFieldVo); |
| | | }); |
| | | if (customFieldApiOverlaps != null && customFieldApiOverlaps.length > 0) { |
| | | customFieldApiOverlaps.forEach(function (customFieldApiOverlap) { |
| | | $scope.vm.form.customFields.push(customFieldApiOverlap.customFieldVo); |
| | | }); |
| | | } |
| | | } |
| | | else { |
| | | SweetAlert.swal($filter("translate")("issue.failedToIssueTypeListLookup"), result.data.message.message, "error"); // "이슈 유형 목록 조회 실패" |
| | | } |
| | | }); |
| | | } |
| | | |
| | | $scope.$watch("vm.issueTypeId", function (newValue, oldValue){ |
| | | if (newValue != null && newValue !== "") { |
| | | $scope.fn.loadPage(); |
| | | } |
| | | }); |
| | | |
| | | function getIssueTypes() { |
| | | var conditions = { |
| | |
| | | if (result.data.message.status === "success") { |
| | | $scope.vm.issueTypes = result.data.data; |
| | | if ($scope.vm.issueTypes != null && $scope.vm.issueTypes.length > 0) { |
| | | $scope.vm.issueTypeId = $scope.vm.issueTypes[0].id.toString(); |
| | | $scope.fn.onChangeIssueType(); |
| | | if ($scope.vm.issueTypeId === "") { |
| | | $scope.vm.issueTypeId = $scope.vm.issueTypes[0].id.toString(); |
| | | } |
| | | |
| | | |
| | | // if ($scope.vm.tab === "API_COL_SETTING") { |
| | | // $scope.fn.onChangeIssueType(); |
| | | // } else if ($scope.vm.tab === "API_SPEC_SETTING") { |
| | | // $scope.fn.onChangeIssueTypeSpec(); |
| | | // } else if ($scope.vm.tab === "API_OVERLAP_SETTING") { |
| | | // } |
| | | } |
| | | } |
| | | else { |
| | |
| | | }); |
| | | } |
| | | |
| | | function getCurrentIssueTypeVo() { |
| | | var issueTypeId = $scope.vm.issueTypeId; |
| | | |
| | | var issueTypeVo = null; |
| | | $scope.vm.issueTypes.forEach(function (issueType) { |
| | | if (issueType.id == issueTypeId) { |
| | | issueTypeVo = issueType; |
| | | } |
| | | }); |
| | | return issueTypeVo; |
| | | } |
| | | |
| | | // 자동 동료 이슈 상태 변경시 |
| | | function onChangeEndIssueStatus() { |
| | | |
| | | } |
| | | |
| | | function onChangeIssueTypeOverlap() { |
| | | $scope.fn.getIssueStatuses(); |
| | | $scope.fn.getIssueTypeCustomFields(); |
| | | $scope.fn.getOverlapList(); |
| | | } |
| | | |
| | | function onChangeIssueType() { |
| | | function formSubmitCompleteIssueStatus() { |
| | | if ($scope.vm.issueTypeId != null) { |
| | | let conditions = { |
| | | issueTypeId: $scope.vm.issueTypeId |
| | | let content = { |
| | | issueTypeId : $scope.vm.issueTypeId, |
| | | projectId : $scope.vm.projectId, |
| | | issueStatusId: $scope.vm.completeIssueStatusId === "none" ? null : $scope.vm.completeIssueStatusId |
| | | } |
| | | |
| | | Api.findApiDefault($resourceProvider.getContent( |
| | | conditions, $resourceProvider.getPageContent(0, 1000))).then(function (result) { |
| | | $scope.fn.initForm(); |
| | | if (result.data.message.status === "success") { |
| | | if (angular.isDefined(result.data.data)) { |
| | | $scope.vm.form.issueApiDefault = result.data.data; |
| | | $scope.vm.form.issueApiDefault.priorityId = result.data.data.priorityId != null ? result.data.data.priorityId.toString() : ""; |
| | | $scope.vm.form.issueApiDefault.severityId = result.data.data.severityId != null ? result.data.data.severityId.toString() : ""; |
| | | Api.saveCompleteIssueStatus($resourceProvider.getContent( |
| | | content, $resourceProvider.getPageContent(0, 1000))).then(function (result) { |
| | | |
| | | // if (angular.isDefined(result.data.data.projectVo)) { |
| | | // $scope.vm.projects = []; |
| | | // $scope.vm.projects.push(result.data.data.projectVo); |
| | | // } |
| | | } |
| | | if (result.data.message.status === "success") { |
| | | SweetAlert.swal($filter("translate")("api.successToApiAutoCompleteIssueStatus"), result.data.message.message, "success"); // "설정 성공" |
| | | //$scope.fn.getIssueTypes(); |
| | | $scope.fn.findIssueList($scope.vm.projectId); |
| | | } else { |
| | | SweetAlert.swal($filter("translate")("common.failedToIssueTypeDefault"), result.data.message.message, "error"); // "프로젝트 목록 조회 실패" |
| | | SweetAlert.swal($filter("translate")("api.failedToApiAutoCompleteIssueStatus"), result.data.message.message, "error"); // "설정 실패" |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | // 폼 체크 |
| | |
| | | return false; |
| | | } |
| | | |
| | | function formSubmit() { |
| | | function formSubmitColumnSetting() { |
| | | if ($scope.vm.issueTypeId == null) |
| | | return; |
| | | |
| | | let condition = { |
| | | issueTypeId : $scope.vm.issueTypeId, |
| | | title : $scope.vm.form.issueApiDefault.title, |
| | | // projectId : $scope.vm.projects != null && $scope.vm.projects.length > 0 ? $scope.vm.projects[0].id : null, |
| | | projectId : $scope.vm.projectId, |
| | | priorityId : $scope.vm.form.issueApiDefault.priorityId, |
| | | severityId : $scope.vm.form.issueApiDefault.severityId, |
| | | description : $scope.vm.form.issueApiDefault.description, |
| | |
| | | |
| | | let condition = { |
| | | issueTypeId : $scope.vm.issueTypeId, |
| | | projectId : $scope.vm.projectId, |
| | | customFieldIds : (function () { |
| | | var ids = []; |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | // 이슈 유형에 연결된 사용자 정의 필드 |
| | | function getIssueTypeCustomFields() { |
| | | |
| | | $scope.vm.form.issueCustomFields = []; |
| | | |
| | | var issueTypeVo = $scope.fn.getCurrentIssueTypeVo(); |
| | | var projectId = $scope.vm.projectId; |
| | | |
| | | if (issueTypeVo == null || projectId == null) return; |
| | | |
| | | IssueTypeCustomField.find($resourceProvider.getContent({ |
| | | projectId : projectId, |
| | | IssueTypeId : issueTypeVo.id }, |
| | | $resourceProvider.getPageContent(0, 1000))).then(function (result) { |
| | | $scope.vm.form.issueCustomFields = []; |
| | | if (result.data.message.status === "success") { |
| | | |
| | | angular.forEach(result.data.data, function (issueTypeCustomField) { |
| | | $scope.vm.form.issueCustomFields.push(issueTypeCustomField); |
| | | }); |
| | | |
| | | $scope.$broadcast("getIssueTypeListComplete", $scope.vm.form.issueCustomFields); |
| | | } |
| | | else { |
| | | |
| | | SweetAlert.swal($filter("translate")("issue.failedToUserDefinedFieldListAssociatedLookup"), result.data.message.message, "error"); // 이슈 유형에 연결된 사용자 정의 필드 목록 조회 실패 |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | // 중요도 목록 |
| | | function getSeverities() { |
| | | Severity.find($resourceProvider.getContent({}, |
| | |
| | | }); |
| | | } |
| | | |
| | | $rootScope.$on("changeColumnSettingTab", function (event, args){ |
| | | $scope.fn.start(); |
| | | $scope.$on("getIssueTypeListComplete", function (event, args) { |
| | | if ($scope.vm.tab === "API_SPEC_SETTING") { |
| | | $scope.fn.createRequestAddJson(); |
| | | $scope.fn.createRequestModifyJson(); |
| | | } |
| | | }); |
| | | |
| | | |
| | | $rootScope.$on("changeOverlapSettingTab", function (event, args){ |
| | | $scope.fn.getOverlapList(); |
| | | }); |
| | | |
| | | |
| | | function changeTab(tab) { |
| | | $scope.vm.tab = tab; |
| | | $scope.fn.loadPage(); |
| | | } |
| | | |
| | | // 현재 탭 페이지 불러오기 |
| | | function loadPage() { |
| | | let tab = $scope.vm.tab; |
| | | |
| | | if (tab === "API_COL_SETTING") { |
| | | $rootScope.$broadcast("changeColumnSettingTab"); |
| | | $scope.fn.onChangeColumnSetting(); |
| | | } else if (tab === "API_OVERLAP_SETTING") { |
| | | $rootScope.$broadcast("changeOverlapSettingTab"); |
| | | $scope.fn.onChangeIssueTypeOverlap(); |
| | | } else if (tab === "API_SPEC_SETTING") { |
| | | $scope.fn.onChangeIssueTypeSpec(); |
| | | } |
| | | } |
| | | |
| | | function start() { |
| | | $scope.fn.initForm(); |
| | | $scope.fn.getSeverities(); |
| | | $scope.fn.getPriorities(); |
| | | $scope.fn.getIssueTypes(); |
| | | } |
| | | $scope.fn.start(); |
| | | // 자동 종료 이슈 상태 적용 |
| | | function setApiIssueTypeStatus() { |
| | | if ($scope.vm.issueStatuses != null) { |
| | | $scope.vm.completeIssueStatuses = []; |
| | | |
| | | $scope.vm.issueStatuses.forEach(function (issueStatus) { |
| | | if (issueStatus.issueStatusType === "CLOSE") { |
| | | $scope.vm.completeIssueStatuses.push(issueStatus); |
| | | } |
| | | }); |
| | | |
| | | // 설정된 상태 지정 |
| | | $scope.vm.completeIssueStatusId = "none"; |
| | | let issueTypeVo = $scope.fn.getCurrentIssueTypeVo(); |
| | | if (issueTypeVo.completeIssueStatusVo != null) { |
| | | $scope.vm.completeIssueStatuses.forEach(function (issueStatus) { |
| | | if (issueStatus.id === issueTypeVo.completeIssueStatusVo.id) { |
| | | $scope.vm.completeIssueStatusId = issueStatus.id.toString(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | function getIssueStatuses() { |
| | | var condition = { |
| | | issueTypeId: $scope.vm.issueTypeId |
| | | } |
| | | IssueStatus.findIssueStatusesByIssueType($resourceProvider.getContent(condition, |
| | | $resourceProvider.getPageContent(0, 1000))).then(function (result) { |
| | | |
| | | if (result.data.message.status === "success") { |
| | | $scope.vm.issueStatuses = result.data.data; |
| | | |
| | | // $scope.vm.issueStatusId = ""; |
| | | if ($scope.vm.issueStatuses != null && $scope.vm.issueStatuses.length > 0) { |
| | | $scope.vm.issueStatusId = $scope.vm.issueStatuses[0].id.toString(); |
| | | } |
| | | |
| | | if ($scope.vm.tab === "API_OVERLAP_SETTING") { |
| | | $scope.fn.setApiIssueTypeStatus(); |
| | | } |
| | | |
| | | $scope.$broadcast("getIssueStatusComplete", $scope.vm.issueStatuses); |
| | | } else { |
| | | SweetAlert.swal($filter("translate")("issue.failedToCriticalListLookup"), result.data.message.message, "error"); // 중요도 목록 조회 실패 |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function onChangeColumnSetting() { |
| | | var promises = { |
| | | severities : $scope.fn.getSeverities(), |
| | | priorities : $scope.fn.getPriorities(), |
| | | } |
| | | $q.all(promises).then(function (results) { |
| | | if ($scope.vm.issueTypeId != null && $scope.vm.issueTypeId !== "none") { |
| | | let conditions = { |
| | | issueTypeId: $scope.vm.issueTypeId |
| | | } |
| | | |
| | | Api.findApiDefault($resourceProvider.getContent( |
| | | conditions, $resourceProvider.getPageContent(0, 1000))).then(function (result) { |
| | | $scope.fn.initForm(); |
| | | |
| | | if (result.data.message.status === "success") { |
| | | if (angular.isDefined(result.data.data)) { |
| | | $scope.vm.form.issueApiDefault = result.data.data; |
| | | $scope.vm.form.issueApiDefault.priorityId = result.data.data.priorityId != null ? result.data.data.priorityId.toString() : ""; |
| | | $scope.vm.form.issueApiDefault.severityId = result.data.data.severityId != null ? result.data.data.severityId.toString() : ""; |
| | | } |
| | | } else { |
| | | SweetAlert.swal($filter("translate")("common.failedToIssueTypeDefault"), result.data.message.message, "error"); // "프로젝트 목록 조회 실패" |
| | | } |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | // 프로젝트 변경시 |
| | | function onChangeProject() { |
| | | $scope.fn.findIssueList($scope.vm.projectId); |
| | | } |
| | | |
| | | // 이슈 유형 목록 가져오기 |
| | | function findIssueList(projectId) { |
| | | if ($rootScope.projects == null || $rootScope.projects.length <= 1) |
| | | return; |
| | | |
| | | // 이슈 타입 목록 검색 조건을 만든다. |
| | | var conditions = { |
| | | projectId : projectId > -1 ? projectId : null, |
| | | useProject : true, |
| | | deep : "01" // 이슈 유형에 연결된 워크플로우 정보를 찾는다. |
| | | } |
| | | IssueType.find($resourceProvider.getContent(conditions, |
| | | $resourceProvider.getPageContent(0, 100))).then(function (result) { |
| | | |
| | | if (result.data.message.status === "success") { |
| | | $scope.vm.issueTypes = result.data.data; |
| | | if ($scope.vm.issueTypes != null && $scope.vm.issueTypes.length > 0) { |
| | | $scope.vm.issueTypeId = $scope.vm.issueTypes[0].id.toString(); |
| | | $scope.fn.getIssueStatuses(); |
| | | $scope.fn.getIssueTypeCustomFields(); |
| | | } else { |
| | | $scope.vm.issueTypeId = "none"; |
| | | } |
| | | } |
| | | else { |
| | | SweetAlert.error($filter("translate")("managementType.failedToIssueTypeList"), result.data.message.message); // "이슈 유형 목록 조회 실패" |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | function onChangeIssueTypeSpec() { |
| | | $scope.fn.getIssueStatuses(); |
| | | $scope.fn.getIssueTypeCustomFields(); |
| | | } |
| | | |
| | | // 요청 데이터 만들기( 추가) |
| | | function createRequestAddJson() { |
| | | var customFields = $scope.fn.createCustomFields(); |
| | | |
| | | var jsonData = { |
| | | token: "||발급받은 토큰}||", |
| | | title: "||이슈 제목||", |
| | | issueTypeId: $scope.vm.issueTypeId, |
| | | apiType: "add", |
| | | customFields : customFields |
| | | }; |
| | | |
| | | $scope.vm.sampleJsonAdd = JSON.stringify(jsonData,undefined, 4); |
| | | } |
| | | |
| | | function createCustomFields() { |
| | | var customFields = []; |
| | | $scope.vm.form.issueCustomFields.forEach(function (issueCustomField){ |
| | | customFields.push({ |
| | | customFieldId: issueCustomField.customFieldVo.id, |
| | | useValue: "||입력값||" |
| | | }) |
| | | }); |
| | | return customFields; |
| | | } |
| | | |
| | | // 요청 데이터 만들기(수정) |
| | | function createRequestModifyJson() { |
| | | var customFields = $scope.fn.createCustomFields(); |
| | | |
| | | var jsonData = { |
| | | token: "||발급받은 토큰||", |
| | | issueTypeId: $scope.vm.issueTypeId, |
| | | apiType: "modify", |
| | | issueStatusId: $scope.vm.issueStatusId, |
| | | customFields : customFields |
| | | }; |
| | | |
| | | $scope.vm.sampleJsonModify = JSON.stringify(jsonData, undefined, 2); |
| | | } |
| | | |
| | | $scope.$watch(function() { |
| | | return $rootScope.projects; |
| | | }, function() { |
| | | if ($rootScope.projects != null && $rootScope.projects.length > 0) { |
| | | // 공통 데이터 불러오기 |
| | | $scope.fn.getProjects(); |
| | | $scope.fn.findIssueList($scope.vm.projectId); |
| | | // $scope.fn.getIssueTypes(); |
| | | } |
| | | }, true); |
| | | |
| | | |
| | | function getProjects() { |
| | | if ($rootScope.projects != null) { |
| | | $scope.vm.projects = []; |
| | | $rootScope.projects.forEach(function (project){ |
| | | if (project.id > -1) { |
| | | $scope.vm.projects.push(project); |
| | | } |
| | | }); |
| | | |
| | | if ( $scope.vm.projects.length > 0) { |
| | | $scope.vm.projectId = $scope.vm.projects[0].id.toString(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if ($scope.vm.tab === "") { |
| | | $scope.fn.changeTab("API_COL_SETTING"); |
| | | } |
| | | }]); |
| | | }); |