Skip to content

Commit

Permalink
Add a route to view clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
turtle0x1 committed Nov 9, 2021
1 parent 469499b commit 812fb9e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 38 deletions.
12 changes: 2 additions & 10 deletions src/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ body {
cursor: default;
}

.cluster-title:hover {
color: #167495 !important; /* Eugh */
}

.cluster-title-not-admin:hover {
color: #4dbd74 !important;
.cluster-title {
cursor: pointer;
}

.text-underline {
Expand All @@ -85,10 +81,6 @@ body {
text-decoration: line-through !important;
}

.toggleCard, .cluster-title {
cursor: pointer;
}

.sidebar .nav-dropdown-toggle.disabled::before {
display: none !important;
}
Expand Down
19 changes: 18 additions & 1 deletion src/views/boxes/cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,24 @@
</div>
</div>
<script>
function loadClusterView(clusterId){
var currentCluster = {
clusterId: null
};
function loadClusterView(req){
let clusterId = req.data.clusterId;
currentCluster.clusterId = clusterId;
createDashboardSidebar()
if(!userDetails.isAdmin){
router.navigate("/404")
return false;
}
let x = $(this).data();
$("#sidebar-ul").find(".text-info").removeClass("text-info");
$("#sidebar-ul").find(".active").removeClass("active");
$(this).addClass("text-info");
$(".boxSlide, #clusterContents").hide();
$("#clusterBox, #clusterOverview").show();
Expand Down
42 changes: 15 additions & 27 deletions src/views/boxes/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,16 +629,13 @@ function createDashboardSidebar()
let currentHostId = currentServer.hostId == null ? null : currentServer.hostId;

let hosts = `<li class="nav-item mt-2">
<a class="nav-link ${currentHostId == null && currentContainerDetails == null ? "active" : ""} p-0" href="/" data-navigo>
<a class="nav-link ${currentHostId == null && currentContainerDetails == null && currentCluster.clusterId == null ? "active" : ""} p-0" href="/" data-navigo>
<i class="fas fa-tachometer-alt"></i> Dashboard
</a>
</li>`;

$.each(data.clusters, function(i, item){
hosts += `<li data-cluster="${i}" class="c-sidebar-nav-title cluster-title text-success ps-1 pt-2"><u>Cluster ${i}</u></li>`;

hostsTrs += `<tr><td colspan="999" class="bg-success text-center text-white">Cluster ${i}</td></tr>`

hosts += `<li href="/cluster/${i}" class="c-sidebar-nav-title cluster-title text-success pt-2" data-navigo><u>Cluster ${i}</u></li>`
$.each(item.members, function(_, host){
let disabled = "";
let expandBtn = '<button class="btn btn-outline-secondary float-end showServerInstances"><i class="fas fa-caret-left"></i></button>';
Expand All @@ -649,16 +646,21 @@ function createDashboardSidebar()
expandBtn = '';
}

hosts += `<li data-hostId="${host.hostId}" data-alias="${host.alias}" class="nav-item containerList dropdown">
<a class="nav-link ${active} ${disabled}" href="/host/${host.hostId}/overview" data-navigo>
<i class="fas fa-server"></i> ${host.alias}
${expandBtn}
</a>
<div id="${host.hostId}" class="collapse">
<ul class="dropdown-menu dropdown-menu-dark hostInstancesUl">

hosts += `<li class="mb-2" data-hostId="${host.hostId}" data-alias="${host.alias}">
<div>
<a class="nav-link ${active} d-inline ps-0 ${disabled}" href="/host/${host.hostId}/overview" data-navigo>
<i class="fas fa-server"></i> ${host.alias}
</a>
<button class="btn btn-outline-secondary d-inline btn-sm btn-toggle align-items-center rounded collapsed showServerInstances d-inline float-end me-2" data-bs-toggle="collapse" data-bs-target="#host-${host.hostId}" aria-expanded="false">
<i class="fas fa-caret-left"></i>
</button>
</div>
<div class="collapse mt-2 bg-dark text-white" id="host-${host.hostId}">
<ul class="btn-toggle-nav list-unstyled fw-normal pb-1 hostInstancesUl" style="display: inline;">
</ul>
</div>
</li>`;
</li>`
});
});

Expand Down Expand Up @@ -885,9 +887,6 @@ function loadDashboard(){
let projectsDropdown = "";

$.each(data.clustersAndHosts.clusters, function(i, item){

let cTitleClass = userDetails.isAdmin ? "cluster-title" : "cluster-title-not-admin";

projectsDropdown += `<b>Cluster ${i}</b>`

$.each(item.members, function(_, host){
Expand Down Expand Up @@ -1168,17 +1167,6 @@ function loadDashboard(){
});
}

$(document).on("click", ".cluster-title", function(e){
if(!userDetails.isAdmin){
return false;
}
let x = $(this).data();
$("#sidebar-ul").find(".text-info").removeClass("text-info");
$("#sidebar-ul").find(".active").removeClass("active");
$(this).addClass("text-info");
loadClusterView(x.cluster);
});

$(document).on("click", "#openSearch", function(){
$.confirm({
title: `Search`,
Expand Down
1 change: 1 addition & 0 deletions src/views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@

router.on('/instance/:hostId/:instance', loadContainerViewReq);
router.on("/backups", loadBackupsView);
router.on("/cluster/:clusterId", loadClusterView);
router.on("/cloudConfig", loadCloudConfigOverview);
router.on("/cloudConfig/:id", loadCloudConfigView);
router.on("/deployments", loadDeploymentsView);
Expand Down

0 comments on commit 812fb9e

Please sign in to comment.