2016-02-09 18:58:29 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2016 ownCloud Inc
|
|
|
|
*
|
|
|
|
* @author Lukas Reschke <lukas@owncloud.com>
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new authentication token and loads the updater URL
|
|
|
|
*/
|
2016-09-23 11:08:18 +00:00
|
|
|
var loginToken = '';
|
2016-02-09 18:58:29 +00:00
|
|
|
$(document).ready(function(){
|
2016-09-23 11:08:18 +00:00
|
|
|
$('#oca_updatenotification_button').click(function() {
|
|
|
|
// Load the new token
|
|
|
|
$.ajax({
|
|
|
|
url: OC.generateUrl('/apps/updatenotification/credentials')
|
|
|
|
}).success(function(data) {
|
|
|
|
loginToken = data;
|
|
|
|
$.ajax({
|
|
|
|
url: OC.webroot+'/updater/',
|
|
|
|
headers: {
|
|
|
|
'X-Updater-Auth': loginToken
|
|
|
|
},
|
|
|
|
method: 'POST',
|
|
|
|
success: function(data){
|
|
|
|
if(data !== 'false') {
|
|
|
|
var body = $('body');
|
|
|
|
$('head').remove();
|
|
|
|
body.html(data);
|
|
|
|
body.removeAttr('id');
|
|
|
|
body.attr('id', 'body-settings');
|
|
|
|
}
|
2016-09-27 12:47:59 +00:00
|
|
|
},
|
|
|
|
error: function(){
|
|
|
|
OC.Notification.showTemporary(t('updatenotification', 'Could not start updater, please try the manual update'));
|
|
|
|
$('#oca_updatenotification_button').addClass('hidden');
|
|
|
|
$('#oca_updatenotification_section .button').removeClass('hidden');
|
2016-09-23 11:08:18 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-03-04 12:56:13 +00:00
|
|
|
$('#release-channel').change(function() {
|
|
|
|
var newChannel = $('#release-channel').find(":selected").val();
|
2016-05-09 07:43:06 +00:00
|
|
|
|
|
|
|
if (newChannel === 'git' || newChannel === 'daily') {
|
2016-05-10 09:04:24 +00:00
|
|
|
$('#oca_updatenotification_groups em').removeClass('hidden');
|
2016-05-09 07:43:06 +00:00
|
|
|
} else {
|
2016-05-10 09:04:24 +00:00
|
|
|
$('#oca_updatenotification_groups em').addClass('hidden');
|
2016-05-09 07:43:06 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 12:56:13 +00:00
|
|
|
$.post(
|
|
|
|
OC.generateUrl('/apps/updatenotification/channel'),
|
|
|
|
{
|
|
|
|
'channel': newChannel
|
|
|
|
},
|
|
|
|
function(data){
|
|
|
|
OC.msg.finishedAction('#channel_save_msg', data);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2016-05-09 07:43:06 +00:00
|
|
|
|
|
|
|
var $notificationTargetGroups = $('#oca_updatenotification_groups_list');
|
|
|
|
OC.Settings.setupGroupsSelect($notificationTargetGroups);
|
|
|
|
$notificationTargetGroups.change(function(ev) {
|
|
|
|
var groups = ev.val || [];
|
|
|
|
groups = JSON.stringify(groups);
|
2016-09-20 09:17:13 +00:00
|
|
|
OCP.AppConfig.setValue('updatenotification', 'notify_groups', groups);
|
2016-05-09 07:43:06 +00:00
|
|
|
});
|
2016-11-16 14:36:44 +00:00
|
|
|
|
|
|
|
$('#oca_updatenotification_section .icon-info').tooltip({placement: 'right'});
|
2016-02-09 18:58:29 +00:00
|
|
|
});
|