Skip to content

Commit

Permalink
T
Browse files Browse the repository at this point in the history
  • Loading branch information
msune committed Jun 22, 2024
1 parent c76283c commit cc253db
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
21 changes: 11 additions & 10 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<div class="dropdown-menu" aria-labelledby="dashboards" id="nav-dashboards">
<div id="dashboard-list-custom"></div>
<div class="dropdown-divider"></div>
<h6 class="dropdown-header">Preset</h6>
<div id="dashboard-list-preset"></div>
</div>
</li>
Expand Down Expand Up @@ -94,36 +95,36 @@
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="examplemodallabel">create a dashboard</h5>
<h5 class="modal-title" id="examplemodallabel">Create a dashboard</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="name-group">
<label for="modal-dashboard-id" class="col-form-label">id:</label>
<label for="modal-dashboard-id" class="col-form-label">Id:</label>
<input type="text" class="form-control" id="modal-dashboard-id" disabled>
</div>
<div class="name-group">
<label for="modal-dashboard-name" class="col-form-label">name:</label>
<label for="modal-dashboard-name" class="col-form-label">Name:</label>
<input type="text" class="form-control" id="modal-dashboard-name">
</div>
<div class="form-group">
<label for="modal-dashboard-description" class="col-form-label">description:</label>
<label for="modal-dashboard-description" class="col-form-label">Description:</label>
<textarea class="form-control" id="modal-dashboard-description"></textarea>
</div>
<div class="form-group">
<label for="modal-dashboard-url" class="col-form-label">url:</label>
<label for="modal-dashboard-url" class="col-form-label">URL:</label>
<textarea class="form-control" id="modal-dashboard-url" disabled></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="modal-dashboard-close">close</button>
<button type="button" class="btn btn-danger" data-dismiss="modal" id="modal-dashboard-delete">delete</button>
<button type="button" class="btn btn-primary" id="modal-dashboard-create">create</button>
<button type="button" class="btn btn-primary" id="modal-dashboard-update">update</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="modal-dashboard-close">Close</button>
<button type="button" class="btn btn-danger" data-dismiss="modal" id="modal-dashboard-delete">Delete</button>
<button type="button" class="btn btn-primary" id="modal-dashboard-create">Create</button>
<button type="button" class="btn btn-primary" id="modal-dashboard-update">Update</button>
</div>
</div>
</div>
Expand All @@ -134,7 +135,7 @@ <h5 class="modal-title" id="examplemodallabel">create a dashboard</h5>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="examplemodallabel">delete a dashboard</h5>
<h5 class="modal-title" id="examplemodallabel">Delete a dashboard</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="close">
<span aria-hidden="true">&times;</span>
</button>
Expand Down
26 changes: 15 additions & 11 deletions src/js/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ function create_update_dashboard(create){

timer_query_rest(true);
timer_update_labels(true);
},
error: function(xhr, status, error) {
notify_error("Failed: "+op_str+" dashboard '"+name+"'");
}
});
}
Expand All @@ -147,7 +150,7 @@ $("#modal-dashboard-delete").on("click", function(){
//Be kind
$("#modal-confirm-dashboard-name").html(name);
$("#modal-confirm button.confirm_delete").attr('data-url', url);
$("#modal-confirm button.confirm_delete").attr('data-name', url);
$("#modal-confirm button.confirm_delete").attr('data-name', name);
$("#modal-confirm").modal("show");

$("#modal-confirm button.confirm_delete").on("click", function(){
Expand All @@ -165,6 +168,9 @@ $("#modal-dashboard-delete").on("click", function(){

timer_query_rest(true);
timer_update_labels(true);
},
error: function(xhr, status, error) {
notify_error("Failed: deleting dashboard '"+name+"'");
}
});
});
Expand Down Expand Up @@ -193,11 +199,11 @@ function update_dashboard_list(){
d = dashboards[i];
if(d["dataCube"] != curr_datacube)
continue;
elem = '<a class="dropdown-item dashboard" datacube="'+d["dataCube"]+'" href="#" dash-id="'+d["shortName"]+'">';
elem = '<div class="d-flex"><span class="w-100"><a class="dropdown-item dashboard" datacube="'+d["dataCube"]+'" href="#" dash-id="'+d["shortName"]+'">'+d["shortName"]+'</a></span>';
if(d["preset"])
dashboard_list_preset += elem+d["shortName"]+'</a>';
dashboard_list_preset += elem+"</div>";
else
dashboard_list_custom += '<a class="dashboard-edit" dash-id="'+d["shortName"]+'"><span data-feather="edit-2"></span></a>'+elem+d["shortName"]+'</a>';
dashboard_list_custom += elem+'<span class="pr-3"><a class="dashboard-edit pl-1 cursor-pointer" dash-id="'+d["shortName"]+'"><span data-feather="edit-2"></span></a></span></div>';
dashboard_urls_[d["hash"]] = d;
}

Expand Down Expand Up @@ -257,26 +263,24 @@ function set_current_dashboard(){
label.text(label_text);
}

function timer_query_rest(one_time = false){
function timer_query_rest(){
rest_query_datacubes();
rest_query_dashboards();
if(!one_time)
setInterval(timer_query_rest, 5000);
}

function timer_update_labels(one_time = false){
function timer_update_views(){
set_current_datacube();
update_dashboard_list();
set_current_dashboard();
if(!one_time)
setInterval(timer_update_labels, 250);
}

//Main routines
$( document ).ready(function(){
//Query REST periodically
setInterval(timer_query_rest, 5000);
timer_query_rest();

//Update labels
timer_update_labels();
setInterval(timer_update_views, 250);
timer_update_views();
});

0 comments on commit cc253db

Please sign in to comment.