mirror of
				https://github.com/billz/raspap-webgui.git
				synced 2025-03-01 10:31:47 +00:00 
			
		
		
		
	Set/read plugin-installed flag
This commit is contained in:
		@@ -471,54 +471,65 @@ $('#js-sys-reboot, #js-sys-shutdown').on('click', function (e) {
 | 
			
		||||
$('#install-user-plugin').on('shown.bs.modal', function (e) {
 | 
			
		||||
    var button = $(e.relatedTarget);
 | 
			
		||||
    var manifestData = button.data('plugin-manifest');
 | 
			
		||||
    var installed = button.data('plugin-installed');
 | 
			
		||||
 | 
			
		||||
        if (manifestData) {
 | 
			
		||||
            $('#plugin-uri').html(manifestData.plugin_uri
 | 
			
		||||
                ? `<a href="${manifestData.plugin_uri}" target="_blank">${manifestData.plugin_uri}</a>`
 | 
			
		||||
                : 'Unknown'
 | 
			
		||||
    if (manifestData) {
 | 
			
		||||
        $('#plugin-uri').html(manifestData.plugin_uri
 | 
			
		||||
            ? `<a href="${manifestData.plugin_uri}" target="_blank">${manifestData.plugin_uri}</a>`
 | 
			
		||||
            : 'Unknown'
 | 
			
		||||
        );
 | 
			
		||||
        $('#plugin-icon').attr('class', `${manifestData.icon || 'fas fa-plug'} link-secondary h5 me-2`);
 | 
			
		||||
        $('#plugin-name').text(manifestData.name || 'Unknown');
 | 
			
		||||
        $('#plugin-version').text(manifestData.version || 'Unknown');
 | 
			
		||||
        $('#plugin-description').text(manifestData.description || 'No description provided');
 | 
			
		||||
        $('#plugin-author').html(manifestData.author
 | 
			
		||||
                ? manifestData.author + (manifestData.author_uri
 | 
			
		||||
                ? ` (<a href="${manifestData.author_uri}" target="_blank">profile</a>)` : '') : 'Unknown'
 | 
			
		||||
            );
 | 
			
		||||
            $('#plugin-icon').attr('class', `${manifestData.icon || 'fas fa-plug'} link-secondary h5 me-2`);
 | 
			
		||||
            $('#plugin-name').text(manifestData.name || 'Unknown');
 | 
			
		||||
            $('#plugin-version').text(manifestData.version || 'Unknown');
 | 
			
		||||
            $('#plugin-description').text(manifestData.description || 'No description provided');
 | 
			
		||||
            $('#plugin-author').html(manifestData.author
 | 
			
		||||
                    ? manifestData.author + (manifestData.author_uri
 | 
			
		||||
                    ? ` (<a href="${manifestData.author_uri}" target="_blank">profile</a>)` : '') : 'Unknown'
 | 
			
		||||
                );
 | 
			
		||||
            $('#plugin-license').text(manifestData.license || 'Unknown');
 | 
			
		||||
            $('#plugin-locale').text(manifestData.default_locale || 'Unknown');
 | 
			
		||||
            $('#plugin-configuration').html(formatProperty(manifestData.configuration || {}));
 | 
			
		||||
            $('#plugin-dependencies').html(formatProperty(manifestData.dependencies || {}));
 | 
			
		||||
            $('#plugin-sudoers').html(formatProperty(manifestData.sudoers || []));
 | 
			
		||||
            $('#plugin-user-name').html(manifestData.user_nonprivileged.name || 'None');
 | 
			
		||||
        }
 | 
			
		||||
        $('#plugin-license').text(manifestData.license || 'Unknown');
 | 
			
		||||
        $('#plugin-locale').text(manifestData.default_locale || 'Unknown');
 | 
			
		||||
        $('#plugin-configuration').html(formatProperty(manifestData.configuration || {}));
 | 
			
		||||
        $('#plugin-dependencies').html(formatProperty(manifestData.dependencies || {}));
 | 
			
		||||
        $('#plugin-sudoers').html(formatProperty(manifestData.sudoers || []));
 | 
			
		||||
        $('#plugin-user-name').html(manifestData.user_nonprivileged.name || 'None');
 | 
			
		||||
    }
 | 
			
		||||
    if (installed) {
 | 
			
		||||
        $('#js-install-plugin-confirm').html('OK');
 | 
			
		||||
    } else {
 | 
			
		||||
        $('#js-install-plugin-confirm').html('Install now');
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$('#js-install-plugin-confirm').on('click', function (e) {
 | 
			
		||||
    var progressText = $('#js-install-plugin-confirm').attr('data-message');
 | 
			
		||||
    var successHtml = $('#plugin-install-message').attr('data-message');
 | 
			
		||||
    var closeHtml = $('#js-system-reset-cancel').attr('data-message');
 | 
			
		||||
    var pluginUri = $('#plugin-uri a').attr('href');
 | 
			
		||||
    var pluginVersion = $('#plugin-version').text();
 | 
			
		||||
    var csrfToken = $('meta[name=csrf_token]').attr('content');
 | 
			
		||||
 | 
			
		||||
    $("#install-user-plugin").modal('hide');
 | 
			
		||||
    $("#install-plugin-progress").modal('show');
 | 
			
		||||
 | 
			
		||||
    $.post('ajax/plugins/do_plugin_install.php?',{'plugin_uri': pluginUri, 'plugin_version': pluginVersion, 'csrf_token': csrfToken},function(data){
 | 
			
		||||
        setTimeout(function(){
 | 
			
		||||
            response = JSON.parse(data);
 | 
			
		||||
            if(response === true) {
 | 
			
		||||
                $('#plugin-install-message').text(successHtml);
 | 
			
		||||
                $('#plugin-install-message').find('i').removeClass('fas fa-cog fa-spin link-secondary').addClass('fas fa-check');
 | 
			
		||||
                $('#js-install-plugin-ok').removeAttr("disabled");
 | 
			
		||||
            } else {
 | 
			
		||||
                $('#plugin-install-message').text('An error occurred installing the plugin.');
 | 
			
		||||
                $('#plugin-install-message').find('i').removeClass('fas fa-cog fa-spin link-secondary');
 | 
			
		||||
                $('#js-install-plugin-ok').removeAttr("disabled");
 | 
			
		||||
            }
 | 
			
		||||
        },300);
 | 
			
		||||
    });
 | 
			
		||||
    if ($('#js-install-plugin-confirm').text() === 'Install now') {
 | 
			
		||||
        $("#install-plugin-progress").modal('show');
 | 
			
		||||
 | 
			
		||||
        $.post('ajax/plugins/do_plugin_install.php?',{'plugin_uri': pluginUri,
 | 
			
		||||
            'plugin_version': pluginVersion, 'csrf_token': csrfToken},function(data){
 | 
			
		||||
            setTimeout(function(){
 | 
			
		||||
                response = JSON.parse(data);
 | 
			
		||||
                if (response === true) {
 | 
			
		||||
                    $('#plugin-install-message').contents().first().replaceWith(successHtml);
 | 
			
		||||
                    $('#plugin-install-message').find('i')
 | 
			
		||||
                    .removeClass('fas fa-cog fa-spin link-secondary')
 | 
			
		||||
                    .addClass('fas fa-check');
 | 
			
		||||
                    $('#js-install-plugin-ok').removeAttr("disabled");
 | 
			
		||||
                } else {
 | 
			
		||||
                    $('#plugin-install-message').contents().first().replaceWith('An error occurred installing the plugin.');
 | 
			
		||||
                    $('#plugin-install-message').find('i').removeClass('fas fa-cog fa-spin link-secondary');
 | 
			
		||||
                    $('#js-install-plugin-ok').removeAttr("disabled");
 | 
			
		||||
                }
 | 
			
		||||
            },200);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$('#js-install-plugin-ok').on('click', function (e) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
#
 | 
			
		||||
# PluginInstaller helper for RaspAP 
 | 
			
		||||
# # @author billz
 | 
			
		||||
# @author billz
 | 
			
		||||
# license: GNU General Public License v3.0
 | 
			
		||||
 | 
			
		||||
# Exit on error
 | 
			
		||||
 
 | 
			
		||||
@@ -428,7 +428,7 @@ class PluginInstaller
 | 
			
		||||
            if ($installed === true ) {
 | 
			
		||||
                $button = '<button type="button" class="btn btn-outline btn-primary btn-sm text-nowrap"
 | 
			
		||||
                    name="plugin-details" data-bs-toggle="modal" data-bs-target="#install-user-plugin"
 | 
			
		||||
                    data-plugin-manifest="' .$manifest. '"> ' . _("Installed") .'</button>';
 | 
			
		||||
                    data-plugin-manifest="' .$manifest. '" data-plugin-installed="' .$installed. '"> ' . _("Installed") .'</button>';
 | 
			
		||||
            } else {
 | 
			
		||||
                $button = '<button type="button" class="btn btn-outline btn-primary btn-sm text-nowrap"
 | 
			
		||||
                    name="install-plugin" data-bs-toggle="modal" data-bs-target="#install-user-plugin"
 | 
			
		||||
 
 | 
			
		||||
@@ -164,7 +164,7 @@
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="modal-footer">
 | 
			
		||||
      <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal"><?php echo _("Cancel"); ?></button>
 | 
			
		||||
      <button type="button" id="js-install-plugin-confirm" data-message="<?php echo _("Plugin installation in progress..."); ?>" class="btn btn-outline-success btn-activate"><?php echo _("Install now"); ?></button>
 | 
			
		||||
      <button type="button" id="js-install-plugin-confirm" data-message="<?php echo _("Plugin installation in progress..."); ?>" class="btn btn-outline-success btn-activate"></button>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user