bhaskar 2 years ago
commit 1602dbbf03

@ -50,6 +50,7 @@
<!----------------**************************---------------------> <!----------------**************************--------------------->
<rapi-doc <rapi-doc
spec-url="http://35.207.198.4:3000/documentation/json" spec-url="http://35.207.198.4:3000/documentation/json"
show-header = 'false' show-header = 'false'
allow-authentication ="true" allow-authentication ="true"
> >

@ -0,0 +1,67 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
.btn{
width: 90px;
height: 32px;
font-size:13px;
background-color: #47AFE8;
color: #fff;
border: none;
margin: 0 2px;
border-radius: 2px;
cursor:pointer;
outline:none;
}
.txt{
width: 100px;
height: 30px;
font-size:13px;
background-color: transparent;
border: 1px solid #47AFE8;
color: #fff;
padding:0 8px;
margin: 0 2px;
border-radius: 2px;
outline:none;
}
rapi-doc{
width:100%;
}
</style>
<script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
<script>
function setApiKey(){
const docEl = document.getElementById('thedoc');
const keyInputEl = document.getElementById('key-val-input');
docEl.setAttribute('api-key-name','Authorization');
docEl.setAttribute('api-key-location','header');
docEl.setAttribute('api-key-value',keyInputEl.value);
}
</script>
</head>
<body>
<!-- Do not commit this file into the server , ignore it by adding it to .gitignore -->
<!----------------**************************--------------------->
<rapi-doc
spec-url="http://35.207.198.35.207.198.44:3000/documentation/json"
show-header = 'false'
allow-authentication ="true"
>
<!--
below html is custom html that adds an input field and a button in header
on clicking the button the 'api-key-value' is set to the value in input box
-->
<!--div slot='header' style='display:flex; margin:0 16px;'>
<input class='txt' id='key' type='text' >
<button class='btn' onclick='setApiKey()' > Set Key </button >
</div-->
</rapi-doc>
</body>
</html>

@ -14,8 +14,9 @@ exports.options = {
}, },
// We have to change this beacause this is running on local // We have to change this beacause this is running on local
// we have to run on this on swagger // we have to run on this on swagger
//host: "localhost:5000", //Devlopemnt host on lcoal //host: "localhost:3000", //Devlopemnt host on lcoal
host: "35.207.198.4:3000", //Production for swagger
host: "35.207.198.4:3000", //Production for swagger
schemes: ["http"], schemes: ["http"],
consumes: ["application/json"], consumes: ["application/json"],
produces: ["application/json"], produces: ["application/json"],

@ -370,51 +370,51 @@ exports.motorAction = async (req, reply) => {
// if(supplier_tank_type==="sump" && receiver_type === "sump"){ if(supplier_tank_type==="sump" && receiver_type === "sump"){
// const receiver_capacity = parseInt(receiver_tank_info.capacity.replace(/,/g, ''), 10) const receiver_capacity = parseInt(receiver_tank_info.capacity.replace(/,/g, ''), 10)
// // console.log(receiver_capacity,"0",receiver_tank_info.tankName) // console.log(receiver_capacity,"0",receiver_tank_info.tankName)
// await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "1" } }); await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "1" } });
// const supplier_tank_info = await Tank.findOne({ customerId ,tankName:supplier_tank,tankLocation:supplier_tank_type}); const supplier_tank_info = await Tank.findOne({ customerId ,tankName:supplier_tank,tankLocation:supplier_tank_type});
// let supplier_waterlevel = parseInt(supplier_tank_info.waterlevel.replace(/,/g, ''), 10) let supplier_waterlevel = parseInt(supplier_tank_info.waterlevel.replace(/,/g, ''), 10)
// let receiver_waterlevel = parseInt(receiver_tank_info.waterlevel.replace(/,/g, ''), 10) let receiver_waterlevel = parseInt(receiver_tank_info.waterlevel.replace(/,/g, ''), 10)
// // console.log(receiver_waterlevel,"1") // console.log(receiver_waterlevel,"1")
// intervals[interval_variable] = setInterval(async function () { intervals[interval_variable] = setInterval(async function () {
// // Calculate new water levels // Calculate new water levels
// const rcvr_info = await Tank.findOne({ customerId ,tankName:receiver_tank,tankLocation:receiver_type}); const rcvr_info = await Tank.findOne({ customerId ,tankName:receiver_tank,tankLocation:receiver_type});
// const supplier_capacity = parseInt(supplier_tank_info.capacity.replace(/,/g, ''), 10) const supplier_capacity = parseInt(supplier_tank_info.capacity.replace(/,/g, ''), 10)
// // Calculate new water levels // Calculate new water levels
// const newWaterLevel = receiver_waterlevel + 300//Math.floor(supplier_waterlevel * 0.1); const newWaterLevel = receiver_waterlevel + 300//Math.floor(supplier_waterlevel * 0.1);
// const newSupplierWaterLevel = Math.min(supplier_capacity, supplier_waterlevel - 300);// Math.floor(supplier_waterlevel * 0.15)); const newSupplierWaterLevel = Math.min(supplier_capacity, supplier_waterlevel - 300);// Math.floor(supplier_waterlevel * 0.15));
// // Check if updating should stop // Check if updating should stop
// if ((newWaterLevel/receiver_capacity)*100 >= 97 || (newWaterLevel/receiver_capacity)*100 >= desired_water_percentage || rcvr_info.motor_status === "0" || (newSupplierWaterLevel/supplier_capacity)*100 <= 5 ) { if ((newWaterLevel/receiver_capacity)*100 >= 97 || (newWaterLevel/receiver_capacity)*100 >= desired_water_percentage || rcvr_info.motor_status === "0" || (newSupplierWaterLevel/supplier_capacity)*100 <= 5 ) {
// clearInterval(intervals[interval_variable]); // Clear the interval for this tank clearInterval(intervals[interval_variable]); // Clear the interval for this tank
// delete intervals[interval_variable]; delete intervals[interval_variable];
// await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "0" } }); await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "0" } });
// console.log("end for" + receiver_tank); console.log("end for" + receiver_tank);
// } else { } else {
// // Update water levels in database // Update water levels in database
// supplier_waterlevel = newSupplierWaterLevel; supplier_waterlevel = newSupplierWaterLevel;
// receiver_waterlevel = newWaterLevel; receiver_waterlevel = newWaterLevel;
// console.log(supplier_waterlevel,"0") console.log(supplier_waterlevel,"0")
// console.log(receiver_waterlevel,"1") console.log(receiver_waterlevel,"1")
// // console.log((newSupplierWaterLevel/supplier_capacity)*100) // console.log((newSupplierWaterLevel/supplier_capacity)*100)
// // console.log((newWaterLevel/receiver_capacity)*100) // console.log((newWaterLevel/receiver_capacity)*100)
// await Promise.all([ await Promise.all([
// Tank.findOneAndUpdate({customerId, tankName: receiver_tank}, { $set: { waterlevel: newWaterLevel } }), Tank.findOneAndUpdate({customerId, tankName: receiver_tank}, { $set: { waterlevel: newWaterLevel } }),
// Tank.findOneAndUpdate({customerId, tankName: supplier_tank}, { $set: { waterlevel: newSupplierWaterLevel } }) Tank.findOneAndUpdate({customerId, tankName: supplier_tank}, { $set: { waterlevel: newSupplierWaterLevel } })
// ]); ]);
// } }
// }, 2000); }, 2000);
// } }

Loading…
Cancel
Save