This commit is contained in:
Leo 2024-01-27 16:59:14 +08:00
parent 54e2987762
commit c3ffbc00af
2 changed files with 3 additions and 101 deletions

View File

@ -6,8 +6,8 @@ const fs = require('fs');
const sequelize = new Sequelize(
"eco_saver",
"DB_USER='mpuser",
"DB_PASS='majorprojectpassword1234!",
process.env.DB_USER,
process.env.DB_PASS,
{
host: "mpsqldatabasean.mysql.database.azure.com",
dialect: 'mysql',
@ -15,7 +15,7 @@ const sequelize = new Sequelize(
attributeBehavior: 'escape',
dialectOptions: {
ssl: {
ca: fs.readFileSync(path.resolve(__dirname, '../cert/DigiCertGlobalRootCA.crt_3.pem')),
ca: fs.readFileSync(path.resolve(__dirname, '../cert/DigiCertGlobalRootCA.crt.pem')),
},
},

View File

@ -1,98 +0,0 @@
function generateKey() {
// Create the overlay dynamically
var overlay = document.createElement('div');
overlay.className = 'overlay';
// Create the small screen dynamically
var generateKeyScreen = document.createElement('div');
generateKeyScreen.className = 'generate-key-screen';
// Generate random public and private keys
var publicKey = generateRandomKey();
var privateKey = generateRandomKey();
// Add input fields for Name, Public Key, Private Key, Key Type, and Created
generateKeyScreen.innerHTML = `
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br>
<label for="publicKey">Public Key:</label>
<input type="text" id="publicKey" name="publicKey" value="${publicKey}" readonly>
<button onclick="copyToClipboard('publicKey')">Copy</button><br>
<label for="privateKey">Private Key:</label>
<input type="text" id="privateKey" name="privateKey" value="${privateKey}" readonly>
<button onclick="copyToClipboard('privateKey')">Copy</button><br>
<label for="created">Created:</label>
<input type="text" id="created" name="created" value="${getCurrentDate()}" readonly><br>
<button onclick="saveKey()">Save Key</button>
<button onclick="closeGenerateKey()">Close</button>
`;
// Append the overlay and small screen to the body
document.body.appendChild(overlay);
document.body.appendChild(generateKeyScreen);
// Display the overlay and small screen
overlay.style.display = 'block';
generateKeyScreen.style.display = 'block';
}
function generateRandomKey() {
// Generate a random string as a key (you might want to use a more robust key generation method)
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
}
function getCurrentDate() {
// Get the current date and format it as 'YYYY-MM-DD'
return new Date().toISOString().split('T')[0];
}
function copyToClipboard(elementId) {
// Copy the text from the specified input field to the clipboard
var element = document.getElementById(elementId);
element.select();
document.execCommand('copy');
// Optionally, you can provide feedback to the user (e.g., display a tooltip)
alert('Copied to clipboard: ' + element.value);
}
function saveKey() {
// Retrieve values from input fields
var name = document.getElementById('name').value;
var publicKey = document.getElementById('publicKey').value;
var privateKey = document.getElementById('privateKey').value;
var created = document.getElementById('created').value;
// Create a new table row with the key information
var newRow = document.createElement('tr');
newRow.innerHTML = `
<td>${name}</td>
<td>${publicKey}</td>
<td>${privateKey}</td>
<td>${created}</td>
`;
// Append the new row to the table body
var tableBody = document.querySelector('#content-get-api tbody');
tableBody.appendChild(newRow);
// Optionally, you can close the small screen
closeGenerateKey();
}
function closeGenerateKey() {
var overlay = document.querySelector('.overlay');
var generateKeyScreen = document.querySelector('.generate-key-screen');
// Hide and remove the overlay and small screen from the DOM
overlay.style.display = 'none';
generateKeyScreen.style.display = 'none';
document.body.removeChild(overlay);
document.body.removeChild(generateKeyScreen);
}