mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Buttons make more sense for this interface
This commit is contained in:
parent
e5ce0ac19d
commit
eab2e2c368
2 changed files with 53 additions and 52 deletions
|
@ -45,7 +45,7 @@
|
|||
|
||||
// Status & actions for a service
|
||||
app.get('#/services/:service', function (c) {
|
||||
c.api('GET', '/services/'+ c.params['service'], {}, function(data) { // ?
|
||||
c.api('GET', '/services/'+ c.params['service'], {}, function(data) {
|
||||
var data2 = {
|
||||
service: data
|
||||
};
|
||||
|
@ -64,7 +64,50 @@
|
|||
{
|
||||
data2.service.active_at = 0;
|
||||
}
|
||||
c.view('service/service_info', data2);
|
||||
c.view('service/service_info', data2, function() {
|
||||
|
||||
// Configure behavior for enable/disable and start/stop buttons
|
||||
$('button[data-action]').on('click', function() {
|
||||
|
||||
var service = $(this).data('service');
|
||||
var action = $(this).data('action');
|
||||
|
||||
c.confirm("Service", y18n.t('confirm_service_' + action, [service]), function(){
|
||||
|
||||
var method = null,
|
||||
endurl = service;
|
||||
|
||||
switch (action) {
|
||||
case 'start':
|
||||
method = 'PUT';
|
||||
break;
|
||||
case 'stop':
|
||||
method = 'DELETE';
|
||||
break;
|
||||
case 'enable':
|
||||
method = 'PUT';
|
||||
endurl += '/enable';
|
||||
break;
|
||||
case 'disable':
|
||||
method = 'DELETE';
|
||||
endurl += '/enable';
|
||||
break;
|
||||
default:
|
||||
c.flash('fail', y18n.t('unknown_action', [action]));
|
||||
c.redirect_to('#/services/'+ service, {slide: false});
|
||||
}
|
||||
|
||||
if (method && endurl) {
|
||||
c.api(method, '/services/'+ endurl, {}, function(data) {
|
||||
c.redirect_to('#/services/'+ service, {slide: false});
|
||||
});
|
||||
}
|
||||
else {
|
||||
c.redirect_to('#/services/'+ service, {slide: false});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -83,46 +126,4 @@
|
|||
});
|
||||
});
|
||||
|
||||
// Enable/Disable & Start/Stop service
|
||||
app.get('#/services/:service/:action', function (c) {
|
||||
c.confirm(
|
||||
"Service",
|
||||
// confirm_service_start, confirm_service_stop, confirm_service_enable and confirm_service_disable
|
||||
y18n.t('confirm_service_' + c.params['action'].toLowerCase(), [c.params['service']]),
|
||||
function(){
|
||||
var method = null,
|
||||
endurl = c.params['service'];
|
||||
|
||||
switch (c.params['action']) {
|
||||
case 'start':
|
||||
method = 'PUT';
|
||||
break;
|
||||
case 'stop':
|
||||
method = 'DELETE';
|
||||
break;
|
||||
case 'enable':
|
||||
method = 'PUT';
|
||||
endurl += '/enable';
|
||||
break;
|
||||
case 'disable':
|
||||
method = 'DELETE';
|
||||
endurl += '/enable';
|
||||
break;
|
||||
default:
|
||||
c.flash('fail', y18n.t('unknown_action', [c.params['action']]));
|
||||
c.redirect_to('#/services/'+ c.params['service'], {slide: false});
|
||||
}
|
||||
|
||||
if (method && endurl) {
|
||||
c.api(method, '/services/'+ endurl, {}, function(data) {
|
||||
c.redirect_to('#/services/'+ c.params['service'], {slide: false});
|
||||
});
|
||||
}
|
||||
else {
|
||||
c.redirect_to('#/services/'+ c.params['service'], {slide: false});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
|
@ -53,25 +53,25 @@
|
|||
|
||||
<div class="pull-right">
|
||||
{{#is_loaded}}
|
||||
<a href="#/services/{{name}}/disable" role="button" class="btn btn-danger">
|
||||
<button class="btn btn-danger" data-service="{{name}}" data-action="disable">
|
||||
<span class="fa-square-o"></span> {{t 'disable'}}
|
||||
</a>
|
||||
</button>
|
||||
{{/is_loaded}}
|
||||
{{^is_loaded}}
|
||||
<a href="#/services/{{name}}/enable" role="button" class="btn btn-success">
|
||||
<button class="btn btn-success" data-service="{{name}}" data-action="enable">
|
||||
<span class="fa-check-square-o"></span> {{t 'enable'}}
|
||||
</a>
|
||||
</button>
|
||||
{{/is_loaded}}
|
||||
|
||||
{{#is_running}}
|
||||
<a href="#/services/{{name}}/stop" role="button" class="btn btn-danger">
|
||||
<button class="btn btn-danger" data-service="{{name}}" data-action="stop">
|
||||
<span class="fa-stop"></span> {{t 'stop'}}
|
||||
</a>
|
||||
</button>
|
||||
{{/is_running}}
|
||||
{{^is_running}}
|
||||
<a href="#/services/{{name}}/start" role="button" class="btn btn-success">
|
||||
<button class="btn btn-success" data-service="{{name}}" data-action="start">
|
||||
<span class="fa-play"></span> {{t 'start'}}
|
||||
</a>
|
||||
</button>
|
||||
{{/is_running}}
|
||||
<a href="#/services/{{name}}/log" role="button" class="btn btn-default slide">
|
||||
<span class="fa-book"></span> {{t 'log'}}
|
||||
|
|
Loading…
Add table
Reference in a new issue