Clean + adjusting client layer

This commit is contained in:
Hepatica
2024-08-18 06:36:39 +02:00
parent 74abaf534b
commit ef3ccfa686
7 changed files with 1011 additions and 54 deletions

446
Client/index.html Normal file
View File

@@ -0,0 +1,446 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SpCloud</title>
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<div id="globalLoading" class="loading-overlay">
<div class="loading-spinner"></div>
</div>
<div class="container">
<div id="uploadModal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2>Загрузить новое приложение</h2>
<div class="upload-section-modal">
<div class="upload-info">
<label for="appName">App Name:</label>
<input type="text" id="appName" name="appName" required>
<label for="appTarget">Target:</label>
<select id="appTarget" name="appTarget" required>
<option value="dotnet network">dotnet asp</option>
<option value="dotnet">dotnet</option>
</select>
</div>
<div class="upload-window">
<input type="file" id="fileInput" name="fileInput" accept=".rar" required>
<p>SpCloud support only rar</p>
</div>
<button id="uploadBtn" class="upload-button-modal">Загрузить</button>
</div>
</div>
</div>
<!-- Update Modal -->
<div id="updateModal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2>Обновить приложение</h2>
<div class="upload-section-modal">
<div class="upload-info">
<label for="updateAppName">App Name:</label>
<select id="updateAppName" name="updateAppName" required>
<option value="" disabled selected>Выберите приложение</option>
<!-- Options will be dynamically populated -->
</select>
</div>
<div class="upload-window">
<input type="file" id="updateFileInput" name="updateFileInput" accept=".rar" required>
<p>SpCloud support only rar</p>
</div>
<button id="updateBtn" class="upload-button-modal">Обновить</button>
</div>
</div>
</div>
<!-- Delete Modal -->
<div id="deleteModal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2>Удалить приложение</h2>
<div class="upload-section-modal">
<div class="upload-info">
<label for="deleteAppName">App Name:</label>
<select id="deleteAppName" name="deleteAppName" required>
<option value="" disabled selected>Выберите приложение</option>
<!-- Options will be dynamically populated -->
</select>
</div>
<button id="deleteBtn" class="upload-button-modal">Удалить</button>
</div>
</div>
</div>
<header>
<h1>SpCloud</h1>
<div class="user-panel">
<button class="register-button"
onclick="window.location.href='https://discord.com/oauth2/authorize?client_id=1273414933874479185&response_type=code&redirect_uri=https%3A%2F%2Fspcloud.almavid.ru&scope=identify';">Sign
in</button>
<p class="username"></p>
</div>
</header>
<div class="upload-section">
<h2>Окно для загрузки архива приложения</h2>
<div class="buttons">
<button class="upload-button">Загрузить новое приложение</button>
<button class="update-button">Обновить приложение</button>
<button class="delete-button">Удалить своё приложение</button>
</div>
</div>
<div class="server-stats">
<table>
<tr>
<th>Name</th>
<th>AppUrl</th>
<th>CpuUsage</th>
<th>MemoryUsage</th>
<th>Target</th>
</tr>
<!-- Dynamic content will be inserted here -->
</table>
</div>
<div class="server-stats">
<h3>Нагрузка сервера в данный момент</h3>
<p>CPU/RAM/Memory (N/A)</p>
</div>
<footer>
<a href="https://www.youtube.com/watch?v=rUxyKA_-grg">Как пользоваться SpCloud:
https://www.youtube.com/watch?v=rUxyKA_-grg</a>
</footer>
</div>
<script src="scripts.js"></script>
<style>
/* Global Loading Overlay */
.loading-overlay {
display: none; /* Hidden by default */
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background */
z-index: 9999; /* Ensure it's on top of other elements */
justify-content: center;
align-items: center;
}
/* Loading Spinner */
.loading-spinner {
border: 16px solid #f3f3f3; /* Light grey */
border-top: 16px solid #3498db; /* Blue */
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
}
/* Spinner Animation */
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Modal Styles */
.modal {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
/* Enable scroll if needed */
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.4);
/* Black w/ opacity */
}
.modal-content {
background-color: #81d4fa;
margin: 15% auto;
/* 15% from the top and centered */
padding: 20px;
border: 1px solid #888;
width: 50%;
/* Could be more or less, depending on screen size */
border-radius: 10px;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
.upload-section-modal {
text-align: center;
padding: 20px;
background-color: #0288d1;
border-radius: 10px;
}
.upload-info {
margin-bottom: 20px;
}
.upload-info span {
display: inline-block;
margin: 10px;
background-color: #1976d2;
color: white;
padding: 10px;
border-radius: 5px;
}
.upload-window {
background-color: #067ad9;
margin: 0 auto;
border-radius: 5px;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
margin-bottom: 20px;
}
.upload-button-modal {
background-color: #4caf50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
.upload-info select {
padding: 10px;
margin: 10px 0;
border-radius: 5px;
border: none;
background-color: #1976d2;
color: white;
}
body {
font-family: Arial, sans-serif;
background-color: #b3e5fc;
color: #fff;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
width: 80%;
height: 90%;
background-color: #0288d1;
padding: 20px;
border-radius: 10px;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
h1 {
margin: 0;
}
.user-panel {
display: flex;
align-items: center;
justify-content: flex-end;
text-align: right;
}
.register-button {
background-color: #000;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin-left: 10px;
/* Space between the button and username */
}
.username {
margin: 20px;
}
.upload-section {
background-color: #81d4fa;
padding: 20px;
border-radius: 10px;
text-align: center;
margin-bottom: 20px;
}
.upload-section h2 {
margin-top: 0;
}
.buttons {
margin-bottom: 20px;
}
.buttons button {
padding: 10px 20px;
margin: 5px;
border: none;
border-radius: 5px;
cursor: pointer;
}
.upload-button {
background-color: #4caf50;
color: white;
}
.update-button {
background-color: #1976d2;
color: white;
}
.delete-button {
background-color: #d32f2f;
color: white;
}
.upload-window {
background-color:#067ad9;
margin: 0 auto;
border-radius: 5px;
}
.server-stats {
text-align: center;
margin-bottom: 20px;
max-height: 300px;
/* Add a max height for the scroll */
overflow-y: auto;
/* Enable vertical scrolling */
}
table {
width: 100%;
margin-top: 10px;
border-collapse: collapse;
background-color: #000;
color: #fff;
}
table th,
table td {
border: 1px solid #fff;
padding: 10px;
text-align: center;
}
footer {
text-align: center;
}
footer a {
color: #fff;
text-decoration: underline;
}
</style>
</html>

492
Client/scripts.js Normal file
View File

@@ -0,0 +1,492 @@
function fetchAndDisplayAppNamesForDelete() {
const myHeaders = new Headers();
myHeaders.append("Authorization", getCookie("auth_token"));
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("https://spcloudcore.almavid.ru/apps", requestOptions)
.then((response) => response.json())
.then((result) => {
const apps = result.documents;
const appNameSelect = document.getElementById('deleteAppName');
// Clear existing options
appNameSelect.innerHTML = '<option value="" disabled selected>Выберите приложение</option>';
// Populate the select dropdown with app names
apps.forEach(app => {
const option = document.createElement('option');
option.value = app.name;
option.textContent = app.name;
appNameSelect.appendChild(option);
});
})
.catch((error) => console.error('Error:', error));
}
// Open Delete Modal and populate app names
document.querySelector('.delete-button').addEventListener('click', function () {
fetchAndDisplayAppNamesForDelete();
document.getElementById('deleteModal').style.display = "block";
});
// Close Delete Modal
document.querySelector('#deleteModal .close').onclick = function () {
document.getElementById('deleteModal').style.display = "none";
}
// Handle Deletion
document.getElementById("deleteBtn").addEventListener("click", function () {
showLoading();
var deleteAppName = document.getElementById("deleteAppName").value;
if (!deleteAppName) {
alert("Please select an application to delete.");
return;
}
var userConfirmed = confirm("Are you sure you want to delete the application '" + deleteAppName + " ?");
if (!userConfirmed) {
alert("Application deletion cancelled.");
return;
}
const myHeaders = new Headers();
myHeaders.append("Authorization", getCookie("auth_token"));
const formdata = new FormData();
formdata.append("UserId", getCookie("discord_id"));
formdata.append("Name", deleteAppName);
const requestOptions = {
method: "DELETE",
headers: myHeaders,
body: formdata,
redirect: "follow"
};
fetch("https://spcloudcore.almavid.ru/delete", requestOptions)
.then((response) => response.text())
.then((result) => {
hideLoading();
console.log(result);
alert(result);
fetchAndDisplayAppData();
document.getElementById('deleteModal').style.display = "none"; // Close the modal after successful deletion
})
.catch((error) => {
hideLoading();
console.error(error);
alert("Error deleting application.");
});
});
function showLoading() {
document.getElementById('globalLoading').style.display = 'flex';
}
function hideLoading() {
document.getElementById('globalLoading').style.display = 'none';
}
// Get the modal
function fetchAndDisplayAppNames() {
const myHeaders = new Headers();
myHeaders.append("Authorization", getCookie("auth_token"));
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("https://spcloudcore.almavid.ru/apps", requestOptions)
.then((response) => response.json())
.then((result) => {
const apps = result.documents;
const appNameSelect = document.getElementById('updateAppName');
// Clear existing options
appNameSelect.innerHTML = '<option value="" disabled selected>Выберите приложение</option>';
// Populate the select dropdown with app names
apps.forEach(app => {
const option = document.createElement('option');
option.value = app.name;
option.textContent = app.name;
appNameSelect.appendChild(option);
});
})
.catch((error) => console.error('Error:', error));
}
// Get the update modal
var updateModal = document.getElementById("updateModal");
// Get the button that opens the update modal
var updateBtnOpen = document.querySelector('.update-button');
document.querySelector('.update-button').addEventListener('click', function () {
fetchAndDisplayAppNames();
document.getElementById('updateModal').style.display = "block";
});
// Get the <span> element that closes the update modal
var updateSpanClose = updateModal.querySelector('.close');
// When the user clicks the button, open the update modal
updateBtnOpen.onclick = function () {
updateModal.style.display = "block";
}
// When the user clicks on <span> (x), close the update modal
updateSpanClose.onclick = function () {
updateModal.style.display = "none";
}
// When the user clicks anywhere outside of the update modal, close it
window.onclick = function (event) {
if (event.target == updateModal) {
updateModal.style.display = "none";
}
}
// Form submission logic for updating the application
document.getElementById("updateBtn").addEventListener("click", function () {
showLoading();
var updateFileInput = document.getElementById("updateFileInput");
var updateAppName = document.getElementById("updateAppName").value;
if (updateFileInput.files.length === 0) {
alert("Please select a file.");
return;
}
const myHeaders = new Headers();
myHeaders.append("Authorization", getCookie("auth_token"));
const formdata = new FormData();
formdata.append("File", updateFileInput.files[0]);
formdata.append("UserId", getCookie("discord_id"));
formdata.append("Name", updateAppName);
const requestOptions = {
method: "PUT",
headers: myHeaders,
body: formdata,
redirect: "follow"
};
fetch("https://spcloudcore.almavid.ru/update", requestOptions)
.then((response) => response.text())
.then((result) => {
hideLoading();
console.log(result);
alert(result);
fetchAndDisplayAppData();
updateModal.style.display = "none";
})
.catch((error) => {
hideLoading();
console.error(error);
alert("Error updating application.");
});
});
var modal = document.getElementById("uploadModal");
// Get the button that opens the modal
var btn = document.querySelector('.upload-button');
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function () {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function () {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
document.getElementById("uploadBtn").addEventListener("click", function () {
showLoading();
var fileInput = document.getElementById("fileInput");
var appName = document.getElementById("appName").value;
var appTarget = document.getElementById("appTarget").value;
if (fileInput.files.length === 0) {
alert("Please select a file.");
return;
}
const myHeaders = new Headers();
myHeaders.append("Authorization", getCookie("auth_token"));
const formdata = new FormData();
formdata.append("File", fileInput.files[0]);
formdata.append("UserId", getCookie("discord_id"));
formdata.append("Name", appName);
formdata.append("Target", appTarget);
const requestOptions = {
method: "POST",
headers: myHeaders,
body: formdata,
redirect: "follow"
};
fetch("https://spcloudcore.almavid.ru/publish", requestOptions)
.then((response) => response.text())
.then((result) => {
hideLoading();
alert(result);
fetchAndDisplayAppData();
modal.style.display = "none";
})
.catch((error) => {
hideLoading();
console.error(error);
alert("Error uploading file.");
});
});
function getQueryParam(param) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}
const code = getQueryParam('code');
if (code) {
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
const raw = JSON.stringify({
"code": code
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://spcloudcore.almavid.ru/login", requestOptions)
.then(response => response.json())
.then(result => {
const discordId = result.document.discord_id;
const authToken = result.document.auth_token;
const username = result.document.username;
setCookie("discord_id", discordId, 730);
setCookie("auth_token", authToken, 730);
setCookie("username", username, 730);
console.log("Cookies set: discord_id and auth_token");
displayUsername(username);
})
.catch(error => console.error('Error:', error));
}
function setCookie(name, value, days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); // Convert days to milliseconds
const expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/";
}
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
function fetchAndDisplayAppData() {
const myHeaders = new Headers();
myHeaders.append("Authorization", getCookie("auth_token"));
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("https://spcloudcore.almavid.ru/apps", requestOptions)
.then((response) => response.json())
.then((result) => {
const apps = result.documents;
const table = document.querySelector('.server-stats table');
// Clear existing table rows (except headers)
table.querySelectorAll('tr:not(:first-child)').forEach(row => row.remove());
// Loop through each app and create a new table row
apps.forEach(app => {
const row = table.insertRow();
const nameCell = row.insertCell(0);
const urlCell = row.insertCell(1);
const cpuUsageCell = row.insertCell(2);
const memoryUsageCell = row.insertCell(3);
const targetCell = row.insertCell(4);
// Populate cells with app data
nameCell.textContent = app.name; // Ensure the name is displayed
urlCell.textContent = app.url;
cpuUsageCell.textContent = "N/A"; // Placeholder as no CPU usage info is provided
memoryUsageCell.textContent = "N/A"; // Placeholder as no Memory usage info is provided
targetCell.textContent = app.target; // Assuming all services are active as status is not provided
});
})
.catch((error) => console.error('Error:', error));
}
fetchAndDisplayAppData();
function displayUsername(username) {
const usernameElement = document.querySelector('.username');
if (usernameElement) {
usernameElement.textContent = username;
}
}
const storedUsername = getCookie("username");
if (storedUsername) {
displayUsername(storedUsername);
}

View File

@@ -1,6 +1,6 @@
<mxfile host="Electron" modified="2024-08-16T21:20:37.157Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/23.0.2 Chrome/120.0.6099.109 Electron/28.1.0 Safari/537.36" etag="PSu86GYPCNH2GZ5_TS_U" version="23.0.2" type="device">
<mxfile host="Electron" modified="2024-08-18T04:29:53.933Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/23.0.2 Chrome/120.0.6099.109 Electron/28.1.0 Safari/537.36" etag="0jojfn5qSBAhfaUR8JPi" version="23.0.2" type="device">
<diagram name="Page-1" id="Amrm0kvx0odSU5wdFRfC">
<mxGraphModel dx="1024" dy="597" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<mxGraphModel dx="1593" dy="929" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
@@ -56,25 +56,25 @@
<mxGeometry y="90" width="190" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-12" value="&lt;div style=&quot;color: rgb(248, 248, 242); background-color: rgb(33, 33, 33); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 18px;&quot;&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;target&quot;&lt;/span&gt;&lt;span style=&quot;color: #dcdcdc;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;dotnet-6-console&quot;,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&quot;appName&quot;&lt;span style=&quot;color: rgb(220, 220, 220);&quot;&gt;:&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: rgb(206, 145, 120);&quot;&gt;&quot;TestApp&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcdc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="328" y="510" width="222" height="140" as="geometry" />
<mxGeometry x="328" y="490" width="222" height="140" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-14" value="&amp;nbsp;Юзер получает статус загрузки своего приложения и айпи (если приложение должно работать с интернетом)" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="755" y="400" width="150" height="100" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-15" value="&lt;div style=&quot;background-color: rgb(33, 33, 33); line-height: 18px;&quot;&gt;&lt;div style=&quot;color: rgb(248, 248, 242); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: rgb(248, 248, 242); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&quot;status&quot;&lt;span style=&quot;color: rgb(220, 220, 220);&quot;&gt;:&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: rgb(206, 145, 120);&quot;&gt;&quot;success&quot;,&lt;/span&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;font face=&quot;IBMPlexMono, Courier New, monospace, Consolas, Courier New, monospace&quot; color=&quot;#f8f8f2&quot;&gt;&amp;nbsp; &lt;/font&gt;&lt;span style=&quot;color: rgb(156, 220, 254); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(220, 220, 220); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;:&lt;/span&gt; &lt;font face=&quot;IBMPlexMono, Courier New, monospace, Consolas, Courier New, monospace&quot; color=&quot;#ce9178&quot;&gt;&quot;https://test.almavid.ru&quot;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;color: rgb(248, 248, 242); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;/div&gt;" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="725" y="490" width="255" height="150" as="geometry" />
<mxGeometry x="690" y="490" width="255" height="150" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-17" value="SpСloud UI" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="355" y="700" width="160" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-18" value="" style="html=1;whiteSpace=wrap;strokeColor=none;fillColor=#0079D6;labelPosition=center;verticalLabelPosition=middle;verticalAlign=top;align=center;fontSize=12;outlineConnect=0;spacingTop=-6;fontColor=#FFFFFF;sketch=0;shape=mxgraph.sitemap.page;" parent="1" vertex="1">
<mxGeometry x="120" y="690" width="630" height="950" as="geometry" />
<mxGeometry x="120" y="610" width="630" height="950" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-21" value="Зарегистрироваться" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="610" y="760" width="130" height="30" as="geometry" />
<mxGeometry x="610" y="630" width="130" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-22" value="Ник пользователя" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="645" y="800" width="60" height="30" as="geometry" />
<mxGeometry x="645" y="670" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-23" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;Нагрузка сервера в данный момент CPU/RAM/Memory&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="368.75" y="1190" width="145" height="50" as="geometry" />
@@ -119,7 +119,7 @@
<mxGeometry x="453.75" y="1260" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-40" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;Окно для загрузки архива приложения&amp;nbsp;&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="335" y="940" width="200" height="30" as="geometry" />
<mxGeometry x="335" y="840" width="200" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-41" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;Ссылка на видео гайд&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="335" y="1470" width="200" height="30" as="geometry" />
@@ -149,10 +149,10 @@
<mxGeometry y="120" width="140" height="70" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-51" value="" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="359" y="1020" width="160" height="160" as="geometry" />
<mxGeometry x="345" y="940" width="180" height="180" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-52" value="&lt;font style=&quot;font-size: 41px;&quot;&gt;SpСloud&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="409" y="830" width="60" height="30" as="geometry" />
<mxGeometry x="409" y="705" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-53" value="App" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="1170" y="830" width="220" height="180" as="geometry" />
@@ -160,26 +160,74 @@
<mxCell id="vamjHUPJP5RwR4Vbvad3-55" value="Name" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-53" vertex="1">
<mxGeometry y="30" width="220" height="30" as="geometry" />
</mxCell>
<mxCell id="siBud0lxFuAxErJTvobO-3" value="UserId" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" vertex="1" parent="vamjHUPJP5RwR4Vbvad3-53">
<mxCell id="siBud0lxFuAxErJTvobO-3" value="UserId" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-53" vertex="1">
<mxGeometry y="60" width="220" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-56" value="Url" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-53" vertex="1">
<mxGeometry y="90" width="220" height="30" as="geometry" />
</mxCell>
<mxCell id="siBud0lxFuAxErJTvobO-1" value="UrlLocalMachine" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" vertex="1" parent="vamjHUPJP5RwR4Vbvad3-53">
<mxCell id="siBud0lxFuAxErJTvobO-1" value="UrlLocalMachine" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-53" vertex="1">
<mxGeometry y="120" width="220" height="30" as="geometry" />
</mxCell>
<mxCell id="siBud0lxFuAxErJTvobO-2" value="Target" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" vertex="1" parent="vamjHUPJP5RwR4Vbvad3-53">
<mxCell id="siBud0lxFuAxErJTvobO-2" value="Target" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-53" vertex="1">
<mxGeometry y="150" width="220" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-58" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="vamjHUPJP5RwR4Vbvad3-49" target="vamjHUPJP5RwR4Vbvad3-55" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="siBud0lxFuAxErJTvobO-5" value="Обновить текущее приложение&amp;nbsp;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="365" y="980" width="60" height="30" as="geometry" />
<mxCell id="siBud0lxFuAxErJTvobO-5" value="Обновить текущее приложение&amp;nbsp;" style="text;html=1;strokeColor=#001DBC;fillColor=#0050ef;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="400" y="872.5" width="70" height="55" as="geometry" />
</mxCell>
<mxCell id="siBud0lxFuAxErJTvobO-6" value="Загрузить новое приложение&amp;nbsp;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="450" y="980" width="60" height="30" as="geometry" />
<mxCell id="siBud0lxFuAxErJTvobO-6" value="Загрузить новое приложение&amp;nbsp;" style="text;html=1;strokeColor=#2D7600;fillColor=#60a917;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="328" y="870" width="60" height="60" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-1" value="Удалить своё приложение" style="text;html=1;strokeColor=#6F0000;fillColor=#a20025;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#ffffff;" vertex="1" parent="1">
<mxGeometry x="480" y="872.5" width="70" height="55" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-3" value="Загрузить новое приложение&amp;nbsp;" style="text;html=1;strokeColor=#2D7600;fillColor=#60a917;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#ffffff;" vertex="1" parent="1">
<mxGeometry x="1170" y="1080" width="240" height="160" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-4" value="" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#1ba1e2;strokeColor=#006EAF;fontColor=#ffffff;" vertex="1" parent="1">
<mxGeometry x="1030" y="1250" width="520" height="520" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-5" value="App name: Test" style="text;html=1;strokeColor=#001DBC;fillColor=#0050ef;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#ffffff;" vertex="1" parent="1">
<mxGeometry x="1090" y="1290" width="150" height="30" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-7" value="App type: dotnet console" style="text;html=1;strokeColor=#001DBC;fillColor=#0050ef;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#ffffff;" vertex="1" parent="1">
<mxGeometry x="1340" y="1290" width="150" height="30" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-8" value="File input (SpCloud support only rar)" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="1200" y="1410" width="180" height="180" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-9" value="Удалить своё приложение" style="text;html=1;strokeColor=#6F0000;fillColor=#a20025;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#ffffff;" vertex="1" parent="1">
<mxGeometry x="1200" y="1860" width="192.5" height="160" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-22" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#1ba1e2;fontColor=#ffffff;strokeColor=#006EAF;" vertex="1" parent="1">
<mxGeometry x="1036.88" y="2030" width="518.75" height="203.75" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-11" value="App name: Test" style="text;html=1;strokeColor=#001DBC;fillColor=#0050ef;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#ffffff;strokeWidth=2;perimeterSpacing=1;" vertex="1" parent="1">
<mxGeometry x="1100" y="2050" width="150" height="30" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-15" value="Загрузить" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#60a917;fontColor=#ffffff;strokeColor=#2D7600;" vertex="1" parent="1">
<mxGeometry x="1180" y="1620" width="220" height="60" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-16" value="Удалить" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#a20025;fontColor=#ffffff;strokeColor=#6F0000;" vertex="1" parent="1">
<mxGeometry x="1190" y="2110" width="220" height="60" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-23" value="Обновить текущее приложение&amp;nbsp;" style="text;html=1;strokeColor=#001DBC;fillColor=#0050ef;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#ffffff;" vertex="1" parent="1">
<mxGeometry x="1202.5" y="2280" width="195" height="180" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-24" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#1ba1e2;fontColor=#ffffff;strokeColor=#006EAF;" vertex="1" parent="1">
<mxGeometry x="1040.62" y="2470" width="518.75" height="520" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-25" value="App name: Test" style="text;html=1;strokeColor=#001DBC;fillColor=#0050ef;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#ffffff;strokeWidth=2;perimeterSpacing=1;" vertex="1" parent="1">
<mxGeometry x="1110" y="2490" width="150" height="30" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-26" value="Обновить" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#60a917;fontColor=#ffffff;strokeColor=#2D7600;" vertex="1" parent="1">
<mxGeometry x="1186.26" y="2750" width="220" height="60" as="geometry" />
</mxCell>
<mxCell id="z0wMfMEwee2VdXHU60ub-27" value="File input (SpCloud support only rar)" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="1206.25" y="2550" width="180" height="180" as="geometry" />
</mxCell>
</root>
</mxGraphModel>

View File

@@ -45,9 +45,9 @@ public:
file_processing->unzip(filename, this->publish_app_path + app_final_file_path);
check_port_and_increase_if_not_available();
check_port_and_increase_if_not_available();//
file_processing->adjust_nginx_configuration_and_reloud(app->get_name(), std::to_string(last_available_port));
file_processing->adjust_nginx_configuration_and_reloud(app->get_name(), std::to_string(last_available_port));//
file_processing->create_service_file(this->publish_app_path, app_final_file_path, std::to_string(last_available_port));
@@ -63,9 +63,9 @@ public:
file_processing->delete_file(filename);
app->set_url("https://" + app->get_name() + ".almavid.ru/");
app->set_url("https://" + app->get_name() + ".almavid.ru/");//
app->set_url_on_local_machine("http://localhost:" + std::to_string(last_available_port));
app->set_url_on_local_machine("http://localhost:" + std::to_string(last_available_port));//
app->set_service_name(app_final_file_path);

View File

@@ -27,7 +27,7 @@ public:
"--data-urlencode \"client_secret=S_vG4frjIxWoi8mic_GlcxUO0aWxXwRJ\" "
"--data-urlencode \"grant_type=authorization_code\" "
"--data-urlencode \"code=" + auth_code_processed + "\" "
"--data-urlencode \"redirect_uri=https://www.sp-donate.ru/pay/Hepatir\"";
"--data-urlencode \"redirect_uri=https://spcloud.almavid.ru\"";
auto code_request = std::async(std::launch::async, &DiscordService::execute_command, this, command);

View File

@@ -247,49 +247,20 @@ public:
serviceFile << "[Service]\n";
serviceFile << "ExecStart=" << exec_start_command << "\n";
//serviceFile << "ExecStart=/usr/bin/dotnet /home/danilt2000/SpCloud/" + name + "/" + dll_file_name + "\n";
//serviceFile << "ExecStart=/home/danilt2000/SpCloud/SpCloudMain/build/SpCloudMain\n";
serviceFile << "WorkingDirectory=/home/danilt2000/SpCloud/" + name + "\n";
//serviceFile << "WorkingDirectory=/home/danilt2000/SpCloud/SpCloudMain/build\n";
serviceFile << "Restart=always\n";
serviceFile << "User=danilt2000\n";
serviceFile << "Environment=ASPNETCORE_URLS=http://0.0.0.0:" + port + "\n";
serviceFile << "Environment=PATH=/usr/bin\n";
serviceFile << "Environment=NODE_ENV=production\n\n";
serviceFile << "[Install]\n";
serviceFile << "WantedBy=multi-user.target\n";
//Todo check service ->sudo systemctl status <service-name>.service
serviceFile.close();
//std::string command_reload = "sudo systemctl daemon-reload";
///*std::thread commandThreadReload(&CommandService::execute_command, command_reload);
//commandThreadReload.join();*/
//std::string command_enable = "sudo systemctl enable " + name + ".service";
//std::string command_start = "sudo systemctl start " + name + ".service";
////std::thread commandThreadStart(&CommandService::execute_command, commandThreadStart);
////commandThreadStart.join();
//auto request_reload = std::async(std::launch::async, &FileProcessingService::execute_command, this, command_reload);
//std::string response_reload = request_reload.get();
//auto request_enable = std::async(std::launch::async, &FileProcessingService::execute_command, this, command_enable);
//std::string response_enable = request_enable.get();
//auto request_start = std::async(std::launch::async, &FileProcessingService::execute_command, this, command_start);
//std::string response_start = request_start.get();
std::string command_reload = "sudo systemctl daemon-reload";
std::string command_enable = "sudo systemctl enable " + name + ".service";
std::string command_start = "sudo systemctl start " + name + ".service";

View File

@@ -81,7 +81,7 @@ int main()
mongo_service.increase_user_app_count_(app->get_user_id());
res.set_content("App is running on address:" + app->get_url(), "text/plain");
res.set_content("App is running " + app->get_url(), "text/plain");
delete app;
});