mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 17:33:23 +00:00
[Code Review] Updates based on code review by @VWoeltjen
Set export functions on the ExportImageService prototype. Insantiated ExportImageService in the PlotController for better dependcy injection.
This commit is contained in:
parent
3a19890be9
commit
e370271093
@ -22,17 +22,17 @@
|
||||
<span ng-controller="PlotController as plot"
|
||||
class="abs holder holder-plot">
|
||||
<a class="s-button t-export icon-download labeled"
|
||||
ng-click="exportPDF()"
|
||||
ng-click="plot.exportPDF()"
|
||||
title="Export This View's Data">
|
||||
Export as PDF
|
||||
</a>
|
||||
<a class="s-button t-export icon-download labeled"
|
||||
ng-click="exportPNG()"
|
||||
ng-click="plot.exportPNG()"
|
||||
title="Export This View's Data">
|
||||
Export as PNG
|
||||
</a>
|
||||
<a class="s-button t-export icon-download labeled"
|
||||
ng-click="exportJPG()"
|
||||
ng-click="plot.exportJPG()"
|
||||
title="Export This View's Data">
|
||||
Export as JPG
|
||||
</a>
|
||||
|
@ -250,6 +250,7 @@ define(
|
||||
|
||||
self.pending = true;
|
||||
self.$element = $element;
|
||||
self.ExportImageService = new ExportImageService();
|
||||
|
||||
// Initialize axes; will get repopulated when telemetry
|
||||
// metadata becomes available.
|
||||
@ -258,18 +259,6 @@ define(
|
||||
new PlotAxis("ranges", [], AXIS_DEFAULTS[1])
|
||||
];
|
||||
|
||||
$scope.exportPDF = function () {
|
||||
PlotController.prototype.exportPDF(self.$element, 'plot.pdf');
|
||||
};
|
||||
|
||||
$scope.exportPNG = function () {
|
||||
PlotController.prototype.exportPNG(self.$element, 'plot.png');
|
||||
};
|
||||
|
||||
$scope.exportJPG = function () {
|
||||
PlotController.prototype.exportJPG(self.$element, 'plot.jpg');
|
||||
};
|
||||
|
||||
// Watch for changes to the selected axis
|
||||
$scope.$watch("axes[0].active.key", domainRequery);
|
||||
$scope.$watch("axes[1].active.key", rangeRequery);
|
||||
@ -383,22 +372,22 @@ define(
|
||||
/**
|
||||
* Export the plot to PDF
|
||||
*/
|
||||
PlotController.prototype.exportPDF = function (element, filename) {
|
||||
ExportImageService.exportPDF(element[0], filename);
|
||||
PlotController.prototype.exportPDF = function () {
|
||||
this.ExportImageService.exportPDF(this.$element[0], 'plot.pdf');
|
||||
};
|
||||
|
||||
/**
|
||||
* Export the plot to PNG
|
||||
*/
|
||||
PlotController.prototype.exportPNG = function (element, filename) {
|
||||
ExportImageService.exportPNG(element, filename);
|
||||
PlotController.prototype.exportPNG = function () {
|
||||
this.ExportImageService.exportPNG(this.$element[0], 'plot.png');
|
||||
};
|
||||
|
||||
/**
|
||||
* Export the plot to JPG
|
||||
*/
|
||||
PlotController.prototype.exportJPG = function (element, filename) {
|
||||
ExportImageService.exportJPG(element, filename);
|
||||
PlotController.prototype.exportJPG = function () {
|
||||
this.ExportImageService.exportJPG(this.$element[0], 'plot.jpg');
|
||||
};
|
||||
|
||||
return PlotController;
|
||||
|
@ -71,7 +71,7 @@ define(
|
||||
});
|
||||
}
|
||||
|
||||
ExportImageService.exportPDF = function (element, filename) {
|
||||
ExportImageService.prototype.exportPDF = function (element, filename) {
|
||||
renderElement(element, function (img) {
|
||||
var pdf = new jsPDF('l', 'px', [element.offsetHeight, element.offsetWidth]);
|
||||
pdf.addImage(img, 'JPEG', 0, 0, element.offsetWidth, element.offsetHeight);
|
||||
@ -79,13 +79,13 @@ define(
|
||||
}, 'jpeg');
|
||||
};
|
||||
|
||||
ExportImageService.exportJPG = function (element, filename) {
|
||||
ExportImageService.prototype.exportJPG = function (element, filename) {
|
||||
renderElement(element, function (img) {
|
||||
saveAs(img, filename);
|
||||
}, "blob");
|
||||
};
|
||||
|
||||
ExportImageService.exportPNG = function (element, filename) {
|
||||
ExportImageService.prototype.exportPNG = function (element, filename) {
|
||||
renderElement(element, function (img) {
|
||||
saveAs(img, filename);
|
||||
}, "blob");
|
||||
|
Loading…
x
Reference in New Issue
Block a user