mirror of
https://github.com/nasa/openmct.git
synced 2025-01-02 11:26:42 +00:00
Add and Remove corresponding classes to capture higher contrast/print friendly png and jpg exports (#2088)
* add and remove corrensponding class to capture better images (wip) * pass class through exportAsPng and exportAsJpg directly * pass classname from stacked plots into exportImageService * Adding additional export styles Fixes #2088 - WIP * WIP export styles Fixes #2080 - Styling WIP; - Moved styles into plots-main.scss; - Change to how plot hashes are rendered; * add class before clone, because adding it on clone was not rendering new css styles * Export styles Fixes #2080 - Code indenting cleaned up; - Additional styles for export; - Added hide effects for .h-local-controls and unsynced state; * Apply class to cloned element only
This commit is contained in:
parent
d2c5476cdd
commit
9288880e47
@ -51,11 +51,8 @@
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.gl-plot {
|
.gl-plot {
|
||||||
color: $colorPlotFg;
|
color: $colorPlotFg;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -74,7 +71,8 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
top: $interiorMarginSm; left: $interiorMarginSm;
|
top: $interiorMarginSm;
|
||||||
|
left: $interiorMarginSm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,13 +190,13 @@
|
|||||||
|
|
||||||
.gl-plot-hash {
|
.gl-plot-hash {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
border: 0 $colorPlotHash $stylePlotHash;
|
opacity: $opacityPlotHash;
|
||||||
&.hash-v {
|
&.hash-v {
|
||||||
border-right-width: 1px;
|
border-right: 1px $colorPlotHash $stylePlotHash;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
&.hash-h {
|
&.hash-h {
|
||||||
border-bottom-width: 1px;
|
border-bottom: 1px $colorPlotHash $stylePlotHash;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,8 +219,12 @@
|
|||||||
|
|
||||||
height: auto;
|
height: auto;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
&.s-limit-yellow { @include limitBg($colorLimitYellowBg); }
|
&.s-limit-yellow {
|
||||||
&.s-limit-red { @include limitBg($colorLimitRedBg); }
|
@include limitBg($colorLimitYellowBg);
|
||||||
|
}
|
||||||
|
&.s-limit-red {
|
||||||
|
@include limitBg($colorLimitRedBg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.l-oob-data {
|
.l-oob-data {
|
||||||
@ -246,10 +248,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.gl-plot-display-area,
|
.gl-plot-display-area,
|
||||||
.plot-display-area {
|
.plot-display-area {
|
||||||
@if $colorPlotBg != none { background-color: $colorPlotBg; }
|
@if $colorPlotBg != none {
|
||||||
|
background-color: $colorPlotBg;
|
||||||
|
}
|
||||||
cursor: crosshair;
|
cursor: crosshair;
|
||||||
border: 1px solid $colorPlotAreaBorder;
|
border: 1px solid $colorPlotAreaBorder;
|
||||||
}
|
}
|
||||||
@ -303,6 +306,74 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
&.tick-label-y {
|
&.tick-label-y {
|
||||||
right: 0; left: 0;
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.export-plot {
|
||||||
|
$bg: white;
|
||||||
|
$fg: black;
|
||||||
|
$gry: #999;
|
||||||
|
|
||||||
|
background: $bg !important;
|
||||||
|
z-index: -10;
|
||||||
|
|
||||||
|
.l-view-section {
|
||||||
|
$m: $interiorMargin;
|
||||||
|
top: $m !important;
|
||||||
|
right: $m;
|
||||||
|
bottom: $m;
|
||||||
|
left: $m;
|
||||||
|
|
||||||
|
.s-status-timeconductor-unsynced .holder-plot {
|
||||||
|
.t-object-alert.t-alert-unsynced {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.gl-plot-display-area {
|
||||||
|
background: none !important;
|
||||||
|
border-color: $gry !important;
|
||||||
|
|
||||||
|
.gl-plot-local-controls,
|
||||||
|
.h-local-controls {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.gl-plot {
|
||||||
|
color: $fg;
|
||||||
|
|
||||||
|
.gl-plot-hash {
|
||||||
|
opacity: 0.1;
|
||||||
|
border-color: $fg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
thead {
|
||||||
|
border-bottom: none;
|
||||||
|
|
||||||
|
th {
|
||||||
|
background: #eee;
|
||||||
|
border-left-color: $bg;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tbody {
|
||||||
|
tr {
|
||||||
|
border-top: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
color: $fg;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,8 @@ $colorTabHeaderBorder: $colorBodyBg;
|
|||||||
// Plot
|
// Plot
|
||||||
$colorPlotBg: rgba(black, 0.1);
|
$colorPlotBg: rgba(black, 0.1);
|
||||||
$colorPlotFg: $colorBodyFg;
|
$colorPlotFg: $colorBodyFg;
|
||||||
$colorPlotHash: $colorTick;
|
$colorPlotHash: white;
|
||||||
|
$opacityPlotHash: 0.2;
|
||||||
$stylePlotHash: dashed;
|
$stylePlotHash: dashed;
|
||||||
$colorPlotAreaBorder: $colorInteriorBorder;
|
$colorPlotAreaBorder: $colorInteriorBorder;
|
||||||
$colorPlotLabelFg: pushBack($colorPlotFg, 20%);
|
$colorPlotLabelFg: pushBack($colorPlotFg, 20%);
|
||||||
|
@ -183,7 +183,8 @@ $colorTabHeaderBorder: $colorBodyBg;
|
|||||||
// Plot
|
// Plot
|
||||||
$colorPlotBg: rgba(black, 0.05);
|
$colorPlotBg: rgba(black, 0.05);
|
||||||
$colorPlotFg: $colorBodyFg;
|
$colorPlotFg: $colorBodyFg;
|
||||||
$colorPlotHash: $colorTick;
|
$colorPlotHash: black;
|
||||||
|
$opacityPlotHash: 0.2;
|
||||||
$stylePlotHash: dashed;
|
$stylePlotHash: dashed;
|
||||||
$colorPlotAreaBorder: $colorInteriorBorder;
|
$colorPlotAreaBorder: $colorInteriorBorder;
|
||||||
$colorPlotLabelFg: pushBack($colorPlotFg, 20%);
|
$colorPlotLabelFg: pushBack($colorPlotFg, 20%);
|
||||||
|
@ -40,8 +40,8 @@ define(
|
|||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function ExportImageService(dialogService) {
|
function ExportImageService(dialogService) {
|
||||||
this.exportCount = 0;
|
|
||||||
this.dialogService = dialogService;
|
this.dialogService = dialogService;
|
||||||
|
this.exportCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,7 +51,8 @@ define(
|
|||||||
* @param {string} type of image to convert the element to.
|
* @param {string} type of image to convert the element to.
|
||||||
* @returns {promise}
|
* @returns {promise}
|
||||||
*/
|
*/
|
||||||
ExportImageService.prototype.renderElement = function (element, imageType, color) {
|
ExportImageService.prototype.renderElement = function (element, imageType, className) {
|
||||||
|
|
||||||
var dialogService = this.dialogService,
|
var dialogService = this.dialogService,
|
||||||
dialog = dialogService.showBlockingMessage({
|
dialog = dialogService.showBlockingMessage({
|
||||||
title: "Capturing...",
|
title: "Capturing...",
|
||||||
@ -66,18 +67,18 @@ define(
|
|||||||
mimeType = "image/jpeg";
|
mimeType = "image/jpeg";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (className) {
|
||||||
var exportId = 'export-element-' + this.exportCount;
|
var exportId = 'export-element-' + this.exportCount;
|
||||||
this.exportCount++;
|
this.exportCount++;
|
||||||
var oldId = element.id;
|
var oldId = element.id;
|
||||||
element.id = exportId;
|
element.id = exportId;
|
||||||
|
}
|
||||||
|
|
||||||
return html2canvas(element, {
|
return html2canvas(element, {
|
||||||
onclone: function (document) {
|
onclone: function (document) {
|
||||||
// Make export style changes to cloned document so that
|
if (className) {
|
||||||
// users don't see view flickering.
|
|
||||||
var clonedElement = document.getElementById(exportId);
|
var clonedElement = document.getElementById(exportId);
|
||||||
if (clonedElement && color) {
|
clonedElement.classList.add(className);
|
||||||
clonedElement.style.backgroundColor = color;
|
|
||||||
}
|
}
|
||||||
element.id = oldId;
|
element.id = oldId;
|
||||||
}
|
}
|
||||||
@ -107,10 +108,11 @@ define(
|
|||||||
* Takes a screenshot of a DOM node and exports to JPG.
|
* Takes a screenshot of a DOM node and exports to JPG.
|
||||||
* @param {node} element to be exported
|
* @param {node} element to be exported
|
||||||
* @param {string} filename the exported image
|
* @param {string} filename the exported image
|
||||||
|
* @param {string} className to be added to element before capturing (optional)
|
||||||
* @returns {promise}
|
* @returns {promise}
|
||||||
*/
|
*/
|
||||||
ExportImageService.prototype.exportJPG = function (element, filename, color) {
|
ExportImageService.prototype.exportJPG = function (element, filename, className) {
|
||||||
return this.renderElement(element, "jpg", color).then(function (img) {
|
return this.renderElement(element, "jpg", className).then(function (img) {
|
||||||
saveAs(img, filename);
|
saveAs(img, filename);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -119,10 +121,11 @@ define(
|
|||||||
* Takes a screenshot of a DOM node and exports to PNG.
|
* Takes a screenshot of a DOM node and exports to PNG.
|
||||||
* @param {node} element to be exported
|
* @param {node} element to be exported
|
||||||
* @param {string} filename the exported image
|
* @param {string} filename the exported image
|
||||||
|
* @param {string} className to be added to element before capturing (optional)
|
||||||
* @returns {promise}
|
* @returns {promise}
|
||||||
*/
|
*/
|
||||||
ExportImageService.prototype.exportPNG = function (element, filename, color) {
|
ExportImageService.prototype.exportPNG = function (element, filename, className) {
|
||||||
return this.renderElement(element, "png", color).then(function (img) {
|
return this.renderElement(element, "png", className).then(function (img) {
|
||||||
saveAs(img, filename);
|
saveAs(img, filename);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -245,7 +245,7 @@ define([
|
|||||||
*/
|
*/
|
||||||
PlotController.prototype.exportJPG = function () {
|
PlotController.prototype.exportJPG = function () {
|
||||||
this.hideExportButtons = true;
|
this.hideExportButtons = true;
|
||||||
this.exportImageService.exportJPG(this.$element[0], 'plot.jpg', 'white')
|
this.exportImageService.exportJPG(this.$element[0], 'plot.jpg', 'export-plot')
|
||||||
.finally(function () {
|
.finally(function () {
|
||||||
this.hideExportButtons = false;
|
this.hideExportButtons = false;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
@ -256,7 +256,7 @@ define([
|
|||||||
*/
|
*/
|
||||||
PlotController.prototype.exportPNG = function () {
|
PlotController.prototype.exportPNG = function () {
|
||||||
this.hideExportButtons = true;
|
this.hideExportButtons = true;
|
||||||
this.exportImageService.exportPNG(this.$element[0], 'plot.png', 'white')
|
this.exportImageService.exportPNG(this.$element[0], 'plot.png', 'export-plot')
|
||||||
.finally(function () {
|
.finally(function () {
|
||||||
this.hideExportButtons = false;
|
this.hideExportButtons = false;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
@ -142,7 +142,7 @@ define([
|
|||||||
|
|
||||||
StackedPlotController.prototype.exportJPG = function () {
|
StackedPlotController.prototype.exportJPG = function () {
|
||||||
this.hideExportButtons = true;
|
this.hideExportButtons = true;
|
||||||
this.exportImageService.exportJPG(this.$element[0], 'stacked-plot.jpg')
|
this.exportImageService.exportJPG(this.$element[0], 'stacked-plot.jpg', 'export-plot')
|
||||||
.finally(function () {
|
.finally(function () {
|
||||||
this.hideExportButtons = false;
|
this.hideExportButtons = false;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
@ -150,7 +150,7 @@ define([
|
|||||||
|
|
||||||
StackedPlotController.prototype.exportPNG = function () {
|
StackedPlotController.prototype.exportPNG = function () {
|
||||||
this.hideExportButtons = true;
|
this.hideExportButtons = true;
|
||||||
this.exportImageService.exportPNG(this.$element[0], 'stacked-plot.png')
|
this.exportImageService.exportPNG(this.$element[0], 'stacked-plot.png', 'export-plot')
|
||||||
.finally(function () {
|
.finally(function () {
|
||||||
this.hideExportButtons = false;
|
this.hideExportButtons = false;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
Loading…
Reference in New Issue
Block a user