diff options
Diffstat (limited to 'settings')
-rw-r--r-- | settings/ajax/enableapp.php | 12 | ||||
-rw-r--r-- | settings/css/settings.css | 8 | ||||
-rw-r--r-- | settings/js/apps.js | 55 | ||||
-rw-r--r-- | settings/templates/apps.php | 1 |
4 files changed, 54 insertions, 22 deletions
diff --git a/settings/ajax/enableapp.php b/settings/ajax/enableapp.php index ab84aee5166..735794360b3 100644 --- a/settings/ajax/enableapp.php +++ b/settings/ajax/enableapp.php @@ -3,10 +3,10 @@ OC_JSON::checkAdminUser(); OCP\JSON::callCheck(); -$appid = OC_App::enable(OC_App::cleanAppId($_POST['appid'])); -if($appid !== false) { - OC_JSON::success(array('data' => array('appid' => $appid))); -} else { - $l = OC_L10N::get('settings'); - OC_JSON::error(array("data" => array( "message" => $l->t("Could not enable app. ") ))); +try { + OC_App::enable(OC_App::cleanAppId($_POST['appid'])); + OC_JSON::success(); +} catch (Exception $e) { + OC_Log::write('core', $e->getMessage(), OC_Log::ERROR); + OC_JSON::error(array("data" => array("message" => $e->getMessage()) )); } diff --git a/settings/css/settings.css b/settings/css/settings.css index 20df5d86d65..d5ffe448482 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -61,7 +61,7 @@ select.quota.active { background: #fff; } .ie8 table.hascontrols tbody tr{border-collapse:collapse;border: 1px solid #ddd !important;} /* APPS */ -.appinfo { margin: 1em; } +.appinfo { margin: 1em 40px; } h3 { font-size: 1.4em; font-weight: bold; } ul.applist a { height: 2.2em; @@ -72,6 +72,12 @@ ul.applist .app-external { } li { color:#888; } li.active { color:#000; } +#leftcontent .appwarning { + background: #fcc; +} +#leftcontent .appwarning:hover { + background: #fbb; +} small.externalapp { color:#FFF; background-color:#BBB; font-weight:bold; font-size: 0.6em; margin: 0; padding: 0.1em 0.2em; border-radius: 4px;} small.externalapp.list { float: right; } small.recommendedapp { color:#FFF; background-color:#888; font-weight:bold; font-size: 0.6em; margin: 0; padding: 0.1em 0.2em; border-radius: 4px;} diff --git a/settings/js/apps.js b/settings/js/apps.js index cf8cd91bd40..d9817aff6b6 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -27,7 +27,7 @@ OC.Settings.Apps = OC.Settings.Apps || { } page.find('small.externalapp').attr('style', 'visibility:visible'); page.find('span.author').text(app.author); - page.find('span.licence').text(app.licence); + page.find('span.licence').text(app.license); if (app.update !== false) { page.find('input.update').show(); @@ -50,44 +50,64 @@ OC.Settings.Apps = OC.Settings.Apps || { page.find('p.appslink').hide(); page.find('span.score').hide(); } + if (typeof($('#leftcontent li[data-id="'+app.id+'"]').data('errormsg')) !== "undefined") { + page.find(".warning").show(); + page.find(".warning").text($('#leftcontent li[data-id="'+app.id+'"]').data('errormsg')); + } else { + page.find(".warning").hide(); + } }, enableApp:function(appid, active, element) { console.log('enableApp:', appid, active, element); var appitem=$('#leftcontent li[data-id="'+appid+'"]'); - var 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') { - OC.dialogs.alert('Error while disabling app', t('core', 'Error')); + if (result.data && result.data.message) { + OC.Settings.Apps.showErrorMessage(result.data.message); + appitem.data('errormsg', result.data.message); + } else { + OC.Settings.Apps.showErrorMessage(t('settings', 'Error while disabling app')); + appitem.data('errormsg', t('settings', 'Error while disabling app')); + } + element.val(t('settings','Disable')); + appitem.addClass('appwarning'); } else { - element.data('active',false); + appitem.data('active',false); OC.Settings.Apps.removeNavigation(appid); + appitem.removeClass('active'); element.val(t('settings','Enable')); } },'json'); - $('#leftcontent li[data-id="'+appid+'"]').removeClass('active'); } else { $.post(OC.filePath('settings','ajax','enableapp.php'),{appid:appid},function(result) { if(!result || result.status !== 'success') { - OC.dialogs.alert('Error while enabling app', t('core', 'Error')); - } - else { + if (result.data && result.data.message) { + OC.Settings.Apps.showErrorMessage(result.data.message); + appitem.data('errormsg', result.data.message); + } else { + OC.Settings.Apps.showErrorMessage(t('settings', 'Error while enabling app')); + appitem.data('errormsg', t('settings', 'Error while disabling app')); + } + element.val(t('settings','Enable')); + appitem.addClass('appwarning'); + } else { OC.Settings.Apps.addNavigation(appid); - element.data('active',true); + appitem.data('active',true); + appitem.addClass('active'); element.val(t('settings','Disable')); } },'json') .fail(function() { - OC.dialogs.alert('Error while enabling app', t('core', 'Error')); - element.data('active',false); + OC.Settings.Apps.showErrorMessage(t('settings', 'Error while enabling app')); + appitem.data('errormsg', t('settings', 'Error while enabling app')); + appitem.data('active',false); + appitem.addClass('appwarning'); OC.Settings.Apps.removeNavigation(appid); element.val(t('settings','Enable')); }); - $('#leftcontent li[data-id="'+appid+'"]').addClass('active'); } }, updateApp:function(appid, element) { @@ -95,7 +115,8 @@ OC.Settings.Apps = OC.Settings.Apps || { element.val(t('settings','Updating....')); $.post(OC.filePath('settings','ajax','updateapp.php'),{appid:appid},function(result) { if(!result || result.status !== 'success') { - OC.dialogs.alert(t('settings','Error while updating app'),t('settings','Error')); + OC.Settings.Apps.showErrorMessage(t('settings','Error while updating app'),t('settings','Error')); + element.val(t('settings','Update')); } else { element.val(t('settings','Updated')); @@ -167,6 +188,10 @@ OC.Settings.Apps = OC.Settings.Apps || { } } }); + }, + showErrorMessage: function(message) { + $('.appinfo .warning').show(); + $('.appinfo .warning').text(message); } }; diff --git a/settings/templates/apps.php b/settings/templates/apps.php index d60fd82f917..0b76f775fea 100644 --- a/settings/templates/apps.php +++ b/settings/templates/apps.php @@ -41,5 +41,6 @@ print_unescaped($l->t('<span class="licence"></span>-licensed by <span class="author"></span>'));?></p> <input class="enable hidden" type="submit" /> <input class="update hidden" type="submit" value="<?php p($l->t('Update')); ?>" /> + <div class="warning hidden"></div> </div> </div> |