-
Notifications
You must be signed in to change notification settings - Fork 21
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
Showing
8 changed files
with
255 additions
and
70 deletions.
There are no files selected for viewing
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
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
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,39 +1,83 @@ | ||
const mediaCard = require("../cards/MediaCard"); | ||
const cType = require("../cards/CardType"); | ||
const util = require('util'); | ||
const util = require("util"); | ||
const axios = require("axios"); | ||
const { CardTypeEnum } = require("../cards/CardType"); | ||
var playing = null; | ||
|
||
/** | ||
/** | ||
* @desc Used to get a list of custom pictures | ||
*/ | ||
class Awtrix { | ||
constructor() { } | ||
constructor() {} | ||
|
||
/** | ||
* @desc Custom link slide array | ||
*/ | ||
async post(ip,payload) { | ||
try{ | ||
await axios.post( | ||
ip + "/api/custom?name=posterr", null | ||
) | ||
|
||
await axios.post( | ||
ip + "/api/custom?name=posterr", payload | ||
) | ||
|
||
return 0; | ||
async post(ip, payload) { | ||
if (payload !== null) { | ||
try { | ||
await axios.post(ip + "/api/custom?name=" + payload.unique, payload); | ||
|
||
return 0; | ||
} catch (ex) { | ||
let now = new Date(); | ||
throw "Awtrix add failed - " + ex; | ||
} | ||
} | ||
catch(ex){ | ||
} | ||
|
||
async delete(ip, appName) { | ||
try { | ||
await axios.post(ip + "/api/custom?name=" + appName, null); | ||
|
||
return 0; | ||
} catch (ex) { | ||
let now = new Date(); | ||
console.log(now.toLocaleString() + " * Awtrix post failed - " + ex); | ||
} | ||
throw "Awtrix delete failed - " + ex; | ||
} | ||
} | ||
|
||
async clear(ip) { | ||
try { | ||
await axios.get(ip + "/api/loop").then(function (response) { | ||
if (Object.keys(response.data).length > 0) { | ||
Object.keys(response.data).forEach((app) => { | ||
if (app.search(/posterr/i) !== -1) { | ||
axios.post(ip + "/api/custom?name=" + app, null); | ||
let now = new Date(); | ||
console.log(now.toLocaleString() + " Awtrix Clearing " + app); | ||
} | ||
}); | ||
} | ||
}); | ||
} catch (ex) { | ||
throw " Awtrix initialisation failed"; | ||
console.log('throw'); | ||
} | ||
} | ||
|
||
async rtttl(ip,tune) { | ||
try { | ||
await axios.post(ip + "/api/rtttl",tune); | ||
return 0; | ||
} catch (ex) { | ||
throw "Awtrix greeting failed - " + ex; | ||
} | ||
|
||
} | ||
|
||
async appFind(oldApps, uniqueValue) { | ||
const result = oldApps.find(({ unique }) => unique === uniqueValue); | ||
|
||
return result; | ||
} | ||
|
||
async appFindID(appsArray, value) { | ||
const result = oldApps.find((element) => element === value); | ||
|
||
return result; | ||
} | ||
} | ||
|
||
module.exports = Awtrix; |
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
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
Oops, something went wrong.