From 0502d138629ce4f1491eaf8bfff32182f24f36fe Mon Sep 17 00:00:00 2001 From: tuxudo Date: Wed, 9 Aug 2023 13:38:51 -0400 Subject: [PATCH] Check for new MunkiReport version on Module Marketplace (#1517) --- app/views/system/module_marketplace.php | 37 +++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/app/views/system/module_marketplace.php b/app/views/system/module_marketplace.php index 0897db397..dcf3c2454 100755 --- a/app/views/system/module_marketplace.php +++ b/app/views/system/module_marketplace.php @@ -3,7 +3,7 @@
-

+

@@ -203,7 +203,10 @@ alert(obj.msg); } }); - }); + + // Get latest verison of MunkiReport-PHP + getLatestMRVersion(); + }); // Get module info via API and display in modal function viewModule(module){ @@ -289,6 +292,36 @@ function getInstall(module){ $('#myModal').modal('show'); } + // Get latest version of MunkiReport-PHP from GitHub + function getLatestMRVersion(){ + $.ajax({ + type: "GET", + url: 'https://api.github.com/repos/munkireport/munkireport-php/releases/latest', // API page to get JSON from + dataType: "jsonp", + success: function (obj, textstatus) { + + try { + var latest_tag = obj.data['tag_name'].replace('v', ''); + var current_tag_array = "".split('.'); + var current_tag = current_tag_array[0]+"."+current_tag_array[1]+"."+current_tag_array[2]; + var html_url = obj.data['html_url']; + } + catch(err) { + console.log("Error getting latest version of MunkiReport-PHP from GitHub!"); + var latest_tag, html_url, current_tag = ""; + } + + // If we have a new version, show the new version button + if (current_tag != "" && latest_tag != "" && compareVersions(current_tag, '<', latest_tag)) { + $('#new_mr_version').html('New version of MunkiReport available: v'+latest_tag+'