/** * Created by wisestone on 2018-11-05. */ 'use strict'; define(['app', 'saveSvgAsPng'], function (app, saveSvgAsPng) { app.directive('issueStatusWidget', ['$log', '$rootScope', '$resourceProvider', 'SweetAlert', 'Workspace', '$filter', function ($log, $rootScope, $resourceProvider, SweetAlert, Workspace, $filter) { return { restrict : 'E', scope : { dynamicWidth : "=", issueStatusWidget : '=', }, replace : true, templateUrl : '../custom_components/widget/issue-status-widget/issue-status-widget.html', controller : function ($scope, $element, $attrs) { // 함수 모음 $scope.fn = { downloadImage : downloadImage // 이미지 다운로드 }; // 변수 모음 $scope.vm = { dynamicWidth : false, options : { chart : { type : 'multiBarChart', height : 400, margin : { top : 50, right : 20, bottom : 45, left : 45 }, clipEdge: true, duration: 100, stacked: true, xAxis: { axisLabel: '', tickFormat: function(d){ if (d.length > 15) { return d.slice(0, 15) + "..."; } return d; } }, yAxis: { axisLabel: 'Y Axis', axisLabelDistance: 100, tickFormat: function(d){ return d3.format(',.0f')(d); } }, legendPosition : 'bottom', } }, data : [] }; // 전체 이슈 처리 현황 정보가 변경될때 감지한다. $scope.$watch("issueStatusWidget", function (newValue) { $scope.vm.dynamicWidth = false; if ($rootScope.isDefined(newValue)) { $scope.vm.data = newValue; } }); // 이미지 다운로드 function downloadImage() { if ((navigator.userAgent.indexOf('MSIE') > 0 || navigator.userAgent.indexOf('Trident') > 0 || /iPad|iPhone|iPod/.test(navigator.userAgent))) { 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.statusOfIssuesPNG"), { canvg : null, backgroundColor: '#f1f1f1' }); // 상태별 이슈 현황.png } else { // 웹 소켓 연결이 안되어 있을 경우에는 직접 alert 를 표시한다. if ($rootScope.getObjectKeys($rootScope.users) < 1) { SweetAlert.error($filter("translate")("dashboard.excludeWorkspaceParticipation"), result.data.message.message); // 업무 공간 참여 제외 } } }); } }, link : function (scope, element, attrs) { } }; }]) });