add dashboard for testing
This commit is contained in:
parent
cae03f0e30
commit
8e5421ed17
5 changed files with 100 additions and 8 deletions
4
app.js
4
app.js
|
|
@ -36,7 +36,7 @@ app
|
|||
.use(express.json())
|
||||
.use(express.urlencoded({ extended: false }))
|
||||
.use(cookieParser())
|
||||
.use(express.static(path.join(__dirname, "public")));
|
||||
.use(express.static('public'));
|
||||
|
||||
app.use("/", indexRouter);
|
||||
app.use("/users", usersRouter);
|
||||
|
|
@ -84,7 +84,7 @@ const sheet = GoogleFunctions.SpreadSheets(auth);
|
|||
// GoogleFunctions.getPriceSlotValues(sheet, "tha");
|
||||
|
||||
// v3 !!!!
|
||||
GoogleFunctions.syncProfilePrice(sheet, "tha", false);
|
||||
// GoogleFunctions.syncProfilePrice(sheet, "tha", false);
|
||||
//
|
||||
|
||||
// Test Taobin SyncText
|
||||
|
|
|
|||
|
|
@ -28,4 +28,7 @@ endpointMap = {
|
|||
|
||||
res.render("heartbeat");
|
||||
},
|
||||
'info': function(req, res, next){
|
||||
res.json(heartbeatApiInfo);
|
||||
}
|
||||
};
|
||||
|
|
@ -26,12 +26,19 @@ endpointMap = {
|
|||
|
||||
res.render("apiInfo");
|
||||
},
|
||||
"run/now": function (req, res, next) {
|
||||
GoogleFunctions.syncProfilePrice(sheet, "tha", false);
|
||||
res.send("Force run `Sync Thai Price Slots`");
|
||||
"info": function(req, res, next) {
|
||||
res.json(syncThaiProfilePriceSlotApiInfo);
|
||||
},
|
||||
"run/test": function (req, res, next) {
|
||||
GoogleFunctions.syncProfilePrice(sheet, "tha", true);
|
||||
res.send("Force run `Sync Thai Price Slots` test mode");
|
||||
"run/now": async function (req, res, next) {
|
||||
// res.json({ status: "running" });
|
||||
await GoogleFunctions.syncProfilePrice(sheet, "tha", false);
|
||||
res.json({ status: "success", message: "Force run `Sync Thai Price Slots`" });
|
||||
// res.send("Force run `Sync Thai Price Slots`");
|
||||
},
|
||||
"run/test": async function (req, res, next) {
|
||||
// res.json({ status: "running" });
|
||||
await GoogleFunctions.syncProfilePrice(sheet, "tha", true);
|
||||
res.json({ status: "success", message: "Force run `Sync Thai Price Slots` test mode" });
|
||||
// res.send("Force run `Sync Thai Price Slots` test mode");
|
||||
},
|
||||
};
|
||||
|
|
|
|||
58
public/index.html
Normal file
58
public/index.html
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/purecss@3.0.0/build/pure-min.css"
|
||||
integrity="sha384-X38yfunGUhNzHpBaEBsWLO+A0HDYOQi8ufWDkZ0k9e0eXz/tH3II7uKZ9msv++Ls"
|
||||
crossorigin="anonymous"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<script src="scripts/test.js"></script>
|
||||
<div class="pure-g">
|
||||
<div class="pure-u-1-2">
|
||||
<h1>Heartbeat</h1>
|
||||
<button
|
||||
class="pure-button pure-button-primary"
|
||||
onclick="getHeartBeatInfo()"
|
||||
>
|
||||
Info
|
||||
</button>
|
||||
<h1>Sync Price Slot (THA)</h1>
|
||||
<button
|
||||
class="pure-button pure-button-primary"
|
||||
onclick="getSyncPriceInfo()"
|
||||
>
|
||||
Info
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="pure-button pure-button-primary"
|
||||
onclick="setSyncPriceRunTest()"
|
||||
>
|
||||
Test
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="pure-button pure-button-primary"
|
||||
onclick="setSyncPriceRunNow()"
|
||||
>
|
||||
Run Now
|
||||
</button>
|
||||
</div>
|
||||
<div class="pure-u-1-2" style="background-color: aliceblue">
|
||||
<!-- show output -->
|
||||
<h1>Output</h1>
|
||||
<textarea
|
||||
id="output"
|
||||
cols="100"
|
||||
rows="45"
|
||||
readonly
|
||||
style="resize: none"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
24
public/scripts/test.js
Normal file
24
public/scripts/test.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
console.log("Hello, World!");
|
||||
|
||||
function sendToOutput(message){
|
||||
document.getElementById("output").value += message + "\n";
|
||||
}
|
||||
|
||||
function getHeartBeatInfo(){
|
||||
fetch("http://localhost:36530/heartbeat/info").then(response => response.json()).then(data => sendToOutput(JSON.stringify(data)));
|
||||
}
|
||||
|
||||
// Sync Price Slot Command Shortcuts
|
||||
//
|
||||
//
|
||||
function getSyncPriceInfo(){
|
||||
fetch("http://localhost:36530/syncProfilePriceSlotSheet/info").then(response => response.json()).then(data => sendToOutput(JSON.stringify(data)));
|
||||
}
|
||||
|
||||
function setSyncPriceRunTest(){
|
||||
fetch("http://localhost:36530/syncProfilePriceSlotSheet/run/test").then(response => response.json()).then(data => sendToOutput(JSON.stringify(data)));
|
||||
}
|
||||
|
||||
function setSyncPriceRunNow(){
|
||||
fetch("http://localhost:36530/syncProfilePriceSlotSheet/run/now").then(response => response.json()).then(data => sendToOutput(JSON.stringify(data)));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue