Skip to content

Commit

Permalink
servershell: add autocompletion for "new" command (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
brainexe authored Jul 19, 2024
1 parent b9ba50a commit 6463de5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ $(document).ready(function() {
});
}
}
if (command === 'new') {
let search_string = values.split(' ').shift();
servershell.servertypes.forEach(function(servertype) {
if (search_string && !servertype.startsWith(search_string)) {
return;
}

choices.push({
'label': `Servertype: ${servertype}`,
'value': `${command} ${servertype}`,
});
});
}
}

// Don't auto complete if the user has already entered everything
Expand Down
1 change: 1 addition & 0 deletions serveradmin/servershell/templates/servershell/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
servershell.command = "";
servershell.understood = "";
servershell.attributes = {% autoescape off %}{{ attributes|json }}{% endautoescape %};
servershell.servertypes = {% autoescape off %}{{ servertypes|json }}{% endautoescape %};
servershell.offset = {{ offset }};
servershell.limit = {{ limit }};
servershell.order_by = "{{ order_by }}";
Expand Down
1 change: 1 addition & 0 deletions serveradmin/servershell/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def index(request):
'shown_attributes': shown_attributes,
'deep_link': bool(strtobool(request.GET.get('deep_link', 'false'))),
'attributes': attributes_json,
'servertypes': list(Servertype.objects.values_list('servertype_id', flat=True)),
'offset': 0,
'limit': request.session.get('limit', NUM_SERVERS_DEFAULT),
'order_by': 'hostname',
Expand Down

0 comments on commit 6463de5

Please sign in to comment.