copy-paste error

This commit is contained in:
Andrew Manning 2016-05-09 21:17:47 -04:00
parent d714cd76dd
commit 180731c162
3 changed files with 47 additions and 10 deletions

View File

@ -51,6 +51,10 @@ class Admin extends \Zotlabs\Web\Controller {
$this->admin_page_plugins_post('removerepo'); $this->admin_page_plugins_post('removerepo');
break; break;
} }
if (argc() > 2 && argv(2) === 'updaterepo') {
$this->admin_page_plugins_post('updaterepo');
break;
}
if (argc() > 2 && if (argc() > 2 &&
is_file("addon/" . argv(2) . "/" . argv(2) . ".php")){ is_file("addon/" . argv(2) . "/" . argv(2) . ".php")){
@include_once("addon/" . argv(2) . "/" . argv(2) . ".php"); @include_once("addon/" . argv(2) . "/" . argv(2) . ".php");
@ -1714,6 +1718,22 @@ class Admin extends \Zotlabs\Web\Controller {
function admin_page_plugins_post($action) { function admin_page_plugins_post($action) {
switch($action) { switch($action) {
case 'updaterepo':
if(array_key_exists('repoName', $_REQUEST)) {
$repoName = $_REQUEST['repoName'];
} else {
json_return_and_die(array('message' => 'No repo name provided.', 'success' => false));
}
$repoDir = __DIR__ . '/../../store/git/sys/extend/addon/'.$repoName;
if(!is_dir($repoDir)) {
json_return_and_die(array('message' => 'Invalid addon repo.', 'success' => false));
}
$git = new GitRepo('sys', null, false, $repoName, $repoDir);
if($git->pull()) {
json_return_and_die(array('message' => 'Repo updated.', 'success' => true));
} else {
json_return_and_die(array('message' => 'Error updating addon repo.', 'success' => false));
}
case 'removerepo': case 'removerepo':
if(array_key_exists('repoName', $_REQUEST)) { if(array_key_exists('repoName', $_REQUEST)) {
$repoName = $_REQUEST['repoName']; $repoName = $_REQUEST['repoName'];

View File

@ -82,7 +82,9 @@ class GitRepo {
} }
} }
} }
public function pull() {
return $this->git->pull();
}
/** /**
* delete repository from disk * delete repository from disk
*/ */

View File

@ -14,18 +14,19 @@
<div id="chat-rotator"></div> <div id="chat-rotator"></div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
<div class="section-content-wrapper"> <div class="section-content-info-wrapper">
<h1>Installed Addon Repositories</h1> <h3>Installed Addon Repositories</h3>
{{foreach $addonrepos as $repo}} {{foreach $addonrepos as $repo}}
<div class="section-content-tools-wrapper"> <div class="section-content-tools-wrapper">
<div> <div>
<h2>{{$repo.name}}</h2> <div class="pull-left">{{$repo.name}}</div>
<div class='desc'>{{$repo.description}}</div> <!--<button class="btn btn-xs btn-primary pull-right" onclick="switchAddonRepoBranch('{{$repo.name}}'); return false;">{{$repoBranchButton}}</button>-->
<button class="btn btn-success" onclick="updateAddonRepo('{{$repo.name}}'); return false;">{{$repoUpdateButton}}</button> <button class="btn btn-xs btn-danger pull-right" onclick="removeAddonRepo('{{$repo.name}}'); return false;"><i class='fa fa-trash-o'></i>&nbsp;{{$repoRemoveButton}}</button>
<button class="btn btn-primary" onclick="switchAddonRepoBranch('{{$repo.name}}'); return false;">{{$repoBranchButton}}</button> &nbsp;
<button class="btn btn-danger" onclick="removeAddonRepo('{{$repo.name}}'); return false;">{{$repoRemoveButton}}</button> <button class="btn btn-xs btn-success pull-right" onclick="updateAddonRepo('{{$repo.name}}'); return false;"><i class='fa fa-download'></i>&nbsp;{{$repoUpdateButton}}</button>
</div> </div>
</div> </div>
<div class="clear"></div>
{{/foreach}} {{/foreach}}
</div> </div>
<div class="section-content-wrapper-np"> <div class="section-content-wrapper-np">
@ -110,6 +111,20 @@
function updateAddonRepo(repoName) { function updateAddonRepo(repoName) {
window.console.log('updateAddonRep:; ' + repoName); window.console.log('updateAddonRep:; ' + repoName);
// TODO: Update an existing repo // TODO: Update an existing repo
if(confirm('Are you sure you want to update the addon repo ' + repoName + '?')) {
$.post(
"/admin/plugins/updaterepo", {repoName: repoName},
function(response) {
if (response.success) {
window.console.log('Addon repo'+repoName+'successfully updated :' + response['message']);
alert('Repo updated');
} else {
window.console.log('Error installing repo :' + response['message']);
}
return false;
},
'json');
}
} }
function switchAddonRepoBranch(repoName) { function switchAddonRepoBranch(repoName) {
window.console.log('switchAddonRepoBranch: ' + repoName); window.console.log('switchAddonRepoBranch: ' + repoName);
@ -117,20 +132,20 @@
} }
function removeAddonRepo(repoName) { function removeAddonRepo(repoName) {
window.console.log('removeAddonRepo: ' + repoName); window.console.log('removeAddonRepo: ' + repoName);
// TODO: Unlink the addons and delete the addon repo // TODO: Unlink the addons
if(confirm('Are you sure you want to remove the addon repo ' + repoName + '?')) { if(confirm('Are you sure you want to remove the addon repo ' + repoName + '?')) {
$.post( $.post(
"/admin/plugins/removerepo", {repoName: repoName}, "/admin/plugins/removerepo", {repoName: repoName},
function(response) { function(response) {
if (response.success) { if (response.success) {
window.console.log('Addon repo'+repoName+'successfully removed :' + response['message']); window.console.log('Addon repo'+repoName+'successfully removed :' + response['message']);
alert('Repo deleted');
} else { } else {
window.console.log('Error installing repo :' + response['message']); window.console.log('Error installing repo :' + response['message']);
} }
return false; return false;
}, },
'json'); 'json');
//alert('Deleted');
} }
} }