Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit f2ce88e

Browse files
committed
webui: Better handle some visualisation deletion cases
1 parent dc6a4aa commit f2ce88e

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

webui/templates/visualise.html

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,12 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg">&nbsp;{{ statu
422422
$scope.statusMessage = "";
423423
}
424424

425+
// Clear out any existing table data
426+
$scope.clearData = function() {
427+
$scope.db.ColNames = [];
428+
$scope.db.Records = [];
429+
}
430+
425431
// Handle browser resize events
426432
function resizeEvent() {
427433
if (dataReceived === true) {
@@ -433,14 +439,16 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg">&nbsp;{{ statu
433439
// Change to a newly selected visualisation
434440
// Note, the 'execNewVis' parameter controls whether to execute and display the visualisation after loading it
435441
$scope.changeVis = function(newVis, execNewVis) {
442+
// Clear out any existing table data and chart
443+
$scope.showVis = false;
444+
$scope.clearData();
445+
436446
// Retrieve the SQL and chart settings for the newly chosen visualisation from the server
437447
$http.get("/x/visget/[[ .DB.Info.Owner ]]/[[ .DB.Info.Database ]]?visname="+newVis).then(
438448
function success(response) {
439449
if (execNewVis) {
440-
// Clear any existing status message, chart, and table data
450+
// Clear any existing status message
441451
$scope.statusMessage = "";
442-
$scope.showVis = true;
443-
$scope.clearData();
444452
}
445453

446454
// Apply the retrieved information
@@ -460,14 +468,14 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg">&nbsp;{{ statu
460468

461469
// If requested, we execute the newly loaded visualisation
462470
if (execNewVis) {
471+
$scope.showVis = true;
463472
$scope.execSQL();
464473
}
465474
}, function failure(response) {
466475
if (execNewVis) {
467476
// Retrieving visualisation text failed, so display the returned error message
468477
$scope.statusMessageColour = "red";
469478
$scope.statusMessage = nowString() + "Retrieving visualisation failed: " + response.data;
470-
$scope.showVis = false;
471479
}
472480
}
473481
)
@@ -525,12 +533,6 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg">&nbsp;{{ statu
525533
$scope.doChart(true);
526534
};
527535

528-
// Clear out any existing table data
529-
$scope.clearData = function() {
530-
$scope.db.ColNames = [];
531-
$scope.db.Records = [];
532-
}
533-
534536
// Deletes a saved visualisation
535537
$scope.deleteVis = function() {
536538
// Check if the user is logged in
@@ -555,6 +557,10 @@ <h4 style="color: {{ statusMessageColour }};" data-cy="statusmsg">&nbsp;{{ statu
555557
// Remove the visualisation from the drop-down list
556558
$scope.visNames.splice(arrIdx, 1);
557559

560+
// Clear out any existing table data, and remove any chart
561+
$scope.showVis = false;
562+
$scope.clearData();
563+
558564
// If the currently selected visualisation was the deleted one, pick the first in the remaining
559565
// visualisation list as the new selection
560566
if($scope.visName === name) {

0 commit comments

Comments
 (0)