| | |
| | | 'app', 'angular' |
| | | ], |
| | | function (app, angular) { |
| | | app.controller('apiSettingController', ['$scope', '$rootScope', '$log', '$resourceProvider','$uibModal', 'SweetAlert', '$timeout', '$filter', |
| | | function ($scope, $rootScope, $log, $resourceProvider, $uibModal, SweetAlert, $timeout, $filter) { |
| | | 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) { |
| | | |
| | | $scope.fn = { |
| | | changeTab : changeTab, |
| | | add : add, |
| | | getIssueTypeCallback : getIssueTypeCallback, |
| | | getProjectListCallback : getProjectListCallback, |
| | | formSubmit : formSubmit, |
| | | formCheck : formCheck, |
| | | initForm : initForm, |
| | | getPriorities : getPriorities, |
| | | getSeverities : getSeverities, |
| | | start : start |
| | | }; |
| | | |
| | | $scope.vm = { |
| | | tab : "API_COL_SETTING", |
| | | issueTypes : [], |
| | | severities : [], |
| | | priorities : [], |
| | | // projects : [], |
| | | form : { |
| | | issueApiDefault : { |
| | | title : "", |
| | | description : "", |
| | | priorityId : "", |
| | | severityId : "", |
| | | // projectName : "", |
| | | } |
| | | }, |
| | | |
| | | } |
| | | autoCompletePage : { |
| | | issueType : { |
| | | page : 0, |
| | | totalPage : 0 |
| | | }, |
| | | // project : { |
| | | // page : 0, |
| | | // totalPage : 0 |
| | | // } |
| | | }, |
| | | issueTypeName : "", |
| | | issueTypeData : null // 이슈 유형 객체 |
| | | }; |
| | | |
| | | // 생성 팝업 |
| | | function add() { |
| | | $uibModal.open({ |
| | | templateUrl : 'views/api/apiOverlapAdd.html', |
| | | size : "sm", |
| | | // controller : 'apiOverlapAddController', |
| | | backdrop : 'static' |
| | | angular.extend(this, $controller('autoCompleteController', {$scope : $scope, $injector : $injector})); |
| | | |
| | | function initForm() { |
| | | $scope.vm.form.issueApiDefault.title = ""; |
| | | $scope.vm.form.issueApiDefault.description = ""; |
| | | $scope.vm.form.issueApiDefault.priorityId = ""; |
| | | $scope.vm.form.issueApiDefault.severityId = ""; |
| | | } |
| | | |
| | | // 이슈 유형 클릭시 |
| | | $scope.$on("onClickIssueType", function (evnet, args) { |
| | | if (args != null && args.length > 0) { |
| | | |
| | | let conditions = { |
| | | issueTypeId: args[0].id |
| | | } |
| | | |
| | | Api.findApiDefault($resourceProvider.getContent( |
| | | conditions, $resourceProvider.getPageContent(0, 0))).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.toString(); |
| | | $scope.vm.form.issueApiDefault.severityId = result.data.data.severityId.toString(); |
| | | |
| | | // if (angular.isDefined(result.data.data.projectVo)) { |
| | | // $scope.vm.projects = []; |
| | | // $scope.vm.projects.push(result.data.data.projectVo); |
| | | // } |
| | | } |
| | | } else { |
| | | SweetAlert.swal($filter("translate")("common.failedToIssueTypeDefault"), result.data.message.message, "error"); // "프로젝트 목록 조회 실패" |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | // 폼 체크 |
| | | function formCheck(formInvalid) { |
| | | if (formInvalid) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | function formSubmit() { |
| | | if ($scope.vm.issueTypes == null || $scope.vm.issueTypes.length === 0) |
| | | return; |
| | | |
| | | let condition = { |
| | | issueTypeId : $scope.vm.issueTypes[0].id, |
| | | 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, |
| | | severityId : $scope.vm.form.issueApiDefault.severityId, |
| | | description : $scope.vm.form.issueApiDefault.description, |
| | | } |
| | | |
| | | Api.modifyApiDefault($resourceProvider.getContent(condition, |
| | | $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 토큰 생성 성공" |
| | | } |
| | | else { |
| | | SweetAlert.swal($filter("translate")("api.failedToApiIssueDefault"), result.data.message.message, "error"); // "api 토큰 생성 실패" |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function getIssueTypeCallback(result) { |
| | | $scope.vm.autoCompletePage.issueType.totalPage = result.data.page.totalPage; |
| | | } |
| | | |
| | | function getProjectListCallback(result) { |
| | | $scope.vm.autoCompletePage.project.totalPage = result.data.page.totalPage; |
| | | } |
| | | |
| | | // 우선순위 목록 |
| | | function getPriorities() { |
| | | Priority.find($resourceProvider.getContent({}, |
| | | $resourceProvider.getPageContent(0, 1000))).then(function (result) { |
| | | |
| | | if (result.data.message.status === "success") { |
| | | $scope.vm.priorities = result.data.data; |
| | | } |
| | | else { |
| | | SweetAlert.swal($filter("translate")("issue.failedToPriorityListLookup"), result.data.message.message, "error"); // 우선순위 목록 조회 실패 |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 중요도 목록 |
| | | function getSeverities() { |
| | | Severity.find($resourceProvider.getContent({}, |
| | | $resourceProvider.getPageContent(0, 1000))).then(function (result) { |
| | | |
| | | if (result.data.message.status === "success") { |
| | | $scope.vm.severities = result.data.data; |
| | | } |
| | | else { |
| | | SweetAlert.swal($filter("translate")("issue.failedToCriticalListLookup"), result.data.message.message, "error"); // 중요도 목록 조회 실패 |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | function changeTab(tab) { |
| | | $scope.vm.tab = tab; |
| | |
| | | } |
| | | } |
| | | |
| | | function start() { |
| | | $scope.fn.initForm(); |
| | | $scope.fn.getSeverities(); |
| | | $scope.fn.getPriorities(); |
| | | } |
| | | |
| | | $scope.fn.start(); |
| | | }]); |
| | | }); |