lxd-dashboard/admin/index.html
matthewalanpenning a0eaaccfc6 v1.2.1
2021-02-02 21:09:35 -05:00

436 lines
No EOL
15 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
<link rel="icon" type="image/png" href="theme/images/logo_light.png">
<title>lxdware - dashboard</title>
<!-- Custom fonts for this template-->
<link href="theme/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
<!-- Custom styles for this template-->
<link href="theme/css/sb-admin-2.css" rel="stylesheet">
<!-- Custom styles for this page -->
<link href="theme/vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
</head>
<body id="page-top">
<!-- Page Wrapper -->
<div id="wrapper">
<!-- Sidebar -->
<ul class="navbar-nav bg-gradient-dark sidebar sidebar-dark accordion" id="accordionSidebar">
<!-- Sidebar - Brand -->
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.html">
<div class="sidebar-brand-icon rotate-n-0">
<img src="theme/images/logo_dark.png" style="width: 2rem;"></img>
<!-- <i class="fas fa-cube" style="width: 2rem;"></i> -->
</div>
<div class="sidebar-brand-text mx-3">LXDWARE</div>
</a>
<!-- Divider -->
<hr class="sidebar-divider">
<!-- Nav Item - Dashboard -->
<li class="nav-item">
<a class="nav-link" href="index.html">
<i class="fas fa-fw fa-server"></i>
<span>Hosts</span></a>
</li>
<!-- Divider -->
<hr class="sidebar-divider d-none d-md-block">
<!-- Sidebar Toggler (Sidebar) -->
<div class="text-center d-none d-md-inline">
<button class="rounded-circle border-0" id="sidebarToggle"></button>
</div>
</ul>
<!-- End of Sidebar -->
<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<!-- Topbar -->
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
<!-- Sidebar Toggle (Topbar) -->
<button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
<i class="fa fa-bars"></i>
</button>
<!-- Topbar Navbar -->
<ul class="navbar-nav ml-auto">
<div class="topbar-divider d-none d-sm-block"></div>
<!-- Nav Item - User Information -->
<li class="nav-item dropdown no-arrow">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="mr-2 d-none d-lg-inline text-gray-600">Admin</span>
</a>
<!-- Dropdown - User Information -->
<div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
<a class="dropdown-item" href="index.html">
<i class="fas fa-server fa-sm fa-fw mr-2 text-gray-400"></i>
Hosts
</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#aboutModal">
<i class="fas fa-info-circle fa-sm fa-fw mr-2 text-gray-400"></i>
About
</a>
<a class="dropdown-item" href="#" onclick="logout()">
<i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i>
Logout
</a>
</div>
</li>
</ul>
</nav>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Remote LXD Hosts</h1>
</div>
<div class="row">
<div class="col-12">
<!-- LXD Host List -->
<div class="card shadow mb-4">
<!-- Card Header - Dropdown -->
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">LXD Hosts</h6>
<div class="dropdown no-arrow">
<a class="dropdown-toggle mr-3" href="#" data-toggle="modal" data-target="#clientCertModal">
View Certificate</a>
<a class="dropdown-toggle mr-3" href="#" data-toggle="modal" data-target="#addLxdModal">
Add Host</a>
<a class="dropdown-toggle mr-2" href="#" data-toggle="modal" data-target="#helpModal" title="Help" aria-hidden="true">
<i class="fas fa-question-circle fa-sm fa-fw"></i></a>
</div>
</div>
<!-- Card Body -->
<div class="card-body">
<div class="row">
<div class="col-12">
<div class="table-responsive">
<table class="table" id="lxdListTable" width="100%" cellspacing="0">
</table>
</div>
</div>
</div>
</div>
</div>
<!-- End LXD Host List -->
</div>
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
<!-- Footer -->
<footer class="sticky-footer bg-white">
<div class="container my-auto">
<div class="copyright text-center my-auto">
<span>Copyright &copy; lxdware.com 2021</span>
</div>
</div>
</footer>
<!-- End of Footer -->
</div>
<!-- End of Content Wrapper -->
</div>
<!-- End of Page Wrapper -->
<!-- Scroll to Top Button-->
<a class="scroll-to-top rounded" href="#page-top">
<i class="fas fa-angle-up"></i>
</a>
<!-- Help Modal-->
<div class="modal fade" id="helpModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Instructions</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12">
<p>Before adding a remote host, first copy the client <a href="#" data-toggle="modal" data-target="#clientCertModal">certificate</a>
and paste it into a new file on your remote LXD server such as <strong><em>lxdware.crt</em></strong>.</p>
<p>Import the certificate on your remote LXD server by running the command: <code>lxc config trust add lxdware.crt</code></p>
<p>For LXD hosts that are not part of a cluster, use the <code>lxc config set core.https_address [::]</code>
command to listen for incoming connections.</p>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Dismiss</button>
</div>
</div>
</div>
</div>
<!-- Client Cert Modal-->
<div class="modal fade" id="clientCertModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">LXD Client Certificate</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12">
<pre><div id="clientCert"></div></pre>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Dismiss</button>
</div>
</div>
</div>
</div>
<!-- Remote Host Modal-->
<div class="modal fade" id="addLxdModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add LXD Remote Host</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<label class="col-3 col-form-label text-right">Address: </label>
<div class="col-7">
<div class="form-group">
<input type="text" class="form-control" id="hostInput" required="required" placeholder="IP address or FQDN of LXD server" name="host">
</div>
</div>
</div>
<div class="row">
<label class="col-3 col-form-label text-right">Port: </label>
<div class="col-7">
<div class="form-group">
<input type="number" class="form-control" id="portInput" required="required" placeholder="8443" value="8443" name="port">
</div>
</div>
</div>
<div class="row">
<label class="col-3 col-form-label text-right">Alias: </label>
<div class="col-7">
<div class="form-group">
<input type="text" class="form-control" id="aliasInput" placeholder="Enter name of server" name="alias">
</div>
</div>
</div>
</div> <!-- End Modal Body-->
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
<a class="btn btn-primary" href="#" onclick="addRemote()" data-dismiss="modal">Submit</a>
</div>
</div>
</div>
</div>
<!-- Delete Remote Host Modal-->
<div class="modal fade" id="removeRemote" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Remove Remote Host</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">Are you sure you want to remove this host?</div>
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
<a class="btn btn-primary" href="#" onclick="removeRemote()" data-dismiss="modal">Yes</a>
</div>
</div>
</div>
</div>
<!-- About Modal-->
<div class="modal fade" id="aboutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">About LXDWARE Dashboard</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12">
<div id="about"></div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Dismiss</button>
</div>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript-->
<script src="theme/vendor/jquery/jquery.min.js"></script>
<script src="theme/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="theme/vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Custom scripts for all pages-->
<script src="theme/js/sb-admin-2.min.js"></script>
<!-- Page level plugins -->
<script src="theme/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="theme/vendor/datatables/dataTables.bootstrap4.min.js"></script>
</body>
<script>
function logout(){
var http = new XMLHttpRequest();
http.open("get", "../admin/index.html", false, "null", "null");
http.send("");
window.location.replace("../index.html");
}
function reloadPageContent() {
$('#lxdListTable').DataTable().ajax.reload(null, false);
}
function loadPageContent(){
//Check Authorization
$.get("./php/auth/auth-check.php", function (data) {
if (data != "true") {
window.location.replace("../index.html");
}
});
$('#lxdListTable').DataTable( {
ajax: "./php/lxd/remote-list.php",
columns: [
{},
{ title: "Host" },
{ title: "Port" },
{ title: "Alias" },
{ title: "Protocol" },
{ title: "Action" }
],
order: [],
columnDefs: [
{ targets: 0, orderable: false, width: "25px" }
]
});
//Load the basic info for the certificate
$.get("./php/lxd/lxc-cert.php", function (data) {
$("#clientCert").html(data);
});
//Set the page content to reload in 5 seconds
setInterval(() => { reloadPageContent(); }, 5000);
}
function addRemote(){
var hostName = $("#hostInput").val();
var portNumber = $("#portInput").val();
var aliasName = $("#aliasInput").val();
console.log("Info: adding remote host " + hostName + ":" + portNumber);
$.get("./php/lxd/remotes.php?host=" + encodeURI(hostName) + "&port=" + encodeURI(portNumber) + "&alias=" + encodeURI(aliasName) + "&action=addRemote", function (data) {
console.log(data);
if (data.substring(0, 5) == "Error"){
alert(data);
}
setTimeout(() => { reloadPageContent(); }, 1000);
});
}
function removeRemote(remoteID){
console.log("Info: removing remote host, id number " + remoteID);
$.get("./php/lxd/remotes.php?id=" + encodeURI(remoteID) + "&action=removeRemote", function (data) {
console.log(data);
if (data.substring(0, 5) == "Error"){
alert(data);
}
setTimeout(() => { reloadPageContent(); }, 1000);
});
}
$(document).ready(function(){
//Load the card contents
loadPageContent();
//Load the about info for the about modal
$.get("./about.html", function (data) {
$("#about").html(data);
});
});
</script>
</html>