diff --git a/app.py b/app.py index 844b45c..afcf388 100644 --- a/app.py +++ b/app.py @@ -731,6 +731,30 @@ def anomalies(): anomalies = Anomaly.query.join(Device).filter(Device.user_id == current_user.id).order_by(Anomaly.timestamp.desc()).all() return render_template('anomalies.html', anomalies=anomalies) +@app.route('/devices/update_selected', methods=['POST']) +@login_required +def update_selected_devices(): + selected_ids = request.form.getlist('selected_devices') + if not selected_ids: + flash("Nie wybrano żadnych urządzeń.") + return redirect(url_for('devices')) + for device_id in selected_ids: + device = Device.query.get(device_id) + if device and device.user_id == current_user.id: + result, update_available, current_version, current_firmware = check_device_update(device) + device.last_log = result + device.last_check = datetime.utcnow() + device.update_required = update_available + device.current_version = current_version + device.current_firmware = current_firmware + db.session.commit() + # Dodaj log dla aktualizacji + log_entry = Log(message=result, device_id=device.id, user_id=device.user_id) + db.session.add(log_entry) + db.session.commit() + flash("Wybrane urządzenia zostały zaktualizowane.") + return redirect(url_for('devices')) + # Zamknięcie harmonogramu przy zatrzymaniu aplikacji atexit.register(lambda: scheduler.shutdown()) diff --git a/templates/devices.html b/templates/devices.html index 725c8ad..6b877b3 100644 --- a/templates/devices.html +++ b/templates/devices.html @@ -2,53 +2,75 @@ {% block title %}Moje urządzenia - RouterOS Update{% endblock %} {% block content %}
Nazwa / Adres IP | -Ostatnie sprawdzenie | -Status | -System / Firmware | -Akcje | -
---|---|---|---|---|
- {% if device.name %}
- {{ device.name }} |
- {{ device.ip }}
- {% else %}
- {{ device.ip }}
- {% endif %}
- |
- {{ device.last_check.strftime('%Y-%m-%d %H:%M:%S') if device.last_check else 'Brak' }} | -- {% if device.update_required %} - Wymaga aktualizacji - {% else %} - Aktualny - {% endif %} - | -
-
- System: {{ device.current_version or 'Brak' }} - Firmware: {{ device.current_firmware or 'Brak' }} - - |
- - - - - | -
Brak dodanych urządzeń. | -