diff --git a/src/dashboard/views.py b/src/dashboard/views.py index 7ee9cc9..f6bd5e9 100644 --- a/src/dashboard/views.py +++ b/src/dashboard/views.py @@ -35,12 +35,12 @@ def devices(request): @login_required def system(request): return render(request, 'dashboard/system.html') - + @login_required def system_retrieve_logs(request): ''' - Called by the dashboard system page with ajax request every 1s, to get the logs and print them + Called by the dashboard system page with ajax request every seconds, to get the logs and print them ''' if request.is_ajax(): alert_logs = Log.objects.filter(agent='Alert manager') diff --git a/src/scheduler/templates/scheduler/current_schedule.html b/src/scheduler/templates/scheduler/current_schedule.html index 7c2a2d2..b2781cb 100644 --- a/src/scheduler/templates/scheduler/current_schedule.html +++ b/src/scheduler/templates/scheduler/current_schedule.html @@ -25,16 +25,22 @@
-

Schedule info

+

Schedule info

+ + {% if schedule = None %} + +

There is no schedule in the database

+ + {% else %}
Schedule Night Start: {{schedule.plan_night_start|jdtodate}}
- +
Schedule Start: {{schedule.plan_start|jdtodate}}
- +
Schedule End: {{schedule.plan_end|jdtodate}}
@@ -53,10 +59,9 @@
-

List of Sequences - {{sequences|length}}

- +
@@ -92,8 +97,8 @@
+ {% endif %} {% endblock %} - \ No newline at end of file diff --git a/src/scheduler/views.py b/src/scheduler/views.py index cb6ac97..7bab9eb 100644 --- a/src/scheduler/views.py +++ b/src/scheduler/views.py @@ -8,13 +8,19 @@ SIMULATION_FILE = 'file:./scheduler/sequences_cador.html' @login_required def current_schedule(request): - schedule = Schedule.objects.order_by("-created")[0] - shs_list = schedule.shs.all() - sequences = [(shs.sequence, shs) for shs in shs_list] - - nb_scheduled_sequences = len(shs_list) - executed_sequences = len([shs for shs in shs_list if shs.status == Sequence.EXECUTED]) - + if (len(Schedule.objects.all()) > 0): # checking if the schedule is empty + schedule = Schedule.objects.order_by("-created")[0] # Sorting Schedule + shs_list = schedule.shs.all() # getting all the schedule has sequences references + sequences = [(shs.sequence, shs) for shs in shs_list] # getting all sequences + + nb_scheduled_sequences = len(shs_list) + executed_sequences = len([shs for shs in shs_list if shs.status == Sequence.EXECUTED]) + else: # if empty set everything to 0 / None (variables are checked in src/templates/scheduler/current_schedule.html) + schedule = None + sequences = None + shs_list = None + nb_scheduled_sequences = 0 + executed_sequences = 0 return render(request, 'scheduler/current_schedule.html', {'sequences' : sequences, 'schedule' : schedule, 'nb_scheduled_sequences' : nb_scheduled_sequences, 'executed_sequences' : executed_sequences}) @@ -31,4 +37,3 @@ def schedule_simulation(request): sequences.sort(key=lambda seq: seq[1].tsp) return render(request, 'scheduler/current_schedule.html', {'sequences' : sequences, 'schedule' : schedule, 'nb_scheduled_sequences' : nb_scheduled_sequences, 'executed_sequences' : executed_sequences}) - -- libgit2 0.21.2