mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'dev' into bugfix/user-delete
This commit is contained in:
commit
ee067af0f4
@ -4,6 +4,7 @@
|
||||
TBD
|
||||
### Bug fixes
|
||||
- Fix logic issue with `get_files` API permissions check ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/654))
|
||||
- Fix notifications not showing up/being reset #298 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/660))
|
||||
### Tweaks
|
||||
- Auto refresh Crafty Announcements on 30m interval ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/653))
|
||||
- Improve Crafty toggle buttons and Webhooks page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/656))
|
||||
|
@ -578,16 +578,19 @@ class Helpers:
|
||||
return version_data
|
||||
|
||||
def get_announcements(self):
|
||||
data = []
|
||||
try:
|
||||
data = []
|
||||
response = requests.get("https://craftycontrol.com/notify", timeout=2)
|
||||
data = json.loads(response.content)
|
||||
if self.update_available:
|
||||
data.append(self.update_available)
|
||||
return data
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to fetch notifications with error: {e}")
|
||||
|
||||
if self.update_available:
|
||||
data.append(self.update_available)
|
||||
return data
|
||||
if self.update_available:
|
||||
data = [self.update_available]
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_version_string(self):
|
||||
version_data = self.get_version()
|
||||
|
@ -29,6 +29,14 @@ class ApiAnnounceIndexHandler(BaseApiHandler):
|
||||
) = auth_data
|
||||
|
||||
data = self.helper.get_announcements()
|
||||
if not data:
|
||||
return self.finish_json(
|
||||
424,
|
||||
{
|
||||
"status": "error",
|
||||
"data": "Failed to get announcements",
|
||||
},
|
||||
)
|
||||
cleared = str(
|
||||
self.controller.users.get_user_by_id(auth_data[4]["user_id"])[
|
||||
"cleared_notifs"
|
||||
@ -84,6 +92,14 @@ class ApiAnnounceIndexHandler(BaseApiHandler):
|
||||
},
|
||||
)
|
||||
announcements = self.helper.get_announcements()
|
||||
if not announcements:
|
||||
return self.finish_json(
|
||||
424,
|
||||
{
|
||||
"status": "error",
|
||||
"data": "Failed to get current announcements",
|
||||
},
|
||||
)
|
||||
res = [d.get("id", None) for d in announcements]
|
||||
cleared_notifs = str(
|
||||
self.controller.users.get_user_by_id(auth_data[4]["user_id"])[
|
||||
|
@ -93,7 +93,7 @@
|
||||
return true;
|
||||
}
|
||||
function updateAnnouncements(data) {
|
||||
console.log(data)
|
||||
console.log(data);
|
||||
let text = "";
|
||||
for (let value of data) {
|
||||
text += `<li class="card-header header-sm justify-content-between align-items-center" id="${value.id}"><p style="float: right;"><i data-id="${value.id}"class="clear-button fa-regular fa-x"></i></p><a style="color: var(--purple);" href=${value.link} target="_blank"><h6>${value.title}</h6><small><p>${value.date}</p></small><p>${value.desc}</p></li></a>`
|
||||
@ -138,12 +138,12 @@
|
||||
console.log(responseData);
|
||||
setTimeout(function() {
|
||||
getAnnouncements();
|
||||
}, 1800);
|
||||
}, 1800000); //Wait 30 minutes in miliseconds
|
||||
console.log("Registered annoucement fetch event in 30 minutes.")
|
||||
if (responseData.status === "ok") {
|
||||
updateAnnouncements(responseData.data)
|
||||
} else {
|
||||
updateAnnouncements("<li><p>Trouble Getting Annoucements</p></li>")
|
||||
updateAnnouncements([])
|
||||
}
|
||||
}
|
||||
async function send_clear(uuid) {
|
||||
|
Loading…
Reference in New Issue
Block a user