/**
|
* Created by wisestone on 2018-11-05.
|
*/
|
'use strict';
|
|
define(['app', 'saveSvgAsPng'],
|
function (app, saveSvgAsPng) {
|
app.directive('issueTypeWidget', ['$log', '$rootScope', '$resourceProvider', 'SweetAlert', 'Workspace', '$filter', 'Widget',
|
function ($log, $rootScope, $resourceProvider, SweetAlert, Workspace, $filter, Widget) {
|
return {
|
restrict : 'E',
|
scope : {
|
issueTypeWidget : '=',
|
},
|
replace : true,
|
templateUrl : '../custom_components/widget/issue-type-widget/issue-type-widget.html',
|
controller : function ($scope, $element, $attrs) {
|
|
// 함수 모음
|
$scope.fn = {
|
saveIssueTypeWidget : saveIssueTypeWidget, // 마지막으로 선택한 프로젝트 정보를 저장한다.
|
findIssueTypeWidget : findIssueTypeWidget, // 프로젝트 별 이슈 타입에 대한 이슈 현황을 조회한다.
|
downloadImage : downloadImage // 이미지 다운로드
|
};
|
|
// 변수 모음
|
$scope.vm = {
|
projectId : "",
|
options : {
|
chart : {
|
type : 'pieChart',
|
height : 350,
|
x : function (d) {
|
return d.name;
|
},
|
y : function (d) {
|
return d.issueCount;
|
},
|
showLabels : true,
|
showTooltipPercent : true,
|
duration : 500,
|
labelThreshold : 0.01,
|
labelSunbeamLayout : false,
|
legendPosition : "bottom",
|
legend : {
|
maxKeyLength : 15
|
},
|
valueFormat : function (d) {
|
return d3.format(',.0f')(d);
|
}
|
}
|
}
|
};
|
|
// 전체 이슈 처리 현황 정보가 변경될때 감지한다.
|
$scope.$watch("issueTypeWidget", function (newValue) {
|
if ($rootScope.isDefined(newValue)) {
|
$scope.fn.saveIssueTypeWidget(newValue);
|
}
|
});
|
|
// 마지막으로 선택한 프로젝트 정보를 저장한다.
|
function saveIssueTypeWidget(result) {
|
$scope.vm.issueTypeWidget = result;
|
|
if ($scope.vm.issueTypeWidget.projectVos.length > 0) {
|
$scope.vm.issueTypeWidget.projectVos[0].checked = true;
|
// 최초 접근시 선택된 프로젝트 아이디
|
$scope.vm.projectId = $scope.vm.issueTypeWidget.projectVos[0].id;
|
}
|
}
|
|
// 이미지 다운로드
|
function downloadImage() {
|
if ((navigator.userAgent.indexOf('MSIE') > 0 || navigator.userAgent.indexOf('Trident') > 0)) {
|
SweetAlert.warning($filter("translate")("dashboard.notSupportedImageDownload"), $filter("translate")("dashboard.ieNotSupportedImageDownload")); // 이미지 다운로드 미지원, IE 에서는 이미지 다운로드를 지원하지 않습니다.
|
return;
|
}
|
|
// 업무 공간에서 해당 사용자가 활성 상태 인지 확인 후 이미지 다운로드를 실행한다.
|
Workspace.checkUseWorkspace($resourceProvider.getContent({},
|
$resourceProvider.getPageContent(0, 0))).then(function (result) {
|
|
if (result.data.message.status === "success") {
|
saveSvgAsPng.saveSvgAsPng($($element).find("svg")[0], $filter("translate")("dashboard.issueTypeStandIssues"), {canvg : null, backgroundColor : '#f1f1f1'}); // 상태별 이슈 현황.png
|
}
|
else {
|
// 웹 소켓 연결이 안되어 있을 경우에는 직접 alert 를 표시한다.
|
if ($rootScope.getObjectKeys($rootScope.users) < 1) {
|
SweetAlert.error($filter("translate")("dashboard.excludeWorkspaceParticipation"), result.data.message.message); // 업무 공간 참여 제외
|
}
|
}
|
});
|
}
|
|
// 프로젝트 별 이슈 타입에 대한 이슈 현황을 조회한다.
|
function findIssueTypeWidget(projectId) {
|
// 검색 조건
|
var content = {
|
projectId : projectId
|
};
|
|
Widget.findByStandIssueType($resourceProvider.getContent(content,
|
$resourceProvider.getPageContent(0, 0))).then(function (result) {
|
|
if (result.data.message.status === "success") {
|
// 멤버별 진행률 정보를 저장한다.
|
$scope.fn.saveIssueTypeWidget(result.data.issueTypeWidget);
|
|
angular.forEach($scope.vm.issueTypeWidget.projectVos, function (projectVo) {
|
if (projectVo.id === projectId) {
|
projectVo.checked = true;
|
// 사용자가 프로젝트를 선택했을 때 프로젝트 아이디 정보를 다시 저장
|
$scope.vm.projectId = projectVo.id;
|
}
|
else {
|
projectVo.checked = false;
|
}
|
});
|
}
|
else {
|
SweetAlert.error($filter("translate")("dashboard.failedToCheckProgressMember"), result.data.message.message); // 멤버별 진행률 조회 실패
|
}
|
});
|
}
|
},
|
link : function (scope, element, attrs) {
|
|
}
|
};
|
}])
|
});
|