-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd5b873
commit c9f5e9d
Showing
15 changed files
with
21,786 additions
and
12 deletions.
There are no files selected for viewing
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Message of the Day</title> | ||
<!-- Add any necessary CSS or external libraries here --> | ||
<script src="scripts/getStyle.js"></script> | ||
</head> | ||
<body> | ||
<div class="w-full px-8 flex justify-center"> | ||
<div class="w-full max-w-xl"> | ||
<header class="flex justify-between items-center"> | ||
<h1 class="text-3xl font-bold italic py-4">Message of the Day</h1> | ||
<img class="h-8" alt="Logo da Cargill" src="assets/cargillLogo.png" /> | ||
</header> | ||
|
||
<div class="grid gap-3"> | ||
<input | ||
class="border-2 rounded-md py-1 px-2 border-slate-300" | ||
type="text" | ||
id="messageL1" | ||
placeholder="Message Line 1" | ||
/> | ||
<input | ||
class="border-2 rounded-md py-1 px-2 border-slate-300" | ||
type="text" | ||
id="messageL2" | ||
placeholder="Message Line 2" | ||
/> | ||
<input | ||
class="border-2 rounded-md py-1 px-2 border-slate-300" | ||
type="text" | ||
id="messageL3" | ||
placeholder="Message Line 3" | ||
/> | ||
<div class="grid sm:grid-cols-3 gap-3"> | ||
<input | ||
class="border-2 rounded-md py-1 px-2 border-slate-300 col-span-2" | ||
type="number" | ||
min="0" | ||
max="120" | ||
id="setTimeInput" | ||
placeholder="Message duration" | ||
oninput="setTimeOut.value='Expires in ' + (setTimeInput.value || 0) + ' hours';checkSetTime()" | ||
/> | ||
<output id="setTimeOut"></output> | ||
</div> | ||
<button | ||
id="setTimeButton" | ||
class="bg-cyan-900 hover:bg-cyan-600 text-white font-bold py-2 px-3 rounded-md disabled:bg-gray-400 disabled:cursor-not-allowed" | ||
onclick="setMessage()" | ||
> | ||
Set Messages | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<!-- Include your JavaScript code below --> | ||
<script src="scripts/setMessage.js"></script> | ||
<script src="scripts/checkSetTime.js"></script> | ||
<script> | ||
checkSetTime(); | ||
document.getElementById("setTimeOut").value = | ||
"Expires in " + (document.getElementById("setTimeInput").value || 0) + " hours"; | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# FEWS Message of the Day | ||
|
||
A simple website that allows users to set daily messages. | ||
|
||
## Features | ||
|
||
- Simple and intuitive interface | ||
- Auto-authorization | ||
- Cleaner notifications | ||
- Powered by PI Web API | ||
|
||
## Colaborators | ||
|
||
- Kaio Lima | ||
- Gabriel Jamur | ||
- Henrique Lozano |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function checkSetTime() { | ||
const setTimeOut = document.getElementById("setTimeOut").value; | ||
|
||
let setTimeButton = document.getElementById("setTimeButton"); | ||
|
||
if (setTimeOut) setTimeButton.disabled = false; | ||
else setTimeButton.disabled = true; | ||
} | ||
|
||
checkSetTime(); // Call the function initially to set the button state |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
async function setMessage() { | ||
const messageL1 = document.getElementById("messageL1").value; | ||
const messageL2 = document.getElementById("messageL2").value; | ||
const messageL3 = document.getElementById("messageL3").value; | ||
const setTimeInput = document.getElementById("setTimeInput").value; | ||
|
||
const currentUrl = window.location.host; | ||
const headers = new Headers(); | ||
headers.append("Content-Type", "application/json"); | ||
//headers.append("Authorization", ""); | ||
//headers.append("X-Requested-With", ""); | ||
|
||
const now = new Date(); | ||
const elementPath = getUrlPath(); | ||
const content = bodyBuilder( | ||
currentUrl, | ||
elementPath, | ||
now, | ||
messageL1, | ||
messageL2, | ||
messageL3, | ||
setTimeInput | ||
); | ||
const parsedContent = JSON.stringify(content); | ||
//console.log(parsedContent); | ||
|
||
fetch("https://" + currentUrl + "/piwebapi/batch", { | ||
method: "POST", | ||
headers: headers, | ||
body: parsedContent, | ||
credentials: "same-origin", | ||
}) | ||
.then((response) => { | ||
if (response.ok) { | ||
//console.log("OK", response); | ||
alert("Snooze set with success!"); | ||
} else { | ||
throw new Error("Network response failed ", response.json()); | ||
} | ||
}) | ||
.catch((error) => alert(error)); | ||
|
||
function getUrlPath() { | ||
const params = new URLSearchParams(window.location.search); | ||
const path = params.get("path"); | ||
|
||
return path; | ||
} | ||
function bodyBuilder( | ||
serverName, | ||
elementPath, | ||
now, | ||
messageL1, | ||
messageL2, | ||
messageL3, | ||
setTimeInput | ||
) { | ||
return { | ||
GET_Message_L1_WebID: { | ||
Method: "GET", | ||
Resource: | ||
"https://" + | ||
serverName + | ||
"/piwebapi/attributes?path=" + | ||
elementPath + | ||
"|L1+Display+Message|L1+Message+of+the+Day", | ||
}, | ||
POST_Message_L1_Value: { | ||
Method: "POST", | ||
ParentIDs: ["GET_Message_L1_WebID"], | ||
Content: | ||
'{"Value": "' + | ||
messageL1 + | ||
'", "Timestamp": "' + | ||
now.toISOString() + | ||
'",}', | ||
RequestTemplate: { | ||
Resource: "https://" + serverName + "/piwebapi/streams/{0}/value", | ||
}, | ||
Parameters: ["$.GET_Message_L1_WebID.Content.WebId"], | ||
}, | ||
GET_Message_L2_WebID: { | ||
Method: "GET", | ||
Resource: | ||
"https://" + | ||
serverName + | ||
"/piwebapi/attributes?path=" + | ||
elementPath + | ||
"|L2+Display+Message|L2+Message+of+the+Day", | ||
}, | ||
POST_Message_L2_Value: { | ||
Method: "POST", | ||
ParentIDs: ["GET_Message_L2_WebID"], | ||
Content: | ||
'{"Value": "' + | ||
messageL2 + | ||
'", "Timestamp": "' + | ||
now.toISOString() + | ||
'",}', | ||
RequestTemplate: { | ||
Resource: "https://" + serverName + "/piwebapi/streams/{0}/value", | ||
}, | ||
Parameters: ["$.GET_Message_L2_WebID.Content.WebId"], | ||
}, | ||
GET_Message_L3_WebID: { | ||
Method: "GET", | ||
Resource: | ||
"https://" + | ||
serverName + | ||
"/piwebapi/attributes?path=" + | ||
elementPath + | ||
"|L3+Display+Message|L3+Message+of+the+Day", | ||
}, | ||
POST_Message_L3_Value: { | ||
Method: "POST", | ||
ParentIDs: ["GET_Message_L3_WebID"], | ||
Content: | ||
'{"Value": "' + | ||
messageL3 + | ||
'", "Timestamp": "' + | ||
now.toISOString() + | ||
'",}', | ||
RequestTemplate: { | ||
Resource: "https://" + serverName + "/piwebapi/streams/{0}/value", | ||
}, | ||
Parameters: ["$.GET_Message_L3_WebID.Content.WebId"], | ||
}, | ||
GET_Expiration_Time_WebID: { | ||
Method: "GET", | ||
Resource: | ||
"https://" + | ||
serverName + | ||
"/piwebapi/attributes?path=" + | ||
elementPath + | ||
"|L1+Display+Message|Expiration+Time+(Hours)", | ||
}, | ||
POST_Expiration_Time_Value: { | ||
Method: "POST", | ||
ParentIDs: ["GET_Expiration_Time_WebID"], | ||
Content: | ||
'{"Value": "' + | ||
setTimeInput + | ||
'", "Timestamp": "' + | ||
now.toISOString() + | ||
'",}', | ||
RequestTemplate: { | ||
Resource: "https://" + serverName + "/piwebapi/streams/{0}/value", | ||
}, | ||
Parameters: ["$.GET_Expiration_Time_WebID.Content.WebId"], | ||
}, | ||
}; | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,8 @@ | ||
# FEWS Snooze | ||
# FEWS Apps | ||
|
||
A simple website that allows users to ignore PI Notifications from specific tags. | ||
A repository for small applications that belong to FEWS | ||
|
||
## Features | ||
## Current Apps | ||
|
||
- Simple and intuitive interface | ||
- Auto-authorization | ||
- Cleaner notifications | ||
- Powered by PI Web API | ||
|
||
## Colaborators | ||
|
||
- Kaio Lima | ||
- Henrique Lozano | ||
- Message of the Day | ||
- Snooze |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# FEWS Snooze | ||
|
||
A simple website that allows users to ignore PI Notifications from specific tags. | ||
|
||
## Features | ||
|
||
- Simple and intuitive interface | ||
- Auto-authorization | ||
- Cleaner notifications | ||
- Powered by PI Web API | ||
|
||
## Colaborators | ||
|
||
- Kaio Lima | ||
- Henrique Lozano |
File renamed without changes.
Oops, something went wrong.