| | |
| | | 'app', 'angular' |
| | | ], |
| | | function (app, angular) { |
| | | app.controller('apiSettingController', ['$scope', '$rootScope', '$log', '$resourceProvider','$uibModal', 'SweetAlert', '$timeout', '$filter', '$injector', '$controller', 'Api', 'Priority', 'Severity', |
| | | function ($scope, $rootScope, $log, $resourceProvider, $uibModal, SweetAlert, $timeout, $filter, $injector, $controller, Api, Priority, Severity) { |
| | | app.controller('apiSettingController', ['$scope', '$rootScope', '$log', '$resourceProvider','$uibModal', 'SweetAlert', |
| | | '$timeout', '$filter', '$injector', '$controller', 'Api', 'Priority', 'Severity', 'IssueType', 'IssueTypeCustomField', |
| | | 'IssueStatus', |
| | | function ($scope, $rootScope, $log, $resourceProvider, $uibModal, SweetAlert, |
| | | $timeout, $filter, $injector, $controller, Api, Priority, Severity, IssueType, IssueTypeCustomField, |
| | | IssueStatus) { |
| | | |
| | | $scope.fn = { |
| | | changeTab : changeTab, |
| | |
| | | initForm : initForm, |
| | | getPriorities : getPriorities, |
| | | getSeverities : getSeverities, |
| | | start : start |
| | | start : start, |
| | | getIssueTypes : getIssueTypes, |
| | | onChangeIssueType : onChangeIssueType, |
| | | reset : reset, |
| | | resetOverlap : resetOverlap, |
| | | formSubmitOverlap : formSubmitOverlap, |
| | | removeCustomField : removeCustomField, |
| | | getOverlapList : getOverlapList, |
| | | onChangeIssueTypeOverlap : onChangeIssueTypeOverlap, |
| | | getIssueTypeCustomFields : getIssueTypeCustomFields, |
| | | getCurrentIssueTypeVo : getCurrentIssueTypeVo, |
| | | loadSpec : loadSpec, |
| | | getIssueStatuses : getIssueStatuses, |
| | | onChangeIssueTypeSpec : onChangeIssueTypeSpec, |
| | | createRequestModifyJson : createRequestModifyJson, |
| | | createRequestAddJson : createRequestAddJson, |
| | | createCustomFields : createCustomFields, |
| | | getProjectList : getProjectList |
| | | }; |
| | | |
| | | $scope.vm = { |
| | | tab : "API_COL_SETTING", |
| | | issueTypes : [], |
| | | issueStatuses : [], |
| | | severities : [], |
| | | priorities : [], |
| | | projects : [], |
| | | sampleJsonAdd : "", |
| | | sampleJsonModify : "", |
| | | // projects : [], |
| | | form : { |
| | | issueCustomFields : [], |
| | | issueApiDefault : { |
| | | title : "", |
| | | description : "", |
| | | priorityId : "", |
| | | severityId : "", |
| | | customFields : [], |
| | | // projectName : "", |
| | | } |
| | | }, |
| | | customFieldId : "", |
| | | }, |
| | | |
| | | autoCompletePage : { |
| | |
| | | // totalPage : 0 |
| | | // } |
| | | }, |
| | | issueTypeId : "", |
| | | issueTypeName : "", |
| | | issueTypeData : null // 이슈 유형 객체 |
| | | }; |
| | | |
| | | angular.extend(this, $controller('autoCompleteController', {$scope : $scope, $injector : $injector})); |
| | | issueStatusId : "", |
| | | issueStatusName : "", |
| | | |
| | | customFieldName : "", |
| | | |
| | | projectId : "", |
| | | projectName : "", |
| | | }; |
| | | |
| | | function initForm() { |
| | | $scope.vm.form.issueApiDefault.title = ""; |
| | |
| | | $scope.vm.form.issueApiDefault.severityId = ""; |
| | | } |
| | | |
| | | // 이슈 유형 클릭시 |
| | | $scope.$on("onClickIssueType", function (evnet, args) { |
| | | if (args != null && args.length > 0) { |
| | | function reset() { |
| | | $scope.fn.initForm(); |
| | | $scope.fn.formSubmit(); |
| | | } |
| | | |
| | | function resetOverlap() { |
| | | $scope.vm.form.customFieldIds = []; |
| | | $scope.fn.form.formSubmitOverlap(); |
| | | } |
| | | |
| | | function getOverlapList() { |
| | | let conditions = { |
| | | issueTypeId: $scope.vm.issueTypeId |
| | | } |
| | | |
| | | 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 = []; |
| | | |
| | | if (customFieldApiOverlaps != null) { |
| | | customFieldApiOverlaps.forEach(function (customFieldApiOverlap) { |
| | | $scope.vm.form.customFields.push(customFieldApiOverlap.customFieldVo); |
| | | }); |
| | | } |
| | | } |
| | | else { |
| | | SweetAlert.swal($filter("translate")("issue.failedToIssueTypeListLookup"), result.data.message.message, "error"); // "이슈 유형 목록 조회 실패" |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function getIssueTypes() { |
| | | var conditions = { |
| | | }; |
| | | |
| | | IssueType.find($resourceProvider.getContent( |
| | | conditions, $resourceProvider.getPageContent(0, 1000))).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(); |
| | | if ($scope.vm.tab === "API_COL_SETTING") { |
| | | $scope.fn.onChangeIssueType(); |
| | | } else if ($scope.vm.tab === "API_SPEC_SETTING") { |
| | | $scope.fn.onChangeIssueTypeSpec(); |
| | | } |
| | | } |
| | | } |
| | | else { |
| | | SweetAlert.swal($filter("translate")("issue.failedToIssueTypeListLookup"), result.data.message.message, "error"); // "이슈 유형 목록 조회 실패" |
| | | } |
| | | }); |
| | | } |
| | | |
| | | 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 onChangeIssueTypeOverlap() { |
| | | $scope.fn.getOverlapList(); |
| | | } |
| | | |
| | | function onChangeIssueType() { |
| | | if ($scope.vm.issueTypeId != null) { |
| | | let conditions = { |
| | | issueTypeId: args[0].id |
| | | issueTypeId: $scope.vm.issueTypeId |
| | | } |
| | | |
| | | Api.findApiDefault($resourceProvider.getContent( |
| | | conditions, $resourceProvider.getPageContent(0, 0))).then(function (result) { |
| | | conditions, $resourceProvider.getPageContent(0, 1000))).then(function (result) { |
| | | $scope.fn.initForm(); |
| | | $scope.fn.getIssueTypeCustomFields(); |
| | | |
| | | 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.toString(); |
| | | $scope.vm.form.issueApiDefault.severityId = result.data.data.severityId.toString(); |
| | | $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() : ""; |
| | | |
| | | |
| | | // if (angular.isDefined(result.data.data.projectVo)) { |
| | | // $scope.vm.projects = []; |
| | |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | // 폼 체크 |
| | | function formCheck(formInvalid) { |
| | |
| | | } |
| | | |
| | | function formSubmit() { |
| | | if ($scope.vm.issueTypes == null || $scope.vm.issueTypes.length === 0) |
| | | if ($scope.vm.issueTypeId == null) |
| | | return; |
| | | |
| | | let condition = { |
| | | issueTypeId : $scope.vm.issueTypes[0].id, |
| | | 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, |
| | | priorityId : $scope.vm.form.issueApiDefault.priorityId, |
| | |
| | | $resourceProvider.getPageContent(0, 1))).then(function (result) { |
| | | |
| | | if (result.data.message.status === "success") { |
| | | SweetAlert.swal($filter("translate")("api.successToApiIssueDefault"), result.data.message.message, "success"); // "api 토큰 생성 성공" |
| | | SweetAlert.swal($filter("translate")("api.successToApiIssueDefault"), result.data.message.message, "success"); // "api 기본값 설정 성공" |
| | | } |
| | | else { |
| | | SweetAlert.swal($filter("translate")("api.failedToApiIssueDefault"), result.data.message.message, "error"); // "api 토큰 생성 실패" |
| | | SweetAlert.swal($filter("translate")("api.failedToApiIssueDefault"), result.data.message.message, "error"); // "api 기본값 설정 실패" |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 사용자 정의 필드 선택 항목 삭제 |
| | | function removeCustomField(index) { |
| | | $scope.vm.form.customFields.splice(index, 1); |
| | | } |
| | | |
| | | // 중복 항목 전송 |
| | | function formSubmitOverlap() { |
| | | if ($scope.vm.issueTypeId === null) |
| | | return; |
| | | |
| | | let condition = { |
| | | issueTypeId : $scope.vm.issueTypeId, |
| | | customFieldIds : (function () { |
| | | var ids = []; |
| | | |
| | | angular.forEach($scope.vm.form.customFields, function (customField) { |
| | | ids.push(customField.id); |
| | | }); |
| | | |
| | | return ids; |
| | | })(), |
| | | } |
| | | |
| | | Api.modifyApiOverlap($resourceProvider.getContent(condition, |
| | | $resourceProvider.getPageContent(0, 1))).then(function (result) { |
| | | |
| | | if (result.data.message.status === "success") { |
| | | SweetAlert.swal($filter("translate")("api.successToApiIssueOverlap"), result.data.message.message, "success"); // "api 중복값 설정 성공" |
| | | } |
| | | else { |
| | | SweetAlert.swal($filter("translate")("api.failedToApiIssueOverlap"), result.data.message.message, "error"); // "api 중복값 설정 실패" |
| | | } |
| | | }); |
| | | } |
| | |
| | | }); |
| | | } |
| | | |
| | | // 이슈 유형에 연결된 사용자 정의 필드 |
| | | function getIssueTypeCustomFields() { |
| | | |
| | | $scope.vm.form.issueCustomFields = []; |
| | | |
| | | var issueTypeVo = $scope.fn.getCurrentIssueTypeVo(); |
| | | |
| | | if (issueTypeVo == null) return; |
| | | |
| | | IssueTypeCustomField.find($resourceProvider.getContent({ |
| | | projectId : $scope.vm.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(); |
| | | }); |
| | | |
| | | |
| | | $rootScope.$on("changeOverlapSettingTab", function (event, args){ |
| | | $scope.fn.getOverlapList(); |
| | | }); |
| | | |
| | | $rootScope.$on("changeSpecSettingTab", function (event, args){ |
| | | $scope.fn.loadSpec(); |
| | | }); |
| | | |
| | | $scope.$on("getIssueTypeListComplete", function (event, args) { |
| | | if ($scope.vm.tab === "API_SPEC_SETTING") { |
| | | $scope.fn.createRequestAddJson(); |
| | | $scope.fn.createRequestModifyJson(); |
| | | } |
| | | }); |
| | | |
| | | function changeTab(tab) { |
| | | $scope.vm.tab = tab; |
| | |
| | | $rootScope.$broadcast("changeColumnSettingTab"); |
| | | } else if (tab === "API_OVERLAP_SETTING") { |
| | | $rootScope.$broadcast("changeOverlapSettingTab"); |
| | | } else if (tab === "API_SPEC_SETTING") { |
| | | $rootScope.$broadcast("changeSpecSettingTab"); |
| | | } |
| | | } |
| | | |
| | | 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; |
| | | if ($scope.vm.issueStatuses != null && $scope.vm.issueStatuses.length > 0) { |
| | | $scope.vm.issueStatusId = $scope.vm.issueStatuses[0].id.toString(); |
| | | } |
| | | } |
| | | else { |
| | | SweetAlert.swal($filter("translate")("issue.failedToCriticalListLookup"), result.data.message.message, "error"); // 중요도 목록 조회 실패 |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function onChangeIssueTypeSpec() { |
| | | $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: "||발급받은 토큰||", |
| | | title: "||이슈 제목||", |
| | | issueTypeId: $scope.vm.issueTypeId, |
| | | apiType: "modify", |
| | | issueStatusId: $scope.vm.issueStatusId, |
| | | customFields : customFields |
| | | }; |
| | | |
| | | $scope.vm.sampleJsonModify = JSON.stringify(jsonData, undefined, 2); |
| | | } |
| | | |
| | | function getProjectList() { |
| | | if ($rootScope.projects != null) { |
| | | $scope.vm.projects = []; |
| | | $rootScope.projects.forEach(function (project){ |
| | | if (project.id > -1) { |
| | | $scope.vm.projects.push(project); |
| | | } |
| | | }); |
| | | $scope.vm.projectId = $scope.vm.projects[0].id.toString(); |
| | | } |
| | | } |
| | | |
| | | |
| | | function loadSpec() { |
| | | $scope.fn.getIssueStatuses(); |
| | | $scope.fn.getIssueTypeCustomFields(); |
| | | } |
| | | |
| | | function start() { |
| | | $scope.fn.initForm(); |
| | | $scope.fn.getProjectList(); |
| | | $scope.fn.getSeverities(); |
| | | $scope.fn.getPriorities(); |
| | | $scope.fn.getIssueTypes(); |
| | | } |
| | | |
| | | $scope.fn.start(); |
| | | |
| | | }]); |
| | | }); |