diff --git a/services/webapp/code/rosetta/core_app/templates/containers.html b/services/webapp/code/rosetta/core_app/templates/containers.html index e9ff0f16b309c00e901571f982f38eedad5748f3..de5737a9e5ee40b082b881c0204e8f8b1d1f6d2d 100644 --- a/services/webapp/code/rosetta/core_app/templates/containers.html +++ b/services/webapp/code/rosetta/core_app/templates/containers.html @@ -13,9 +13,45 @@ <h1><a href="/containers">Containers</a> <span style="font-size:18px"> / {{ data.container.name }}</span></h1> {% else %} <h1>Containers</h1> + + <hr/> + + + + <div class="form-filter" style="margin-bottom:20px"> + <form action="" method="POST"> + + <input type="text" class="form-control" id="search_text" name="search_text" placeholder="Search..." style="width:200px; margin:0; display:inline" value="{{data.search_text}}" autofocus> + + <select class="form-control" id="search_type" name="search_type" style="width:120px; margin:0; display:inline"> + + {% if data.search_type == 'All' %} + <option selected>All</option> + {% else %} + <option>All</option> + {% endif %} + + {% if data.search_type == 'Docker' %} + <option selected>Docker</option> + {% else %} + <option>Docker</option> + {% endif %} + + {% if data.search_type == 'Singularity' %} + <option selected>Singularity</option> + {% else %} + <option>Singularity</option> + {% endif %} + + </select> + {% csrf_token %} + <button type="submit" class="btn btn-secondary">Go</button> + </form> + </div> + + {% endif %} - <hr/> <div class="row" style="padding:5px"> {% if data.container %} {% include "components/container.html" with container=data.container details=True %} diff --git a/services/webapp/code/rosetta/core_app/views.py b/services/webapp/code/rosetta/core_app/views.py index db6a6212063e60800244590523d134b262130b7a..1b2014ebbafb8ec089d9c4d2acf6b44f0cc5019e 100644 --- a/services/webapp/code/rosetta/core_app/views.py +++ b/services/webapp/code/rosetta/core_app/views.py @@ -305,11 +305,8 @@ def tasks(request): # Attach user config to computing task.computing.attach_user_conf_data(task.user) - - #---------------- - # Task actions - #---------------- + # Task actions if action=='delete': if task.status not in [TaskStatuses.stopped, TaskStatuses.exited]: try: @@ -363,11 +360,7 @@ def tasks(request): # Do we have to list all the tasks? if not uuid or (uuid and not details): - #---------------- - # Task list - #---------------- - - # Get all tasks + # Get all tasks for list try: tasks = Task.objects.filter(user=request.user).order_by('created') except Exception as e: @@ -600,6 +593,15 @@ def containers(request): uuid = request.GET.get('uuid', None) action = request.GET.get('action', None) + # Get filter/search if any + search_text = request.POST.get('search_text', '') + search_type = request.POST.get('search_type', 'All') + + # Set bak to page data + data['search_type'] = search_type + data['search_text'] = search_text + + # Do we have to operate on a specific container? if uuid: @@ -614,10 +616,7 @@ def containers(request): raise ErrorMessage('Container does not exists or no access rights') data['container'] = container - #------------------- # Container actions - #------------------- - if action and action=='delete': # Delete @@ -628,12 +627,26 @@ def containers(request): logger.error('Error in getting the container with uuid="{}" or performing the required action: "{}"'.format(uuid, e)) return render(request, 'error.html', {'data': data}) - #---------------- - # Container list - #---------------- - # Get containers - data['containers'] = list(Container.objects.filter(user=None)) + list(Container.objects.filter(user=request.user)) + # Get containers for list + if search_type and search_type != 'All': + if search_text: + user_containers = Container.objects.filter(user=None, type=search_type.lower(), name__icontains=search_text) + platform_containers = Container.objects.filter(user=request.user, type=search_type.lower(), name__icontains=search_text) + else: + user_containers = Container.objects.filter(user=None, type=search_type.lower()) + platform_containers = Container.objects.filter(user=request.user, type=search_type.lower()) + + else: + if search_text: + user_containers = Container.objects.filter(user=None, name__icontains=search_text) + platform_containers = Container.objects.filter(user=request.user, name__icontains=search_text) + else: + user_containers = Container.objects.filter(user=None) + platform_containers = Container.objects.filter(user=request.user) + + + data['containers'] = list(user_containers) + list(platform_containers) return render(request, 'containers.html', {'data': data})