Skip to content

Commit

Permalink
Here we go
Browse files Browse the repository at this point in the history
  • Loading branch information
ukdtom committed Feb 27, 2016
1 parent b1e1c9e commit 0122c6b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 12 deletions.
48 changes: 45 additions & 3 deletions http/jscript/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ var webtools = {
longermodulestart: false,
loading: function() {},
changelog: '',
credits: ''
credits: '',
install_WT: function() {},
wait_update: function () {}
};

// Webtools function
Expand Down Expand Up @@ -223,7 +225,7 @@ webtools.listlogfiles = function(callback, activatemodulename) {

$('#LogfilesMenu').append('<li><a class="customlink" href="/webtools2?module=logs&function=download">Download all logfiles as Zip</a></li>');
$('#LogfilesMenu').append('<li><a class="customlink" onclick="javascript:webtools.listlogfiles();">Refresh Logfilelist</a></li>');

if (typeof(callback) != 'undefined') {
callback('LogfileNamesFetch:Success', activatemodulename);
} else {
Expand Down Expand Up @@ -463,12 +465,15 @@ webtools.updates_check = function() {
switch (compare(webtools.version, data.tag_name)) {
case 0:
infoarray.push('You are on the latest and greatest!');
$('#myModalFoot').html('<button type="button" class="btn btn-default" onclick="webtools.install_WT();">Re-Install WebTools</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>');
break;
case -1:
infoarray.push('You\'ve fallen behind. Time to update to the greatest!');
$('#myModalFoot').html('<button type="button" class="btn btn-default" onclick="webtools.install_WT();">Update WebTools</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>');
break;
case 1:
infoarray.push('You are ahead of time. Your version is newer than the one on Github.');
$('#myModalFoot').html('<button type="button" class="btn btn-default" onclick="webtools.install_WT();">Re-Install WebTools</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>');
break;
}
}
Expand All @@ -478,7 +483,44 @@ webtools.updates_check = function() {
$('#updateinfo').html('An error occured while trying to fetch information from Github. Try again in a little while.');
}
});
};
}

webtools.install_WT = function () {
$.ajax({
url: '/webtools2?module=git&function=upgradeWT',
type:'PUT',
success: function (data) {
console.log('success');
console.log(data);
webtools.wait_update();
// Call webtools_wait_for_reload();
// That function is an ajax call for /, if 404, wait for a few seconds, then try again. Otherwise, notify user of updated completed.
},
error: function (data) {
console.log('error');
console.log(data);
webtools.wait_update();
// Notify user
}
})
}

webtools.wait_update = function () {
$('#myModalLabel').html('<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> Waiting for WebTools');
$('#myModalBody').html('<p id="updateinfo">Waiting for WebTools to come online. Will automatically return you to start when ready.</p>');
$('#myModalFoot').html('');
$('#myModal').modal('show');
$.ajax({
url:'/',
type: 'GET',
success: function () {
window.location.href='/';
},
error: function () {
setTimeout(webtools.wait_update,1000);
}
})
}

$(function(ready) {
$('#myModal').on('hidden.bs.modal', function(e) {
Expand Down
21 changes: 12 additions & 9 deletions http/modules/install/jscript/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ install.showChannels = function(button, type, page, highlight) {
// Reset install.channelstoshow
install.channelstoshow = [];
$('#channelmenu>button').removeClass('btn-active');
$('#gitlink').focus();
$('#install_availablechannels').focus();
$('#' + type.replace(' ', '')).addClass('btn-active');

var channellist = [];
Expand Down Expand Up @@ -360,7 +360,9 @@ install.showChannels = function(button, type, page, highlight) {

for (var i = start; i < end; i++) {
var key = install.channelstoshow[i];
var installlink = '';
var link_install = '';
var link_update = '';
var link_uninstall = '';

var isInstalled = false;
var installDate = '';
Expand All @@ -370,23 +372,24 @@ install.showChannels = function(button, type, page, highlight) {
if ((typeof(install.allBundles[key].date) != 'undefined') && (install.allBundles[key].date.length > 0)) {
isInstalled = true;
rowspan = 3;
installlink = '<div class="panel-footer"><button class="btn btn-default btn-xs" onclick="install.installfromgit(\'' + key + '\')">Re-Install with latest available</button>';
link_install = '<button class="btn btn-default btn-xs" onclick="install.installfromgit(\'' + key + '\')">Re-Install with latest available</button>';
}


if ((key.indexOf('http') != -1) && (key.indexOf('https') != -1)) {
if (isInstalled === false) {
installlink = '<div class="panel-footer"><button class="btn btn-default btn-xs" onclick="install.installfromgit(\'' + key + '\')">Install</button>';
link_install = '<div class="panel-footer"><button class="btn btn-default btn-xs" onclick="install.installfromgit(\'' + key + '\')">Install</button>';
}
repolink = '<a href="' + key + '" target="_NEW">' + key + '</a>';
installlink += ' <button class="btn btn-default btn-xs" onclick="install.checkForUpdates(\'' + install.allBundles[key].bundle + '\',\'' + key + '\')">Check for Updates</button>';
link_update += ' <button class="btn btn-default btn-xs" onclick="install.checkForUpdates(\'' + install.allBundles[key].bundle + '\',\'' + key + '\')">Check for Updates</button>';
}


if ((type == 'Unknown') && ((typeof(install.allBundles[key].date) != 'undefined') && (install.allBundles[key].date.length > 0))) {
installlink += ' <button class="btn btn-default btn-xs" onclick="install.removebundleconfirm(\'' + key + '\')">Uninstall Bundle</button></div>';
//if ((type == 'Unknown') && ((typeof(install.allBundles[key].date) != 'undefined') && (install.allBundles[key].date.length > 0))) {
if (isInstalled === true) {
link_uninstall = ' <button class="btn btn-default btn-xs" onclick="install.removebundleconfirm(\'' + key + '\')">Uninstall Bundle</button></div>';
}
installlink += '</div>';
//}

if (((install.showOnlyInstalled === true) && (isInstalled === true)) || (install.showOnlyInstalled === false)) {
var iconurl = 'icons/NoIcon.png';
Expand All @@ -413,7 +416,7 @@ install.showChannels = function(button, type, page, highlight) {
newEntry.push('<tr><td colspan="2"><div class="categoryDiv changeDisplay marginRight"><span class="changeDisplay subheadline">Installed:&nbsp;</span> <span class="changeDisplay"> ' + install.allBundles[key].date + '&nbsp;</span></div><div class="categoryDiv changeDisplay"><span class="changeDisplay subheadline">Latest Update on Github:&nbsp;</span> <span class="changeDisplay"><span id="updateTime_' + install.allBundles[key].bundle.replace('.', '').replace(' ', '') + '">' + updateTime + '&nbsp;</span></span></div></td></tr>')
//}
newEntry.push('</table></div>');
newEntry.push(installlink);
newEntry.push('<div class="panel-footer">' + link_install + link_update + link_uninstall + '</div>');
newEntry.push('</div>');

$('#channellist').append(newEntry.join('\n'));
Expand Down

0 comments on commit 0122c6b

Please sign in to comment.