diff --git a/README.md b/README.md
index 823221f..f6dc76e 100644
--- a/README.md
+++ b/README.md
@@ -98,7 +98,7 @@ sudo systemctl daemon-reload
```
Dashboard: `http://0.0.0.0:8090/`
-Combined API: `GET /api/k1/combined?history_days=30`
+Combined API: `GET /api/combined?history_days=30`
## Environment
diff --git a/app.py b/app.py
index 3e07b8d..9b19d60 100644
--- a/app.py
+++ b/app.py
@@ -95,7 +95,7 @@ def get_db_data(db_path, table_name):
for row in rows:
data.append({
'id': row[0],
- 'camera_name': row[1],
+ 'name': row[1],
'date': row[2],
'counter_value': row[3]
})
@@ -340,11 +340,11 @@ def filter_data_by_cycle(data, cycle_start, cycle_end):
return filtered_data
def is_masuk_out_item(item):
- camera_name = str(item['camera_name']).lower().strip()
+ source_name = str(item.get('name', '')).lower().strip()
return (
- camera_name.endswith('_out')
- or camera_name.endswith('-out')
- or camera_name.endswith(' out')
+ source_name.endswith('_out')
+ or source_name.endswith('-out')
+ or source_name.endswith(' out')
)
def get_counter_settings_from_dashboard(dashboard_settings):
@@ -427,13 +427,13 @@ def filter_data_by_date(data, target_date):
def get_json_counter_items(json_data):
items = []
- for camera_name, camera_data in json_data.items():
+ for source_name, source_data in json_data.items():
karung_count = 0
- if isinstance(camera_data, dict):
- karung_count = camera_data.get('karung', 0)
+ if isinstance(source_data, dict):
+ karung_count = source_data.get('karung', 0)
items.append({
- 'camera_name': camera_name,
+ 'name': source_name,
'karung': karung_count,
})
@@ -443,7 +443,7 @@ def format_history_items(data):
return [
{
'id': item['id'],
- 'camera_name': item['camera_name'],
+ 'name': item['name'],
'date': format_history_date(item['date']),
'counter_value': item['counter_value'],
}
@@ -650,8 +650,8 @@ def get_active_cycle_sections():
},
})
-@app.route('/api/k1/combined', methods=['GET'])
-def get_k1_combined():
+@app.route('/api/combined', methods=['GET'])
+def get_combined():
history_days_raw = request.args.get('history_days', DEFAULT_COMBINED_HISTORY_DAYS)
try:
history_days = int(history_days_raw)
@@ -683,7 +683,7 @@ def get_k1_combined():
'totals': {
'tuang': tuang_payload['totals']['today'],
'masuk': sum(
- item['karung'] if not is_masuk_out_item({'camera_name': item['camera_name']}) else -item['karung']
+ item['karung'] if not is_masuk_out_item(item) else -item['karung']
for item in masuk_today
),
},
@@ -717,11 +717,11 @@ def index():
item['display_date'] = format_history_date(item['date'])
tuang_json_data = {
- item['camera_name']: {'karung': item['karung']}
+ item['name']: {'karung': item['karung']}
for item in today_section['tuang']
}
masuk_json_data = {
- item['camera_name']: {'karung': item['karung']}
+ item['name']: {'karung': item['karung']}
for item in today_section['masuk']
}
tuang_json_total = today_section['totals']['tuang']
diff --git a/templates/index.html b/templates/index.html
index c3bc565..34112e2 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1342,7 +1342,7 @@
- | Camera Name |
+ Nama |
Tanggal |
Jumlah Karung |
@@ -1351,7 +1351,7 @@
{% for item in tuang_db_data %}
|
- TUANG {{ item.camera_name }}
+ TUANG {{ item.name }}
|
{{ item.display_date }} |
{{ item.counter_value }} |
@@ -1374,7 +1374,7 @@
- | Camera Name |
+ Nama |
Tanggal |
Jumlah Karung |
@@ -1383,7 +1383,7 @@
{% for item in masuk_db_data %}
|
- MASUK {{ item.camera_name }}
+ MASUK {{ item.name }}
|
{{ item.date }} |
{{ item.counter_value }} |
@@ -1458,12 +1458,12 @@
}
listElement.innerHTML = items.map((item) => {
- const cameraName = escapeHtml(item.camera_name || '');
+ const sourceName = escapeHtml(item.name || '');
const karungCount = Number(item.karung || 0);
return `
-
${cameraName}
+
${sourceName}
${karungCount} karung
`;