aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Admin.php23
-rwxr-xr-xview/tpl/admin_plugins.tpl26
-rw-r--r--view/tpl/admin_plugins_addrepo.tpl2
3 files changed, 39 insertions, 12 deletions
diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php
index 9bc0482c0..ae0a0ad85 100644
--- a/Zotlabs/Module/Admin.php
+++ b/Zotlabs/Module/Admin.php
@@ -1651,10 +1651,8 @@ class Admin extends \Zotlabs\Web\Controller {
if(array_key_exists('repoURL',$_REQUEST)) {
require __DIR__ . '/../../library/PHPGit.autoload.php'; // Load PHPGit dependencies
- info('Repo URL submitted: ' . $_REQUEST['repoURL']);
- //$git = new Git();
+ logger('Repo URL submitted: ' . $_REQUEST['repoURL']);
$repoURL = $_REQUEST['repoURL'];
- //logger('hubsites: new git object created: ' . json_encode($git));
$urlpath = parse_url($repoURL, PHP_URL_PATH);
$lastslash = strrpos($urlpath, '/') + 1;
$gitext = strrpos($urlpath, '.');
@@ -1666,27 +1664,32 @@ class Admin extends \Zotlabs\Web\Controller {
break;
}
$storepath = realpath(__DIR__ . '/../../store/');
- logger('storepath: ' . $storepath);
+ //logger('storepath: ' . $storepath);
$repopath = $storepath . '/pluginrepos/' . $reponame;
if (!file_exists($repopath)) {
- logger('epopath does not exist');
+ //logger('repopath does not exist');
if (mkdir($repopath, 0770, true)) {
- logger('repopath created');
+ //logger('repopath created');
$git = new Git();
- logger('new git object created');
+ //logger('new git object created');
$cloned = $git->clone($repoURL, $repopath);
if (!$cloned) {
logger('git clone failed');
notice('Repo coule not be cloned. Filesystem path error.');
- return null;
+ json_return_and_die(array('message' => 'Repo coule not be cloned. Filesystem path error.', 'success' => false));
}
+ json_return_and_die(array('message' => 'Successfully cloned to: ' . $repopath , 'success' => true));
} else {
logger('repopath could not be created');
notice('Repo coule not be cloned. Filesystem path error.');
- return null;
+ json_return_and_die(array('message' => 'Repo coule not be cloned. Filesystem path error', 'success' => false));
}
- }
+ } else {
+ json_return_and_die(array('message' => 'Repo already exists at: ' . $repopath, 'success' => true));
+ }
+ } else {
+ json_return_and_die(array('message' => 'No repo URL provided', 'success' => false));
}
break;
default:
diff --git a/view/tpl/admin_plugins.tpl b/view/tpl/admin_plugins.tpl
index 3747a59f9..e10cde81d 100755
--- a/view/tpl/admin_plugins.tpl
+++ b/view/tpl/admin_plugins.tpl
@@ -10,6 +10,11 @@
{{$form}}
</div>
<div class="clear"></div>
+ <div id="chat-rotator-wrapper" class="center-block">
+ <div id="chat-rotator"></div>
+ </div>
+ <div class="clear"></div>
+ <div id="new-repo-info" class="section-content-wrapper"></div>
<div class="section-content-wrapper-np">
{{foreach $plugins as $p}}
<div class="section-content-tools-wrapper" id="pluginslist">
@@ -28,4 +33,23 @@
{{/foreach}}
</div>
-</div> \ No newline at end of file
+</div>
+
+<script>
+ function adminPluginsAddRepo() {
+ var repoURL = $('#id_repoURL').val();
+ $('#chat-rotator').spin('tiny');
+ $.post(
+ "/admin/plugins/addrepo", {repoURL: repoURL},
+ function(response) {
+ $('#chat-rotator').spin(false);
+ if (response.success) {
+ $('#new-repo-info').html('<h3>Repo Info</h3><p>The repo was cloned to<br>' + response.message + '</p>');
+ } else {
+ window.console.log('Error adding repo :' + response['message']);
+ }
+ return false;
+ },
+ 'json');
+ }
+</script> \ No newline at end of file
diff --git a/view/tpl/admin_plugins_addrepo.tpl b/view/tpl/admin_plugins_addrepo.tpl
index f6264f879..fe5fecc25 100644
--- a/view/tpl/admin_plugins_addrepo.tpl
+++ b/view/tpl/admin_plugins_addrepo.tpl
@@ -3,6 +3,6 @@
<p class="descriptive-text">{{$desc}}</p>
{{include file="field_input.tpl" field=$repoURL}}
<div class="btn-group pull-right">
- <button id="add-plugin-repo-submit" class="btn btn-primary" type="submit" name="submit">{{$submit}}</button>
+ <button id="add-plugin-repo-submit" class="btn btn-primary" type="submit" name="submit" onclick="adminPluginsAddRepo(); return false;">{{$submit}}</button>
</div>
</form>