Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wWs add svg support #7

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cli/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,15 @@ async function downloadImage(src, assetType, splunkdInfo, projectDir) {

const [mimeType, data] = parseDataUri(imgData.dataURI);
const filename = await storeImage(data, mimeType, { name: id, projectDir });
const newUri = `/assets/${filename}`;
// If the DASHPUB_FQDN env is set and its an SVG then return the link with FQDN prepended
if (process.env.DASHPUB_FQDN && mimeType=="image/svg+xml") {
var newUri = `${process.env.DASHPUB_FQDN}/assets/${filename}`;
} else if (mimeType=="image/svg+xml") {
// Else return the SVG XML content and embed into dash definition
var newUri = data.toString();
} else {
var newUri = `/assets/${filename}`;
}
seenImages[src] = newUri;
return newUri;
}
Expand Down
17 changes: 10 additions & 7 deletions cli/builddash.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,16 @@ async function generateDashboard({ name, targetName = name, app, projectFolder,
viz.options.src = await downloadImage(viz.options.src, 'images', splunkdInfo, projectFolder);
}
}
if (viz.type === 'splunk.choropleth.svg') {
if (viz.options.svg.match(/\$.*\$/g) )
console.log(`Skipping image download due to token ${viz.options.svg}`)
else{
viz.options.svg = await downloadImage(viz.options.svg, 'images', splunkdInfo, projectFolder);
}
}
if (viz.type === 'splunk.choropleth.svg') {
if (viz.options.svg.match(/\$.*\$/g) )
console.log(`Skipping image download due to token ${viz.options.svg}`)
else if (viz.options.svg.startsWith("data:image")) {
console.log("Skipping because image is embedded as string")
}
else {
viz.options.svg = await downloadImage(viz.options.svg, 'images', splunkdInfo, projectFolder);
}
}
} catch (e) {
console.error(`Failed to download image ${viz.options.icon || viz.options.src}`, e);
}
Expand Down