mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
extensions 2
This commit is contained in:
@@ -33,6 +33,51 @@ class Extension extends \Espo\Core\Controllers\Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
public function actionUpload($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$manager = new \Espo\Core\ExtensionManager($this->getContainer());
|
||||
|
||||
$id = $manager->upload($data);
|
||||
$manifest = $manager->getManifest();
|
||||
|
||||
return array(
|
||||
'id' => $id,
|
||||
'version' => $manifest['version'],
|
||||
'name' => $manifest['name'],
|
||||
'description' => $manifest['description'],
|
||||
);
|
||||
}
|
||||
|
||||
public function actionInstall($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$manager = new \Espo\Core\ExtensionManager($this->getContainer());
|
||||
|
||||
$manager->run($data['id']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function actionUninstall($params, $data, $request)
|
||||
{
|
||||
if (!$request->isPost()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
|
||||
$manager = new \Espo\Core\ExtensionManager($this->getContainer());
|
||||
|
||||
$manager->uninstall($data['id']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function actionCreate()
|
||||
{
|
||||
|
||||
36
application/Espo/Core/ExtensionManager.php
Normal file
36
application/Espo/Core/ExtensionManager.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
class ExtensionManager extends Upgrades\Base
|
||||
{
|
||||
protected $packagePath = 'data/upload/extensions';
|
||||
|
||||
protected $scriptNames = array(
|
||||
'before' => 'BeforeUpgrade',
|
||||
'after' => 'AfterUpgrade',
|
||||
);
|
||||
|
||||
}
|
||||
@@ -35,7 +35,15 @@
|
||||
"Extensions": "Extensions",
|
||||
"Upload": "Upload",
|
||||
"Installing...": "Installing...",
|
||||
"Upgrading...": "Upgrading..."
|
||||
"Upgrading...": "Upgrading...",
|
||||
"Upgraded successfully": "Upgraded successfully",
|
||||
"Installed successfully": "Installed successfully",
|
||||
"Ready for upgrade": "Ready for upgrade",
|
||||
"Run Upgrade": "Run Upgrade",
|
||||
"Install": "Install",
|
||||
"Ready for installation": "Ready for installation",
|
||||
"Uninstalling...": "Uninstalling...",
|
||||
"Uninstalled": "Uninstalled"
|
||||
},
|
||||
"layouts": {
|
||||
"list": "List",
|
||||
@@ -102,7 +110,10 @@
|
||||
"selectUpgradePackage": "Select upgrade package",
|
||||
"downloadUpgradePackage": "Download needed upgrade package(s) <a href=\"https://sourceforge.net/projects/espocrm/files/Upgrades/\">here</a>.",
|
||||
"selectLayout": "Select needed layout in the left menu and edit it.",
|
||||
"selectExtensionPackage": "Select extension package"
|
||||
"selectExtensionPackage": "Select extension package",
|
||||
"extensionInstalled": "Extension {name} {version} has been installed.",
|
||||
"installExtension": "Extension {name} {version} is ready for an istallation.",
|
||||
"uninstallConfirmation": "Are you really want to uninstall the extension?"
|
||||
},
|
||||
"descriptions": {
|
||||
"settings": "System settings of application.",
|
||||
|
||||
5
frontend/client/res/templates/admin/extensions/done.tpl
Normal file
5
frontend/client/res/templates/admin/extensions/done.tpl
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
<p class="text-success">
|
||||
{{{text}}}
|
||||
</p>
|
||||
|
||||
5
frontend/client/res/templates/admin/extensions/ready.tpl
Normal file
5
frontend/client/res/templates/admin/extensions/ready.tpl
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
<p class="text-danger">
|
||||
{{{text}}}
|
||||
</p>
|
||||
|
||||
63
frontend/client/src/views/admin/extensions/done.js
Normal file
63
frontend/client/src/views/admin/extensions/done.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('Views.Admin.Extensions.Done', 'Views.Modal', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
cssName: 'done-modal',
|
||||
|
||||
header: false,
|
||||
|
||||
template: 'admin.extensions.done',
|
||||
|
||||
createButton: true,
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
version: this.options.version,
|
||||
name: this.options.name,
|
||||
text: this.translate('extensionInstalled', 'messages', 'Admin').replace('{version}', this.options.version)
|
||||
.replace('{name}', this.options.name)
|
||||
};
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
this.buttons = [
|
||||
{
|
||||
name: 'close',
|
||||
label: 'Close',
|
||||
onClick: function (dialog) {
|
||||
setTimeout(function () {
|
||||
this.getRouter().navigate('#Admin', {trigger: true});
|
||||
}.bind(this), 500);
|
||||
dialog.close();
|
||||
}.bind(this)
|
||||
}
|
||||
];
|
||||
|
||||
this.header = this.getLanguage().translate('Installed successfully', 'labels', 'Admin');
|
||||
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,6 +38,24 @@ Espo.define('Views.Admin.Extensions.Index', 'View', function (Dep) {
|
||||
},
|
||||
'click button[data-action="upload"]': function () {
|
||||
this.upload();
|
||||
},
|
||||
'click [data-action="uninstall"]': function (e) {
|
||||
var id = $(e.currentTarget).data('id');
|
||||
|
||||
var self = this;
|
||||
if (confirm(this.translate('uninstallConfirmation', 'messages', 'Admin'))) {
|
||||
Espo.Ui.notify(this.translate('Uninstalling...', 'labels', 'Admin'));
|
||||
|
||||
$.ajax({
|
||||
url: 'Extension/action/uninstall',
|
||||
type: 'POST',
|
||||
data: JSON.stringify({
|
||||
id: id
|
||||
})
|
||||
}).done(function () {
|
||||
this.collection.fetch();
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -103,7 +121,7 @@ Espo.define('Views.Admin.Extensions.Index', 'View', function (Dep) {
|
||||
view.once('run', function () {
|
||||
view.close();
|
||||
this.$el.find('.panel.upload').addClass('hidden');
|
||||
this.run(data.id, data.version);
|
||||
this.run(data.id, data.version, data.name);
|
||||
}, this);
|
||||
}.bind(this));
|
||||
}.bind(this)).error;
|
||||
@@ -113,7 +131,7 @@ Espo.define('Views.Admin.Extensions.Index', 'View', function (Dep) {
|
||||
this.$el.find('.notify-text').html(text);
|
||||
},
|
||||
|
||||
run: function (id, version) {
|
||||
run: function (id, version, name) {
|
||||
var msg = this.translate('Installing...', 'labels', 'Admin');
|
||||
this.notify('Please wait...');
|
||||
this.textNotification(msg);
|
||||
@@ -134,7 +152,8 @@ Espo.define('Views.Admin.Extensions.Index', 'View', function (Dep) {
|
||||
cache.clear();
|
||||
}
|
||||
this.createView('popup', 'Admin.Extensions.Done', {
|
||||
version: version
|
||||
version: version,
|
||||
name: name
|
||||
}, function (view) {
|
||||
this.notify(false);
|
||||
view.render();
|
||||
|
||||
74
frontend/client/src/views/admin/extensions/ready.js
Normal file
74
frontend/client/src/views/admin/extensions/ready.js
Normal file
@@ -0,0 +1,74 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('Views.Admin.Extensions.Ready', 'Views.Modal', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
cssName: 'ready-modal',
|
||||
|
||||
header: false,
|
||||
|
||||
template: 'admin.extensions.ready',
|
||||
|
||||
createButton: true,
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
version: this.upgradeData.version,
|
||||
text: this.translate('installExtension', 'messages', 'Admin').replace('{version}', this.upgradeData.version)
|
||||
.replace('{name}', this.upgradeData.name)
|
||||
};
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
|
||||
this.buttons = [
|
||||
{
|
||||
name: 'run',
|
||||
text: this.translate('Install', 'labels', 'Admin'),
|
||||
style: 'danger',
|
||||
onClick: function (dialog) {
|
||||
this.run();
|
||||
}.bind(this)
|
||||
},
|
||||
{
|
||||
name: 'cancel',
|
||||
label: 'Cancel',
|
||||
onClick: function (dialog) {
|
||||
dialog.close();
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
this.upgradeData = this.options.upgradeData;
|
||||
|
||||
this.header = this.getLanguage().translate('Ready for installation', 'labels', 'Admin');
|
||||
|
||||
},
|
||||
|
||||
run: function () {
|
||||
this.trigger('run');
|
||||
this.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ Espo.define('Views.Admin.Upgrade.Ready', 'Views.Modal', function (Dep) {
|
||||
this.buttons = [
|
||||
{
|
||||
name: 'run',
|
||||
label: 'Run Upgrade',
|
||||
label: this.translate('Run Upgrade', 'labels', 'Admin'),
|
||||
style: 'danger',
|
||||
onClick: function (dialog) {
|
||||
this.run();
|
||||
|
||||
Reference in New Issue
Block a user