Update connections.js
This commit is contained in:
@@ -108,6 +108,52 @@ async function loadGiteaRepos() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate Gitea Token
|
||||||
|
async function generateGiteaToken() {
|
||||||
|
const url = document.getElementById('giteaUrl').value;
|
||||||
|
const username = document.getElementById('giteaUsername').value;
|
||||||
|
const password = document.getElementById('giteaPassword').value;
|
||||||
|
const otp = document.getElementById('giteaOtp').value;
|
||||||
|
const tokenField = document.getElementById('giteaToken');
|
||||||
|
|
||||||
|
if (!url || !username || !password) {
|
||||||
|
showError('Please fill in the server URL, username, and password');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const requestData = {
|
||||||
|
url: url,
|
||||||
|
username: username,
|
||||||
|
password: password
|
||||||
|
};
|
||||||
|
|
||||||
|
if (otp) {
|
||||||
|
requestData.otp = otp;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch('/api/admin/generate-gitea-token', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRF-Token': getCsrfToken()
|
||||||
|
},
|
||||||
|
body: JSON.stringify(requestData)
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
tokenField.value = data.token;
|
||||||
|
showSuccess(`Token generated successfully: ${data.name}`);
|
||||||
|
} else {
|
||||||
|
throw new Error(data.message || 'Failed to generate token');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
showError(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test Git Connection
|
// Test Git Connection
|
||||||
async function testGitConnection(provider) {
|
async function testGitConnection(provider) {
|
||||||
const saveModal = new bootstrap.Modal(document.getElementById('saveConnectionModal'));
|
const saveModal = new bootstrap.Modal(document.getElementById('saveConnectionModal'));
|
||||||
|
|||||||
Reference in New Issue
Block a user