Ver código fonte

Added docker commit info to see if new update is out

causefx 7 anos atrás
pai
commit
d7943b055f

+ 1 - 0
.gitignore

@@ -73,6 +73,7 @@ users.db
 speedtest.db
 chatpack.db
 Docker.txt
+Github.txt
 Demo.txt
 config/cacert.pem
 config/config.php

+ 2 - 1
api/config/default.php

@@ -209,5 +209,6 @@ return array(
 	'rememberMeDays' => '7',
 	'rememberMe' => true,
 	'plexStrictFriends' => true,
-	'debugAreaAuth' => '1'
+	'debugAreaAuth' => '1',
+	'commit' => 'n/a'
 );

+ 4 - 0
api/functions.php

@@ -30,6 +30,10 @@ if (isset($GLOBALS['dbLocation'])) {
 		$getBranch = file_get_contents(dirname(__DIR__, 1) . DIRECTORY_SEPARATOR . 'Docker.txt');
 		$getBranch = (empty($getBranch)) ? 'v2-master' : $getBranch;
 		$GLOBALS['branch'] = $getBranch;
+		$getCommit = file_get_contents(dirname(__DIR__, 1) . DIRECTORY_SEPARATOR . 'Github.txt');
+		$getCommit = (empty($getCommit)) ? 'n/a' : $getCommit;
+		$GLOBALS['commit'] = $getCommit;
+		
 	}
 	//Upgrade Check
 	upgradeCheck();

+ 1 - 0
api/functions/organizr-functions.php

@@ -95,6 +95,7 @@ function organizrSpecialSettings()
 			'newMessageSound' => (isset($GLOBALS['CHAT-newMessageSound-include'])) ? $GLOBALS['CHAT-newMessageSound-include'] : '',
 			'uuid' => $GLOBALS['uuid'],
 			'docker' => $GLOBALS['docker'],
+			'githubCommit' => $GLOBALS['commit'],
 			'schema' => getSchema(),
 			'debugArea' => qualifyRequest($GLOBALS['debugAreaAuth'])
 		)

+ 1 - 0
api/pages/settings.php

@@ -7,6 +7,7 @@ if (file_exists('config' . DIRECTORY_SEPARATOR . 'config.php')) {
         authDebugCheck();
         sponsorLoad();
         newsLoad();
+        checkCommitLoad();
         [].slice.call(document.querySelectorAll(\'.sttabs\')).forEach(function(el) {
             new CBPFWTabs(el);
         });

+ 27 - 0
js/functions.js

@@ -2982,6 +2982,28 @@ function newsLoad(){
         console.error("Organizr Function: Github Connection Failed");
     });
 }
+function checkCommitLoad(){
+    if(activeInfo.settings.misc.docker && activeInfo.settings.misc.githubCommit !== 'n/a') {
+        getLatestCommitJSON().success(function (data) {
+            try {
+                var latest = data.sha.toString().trim();
+                var current = activeInfo.settings.misc.githubCommit.toString().trim();
+                var link = 'https://github.com/causefx/Organizr/compare/'+current+'...'+latest;
+                if(latest !== current) {
+                    message(window.lang.translate('Update Available'),' <a href="'+link+'" target="_blank"><span lang="en">Compare Difference</span></a> <span lang="en">or</span> <a href="javascript:void(0)" onclick="updateNow()"><span lang="en">Update Now</span></a>', activeInfo.settings.notifications.position, '#FFF', 'update', '600000');
+                }else{
+                    console.log('Organizr Docker - Up to date');
+                }
+            } catch (e) {
+                console.log(e + ' error: ' + data);
+                orgErrorAlert('<h4>' + e + '</h4>' + formatDebug(data));
+                return false;
+            }
+        }).fail(function (xhr) {
+            console.error("Organizr Function: Github Connection Failed");
+        });
+    }
+}
 function sponsorLoad(){
     sponsorsJSON().success(function(data) {
         try {
@@ -3267,6 +3289,11 @@ function newsJSON() {
         url: "https://raw.githubusercontent.com/causefx/Organizr/"+activeInfo.branch+"/js/news.json",
     });
 }
+function getLatestCommitJSON() {
+    return $.ajax({
+        url: "https://api.github.com/repos/causefx/Organizr/commits/"+activeInfo.branch,
+    });
+}
 function marketplaceJSON(type) {
     return $.ajax({
         url: "https://raw.githubusercontent.com/causefx/Organizr/v2-"+type+"/"+type+".json",