Skip to content

Commit

Permalink
Adds dataflow DOT download and user tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurPaiva96 committed Sep 20, 2024
1 parent e441faa commit c94edd0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 19 deletions.
7 changes: 6 additions & 1 deletion capture/noworkflow/now/models/graphs/history_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

from ...persistence.models.trial import Trial
from ...persistence.models.tag import Tag
from ...persistence.models.user import User
from ...utils.cross_version import zip_longest
from .structures import Graph
from ...persistence import relational



Expand Down Expand Up @@ -117,15 +119,18 @@ def _load_trials(self, trial_gen): # pylint: disable=no-self-use
tmap = OrderedDict()
id_s=1
for trial in trial_gen:
user = relational.session.query(User.m).filter(User.m.id==trial.user_id).all()
trial_user = user[0].userLogin if (len(user)>0) else trial.user_id
trial.display = str(trial.id)
trial.level = 0
trial.tooltip = """
<b>{0.script}</b><br>
Id: {0.id}<br>
{status}<br>
User: {user}<br>
Start: {0.start}<br>
Finish: {0.finish}
""".format(trial, status=trial.status.capitalize())
""".format(trial, status=trial.status.capitalize(), user=trial_user)
if trial.finish:
trial.tooltip += """
<br>
Expand Down
27 changes: 19 additions & 8 deletions capture/noworkflow/now/vis/static/dist/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -31593,9 +31593,7 @@ function getDataflow(response, config, parent, dataflowWindowId, dataflowUrl) {
var dataflowWindow = document.getElementById(dataflowWindowId);

// Download SVG Button, excluding hint, and excluding checkbox
downloadDataflow(dataflowWindow, dataflowWindowId);
excludePriorProvenanceHint(dataflowWindow, "Click on a function call, then (Ctrl or Shift)+click on another one to exclude prior provenience");
checkboxOpenDataflowExcludeProvenanceNewWindow(dataflowWindow);
dataflowButtons(dataflowWindow, dataflowWindowId, "Click on a function call, then (Ctrl or Shift)+click on another one to exclude prior provenience", json.dataflow);
var selectedNode;

//dataflowWindow!.style.overflowY = dataflowWindow!.style.overflowX = "auto";
Expand Down Expand Up @@ -31704,9 +31702,7 @@ function dataflowAMinusDataflowB(dataflowA, dataflowB, selectedEvaluationOrder,
console.log(newDataflowString);
console.log("------");
excludingProvenanceWindow.textContent = "";
downloadDataflow(excludingProvenanceWindow, excludingProvenanceWindow.getAttribute("id"));
excludePriorProvenanceHint(excludingProvenanceWindow, "(Ctrl or Shift)+click on a function call to exclude prior provenience");
checkboxOpenDataflowExcludeProvenanceNewWindow(excludingProvenanceWindow);
dataflowButtons(excludingProvenanceWindow, excludingProvenanceWindow.getAttribute("id"), "(Ctrl or Shift)+click on a function call to exclude prior provenience", newDataflowString);
var svgElement = viz.renderSVGElement(newDataflowString);
excludingProvenanceWindow.appendChild(svgElement);
svgPanZoom(svgElement, {
Expand Down Expand Up @@ -31917,13 +31913,28 @@ function addsAutocompleteToDataflowWDF(dataflowEvaluationInput, dataflowTextInpu
}
});
}
function downloadDataflow(dataflowWindow, dataflowWindowId) {
(0,d3_selection__WEBPACK_IMPORTED_MODULE_9__["default"])(dataflowWindow).append("div").append("a").classed("toollink", true).attr("id", dataflowWindowId + "-download").attr("href", "#").style("color", "black").attr("title", "Download dataflow SVG").on("click", function () {
function downloadDataflowAsSVG(dataflowWindow, dataflowWindowId, appendDiv) {
var div = appendDiv ? (0,d3_selection__WEBPACK_IMPORTED_MODULE_9__["default"])(dataflowWindow).append("div").attr("id", dataflowWindowId + "-downloadDiv") : (0,d3_selection__WEBPACK_IMPORTED_MODULE_9__["default"])(document.getElementById(dataflowWindowId + "-downloadDiv"));
div.append("a").classed("toollink", true).attr("id", dataflowWindowId + "-downloadSVG").attr("href", "#").style("color", "black").attr("title", "Download dataflow SVG").on("click", function () {
file_saver__WEBPACK_IMPORTED_MODULE_7__.saveAs(new Blob([dataflowWindow.getElementsByTagName("svg")[0].outerHTML], {
type: "image/svg+xml"
}), "dataflow.svg");
}).append("i").classed("fa fa-download", true);
}
function downloadDataflowAsDOT(dataflowWindow, dataflowWindowId, dataflowDOT, appendDiv) {
var div = appendDiv ? (0,d3_selection__WEBPACK_IMPORTED_MODULE_9__["default"])(dataflowWindow).append("div").attr("id", dataflowWindowId + "-downloadDiv") : (0,d3_selection__WEBPACK_IMPORTED_MODULE_9__["default"])(document.getElementById(dataflowWindowId + "-downloadDiv"));
div.append("a").classed("toollink", true).attr("id", dataflowWindowId + "-downloadDOT").attr("href", "#").style("color", "black").attr("title", "Download dataflow DOT").on("click", function () {
file_saver__WEBPACK_IMPORTED_MODULE_7__.saveAs(new Blob([dataflowDOT.trim()], {
type: "text/plain;charset=utf-8"
}), "dataflow.dot");
}).append("i").classed("fa fa-file-text", true);
}
function dataflowButtons(dataflowWindow, dataflowWindowId, excludeProvenanceHint, dataflowDOT) {
downloadDataflowAsSVG(dataflowWindow, dataflowWindowId, true);
downloadDataflowAsDOT(dataflowWindow, dataflowWindowId, dataflowDOT, false);
excludePriorProvenanceHint(dataflowWindow, excludeProvenanceHint);
checkboxOpenDataflowExcludeProvenanceNewWindow(dataflowWindow);
}
function getRestoreOrCollabCommand(serverUrl, form, modalBody) {
fetch(serverUrl, {
method: 'GET',
Expand Down
2 changes: 1 addition & 1 deletion capture/noworkflow/now/vis/static/dist/bundle.js.map

Large diffs are not rendered by default.

37 changes: 28 additions & 9 deletions npm/packages/nowvis/src/graph/history_graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,7 @@ function getDataflow(response: any, config: HistoryConfig, parent: Element, data
const dataflowWindow = document.getElementById(dataflowWindowId);

// Download SVG Button, excluding hint, and excluding checkbox
downloadDataflow(dataflowWindow, dataflowWindowId);
excludePriorProvenanceHint(dataflowWindow, "Click on a function call, then (Ctrl or Shift)+click on another one to exclude prior provenience");
checkboxOpenDataflowExcludeProvenanceNewWindow(dataflowWindow!);
dataflowButtons(dataflowWindow, dataflowWindowId, "Click on a function call, then (Ctrl or Shift)+click on another one to exclude prior provenience", json.dataflow)

let selectedNode: Element | undefined;

Expand Down Expand Up @@ -1034,9 +1032,7 @@ function dataflowAMinusDataflowB(dataflowA: any, dataflowB: any, selectedEvaluat

excludingProvenanceWindow!.textContent = "";

downloadDataflow(excludingProvenanceWindow, excludingProvenanceWindow!.getAttribute("id")!);
excludePriorProvenanceHint(excludingProvenanceWindow, "(Ctrl or Shift)+click on a function call to exclude prior provenience");
checkboxOpenDataflowExcludeProvenanceNewWindow(excludingProvenanceWindow!);
dataflowButtons(excludingProvenanceWindow, excludingProvenanceWindow!.getAttribute("id")!, "(Ctrl or Shift)+click on a function call to exclude prior provenience", newDataflowString)

let svgElement = viz.renderSVGElement(newDataflowString);
excludingProvenanceWindow!.appendChild(svgElement);
Expand Down Expand Up @@ -1336,10 +1332,11 @@ function addsAutocompleteToDataflowWDF(dataflowEvaluationInput: d3_Selection<HTM
});
}

function downloadDataflow(dataflowWindow: HTMLElement | null, dataflowWindowId: string) {
d3_select(dataflowWindow).append("div").append("a")
function downloadDataflowAsSVG(dataflowWindow: HTMLElement | null, dataflowWindowId: string, appendDiv : boolean) {
let div = appendDiv ? d3_select(dataflowWindow).append("div").attr("id", dataflowWindowId + "-downloadDiv") : d3_select(document.getElementById(dataflowWindowId + "-downloadDiv"));
div.append("a")
.classed("toollink", true)
.attr("id", dataflowWindowId + "-download")
.attr("id", dataflowWindowId + "-downloadSVG")
.attr("href", "#")
.style("color", "black")
.attr("title", "Download dataflow SVG")
Expand All @@ -1350,6 +1347,28 @@ function downloadDataflow(dataflowWindow: HTMLElement | null, dataflowWindowId:
.classed("fa fa-download", true);
}

function downloadDataflowAsDOT(dataflowWindow: HTMLElement | null, dataflowWindowId: string, dataflowDOT : string, appendDiv: boolean) {
let div = appendDiv ? d3_select(dataflowWindow).append("div").attr("id", dataflowWindowId + "-downloadDiv") : d3_select(document.getElementById(dataflowWindowId + "-downloadDiv"));
div.append("a")
.classed("toollink", true)
.attr("id", dataflowWindowId + "-downloadDOT")
.attr("href", "#")
.style("color", "black")
.attr("title", "Download dataflow DOT")
.on("click", () => {
fs.saveAs(new Blob([dataflowDOT.trim()], { type: "text/plain;charset=utf-8" }), "dataflow.dot");
})
.append("i")
.classed("fa fa-file-text", true);
}

function dataflowButtons(dataflowWindow: HTMLElement | null, dataflowWindowId: string, excludeProvenanceHint : string, dataflowDOT : string){
downloadDataflowAsSVG(dataflowWindow, dataflowWindowId, true);
downloadDataflowAsDOT(dataflowWindow, dataflowWindowId, dataflowDOT, false)
excludePriorProvenanceHint(dataflowWindow, excludeProvenanceHint);
checkboxOpenDataflowExcludeProvenanceNewWindow(dataflowWindow!);
}

function getRestoreOrCollabCommand(serverUrl: string, form: d3_Selection<HTMLFormElement, {}, HTMLElement | null, any>,
modalBody: d3_Selection<HTMLDivElement, {}, HTMLElement | null, any>) {
fetch(serverUrl, {
Expand Down

0 comments on commit c94edd0

Please sign in to comment.