[minor] added "Remove app" and updated app list, fixes #1558

This commit is contained in:
Rushabh Mehta 2016-12-27 13:23:11 +05:30
parent 4fcd372921
commit 63b26b0fad
5 changed files with 41 additions and 36 deletions

View file

@ -1,13 +0,0 @@
{
"app_url": "https://github.com/frappe/knowledge_base",
"app_name": "knowledge_base",
"app_icon": "fa fa-question-sign",
"app_color": "#4cd964",
"app_description": "Publish help articles by category on the portal",
"app_publisher": "Frappe",
"app_email": "hello@frappe.io",
"repo_url": "https://github.com/frappe/knowledge_base.git",
"app_title": "Knowledge Base",
"app_version": "0.1.0",
"app_category": "Portal"
}

View file

@ -1,13 +0,0 @@
{
"app_url": "https://github.com/frappe/poll",
"app_name": "poll",
"app_icon": "fa fa-ok-sign",
"app_color": "#4cd964",
"app_description": "Online poll for the website",
"app_publisher": "Frappe",
"app_email": "hello@frappe.io",
"repo_url": "https://github.com/frappe/poll.git",
"app_title": "Poll",
"app_version": "0.1.0",
"app_category": "Portal"
}

View file

@ -7,8 +7,10 @@
<a class="btn btn-default btn-xs"
href="{{ app.app_url }}" target="_blank">{{ __("Website") }}</a>
{% if (app.installed) { %}
<button class="btn btn-default btn-xs" disabled=disabled>
{{ __("Installed") }}</button>
<button class="btn btn-danger btn-xs btn-remove"
data-title="{{ app.app_title }}"
data-app="{{ app.app_name }}">
{{ __("Remove") }}</button>
{% } else { %}
<button class="btn btn-primary btn-xs install"
data-app="{{ app.app_name }}"

View file

@ -150,6 +150,10 @@ frappe.applications.Installer = Class.extend({
me.install_app($(this).attr("data-app"), $(this).attr("data-title"), this);
});
this.wrapper.find(".btn-remove").on("click", function() {
me.remove_app($(this).attr("data-app"), $(this).attr("data-title"), this);
});
},
update_no_result: function() {
@ -162,13 +166,18 @@ frappe.applications.Installer = Class.extend({
method: "frappe.desk.page.applications.applications.install_app",
args: { name: app_name },
freeze: true,
btn: btn,
callback: function(r) {
if(!r.exc) {
frappe.update_msgprint(__("Refreshing..."));
setTimeout(function() { window.location.reload() }, 2000)
}
}
btn: btn
});
});
},
remove_app: function(app_name, app_title, btn) {
frappe.confirm(__("Remove {0} and delete all data?", [app_title]), function() {
frappe.call({
method: "frappe.desk.page.applications.applications.remove_app",
args: { name: app_name },
freeze: true,
btn: btn
});
});
},
@ -193,7 +202,6 @@ frappe.applications.Installer = Class.extend({
frappe.realtime.on("install_app_progress", function(data) {
if(data.status) {
frappe.update_msgprint(data.status);
msg_dialog.show_loading();
}
})
}

View file

@ -11,6 +11,7 @@ import os
import json
from frappe import _
from distutils.spawn import find_executable
from frappe.utils.background_jobs import enqueue
@frappe.whitelist()
def get_app_list():
@ -73,6 +74,12 @@ def install_app(name):
if app_hooks.get('hide_in_installer'):
frappe.throw(_("You cannot install this app"))
enqueue('frappe.desk.page.applications.applications.start_install', name=name)
frappe.msgprint(_('Queued for install'))
def start_install(name):
frappe.publish_realtime("install_app_progress", {"status": _("Installing App {0}").format(name)},
user=frappe.session.user)
@ -81,6 +88,20 @@ def install_app(name):
frappe.publish_realtime("install_app_progress", {"status": _("{0} Installed").format(name)},
user=frappe.session.user)
@frappe.whitelist()
def remove_app(name):
"""Remove installed app"""
frappe.only_for("System Manager")
if name in frappe.get_installed_apps():
enqueue('frappe.desk.page.applications.applications.start_remove', name=name)
frappe.msgprint(_('Queued for backup and removing {0}').format(frappe.bold(name)))
def start_remove(name):
frappe.installer.remove_app(app_name=name, yes=True)
frappe.publish_realtime('msgprint', _('App {0} removed').format(frappe.bold(name)))
def get_app(name):
"""Get app using git clone and install it in bench environment"""
app_listing = get_app_listing()