| | |
| | | function (app, angular) { |
| | | |
| | | app.controller('commonController', ['$scope', '$rootScope', '$log', 'Auth', '$state', 'User', '$resourceProvider', '$uibModal', 'SweetAlert', 'Workspace', '$translate', '$q', |
| | | '$interval', 'IssueSearch', '$filter', 'Notice', 'Project', |
| | | function ($scope, $rootScope, $log, Auth, $state, User, $resourceProvider, $uibModal, SweetAlert, Workspace, $translate, $q, $interval, IssueSearch, $filter, Notice, Project) { |
| | | '$interval', 'IssueSearch', '$filter', 'Notice', 'Project', 'IssueType', |
| | | function ($scope, $rootScope, $log, Auth, $state, User, $resourceProvider, $uibModal, SweetAlert, Workspace, $translate, $q, $interval, IssueSearch, $filter, Notice, Project, IssueType) { |
| | | |
| | | $scope.fn = { |
| | | logout: logout, // 로그아웃 |
| | |
| | | makeIssueSearch: makeIssueSearch, // 이슈 번호를 저장한 후 이슈 목록으로 이동한다. |
| | | disconnectSocket: disconnectSocket, // 웹 소켓 연결 해제 |
| | | sendMessage: sendMessage, |
| | | moveMenu : moveMenu |
| | | moveMenu : moveMenu, |
| | | findIssueList : findIssueList, // 사이드바 이슈 목록 가져오기 |
| | | changeIssueListMenu : changeIssueListMenu, |
| | | setLastIssueType : setLastIssueType, |
| | | searchAll : searchAll // 상단 검색 |
| | | }; |
| | | |
| | | $scope.vm = { |
| | | workProject : -1, |
| | | message: "", |
| | | workProjectId : -1, |
| | | searchAll : { |
| | | keyWord : "" |
| | | } |
| | | }; |
| | | |
| | | |
| | | // session check after route |
| | | $rootScope.$on("$stateChangeStart", function (event, toState, toStateParams) { |
| | | if (!$rootScope.isMainSearch) { |
| | | $scope.vm.searchAll.keyWord = ""; |
| | | } |
| | | }); |
| | | |
| | | // 시스템에서 특정 이슈로 바로 이동할 수 있도록 해준다. |
| | | $scope.$on("makeIssueSearch", function (event, args) { |
| | | // 이슈 번호를 저장한 후 이슈 목록으로 이동한다. |
| | | $scope.fn.makeIssueSearch(args.projectKey, args.issueNumber); |
| | | $scope.fn.makeIssueSearch(args.projectKey, args.issueNumber, args.issueTypeId); |
| | | }); |
| | | |
| | | // 이슈 유형 변경시 |
| | | $scope.$on("modifyIssueType", function (event, args) { |
| | | findIssueList($rootScope.workProject != null ? $rootScope.workProject.id : null); |
| | | }); |
| | | |
| | | // 프로젝트 목록 화면 새로 고침시 |
| | |
| | | findAllWorkproject(); |
| | | }); |
| | | |
| | | $scope.$on("changedLastProject", function () { |
| | | //if ($rootScope.workProject != null) { |
| | | $scope.fn.findIssueList($rootScope.workProject.id); |
| | | //} |
| | | }); |
| | | |
| | | // 메인 상단 검색 |
| | | function searchAll() { |
| | | $rootScope.isMainSearch = true; |
| | | |
| | | if ($state.current.name !== "issues.list" || $state.current.name === "issues.list") { |
| | | $state.go("issues.list"); |
| | | } |
| | | |
| | | $scope.$broadcast("searchIssueList", {keyWord: $scope.vm.searchAll.keyWord}); |
| | | } |
| | | |
| | | function setLastIssueType() { |
| | | if (User != null) { |
| | | User.updateLastIssueType($resourceProvider.getContent( |
| | | {lastIssueTypeId: $rootScope.getCurrentIssueTypeId()}, |
| | | $resourceProvider.getPageContent(0, 0))).then(function (result) { |
| | | |
| | | if (result.data.message.status === "success") { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | function changeIssueListMenu(issueTypeId, changeProject = true) { |
| | | $rootScope.issueTypeMenu = null; |
| | | for (var issueType of $rootScope.workIssueTypes) { |
| | | if (issueType.id === issueTypeId) { |
| | | $rootScope.issueTypeMenu = issueType; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // sidebar 클릭시 프로젝트 아이디 설정 |
| | | if (changeProject) { |
| | | |
| | | $rootScope.$broadcast("changedIssueListMenu", $rootScope.issueTypeMenu); |
| | | $rootScope.changeLastProject($rootScope.issueTypeMenu.projectVo.id, false, false); |
| | | |
| | | if ($rootScope.issueTypeMenu != null) { |
| | | moveMenu("issues.list"); |
| | | } |
| | | } |
| | | //moveMenu("issues.list"); |
| | | |
| | | if ($rootScope.user.lastIssueTypeId !== issueTypeId) { |
| | | $scope.fn.setLastIssueType(issueTypeId); |
| | | } |
| | | } |
| | | |
| | | function moveMenu(stateName) { |
| | | if ($state.current.name == stateName) { |
| | | if ($state.current.name === stateName) { |
| | | $state.reload(); |
| | | } else { |
| | | $state.go(stateName); |
| | |
| | | |
| | | // 메세지 발송 |
| | | function sendMessage() { |
| | | |
| | | var content = { |
| | | description : $scope.vm.message, |
| | | userIds : [1] |
| | |
| | | } |
| | | |
| | | // 이슈 번호를 저장한 후 이슈 목록으로 이동한다. |
| | | function makeIssueSearch(projectKey, issueNumber) { |
| | | function makeIssueSearch(projectKey, issueNumber, issueTypeId) { |
| | | var combinationIssueNumber = projectKey; |
| | | if (issueNumber != undefined) { |
| | | combinationIssueNumber += "-" + issueNumber; |
| | |
| | | $resourceProvider.getPageContent(0, 0))).then(function (result) { |
| | | |
| | | if (result.data.message.status === "success") { |
| | | $scope.fn.changeIssueListMenu(issueTypeId); |
| | | moveMenu("issues.list"); |
| | | } else { |
| | | SweetAlert.error($filter("translate")("issue.failedToSaveFieldConditions"), result.data.message.message); // "검색 필드 조건 저장 실패" |
| | |
| | | if ($rootScope.user.lastProjectId === project.id) { |
| | | $rootScope.workProject = project; |
| | | } |
| | | |
| | | var id = $rootScope.workProject.id === -1 ? null : $rootScope.workProject.id; |
| | | } |
| | | $rootScope.projects = datas; |
| | | $scope.fn.findIssueList(id); |
| | | } |
| | | |
| | | if ($rootScope.user.lastProjectId == null) { |
| | |
| | | }); |
| | | } |
| | | |
| | | // 현재 프로젝트 변경시 |
| | | |
| | | // 이슈 유형 목록 가져오기 |
| | | 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") { |
| | | $rootScope.workIssueTypes = result.data.data; |
| | | |
| | | if ($rootScope.workIssueTypes != null && $rootScope.workIssueTypes.length > 0) { |
| | | $rootScope.workIssueTypes.forEach(function (issueType) { |
| | | |
| | | var selectIssueTypeId = null; |
| | | if (issueType.id === $rootScope.user.lastIssueTypeId) { |
| | | selectIssueTypeId = issueType.id; |
| | | $scope.fn.changeIssueListMenu(issueType.id, false); |
| | | // 이슈목록 새로고침 목록 갱신 |
| | | $scope.$broadcast("findIssueListOK", { myIssueType : issueType} ); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | else { |
| | | SweetAlert.error($filter("translate")("managementType.failedToIssueTypeList"), result.data.message.message); // "이슈 유형 목록 조회 실패" |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | // 프로젝트 변경 |
| | | function changeLastProject(projectId) { |
| | | $rootScope.changeLastProject(projectId); |
| | | |
| | | |
| | | } |
| | | |
| | | // 업무 공간 변경 |
| | |
| | | |
| | | if (result.data.message.status === "success") { |
| | | $rootScope.user = result.data.data; |
| | | $rootScope.setCurrentIssueTypeId() |
| | | $state.go($state.current, {}, {reload: true}); |
| | | |
| | | if ($state.current.name === "dashboards.dashboard") { |
| | |
| | | $scope.fn.findAllWorkproject(); |
| | | }); |
| | | |
| | | |
| | | // 10초마다 웹 소켓 연결을 확인하는 폴링 이벤트 |
| | | $interval(function () { |
| | | //$log.debug("10초마다 소켓 연결을 확인합니다."); |