2018-01-30 19:06:40 +03:00
< template >
< div id = "updatenotification" class = "followupsection" >
2018-02-28 14:34:46 +03:00
< div class = "update" >
2018-01-30 19:06:40 +03:00
< template v-if ="isNewVersionAvailable" >
2018-02-28 14:34:46 +03:00
< p >
< span v-html ="newVersionAvailableString" > < / span > < br >
2018-03-06 19:13:35 +03:00
< span v-if ="!isListFetched" class="icon icon-loading-small" > < / span >
2018-02-28 14:34:46 +03:00
< span v-html ="statusText" > < / span >
< / p >
< template v-if ="missingAppUpdates.length" >
< h3 @click ="toggleHideMissingUpdates" > {{ t ( ' updatenotification ' , ' Apps missing updates ' ) }} < / h3 >
< ul class = "applist" v-if ="!hideMissingUpdates" >
< li v-for ="app in missingAppUpdates"><a :href="'https://apps.nextcloud.com/apps/' + app.appId" :title="t('settings', 'View in store')" > {{ app.appName }} ↗ < / a > < / li >
< / ul >
< / template >
< template v-if ="availableAppUpdates.length" >
< h3 @click ="toggleHideAvailableUpdates" > {{ t ( ' updatenotification ' , ' Apps with available updates ' ) }} < / h3 >
< ul class = "applist" >
< li v-for ="app in availableAppUpdates" v-if="!hideAvailableUpdates"><a :href="'https://apps.nextcloud.com/apps/' + app.appId" :title="t('settings', 'View in store')" > {{ app.appName }} ↗ < / a > < / li >
< / ul >
< / template >
< a v-if ="updaterEnabled" href="#" class="button" @click="clickUpdaterButton" > {{ t ( ' updatenotification ' , ' Open updater ' ) }} < / a >
2018-02-01 13:09:01 +03:00
< a v-if ="downloadLink" :href="downloadLink" class="button" :class="{ hidden: !updaterEnabled }" > {{ t ( ' updatenotification ' , ' Download now ' ) }} < / a >
2018-01-30 19:06:40 +03:00
< / template >
2018-02-01 13:09:01 +03:00
< template v -else -if = " ! isUpdateChecked " > { { t ( 'updatenotification' , 'The update check is not yet finished. Please refresh the page.' ) } } < / template >
2018-01-30 19:06:40 +03:00
< template v-else >
2018-02-01 13:09:01 +03:00
{ { t ( 'updatenotification' , 'Your version is up to date.' ) } }
2018-01-30 19:06:40 +03:00
< span class = "icon-info svg" :title ="lastCheckedOnString" > < / span >
< / template >
< template v-if ="!isDefaultUpdateServerURL" >
< br / >
2018-02-01 13:09:01 +03:00
< em > { { t ( 'updatenotification' , 'A non-default update server is in use to be checked for updates:' ) } } < code > { { updateServerURL } } < / code > < / em >
2018-01-30 19:06:40 +03:00
< / template >
2018-02-28 14:34:46 +03:00
< / div >
2018-01-30 19:06:40 +03:00
< p >
2018-02-01 13:09:01 +03:00
< label for = "release-channel" > { { t ( 'updatenotification' , 'Update channel:' ) } } < / label >
2018-01-30 19:06:40 +03:00
< select id = "release-channel" v-model ="currentChannel" @change="changeReleaseChannel" >
< option v-for ="channel in channels" :value ="channel" > {{ channel }} < / option >
< / select >
< span id = "channel_save_msg" class = "msg" > < / span > < br / >
2018-02-01 13:09:01 +03:00
< em > { { t ( 'updatenotification' , 'You can always update to a newer version / experimental channel. But you can never downgrade to a more stable channel.' ) } } < / em > < br / >
< em > { { 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.' ) } } < / em >
2018-01-30 19:06:40 +03:00
< / p >
< p id = "oca_updatenotification_groups" >
2018-02-01 13:09:01 +03:00
{ { t ( 'updatenotification' , 'Notify members of the following groups about available updates:' ) } }
2018-01-31 12:54:22 +03:00
< v -select multiple :value ="notifyGroups" :options ="availableGroups" > < /v-select><br / >
2018-02-01 13:09:01 +03:00
< em v-if ="currentChannel === 'daily' || currentChannel === 'git'" > {{ t ( ' updatenotification ' , ' Only notification for app updates are available. ' ) }} < / em >
< em v-if ="currentChannel === 'daily'" > {{ t ( ' updatenotification ' , ' The selected update channel makes dedicated notifications for the server obsolete. ' ) }} < / em >
< em v-if ="currentChannel === 'git'" > {{ t ( ' updatenotification ' , ' The selected update channel does not support updates of the server. ' ) }} < / em >
2018-01-30 19:06:40 +03:00
< / p >
< / div >
< / template >
< script >
export default {
name : "root" ,
el : '#updatenotification' ,
data : function ( ) {
return {
newVersionString : '' ,
lastCheckedDate : '' ,
isUpdateChecked : false ,
updaterEnabled : true ,
downloadLink : '' ,
isNewVersionAvailable : false ,
updateServerURL : '' ,
currentChannel : '' ,
channels : [ ] ,
notifyGroups : '' ,
2018-01-31 12:54:22 +03:00
availableGroups : [ ] ,
isDefaultUpdateServerURL : true ,
2018-02-28 14:34:46 +03:00
enableChangeWatcher : false ,
availableAppUpdates : [ ] ,
missingAppUpdates : [ ] ,
appStoreFailed : false ,
appStoreDisabled : false ,
isListFetched : false ,
hideMissingUpdates : false ,
hideAvailableUpdates : true
2018-01-30 19:06:40 +03:00
} ;
} ,
_$el : null ,
_$releaseChannel : null ,
_$notifyGroups : null ,
2018-01-31 12:54:22 +03:00
watch : {
notifyGroups : function ( selectedOptions ) {
if ( ! this . enableChangeWatcher ) {
return ;
}
var selectedGroups = [ ] ;
_ . each ( selectedOptions , function ( group ) {
selectedGroups . push ( group . value ) ;
} ) ;
OCP . AppConfig . setValue ( 'updatenotification' , 'notify_groups' , JSON . stringify ( selectedGroups ) ) ;
2018-02-28 14:34:46 +03:00
} ,
isNewVersionAvailable : function ( ) {
if ( ! this . isNewVersionAvailable ) {
return ;
}
$ . ajax ( {
url : OC . linkToOCS ( 'apps/updatenotification/api/v1/applist' , 2 ) + this . newVersionString ,
type : 'GET' ,
beforeSend : function ( request ) {
request . setRequestHeader ( 'Accept' , 'application/json' ) ;
} ,
success : function ( response ) {
this . availableAppUpdates = response . ocs . data . available ;
this . missingAppUpdates = response . ocs . data . missing ;
this . isListFetched = true ;
this . appStoreFailed = false ;
} . bind ( this ) ,
error : function ( xhr ) {
this . availableAppUpdates = [ ] ;
this . missingAppUpdates = [ ] ;
this . appStoreDisabled = xhr . responseJSON . ocs . data . appstore _disabled ;
this . isListFetched = true ;
this . appStoreFailed = true ;
} . bind ( this )
} ) ;
2018-01-31 12:54:22 +03:00
}
} ,
2018-01-30 19:06:40 +03:00
computed : {
newVersionAvailableString : function ( ) {
2018-02-28 14:34:46 +03:00
return t ( 'updatenotification' , 'A new version is available: <strong>{newVersionString}</strong>' , {
2018-01-30 19:06:40 +03:00
newVersionString : this . newVersionString
} ) ;
} ,
2018-02-28 14:34:46 +03:00
2018-01-30 19:06:40 +03:00
lastCheckedOnString : function ( ) {
return t ( 'updatenotification' , 'Checked on {lastCheckedDate}' , {
lastCheckedDate : this . lastCheckedDate
} ) ;
2018-02-28 14:34:46 +03:00
} ,
statusText : function ( ) {
if ( ! this . isListFetched ) {
2018-03-06 19:13:35 +03:00
return t ( 'updatenotification' , 'Checking apps for compatible updates' ) ;
2018-02-28 14:34:46 +03:00
}
if ( this . appstoreDisabled ) {
return t ( 'updatenotification' , 'Please make sure your config.php does not set <samp>appstoreenabled</samp> to false.' ) ;
}
if ( this . appstoreFailed ) {
return t ( 'updatenotification' , 'Could not connect to the appstore or the appstore returned no updates at all. Search manually for updates or make sure your server has access to the internet and can connect to the appstore.' ) ;
}
return this . missingAppUpdates . length === 0 ? t ( 'updatenotification' , '<strong>All</strong> apps have an update for this version available' , this ) : n ( 'updatenotification' ,
'<strong>%n</strong> app has no update for this version available' ,
'<strong>%n</strong> apps have no update for this version available' ,
this . missingAppUpdates . length , {
version : this . newVersionString
} ) ;
2018-01-30 19:06:40 +03:00
}
} ,
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 ) ;
}
} ) ;
2018-02-28 14:34:46 +03:00
} ,
toggleHideMissingUpdates : function ( ) {
this . hideMissingUpdates = ! this . hideMissingUpdates ;
} ,
toggleHideAvailableUpdates : function ( ) {
this . hideAvailableUpdates = ! this . hideAvailableUpdates ;
2018-01-30 19:06:40 +03:00
}
} ,
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 ) ) ;
2018-01-31 12:54:22 +03:00
$ . ajax ( {
url : OC . generateUrl ( '/settings/users/groups' ) ,
dataType : 'json' ,
success : function ( data ) {
var results = [ ] ;
$ . each ( data . data . adminGroups , function ( i , group ) {
results . push ( { value : group . id , label : group . name } ) ;
} ) ;
$ . each ( data . data . groups , function ( i , group ) {
results . push ( { value : group . id , label : group . name } ) ;
} ) ;
this . availableGroups = results ;
this . enableChangeWatcher = true ;
} . bind ( this )
} ) ;
2018-01-30 19:06:40 +03:00
} ,
updated : function ( ) {
this . _$el . find ( '.icon-info' ) . tooltip ( { placement : 'right' } ) ;
}
}
< / script >