From 9f4bd7cb47af70bfd152a7b3bfb61ecd632fa28d Mon Sep 17 00:00:00 2001
From: kondou
Date: Sun, 18 Aug 2013 13:49:34 +0200
Subject: [PATCH] Don't use an alert for displaying app-mgmt-errors
Rather display a dominant div and mark the problematic app in the applist.
Fix #305
---
lib/installer.php | 2 +-
settings/css/settings.css | 16 +++++++++++++++-
settings/js/apps.js | 37 ++++++++++++++++++++++++++++---------
settings/templates/apps.php | 1 +
4 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/lib/installer.php b/lib/installer.php
index 101c99e9c1..c9d331551c 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -141,7 +141,7 @@ class OC_Installer{
// check if shipped tag is set which is only allowed for apps that are shipped with ownCloud
if(isset($info['shipped']) and ($info['shipped']=='true')) {
OC_Helper::rmdirr($extractDir);
- throw new \Exception($l->t("App can't be installed because it contains the <shipped>true</shipped> tag which is not allowed for non shipped apps"));
+ throw new \Exception($l->t("App can't be installed because it contains the true tag which is not allowed for non shipped apps"));
}
// check if the ocs version is the same as the version in info.xml/version
diff --git a/settings/css/settings.css b/settings/css/settings.css
index 20df5d86d6..38c28dd33b 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;}
@@ -86,6 +92,14 @@ span.version { margin-left:1em; margin-right:1em; color:#555; }
.appslink { text-decoration: underline; }
.score { color:#666; font-weight:bold; font-size:0.8em; }
+.errormsg {
+ margin: 20px;
+ padding: 5px;
+ background: #fdd;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+}
/* LOG */
#log { white-space:normal; }
diff --git a/settings/js/apps.js b/settings/js/apps.js
index 6c835a5999..e49fd21a59 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,6 +50,12 @@ 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(".errormsg").show();
+ page.find(".errormsg").text($('#leftcontent li[data-id="'+app.id+'"]').data('errormsg'));
+ } else {
+ page.find(".errormsg").hide();
+ }
},
enableApp:function(appid, active, element) {
console.log('enableApp:', appid, active, element);
@@ -62,40 +68,48 @@ OC.Settings.Apps = OC.Settings.Apps || {
$.post(OC.filePath('settings','ajax','disableapp.php'),{appid:appid},function(result) {
if(!result || result.status !== 'success') {
if (result.data && result.data.message) {
- OC.dialogs.alert(result.data.message, t('core', 'Error'));
+ OC.Settings.Apps.showErrorMessage(result.data.message);
+ $('#leftcontent li[data-id="'+appid+'"]').data('errormsg', result.data.message);
} else {
- OC.dialogs.alert(t('settings', 'Error while disabling app'), t('core', 'Error'));
+ OC.Settings.Apps.showErrorMessage(t('settings', 'Error while disabling app'));
+ $('#leftcontent li[data-id="'+appid+'"]').data('errormsg', t('settings', 'Error while disabling app'));
}
+ element.val(t('settings','Disable'));
+ $('#leftcontent li[data-id="'+appid+'"]').addClass('appwarning');
}
else {
element.data('active',false);
OC.Settings.Apps.removeNavigation(appid);
+ $('#leftcontent li[data-id="'+appid+'"]').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') {
if (result.data && result.data.message) {
- OC.dialogs.alert(result.data.message, t('core', 'Error'));
+ OC.Settings.Apps.showErrorMessage(result.data.message);
+ $('#leftcontent li[data-id="'+appid+'"]').data('errormsg', result.data.message);
} else {
- OC.dialogs.alert(t('settings', 'Error while enabling app'), t('core', 'Error'));
+ OC.Settings.Apps.showErrorMessage(t('settings', 'Error while enabling app'));
+ $('#leftcontent li[data-id="'+appid+'"]').data('errormsg', t('settings', 'Error while disabling app'));
}
element.val(t('settings','Enable'));
+ $('#leftcontent li[data-id="'+appid+'"]').addClass('appwarning');
} else {
OC.Settings.Apps.addNavigation(appid);
element.data('active',true);
+ $('#leftcontent li[data-id="'+appid+'"]').addClass('active');
element.val(t('settings','Disable'));
}
},'json')
.fail(function() {
- OC.dialogs.alert(t('settings', 'Error while enabling app'), t('core', 'Error'));
+ OC.Settings.Apps.showErrorMessage(t('settings', 'Error while enabling app'));
+ $('#leftcontent li[data-id="'+appid+'"]').data('errormsg', t('settings', 'Error while enabling app'));
element.data('active',false);
OC.Settings.Apps.removeNavigation(appid);
element.val(t('settings','Enable'));
});
- $('#leftcontent li[data-id="'+appid+'"]').addClass('active');
}
},
updateApp:function(appid, element) {
@@ -103,7 +117,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'));
@@ -175,6 +190,10 @@ OC.Settings.Apps = OC.Settings.Apps || {
}
}
});
+ },
+ showErrorMessage: function(message) {
+ $('#rightcontent .errormsg').show();
+ $('#rightcontent .errormsg').text(message);
}
};
diff --git a/settings/templates/apps.php b/settings/templates/apps.php
index d60fd82f91..b6b731ac9c 100644
--- a/settings/templates/apps.php
+++ b/settings/templates/apps.php
@@ -41,5 +41,6 @@
print_unescaped($l->t('-licensed by '));?>
+