/** * @copyright (c) 2018 Joas Schilling * @copyright (c) 2016 ownCloud Inc * * @author Joas Schilling * @author Lukas Reschke * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. */ (function(OC, OCA, OCP, t, $) { "use strict"; OCA.UpdateNotification = OCA.UpdateNotification || {}; OCA.UpdateNotification.Components = OCA.UpdateNotification.Components || {}; OCA.UpdateNotification.Components.Root = { template: '' + '
' + '

' + ' ' + ' ' + ' ' + '' + ' ' + '

' + '' + '

' + ' ' + ' ' + '
' + ' ' + t('updatenotification', 'You can always update to a newer version / experimental channel. But you can never downgrade to a more stable channel.') + '
' + ' ' + t('updatenotification', 'Note that after a new release it can take some time before it shows up here. We roll out new versions spread out over time to our users and sometimes skip a version when issues are found.') + '' + '

' + '' + '

' + ' ' + t('updatenotification', 'Notify members of the following groups about available updates:') + '
' + ' ' + t('updatenotification', 'Only notification for app updates are available.') + '' + ' ' + t('updatenotification', 'The selected update channel makes dedicated notifications for the server obsolete.') + '' + ' ' + t('updatenotification', 'The selected update channel does not support updates of the server.') + '' + '

' + '
', el: '#updatenotification', data: { newVersionString: '', lastCheckedDate: '', isUpdateChecked: false, updaterEnabled: true, downloadLink: '', isNewVersionAvailable: false, updateServerURL: '', currentChannel: '', channels: [], notifyGroups: '', isDefaultUpdateServerURL: true }, _$el: null, _$releaseChannel: null, _$notifyGroups: null, computed: { newVersionAvailableString: function() { return t('updatenotification', 'A new version is available: {newVersionString}', { newVersionString: this.newVersionString }); }, lastCheckedOnString: function() { return t('updatenotification', 'Checked on {lastCheckedDate}', { lastCheckedDate: this.lastCheckedDate }); } }, methods: { /** * Creates a new authentication token and loads the updater URL */ clickUpdaterButton: function() { $.ajax({ url: OC.generateUrl('/apps/updatenotification/credentials') }).success(function(data) { $.ajax({ url: OC.getRootPath()+'/updater/', headers: { 'X-Updater-Auth': data }, method: 'POST', success: function(data){ if(data !== 'false') { var body = $('body'); $('head').remove(); body.html(data); // Eval the script elements in the response var dom = $(data); dom.filter('script').each(function() { eval(this.text || this.textContent || this.innerHTML || ''); }); body.removeAttr('id'); body.attr('id', 'body-settings'); } }, error: function() { OC.Notification.showTemporary(t('updatenotification', 'Could not start updater, please try the manual update')); this.updaterEnabled = false; }.bind(this) }); }.bind(this)); }, changeReleaseChannel: function() { this.currentChannel = this._$releaseChannel.val(); $.ajax({ url: OC.generateUrl('/apps/updatenotification/channel'), type: 'POST', data: { 'channel': this.currentChannel }, success: function (data) { OC.msg.finishedAction('#channel_save_msg', data); } }); }, saveNotifyGroups: function(e) { var groups = e.val || []; groups = JSON.stringify(groups); OCP.AppConfig.setValue('updatenotification', 'notify_groups', groups); } }, mounted: function () { this._$el = $(this.$el); this._$releaseChannel = this._$el.find('#release-channel'); this._$notifyGroups = this._$el.find('#oca_updatenotification_groups_list'); this._$notifyGroups.on('change', function () { this.$emit('input'); }.bind(this)); }, updated: function () { OC.Settings.setupGroupsSelect(this._$notifyGroups); this._$el.find('.icon-info').tooltip({placement: 'right'}); } }; })(OC, OCA, OCP, t, $);