From a27f92a17ae12d2d1ff48b26aadfecd7c221c589 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Mon, 21 Jan 2013 20:40:23 +0100 Subject: we are getting closer. updating is not working yet. --- settings/ajax/apps/ocs.php | 1 + settings/ajax/updateapp.php | 17 +++++++++++++++++ settings/apps.php | 5 ++++- settings/js/apps.js | 30 ++++++++++++++++++++++++++++++ settings/routes.php | 2 ++ settings/templates/apps.php | 4 +++- 6 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 settings/ajax/updateapp.php (limited to 'settings') diff --git a/settings/ajax/apps/ocs.php b/settings/ajax/apps/ocs.php index 1ffba26ad1d..6e09785d236 100644 --- a/settings/ajax/apps/ocs.php +++ b/settings/ajax/apps/ocs.php @@ -54,6 +54,7 @@ if(is_array($catagoryNames)) { 'preview'=>$pre, 'internal'=>false, 'internallabel'=>'3rd Party App', + 'update'=>false, ); } } diff --git a/settings/ajax/updateapp.php b/settings/ajax/updateapp.php new file mode 100644 index 00000000000..68c2bbf7f00 --- /dev/null +++ b/settings/ajax/updateapp.php @@ -0,0 +1,17 @@ + array('appid' => $appid))); +} else { + $l = OC_L10N::get('settings'); + OC_JSON::error(array("data" => array( "message" => $l->t("Could update app. ") ))); +} + + + diff --git a/settings/apps.php b/settings/apps.php index 99a3094399d..a2015801e57 100644 --- a/settings/apps.php +++ b/settings/apps.php @@ -68,13 +68,16 @@ foreach ( $installedApps as $app ) { $info['internal']=true; $info['internallabel']='Internal App'; + + $info['update']=false; }else{ $info['internal']=false; $info['internallabel']='3rd Party App'; - + + $info['update']=OC_Installer::isUpdateAvailable($app); } $info['preview'] = OC_Helper::imagePath('settings', 'trans.png'); diff --git a/settings/js/apps.js b/settings/js/apps.js index c4c36b4bb12..8d214bd1145 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -24,6 +24,14 @@ OC.Settings.Apps = OC.Settings.Apps || { page.find('span.author').text(app.author); page.find('span.licence').text(app.licence); + if (app.update != false) { + page.find('input.update').show(); + page.find('input.update').data('appid', app.id); + page.find('input.update').attr('value',t('settings', 'Update to ')+app.update); + } else { + page.find('input.update').hide(); + } + page.find('input.enable').show(); page.find('input.enable').val((app.active) ? t('settings', 'Disable') : t('settings', 'Enable')); page.find('input.enable').data('appid', app.id); @@ -44,6 +52,7 @@ OC.Settings.Apps = OC.Settings.Apps || { appData = appitem.data('app'); appData.active = !active; appitem.data('app', appData); + element.val(t('settings','Please wait....')); if(active) { $.post(OC.filePath('settings','ajax','disableapp.php'),{appid:appid},function(result) { if(!result || result.status!='success') { @@ -70,6 +79,20 @@ OC.Settings.Apps = OC.Settings.Apps || { $('#leftcontent li[data-id="'+appid+'"]').addClass('active'); } }, + updateApp:function(appid, element) { + console.log('updateApp:', appid, element); + element.val(t('settings','Updateing....')); + $.post(OC.filePath('settings','ajax','updateapp.php'),{appid:appid},function(result) { + if(!result || result.status!='success') { + OC.dialogs.alert('Error while updating app','Error'); + } + else { + element.val(t('settings','Updated')); + element.hide(); + } + },'json'); + }, + insertApp:function(appdata) { var applist = $('#leftcontent li'); var app = @@ -154,6 +177,13 @@ $(document).ready(function(){ OC.Settings.Apps.enableApp(appid, active, element); } }); + $('#rightcontent input.update').click(function(){ + var element = $(this); + var appid=$(this).data('appid'); + if(appid) { + OC.Settings.Apps.updateApp(appid, element); + } + }); if(appid) { var item = $('#leftcontent li[data-id="'+appid+'"]'); diff --git a/settings/routes.php b/settings/routes.php index 9b5bf809230..fa78f566525 100644 --- a/settings/routes.php +++ b/settings/routes.php @@ -51,6 +51,8 @@ $this->create('settings_ajax_enableapp', '/settings/ajax/enableapp.php') ->actionInclude('settings/ajax/enableapp.php'); $this->create('settings_ajax_disableapp', '/settings/ajax/disableapp.php') ->actionInclude('settings/ajax/disableapp.php'); +$this->create('settings_ajax_updateapp', '/settings/ajax/updateapp.php') + ->actionInclude('settings/ajax/updateapp.php'); $this->create('settings_ajax_navigationdetect', '/settings/ajax/navigationdetect.php') ->actionInclude('settings/ajax/navigationdetect.php'); // admin diff --git a/settings/templates/apps.php b/settings/templates/apps.php index 179ce9c5405..8654547ecb3 100644 --- a/settings/templates/apps.php +++ b/settings/templates/apps.php @@ -7,7 +7,7 @@ var appid = '';
- t('Add your App');?> + t('Add your App');?> t('More Apps');?>