mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Fix custom app install + misc detail in regular app install
This commit is contained in:
parent
a3a0d8f49a
commit
1592ab4e73
4 changed files with 62 additions and 53 deletions
|
@ -235,6 +235,22 @@
|
|||
jQuery("#filter-app-cards").on("keyup", function() {
|
||||
cardGrid.isotope({ filter: filterApps });
|
||||
});
|
||||
|
||||
$("#install-custom-app a[role='button']").on('click', function() {
|
||||
|
||||
var url = $("#install-custom-app input[name='url']")[0].value;
|
||||
if (url.indexOf("github.com") < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
c.confirm(
|
||||
y18n.t('applications'),
|
||||
y18n.t('confirm_install_custom_app'),
|
||||
function(){
|
||||
c.redirect_to('#/apps/install/custom/' + encodeURIComponent(url));
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
// render
|
||||
|
@ -376,13 +392,6 @@
|
|||
});
|
||||
})
|
||||
|
||||
// Special case for custom app installation.
|
||||
app.get('#/apps/install/custom', function (c) {
|
||||
// If we try to GET /apps/install/custom, it means that installation fail.
|
||||
// Need to redirect to apps/install to get rid of pacamn and see the log.
|
||||
c.redirect_to('#/apps/install');
|
||||
});
|
||||
|
||||
// Helper function that formats YunoHost style arguments for generating a form
|
||||
function formatYunoHostStyleArguments(args, params) {
|
||||
if (!args) {
|
||||
|
@ -533,16 +542,24 @@
|
|||
displayLicense: (manifest['license'] !== undefined && manifest['license'] !== 'free')
|
||||
};
|
||||
|
||||
formatYunoHostStyleArguments(data.manifest.arguments.install, params);
|
||||
formatYunoHostStyleArguments(manifest.arguments.install, params);
|
||||
|
||||
// Multilingual description
|
||||
data.description = (typeof data.manifest.description[y18n.locale] !== 'undefined') ?
|
||||
data.manifest.description[y18n.locale] :
|
||||
data.manifest.description['en']
|
||||
;
|
||||
if (typeof manifest.description === 'string')
|
||||
{
|
||||
data.description = manifest.description;
|
||||
}
|
||||
else if (typeof manifest.description[y18n.locale] !== 'undefined')
|
||||
{
|
||||
data.description = manifest.description[y18n.locale];
|
||||
}
|
||||
else
|
||||
{
|
||||
data.description = manifest.description['en'];
|
||||
}
|
||||
|
||||
// Multi Instance settings boolean to text
|
||||
data.manifest.multi_instance = data.manifest.multi_instance ? y18n.t('yes') : y18n.t('no');
|
||||
data.manifest.multi_instance = manifest.multi_instance ? y18n.t('yes') : y18n.t('no');
|
||||
|
||||
// View app install form
|
||||
c.view('app/app_install', data);
|
||||
|
@ -573,13 +590,16 @@
|
|||
app_infos.manifest,
|
||||
c.params
|
||||
);
|
||||
},
|
||||
function () {
|
||||
c.redirect_to('#/apps/catalog');
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
c.appInstallForm(
|
||||
c.params['app'],
|
||||
app_name,
|
||||
app_infos.manifest,
|
||||
c.params
|
||||
);
|
||||
|
@ -624,45 +644,31 @@
|
|||
});
|
||||
|
||||
// Install custom app from github
|
||||
app.post('#/apps/install/custom', function(c) {
|
||||
app.get('#/apps/install/custom/:url', function(c) {
|
||||
|
||||
var params = {
|
||||
label: c.params['label'],
|
||||
app: c.params['url']
|
||||
};
|
||||
delete c.params['label'];
|
||||
delete c.params['url'];
|
||||
// Force trailing slash
|
||||
url = c.params['url'];
|
||||
url = url.replace(/\/?$/, '/');
|
||||
raw_manifest_url = url.replace('github.com', 'raw.githubusercontent.com') + 'master/manifest.json'
|
||||
|
||||
c.confirm(
|
||||
y18n.t('applications'),
|
||||
y18n.t('confirm_install_custom_app'),
|
||||
function(){
|
||||
// Fetch manifest.json
|
||||
jQuery.ajax({ url: raw_manifest_url, type: 'GET' })
|
||||
.done(function(manifest) {
|
||||
// raw.githubusercontent.com serve content as plain text
|
||||
manifest = jQuery.parseJSON(manifest) || {};
|
||||
|
||||
// Force trailing slash
|
||||
params.app = params.app.replace(/\/?$/, '/');
|
||||
c.appInstallForm(
|
||||
url,
|
||||
manifest,
|
||||
c.params
|
||||
);
|
||||
|
||||
// Get manifest.json to get additional parameters
|
||||
jQuery.ajax({
|
||||
url: params.app.replace('github.com', 'raw.githubusercontent.com') + 'master/manifest.json',
|
||||
type: 'GET',
|
||||
})
|
||||
.done(function(manifest) {
|
||||
// raw.githubusercontent.com serve content as plain text
|
||||
manifest = jQuery.parseJSON(manifest) || {};
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
c.flash('fail', y18n.t('app_install_custom_no_manifest'));
|
||||
c.redirect("#/apps/catalog/");
|
||||
});
|
||||
|
||||
c.appInstallForm(
|
||||
params.app,
|
||||
manifest,
|
||||
c.params
|
||||
);
|
||||
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
c.flash('fail', y18n.t('app_install_custom_no_manifest'));
|
||||
c.refresh();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Get app change label page
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
app.before(/domains\/add/, prefetchDomains);
|
||||
app.before(/apps\/install\//, prefetchDomains);
|
||||
app.before(/apps\/install\//, prefetchUsers);
|
||||
app.before(/apps\/install\/custom\//, prefetchDomains);
|
||||
app.before(/apps\/install\/custom\//, prefetchUsers);
|
||||
app.before(/apps\/\w+\/actions/, prefetchUsers);
|
||||
app.before(/apps\/\w+\/actions/, prefetchDomains);
|
||||
app.before(/apps\/\w+\/config-panel/, prefetchUsers);
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
{{/apps}}
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div id="install-custom-app" class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title"><span class="fa-fw fa-download"></span> {{t 'custom_app_install'}}</h2>
|
||||
</div>
|
||||
|
@ -92,7 +92,8 @@
|
|||
<span class="fa-fw fa-warning"></span>
|
||||
{{t 'confirm_install_custom_app'}}
|
||||
</p>
|
||||
<form action="#/apps/install/custom" method="POST" class="form-horizontal">
|
||||
|
||||
<form class="form-horizontal">
|
||||
<div class="form-group has-feedback">
|
||||
<label for="url" class="col-sm-12">{{t 'url'}}</label>
|
||||
<div class="col-sm-12">
|
||||
|
@ -104,7 +105,7 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<div class="text-center">
|
||||
<input type="submit" role="button" class="btn btn-success slide" value="{{t 'install'}}">
|
||||
<a role="button" class="btn btn-success slide">{{t 'install'}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>{{t 'id'}}</dt>
|
||||
<dd>{{id}}</dd>
|
||||
<dd>{{manifest.id}}</dd>
|
||||
<dt>{{t 'description'}}</dt>
|
||||
<dd>{{manifest.description}}</dd>
|
||||
<dd>{{description}}</dd>
|
||||
{{#displayLicense}}
|
||||
<dt>{{t 'license'}}</dt>
|
||||
<dd>{{manifest.license}}</dd>
|
||||
|
|
Loading…
Add table
Reference in a new issue