100 lines
3.8 KiB
HTML
100 lines
3.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>File Upload and Git Commit</title>
|
|
<!-- jQuery -->
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
<!-- Tailwind CSS -->
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
</head>
|
|
<body class="bg-gray-100 flex items-center justify-center min-h-screen">
|
|
<div class="bg-white p-8 rounded shadow-md w-full max-w-md">
|
|
<h1 class="text-2xl font-bold mb-6">Upload sys02.lib or Archive</h1>
|
|
|
|
<!-- Tabs -->
|
|
<ul class="flex border-b mb-4" id="tabs">
|
|
<li class="-mb-px mr-1">
|
|
<button class="bg-white inline-block py-2 px-4 font-semibold text-blue-600 border-l border-t border-r rounded-t active" data-tab="lib">sys02.lib</button>
|
|
</li>
|
|
<li class="mr-1">
|
|
<button class="bg-white inline-block py-2 px-4 font-semibold text-gray-600 hover:text-blue-600" data-tab="archive">AC software zip</button>
|
|
</li>
|
|
</ul>
|
|
|
|
<form id="uploadForm">
|
|
<!-- sys02.lib Panel -->
|
|
<div id="panel-lib" class="tab-panel mb-4">
|
|
<label class="block text-gray-700">Select sys02.lib file:</label>
|
|
<input type="file" name="file" accept=".lib" class="mt-1 p-2 border border-gray-300 rounded w-full" required>
|
|
</div>
|
|
|
|
<!-- Archive Panel -->
|
|
<div id="panel-archive" class="tab-panel mb-4 hidden">
|
|
<label class="block text-gray-700">Select ZIP archive:</label>
|
|
<input type="file" name="file" accept=".zip" class="mt-1 p-2 border border-gray-300 rounded w-full" required>
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
<label class="block text-gray-700">Commit Message:</label>
|
|
<input type="text" name="commit_msg" class="mt-1 p-2 border border-gray-300 rounded w-full" placeholder="Enter commit message" required>
|
|
</div>
|
|
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">Submit</button>
|
|
</form>
|
|
<div id="result" class="mt-4"></div>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
$(function() {
|
|
// Tab switching
|
|
$('#tabs button').click(function() {
|
|
var tab = $(this).data('tab');
|
|
|
|
// Remove all active styles, apply inactive style
|
|
$('#tabs button')
|
|
.removeClass('text-blue-600 border-l border-t border-r rounded-t')
|
|
.addClass('text-gray-600 hover:text-blue-600');
|
|
|
|
// Add active styles to the clicked tab
|
|
$(this)
|
|
.removeClass('text-gray-600 hover:text-blue-600')
|
|
.addClass('text-blue-600 border-l border-t border-r rounded-t');
|
|
|
|
// Show the panel
|
|
$('.tab-panel').addClass('hidden');
|
|
$('#panel-' + tab).removeClass('hidden');
|
|
|
|
// Enable/disable file inputs
|
|
$('#panel-lib input[type=file]')
|
|
.prop('disabled', tab !== 'lib')
|
|
.prop('required', tab === 'lib');
|
|
$('#panel-archive input[type=file]')
|
|
.prop('disabled', tab !== 'archive')
|
|
.prop('required', tab === 'archive');
|
|
});
|
|
|
|
// Form submit
|
|
$('#uploadForm').on('submit', function(e) {
|
|
e.preventDefault();
|
|
var formData = new FormData(this);
|
|
$.ajax({
|
|
url: '/upload',
|
|
type: 'POST',
|
|
data: formData,
|
|
processData: false,
|
|
contentType: false,
|
|
success: function (response) {
|
|
$('#result').html('<p class="text-green-600">' + response.message + '</p>');
|
|
},
|
|
error: function (xhr) {
|
|
var error = (xhr.responseJSON && xhr.responseJSON.error) ? xhr.responseJSON.error : 'An error occurred';
|
|
$('#result').html('<p class="text-red-600">' + error + '</p><p class="text-red-600">' + xhr.responseJSON.details + '</p>');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |