Commit 942c6716 authored by Ziirish's avatar Ziirish

create client from template within the UI (fix #266)

parent 1ac06dcf
......@@ -432,7 +432,7 @@ class NewClientSettings(Resource):
"""Creates a new client"""
args = self.parser.parse_args()
newclient = args['newclient']
templates = args['templates']
templates = [x for x in args.get('templates', []) if x]
if not newclient:
self.abort(400, 'No client name provided')
......
......@@ -341,6 +341,10 @@ legend[id] {
color: #fff;
}
.ui-select-multiple input.ui-select-search {
width: auto !important;
}
.table-responsive {
overflow-x: visible;
}
......
......@@ -133,6 +133,7 @@ app.controller('ConfigCtrl', ['$scope', '$http', '$timeout', '$scrollspy', 'DTOp
$scope.client = {};
$scope.defaults = {};
$scope.placeholders = {};
$scope.newclient = {};
$scope.all = {};
$scope.avail = {};
$scope.suggest = {};
......@@ -737,8 +738,12 @@ app.controller('ConfigCtrl', ['$scope', '$http', '$timeout', '$scrollspy', 'DTOp
/* we disable the 'real' form submission */
e.preventDefault();
var form = $(e.target);
var templates = form.find('input[name="templates"]');
submit = form.find('button[type="submit"]');
sav = submit.html();
if ($scope.newclient.templates) {
templates.val($scope.newclient.templates.join(','));
}
submit.html('<i class="fa fa-fw fa-spinner fa-pulse" aria-hidden="true"></i>&nbsp;{{ _("Creating...") }}');
submit.attr('disabled', true);
$.ajax({
......
......@@ -466,12 +466,27 @@
<form action="{{ url_for('api.new_client', server=server) }}" method="POST" ng-submit="createClient($event)">
<fieldset>
<Legend>{{ _('Create new client') }}</Legend>
<div class="input-group col-lg-3">
<input class="form-control" type="text" name="newclient" id="newclient" placeholder="{{ _('Create new client') }}">
<span class="input-group-btn">
<button class="btn btn-success" type="submit"><i class="fa fa-plus" aria-hidden="true"></i></button>
</span>
<div class="form-group">
<div class="input-group">
<input class="form-control" type="text" name="newclient" id="newclient" placeholder="{{ _('Create new client') }}">
<span class="input-group-btn">
<button class="btn btn-success" type="submit"><i class="fa fa-plus" aria-hidden="true"></i></button>
</span>
</div>
</div>
<div class="form-group">
<ui-select multiple ng-model="newclient.templates" ng-disabled="!raw.templates" theme="bootstrap">
<ui-select-match placeholder="{{ _('Select one or several templates') }}">
{% raw %}
{{ $item.name }}
{% endraw %}
</ui-select-match>
<ui-select-choices repeat="value.name as value in raw.templates | filter: $select.search">
<div ng-bind-html="value.name | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
</div>
<input type="hidden" name="templates">
</fieldset>
</form>
</div>
......@@ -500,7 +515,7 @@
<form action="{{ url_for('api.new_template', server=server) }}" method="POST" ng-submit="createTemplate($event)">
<fieldset>
<Legend>{{ _('Create new template') }}</Legend>
<div class="input-group col-lg-3">
<div class="input-group">
<input class="form-control" type="text" name="newtemplate" id="newtemplate" placeholder="{{ _('Create new template') }}">
<span class="input-group-btn">
<button class="btn btn-success" type="submit"><i class="fa fa-plus" aria-hidden="true"></i></button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment