generated from dwd/boilarplate-astro-tailwind
b5
parent
d920cba449
commit
5d2a3f552e
|
@ -31,6 +31,7 @@
|
|||
<div class="flex flex-col">
|
||||
<label for="category">Category<span class="text-[#580a0a] font-bold">*</span></label>
|
||||
<select name="category" id="category" class="border-2 border-[#580a0a] focus:outline-none focus:border-4 focus:border-[#580a0a] rounded-xl p-2">
|
||||
<option :value="bartaData.category">{{ bartaData.category }}</option>
|
||||
<option value="national">National</option>
|
||||
<option value="politics">Politics</option>
|
||||
<option value="local">Local</option>
|
||||
|
@ -74,7 +75,6 @@
|
|||
<button onclick="callApi(event);" class="bg-[#580a0a] text-white px-4 py-2 rounded-lg">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Upload File | Barta-India">
|
||||
<main>
|
||||
<div class="container mx-auto px-4 flex flex-col space-y-4">
|
||||
<h1>Upload File</h1>
|
||||
<form action="https://apisp.dev2.cicdhosting.com/news/add-file/" method="post" enctype="multipart/form-data">
|
||||
<label for="file">Choose a file:</label>
|
||||
<input type="file" name="file" id="file" required>
|
||||
<br>
|
||||
<input type="submit" value="Upload">
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
// function uploadFile() {
|
||||
// var fileInput = document.getElementById('fileInput');
|
||||
// var file = fileInput.files[0];
|
||||
|
||||
// if (file) {
|
||||
// var formData = new FormData();
|
||||
// formData.append('fileInput', file);
|
||||
|
||||
// fetch('https://apisp.dev2.cicdhosting.com/news/add-file/?action=save', {
|
||||
// method: 'POST',
|
||||
// body: formData
|
||||
// })
|
||||
// .then(response => response.json())
|
||||
// .then(data => {
|
||||
// document.getElementById('status').innerText = data.message;
|
||||
// })
|
||||
// .catch(error => {
|
||||
// console.error('Error:', error);
|
||||
// });
|
||||
// } else {
|
||||
// document.getElementById('status').innerText = 'Please select a file.';
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// function fileUpload(){
|
||||
// let formData = new FormData(document.getElementById('uploadForm'));
|
||||
// fetch(`https://apisp.dev2.cicdhosting.com/news/add-file/?action=save`, {
|
||||
// method: 'POST',
|
||||
// body: formData
|
||||
// })
|
||||
// .then(response => response.json())
|
||||
// .then(data => {
|
||||
// console.log(data);
|
||||
// })
|
||||
// .catch(error => {
|
||||
// console.log('An error occurred', error);
|
||||
// });
|
||||
// }
|
||||
</script>
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
---
|
||||
<Layout title="Upload File | Barta-India">
|
||||
<main>
|
||||
<div class="container mx-auto px-4 flex flex-col space-y-4">
|
||||
<h1>Upload File</h1>
|
||||
<form id="formID">
|
||||
<p class="text-red-500" style="display: none;" id="errorMessage"></p>
|
||||
<p class="text-red-500" style="display: none;" id="errorMessage2"></p>
|
||||
<label for="file">Choose a file:</label>
|
||||
<input type="file" name="file" id="file" required>
|
||||
<br>
|
||||
<input onclick="saveFile(event);" type="submit" value="Upload">
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
function saveFile(event){
|
||||
event.preventDefault();
|
||||
let formID = document.getElementById('formID');
|
||||
let formData = new FormData(formID);
|
||||
fetch(`https://apisp.dev2.cicdhosting.com/upload/`,{
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
.then(data => data.json())
|
||||
.then(data => {
|
||||
if(data.error_code == 8050){
|
||||
document.getElementById('errorMessage').innerHTML = data.error;
|
||||
document.getElementById('errorMessage').style.display = 'block';
|
||||
document.getElementById('errorMessage2').style.display = 'none';
|
||||
}
|
||||
if(data.error_code == 8051){
|
||||
document.getElementById('errorMessage2').innerHTML = data.error;
|
||||
document.getElementById('errorMessage2').style.display = 'block';
|
||||
document.getElementById('errorMessage').style.display = 'none';
|
||||
}
|
||||
|
||||
// console.log(data)
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
})
|
||||
}
|
||||
</script>
|
|
@ -34,6 +34,9 @@ import ImageUpload from "../../components/ImageUpload.vue";
|
|||
<div class="flex flex-col">
|
||||
<textarea required name="systemMessage" id="systemMessage" cols="30" rows="3" class="border-2 border-[#580a0a] focus:outline-none focus:border-4 focus:border-[#580a0a] rounded-xl">provide meta_title within 60 characters, meta_description within 160 characters, short_description within 280 characters, heading within 170 characters in en, bn, hi, zh, es ar all in a json structure no use comma after line ending</textarea>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<input type="file" name="file" id="file ">
|
||||
</div>
|
||||
<div>
|
||||
<button id="genButton" onclick="submitNewsPara(event);" class="bg-[#580a0a] text-white px-4 py-2 rounded-lg" >Genarate</button>
|
||||
</div>
|
||||
|
@ -63,12 +66,11 @@ import ImageUpload from "../../components/ImageUpload.vue";
|
|||
|
||||
function submitNewsPara(event) {
|
||||
event.preventDefault();
|
||||
let genButton = document.getElementById('genButton');
|
||||
let langInput = document.getElementById('language');
|
||||
let loadSection = document.getElementById('loadingSection');
|
||||
let newsData = document.getElementById('newsPara');
|
||||
let formData = new FormData(newsData);
|
||||
loadSection.style.display = 'block';
|
||||
|
||||
fetch(`https://apisp.dev2.cicdhosting.com/_dedicated/dwd/multi-lang/`, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
|
|
Loading…
Reference in New Issue