mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Change main domain form.
This commit is contained in:
parent
c909515bf2
commit
4524237d37
2 changed files with 74 additions and 5 deletions
40
js/app.js
40
js/app.js
|
@ -454,7 +454,19 @@ app = Sammy('#main', function (sam) {
|
|||
|
||||
sam.get('#/domains', function (c) {
|
||||
c.api('/domains', function(data) { // http://api.yunohost.org/#!/domain/domain_list_get_2
|
||||
c.view('domain_list', data);
|
||||
c.api('/domain/main', function(data2) {
|
||||
domains = [];
|
||||
$.each(data.Domains, function(k, domain) {
|
||||
domains.push({
|
||||
url: domain,
|
||||
main: (domain == data2.current_main_domain) ? true : false
|
||||
});
|
||||
})
|
||||
|
||||
// Sort domains with main domain first
|
||||
domains.sort(function(a, b){ return -2*(a.main) + 1; })
|
||||
c.view('domain_list', {domains: domains});
|
||||
}, 'PUT')
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -491,6 +503,32 @@ app = Sammy('#main', function (sam) {
|
|||
}
|
||||
});
|
||||
|
||||
// Set default domain
|
||||
sam.post('#/domains', function (c) {
|
||||
if (c.params['domain'] == '') {
|
||||
c.flash('fail', "You should select a domain default domain");
|
||||
store.clear('slide');
|
||||
c.redirect('#/domains');
|
||||
} else if (confirm('Are you sure you want to change the main domain ?')) {
|
||||
|
||||
params = {'new_domain': c.params['domain']}
|
||||
c.api('/domain/main', function(data) { // http://api.yunohost.org/#!/tools/tools_maindomain_put_1
|
||||
store.clear('slide');
|
||||
c.redirect('#/domains');
|
||||
}, 'PUT', params);
|
||||
|
||||
// Wait 15s and refresh the page
|
||||
refreshDomain = window.setTimeout(function(){
|
||||
store.clear('slide');
|
||||
c.redirect('#/domains')
|
||||
}, 15000);
|
||||
|
||||
} else {
|
||||
store.clear('slide');
|
||||
c.redirect('#/domains');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Apps
|
||||
|
|
|
@ -9,13 +9,44 @@
|
|||
<div class="br"></div>
|
||||
|
||||
<div class="list-group">
|
||||
{{#Domains}}
|
||||
{{#domains}}
|
||||
<div class="list-group-item">
|
||||
{{#if main}}
|
||||
<span class="container text-success pull-right">
|
||||
<span class="glyphicon glyphicon-star"></span> Default
|
||||
</span>
|
||||
{{else}}
|
||||
<a href="#/domains/{{.}}/delete" class="btn btn-danger slide back pull-right">
|
||||
<span class="glyphicon glyphicon-trash"></span> Delete
|
||||
</a>
|
||||
<h2 class="list-group-item-heading">{{.}}</h2>
|
||||
<a href="https://{{.}}" target="_blank">https://{{.}}</a>
|
||||
{{/if}}
|
||||
<h2 class="list-group-item-heading">{{url}}</h2>
|
||||
<a href="https://{{url}}" target="_blank">https://{{url}}</a>
|
||||
</div>
|
||||
{{/domains}}
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title">
|
||||
Default domain
|
||||
</h2>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
The default domain is the connection domain where users log in.
|
||||
</p>
|
||||
<form method="POST" action="#/domains" class="row">
|
||||
<div class="col-xs-9 col-sm-6">
|
||||
<select name="domain" required class="form-control">
|
||||
<option value="" default disabled selected>Select domain</option>
|
||||
{{#domains}}{{#unless main}}<option value="{{url}}">{{url}}</option>{{/unless}}{{/domains}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-xs-3 col-sm-6">
|
||||
<input type="submit" class="btn btn-success slide back" value="Set default">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
{{/Domains}}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue