nexo-brain 5.3.19 → 5.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/bin/nexo-brain.js +52 -10
- package/package.json +1 -1
- package/src/auto_update.py +11 -8
- package/src/dashboard/static/favicon 2.svg +32 -0
- package/src/dashboard/static/nexo-logo 2.png +0 -0
- package/src/dashboard/static/nexo-logo 2.svg +40 -0
- package/src/dashboard/static/style 2.css +2458 -0
- package/src/dashboard/templates/adaptive 2.html +118 -0
- package/src/dashboard/templates/artifacts 2.html +133 -0
- package/src/dashboard/templates/backups 2.html +136 -0
- package/src/dashboard/templates/base 2.html +417 -0
- package/src/dashboard/templates/calendar 2.html +591 -0
- package/src/dashboard/templates/chat 2.html +356 -0
- package/src/dashboard/templates/claims 2.html +259 -0
- package/src/dashboard/templates/cortex 2.html +321 -0
- package/src/dashboard/templates/credentials 2.html +128 -0
- package/src/dashboard/templates/crons 2.html +370 -0
- package/src/dashboard/templates/dashboard 2.html +494 -0
- package/src/dashboard/templates/dreams 2.html +252 -0
- package/src/dashboard/templates/email 2.html +160 -0
- package/src/dashboard/templates/evolution 2.html +189 -0
- package/src/dashboard/templates/feed 2.html +249 -0
- package/src/dashboard/templates/followup_health 2.html +170 -0
- package/src/dashboard/templates/graph 2.html +201 -0
- package/src/dashboard/templates/guard 2.html +259 -0
- package/src/dashboard/templates/inbox 2.html +251 -0
- package/src/dashboard/templates/memory 2.html +420 -0
- package/src/dashboard/templates/operations 2.html +608 -0
- package/src/dashboard/templates/plugins 2.html +185 -0
- package/src/dashboard/templates/protocol 2.html +199 -0
- package/src/dashboard/templates/rules 2.html +246 -0
- package/src/dashboard/templates/sentiment 2.html +247 -0
- package/src/dashboard/templates/sessions 2.html +218 -0
- package/src/dashboard/templates/skills 2.html +329 -0
- package/src/dashboard/templates/somatic 2.html +73 -0
- package/src/dashboard/templates/triggers 2.html +133 -0
- package/src/dashboard/templates/trust 2.html +360 -0
- package/src/db/__init__ 2.py +259 -0
- package/src/db/_core 2.py +437 -0
- package/src/db/_credentials 2.py +124 -0
- package/src/db/_episodic 2.py +762 -0
- package/src/db/_evolution 2.py +54 -0
- package/src/db/_fts 2.py +406 -0
- package/src/db/_goal_profiles 2.py +376 -0
- package/src/db/_hot_context 2.py +660 -0
- package/src/db/_outcomes 2.py +800 -0
- package/src/db/_personal_scripts 2.py +582 -0
- package/src/db/_sessions 2.py +330 -0
- package/src/db/_tasks 2.py +91 -0
- package/src/db/_watchers 2.py +173 -0
- package/src/doctor/formatters 2.py +52 -0
- package/src/doctor/models 2.py +69 -0
- package/src/doctor/planes 2.py +87 -0
- package/src/doctor/providers/__init__ 2.py +1 -0
- package/src/doctor/providers/deep 2.py +367 -0
- package/src/evolution_cycle 2.py +519 -0
- package/src/hooks/auto_capture 2.py +208 -0
- package/src/hooks/caffeinate-guard 2.sh +8 -0
- package/src/hooks/capture-session 2.sh +21 -0
- package/src/hooks/capture-tool-logs 2.sh +158 -0
- package/src/hooks/daily-briefing-check 2.sh +33 -0
- package/src/hooks/heartbeat-enforcement 2.py +90 -0
- package/src/hooks/heartbeat-posttool 2.sh +18 -0
- package/src/hooks/inbox-hook 2.sh +76 -0
- package/src/hooks/post-compact 2.sh +152 -0
- package/src/hooks/pre-compact 2.sh +169 -0
- package/src/hooks/protocol-guardrail 2.sh +10 -0
- package/src/hooks/protocol-pretool-guardrail 2.sh +9 -0
- package/src/hooks/session-stop 2.sh +52 -0
- package/src/kg_populate 2.py +292 -0
- package/src/maintenance 2.py +53 -0
- package/src/memory_backends 2.py +71 -0
- package/src/migrate_embeddings 2.py +124 -0
- package/src/nexo_sdk 2.py +103 -0
- package/src/observability 2.py +199 -0
- package/src/plugin_loader 2.py +217 -0
- package/src/plugins/__init__ 2.py +0 -0
- package/src/plugins/artifact_registry 2.py +450 -0
- package/src/plugins/backup 2.py +127 -0
- package/src/plugins/claims_tools 2.py +119 -0
- package/src/plugins/cognitive_memory 2.py +609 -0
- package/src/plugins/core_rules 2.py +252 -0
- package/src/plugins/cortex 2.py +1155 -0
- package/src/plugins/entities 2.py +67 -0
- package/src/plugins/episodic_memory 2.py +560 -0
- package/src/plugins/evolution 2.py +167 -0
- package/src/plugins/goal_engine 2.py +142 -0
- package/src/plugins/guard 2.py +862 -0
- package/src/plugins/impact 2.py +29 -0
- package/src/plugins/knowledge_graph_tools 2.py +137 -0
- package/src/plugins/media_memory_tools 2.py +98 -0
- package/src/plugins/memory_export 2.py +196 -0
- package/src/plugins/outcomes 2.py +130 -0
- package/src/plugins/personal_scripts 2.py +117 -0
- package/src/plugins/preferences 2.py +47 -0
- package/src/plugins/protocol 2.py +1449 -0
- package/src/plugins/simple_api 2.py +106 -0
- package/src/plugins/skills 2.py +341 -0
- package/src/plugins/state_watchers 2.py +79 -0
- package/src/plugins/update 2.py +986 -0
- package/src/plugins/user_state_tools 2.py +43 -0
- package/src/plugins/workflow 2.py +588 -0
- package/src/protocol_settings 2.py +59 -0
- package/src/public_contribution 2.py +466 -0
- package/src/public_evolution_queue 2.py +241 -0
- package/src/requirements 2.txt +14 -0
- package/src/retroactive_learnings 2.py +373 -0
- package/src/rules/__init__ 2.py +0 -0
- package/src/rules/core-rules 2.json +331 -0
- package/src/rules/migrate 2.py +207 -0
- package/src/runtime_power 2.py +874 -0
- package/src/script_registry 2.py +1559 -0
- package/src/scripts/check-context 2.py +272 -0
- package/src/scripts/deep-sleep/apply_findings 2.py +2327 -0
- package/src/scripts/deep-sleep/collect 2.py +928 -0
- package/src/scripts/deep-sleep/extract 2.py +330 -0
- package/src/scripts/deep-sleep/extract-prompt 2.md +285 -0
- package/src/scripts/deep-sleep/synthesize 2.py +312 -0
- package/src/scripts/deep-sleep/synthesize-prompt 2.md +336 -0
- package/src/scripts/nexo-agent-run 2.py +75 -0
- package/src/scripts/nexo-auto-update 2.py +6 -0
- package/src/scripts/nexo-backup 2.sh +25 -0
- package/src/scripts/nexo-brain-activation 2.sh +140 -0
- package/src/scripts/nexo-catchup 2.py +300 -0
- package/src/scripts/nexo-cognitive-decay 2.py +257 -0
- package/src/scripts/nexo-cortex-cycle 2.py +293 -0
- package/src/scripts/nexo-cron-wrapper 2.sh +53 -0
- package/src/scripts/nexo-daily-self-audit 2.py +2161 -0
- package/src/scripts/nexo-dashboard 2.sh +29 -0
- package/src/scripts/nexo-deep-sleep 2.sh +86 -0
- package/src/scripts/nexo-evolution-run 2.py +1664 -0
- package/src/scripts/nexo-followup-hygiene 2.py +139 -0
- package/src/scripts/nexo-hook-record 2.py +42 -0
- package/src/scripts/nexo-immune 2.py +936 -0
- package/src/scripts/nexo-impact-scorer 2.py +117 -0
- package/src/scripts/nexo-inbox-hook 2.sh +74 -0
- package/src/scripts/nexo-install 2.py +6 -0
- package/src/scripts/nexo-learning-housekeep 2.py +401 -0
- package/src/scripts/nexo-learning-validator 2.py +266 -0
- package/src/scripts/nexo-migrate 2.py +260 -0
- package/src/scripts/nexo-outcome-checker 2.py +127 -0
- package/src/scripts/nexo-postmortem-consolidator 2.py +456 -0
- package/src/scripts/nexo-pre-commit 2.py +120 -0
- package/src/scripts/nexo-prevent-sleep 2.sh +35 -0
- package/src/scripts/nexo-proactive-dashboard 2.py +354 -0
- package/src/scripts/nexo-reflection 2.py +256 -0
- package/src/scripts/nexo-runtime-preflight 2.py +274 -0
- package/src/scripts/nexo-sleep 2.py +631 -0
- package/src/scripts/nexo-snapshot-restore 2.sh +35 -0
- package/src/scripts/nexo-sync-clients 2.py +16 -0
- package/src/scripts/nexo-synthesis 2.py +475 -0
- package/src/scripts/nexo-tcc-approve 2.sh +79 -0
- package/src/scripts/nexo-update 2.sh +306 -0
- package/src/scripts/nexo-watchdog 2.sh +1207 -0
- package/src/scripts/nexo-watchdog-smoke 2.py +119 -0
- package/src/scripts/rehydrate_learnings_from_archive 2.py +245 -0
- package/src/server 2.py +1296 -0
- package/src/skills/run-nexo-audit-phase/guide 2.md +43 -0
- package/src/skills/run-nexo-audit-phase/skill 2.json +59 -0
- package/src/skills/run-nexo-core-fix-cycle/guide 2.md +17 -0
- package/src/skills/run-nexo-core-fix-cycle/script 2.py +276 -0
- package/src/skills/run-nexo-core-fix-cycle/skill 2.json +58 -0
- package/src/skills/run-release-final-audit/guide 2.md +16 -0
- package/src/skills/run-release-final-audit/script 2.py +259 -0
- package/src/skills/run-release-final-audit/skill 2.json +77 -0
- package/src/skills/run-runtime-doctor/guide 2.md +12 -0
- package/src/skills/run-runtime-doctor/script 2.py +21 -0
- package/src/skills/run-runtime-doctor/skill 2.json +25 -0
- package/src/skills_runtime 2.py +932 -0
- package/src/state_watchers_runtime 2.py +475 -0
- package/src/storage_router 2.py +32 -0
- package/src/system_catalog 2.py +786 -0
- package/src/tools_coordination 2.py +103 -0
- package/src/tools_credentials 2.py +68 -0
- package/src/tools_drive 2.py +487 -0
- package/src/tools_hot_context 2.py +163 -0
- package/src/tools_learnings 2.py +612 -0
- package/src/tools_menu 2.py +229 -0
- package/src/tools_reminders 2.py +88 -0
- package/src/tools_reminders_crud 2.py +363 -0
- package/src/tools_sessions 2.py +1054 -0
- package/src/tools_system_catalog 2.py +19 -0
- package/src/tools_task_history 2.py +57 -0
- package/src/tools_transcripts 2.py +98 -0
- package/src/transcript_utils 2.py +412 -0
- package/src/user_context 2.py +46 -0
- package/src/user_data_portability 2.py +328 -0
- package/src/user_state_model 2.py +170 -0
- package/templates/CLAUDE.md 2.template +108 -0
- package/templates/CODEX.AGENTS.md 2.template +66 -0
- package/templates/launchagents/README 2.md +132 -0
- package/templates/launchagents/com.nexo.auto-close-sessions 2.plist +39 -0
- package/templates/launchagents/com.nexo.catchup 2.plist +39 -0
- package/templates/launchagents/com.nexo.cognitive-decay 2.plist +40 -0
- package/templates/launchagents/com.nexo.dashboard 2.plist +43 -0
- package/templates/launchagents/com.nexo.deep-sleep 2.plist +43 -0
- package/templates/launchagents/com.nexo.evolution 2.plist +44 -0
- package/templates/launchagents/com.nexo.followup-hygiene 2.plist +45 -0
- package/templates/launchagents/com.nexo.immune 2.plist +41 -0
- package/templates/launchagents/com.nexo.postmortem 2.plist +45 -0
- package/templates/launchagents/com.nexo.self-audit 2.plist +47 -0
- package/templates/launchagents/com.nexo.synthesis 2.plist +45 -0
- package/templates/launchagents/com.nexo.watchdog 2.plist +37 -0
- package/templates/nexo_helper 2.py +301 -0
- package/templates/openclaw 2.json +13 -0
- package/templates/plugin-template 2.py +40 -0
- package/templates/script-template 2.py +59 -0
- package/templates/script-template 2.sh +13 -0
- package/templates/skill-script-template 2.py +48 -0
- package/templates/skill-template 2.md +33 -0
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block title %}Operations{% endblock %}
|
|
4
|
+
{% block page_title %}Operations{% endblock %}
|
|
5
|
+
|
|
6
|
+
{% block head %}
|
|
7
|
+
<style>
|
|
8
|
+
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
9
|
+
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
|
|
10
|
+
.toast-enter { animation: slideIn 0.2s ease-out; }
|
|
11
|
+
.modal-backdrop { backdrop-filter: blur(4px); }
|
|
12
|
+
</style>
|
|
13
|
+
{% endblock %}
|
|
14
|
+
|
|
15
|
+
{% block header_actions %}
|
|
16
|
+
<input
|
|
17
|
+
type="text"
|
|
18
|
+
id="ops-search"
|
|
19
|
+
placeholder="Search..."
|
|
20
|
+
oninput="filterOps()"
|
|
21
|
+
class="bg-slate-800 border border-slate-700 rounded-lg px-3 py-1 text-xs text-slate-200 w-48 focus:outline-none focus:ring-1 focus:ring-violet-500 placeholder-slate-500"
|
|
22
|
+
>
|
|
23
|
+
<select
|
|
24
|
+
id="ops-status"
|
|
25
|
+
onchange="loadOpsData()"
|
|
26
|
+
class="bg-slate-800 border border-slate-700 rounded-lg px-2 py-1 text-xs text-slate-200 focus:outline-none focus:ring-1 focus:ring-violet-500"
|
|
27
|
+
>
|
|
28
|
+
<option value="PENDING">Pending</option>
|
|
29
|
+
<option value="all">All</option>
|
|
30
|
+
<option value="completed">Completed</option>
|
|
31
|
+
<option value="deleted">Deleted</option>
|
|
32
|
+
<option value="history">History</option>
|
|
33
|
+
</select>
|
|
34
|
+
{% endblock %}
|
|
35
|
+
|
|
36
|
+
{% block content %}
|
|
37
|
+
<div class="grid grid-cols-2 gap-6">
|
|
38
|
+
|
|
39
|
+
<!-- LEFT: User's Items (Reminders) -->
|
|
40
|
+
<div>
|
|
41
|
+
<div class="flex items-center justify-between mb-3">
|
|
42
|
+
<div class="flex items-center gap-2">
|
|
43
|
+
<div class="w-2 h-2 rounded-full bg-violet-400"></div>
|
|
44
|
+
<h2 class="text-sm font-display font-semibold text-slate-100">User</h2>
|
|
45
|
+
<span id="reminder-count" class="text-xs px-1.5 py-0.5 rounded-full bg-violet-500/20 text-violet-400 font-mono">0</span>
|
|
46
|
+
</div>
|
|
47
|
+
<button onclick="openCreate('reminder')" class="text-xs px-2 py-1 rounded-md bg-slate-800 text-slate-400 hover:bg-slate-700 hover:text-slate-200 transition-colors">
|
|
48
|
+
+ Add
|
|
49
|
+
</button>
|
|
50
|
+
</div>
|
|
51
|
+
<div id="reminders-list" class="space-y-2">
|
|
52
|
+
<div class="text-xs text-slate-600 font-mono py-4 text-center">Loading...</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<!-- RIGHT: NEXO's Items (Followups) -->
|
|
57
|
+
<div>
|
|
58
|
+
<div class="flex items-center justify-between mb-3">
|
|
59
|
+
<div class="flex items-center gap-2">
|
|
60
|
+
<div class="w-2 h-2 rounded-full bg-pink-400"></div>
|
|
61
|
+
<h2 class="text-sm font-display font-semibold text-slate-100">NEXO</h2>
|
|
62
|
+
<span id="followup-count" class="text-xs px-1.5 py-0.5 rounded-full bg-pink-500/20 text-pink-400 font-mono">0</span>
|
|
63
|
+
</div>
|
|
64
|
+
<button onclick="openCreate('followup')" class="text-xs px-2 py-1 rounded-md bg-slate-800 text-slate-400 hover:bg-slate-700 hover:text-slate-200 transition-colors">
|
|
65
|
+
+ Add
|
|
66
|
+
</button>
|
|
67
|
+
</div>
|
|
68
|
+
<div id="followups-list" class="space-y-2">
|
|
69
|
+
<div class="text-xs text-slate-600 font-mono py-4 text-center">Loading...</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<!-- CREATE/EDIT MODAL -->
|
|
76
|
+
<div id="ops-modal" class="hidden fixed inset-0 z-50 flex items-center justify-center">
|
|
77
|
+
<div class="absolute inset-0 bg-black/60 modal-backdrop" onclick="closeModal()"></div>
|
|
78
|
+
<div class="relative bg-slate-900 border border-slate-700/50 rounded-xl shadow-2xl w-full max-w-md mx-4">
|
|
79
|
+
<div class="flex items-center justify-between px-5 py-4 border-b border-slate-800">
|
|
80
|
+
<h2 id="modal-title" class="text-sm font-display font-semibold text-slate-100">New Item</h2>
|
|
81
|
+
<button onclick="closeModal()" class="w-6 h-6 rounded-md flex items-center justify-center text-slate-500 hover:bg-slate-800 hover:text-slate-300 transition-colors text-lg leading-none">×</button>
|
|
82
|
+
</div>
|
|
83
|
+
<form id="modal-form" onsubmit="submitForm(event)" class="px-5 py-4 space-y-4">
|
|
84
|
+
<div>
|
|
85
|
+
<label class="block text-xs text-slate-400 mb-1.5 font-medium">Description</label>
|
|
86
|
+
<textarea
|
|
87
|
+
name="description"
|
|
88
|
+
rows="3"
|
|
89
|
+
required
|
|
90
|
+
class="w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-xs text-slate-200 focus:outline-none focus:ring-1 focus:ring-violet-500 resize-none placeholder-slate-500"
|
|
91
|
+
placeholder="Describe the item..."
|
|
92
|
+
></textarea>
|
|
93
|
+
</div>
|
|
94
|
+
<div>
|
|
95
|
+
<label class="block text-xs text-slate-400 mb-1.5 font-medium">Date <span class="text-slate-600">(optional)</span></label>
|
|
96
|
+
<input
|
|
97
|
+
type="date"
|
|
98
|
+
name="date"
|
|
99
|
+
class="w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-xs text-slate-200 focus:outline-none focus:ring-1 focus:ring-violet-500"
|
|
100
|
+
>
|
|
101
|
+
</div>
|
|
102
|
+
<div id="category-group" class="hidden">
|
|
103
|
+
<label class="block text-xs text-slate-400 mb-1.5 font-medium">Category</label>
|
|
104
|
+
<select name="category" class="w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-xs text-slate-200 focus:outline-none focus:ring-1 focus:ring-violet-500">
|
|
105
|
+
<option value="general">General</option>
|
|
106
|
+
<option value="ideas">Ideas</option>
|
|
107
|
+
<option value="my-project">My Project</option>
|
|
108
|
+
<option value="project-a">Project A</option>
|
|
109
|
+
<option value="server">Server</option>
|
|
110
|
+
</select>
|
|
111
|
+
</div>
|
|
112
|
+
<div id="verification-group" class="hidden">
|
|
113
|
+
<label class="block text-xs text-slate-400 mb-1.5 font-medium">Verification</label>
|
|
114
|
+
<textarea
|
|
115
|
+
name="verification"
|
|
116
|
+
rows="2"
|
|
117
|
+
class="w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-xs text-slate-200 focus:outline-none focus:ring-1 focus:ring-violet-500 resize-none placeholder-slate-500"
|
|
118
|
+
placeholder="How to verify this is done..."
|
|
119
|
+
></textarea>
|
|
120
|
+
</div>
|
|
121
|
+
<div id="reasoning-group" class="hidden">
|
|
122
|
+
<label class="block text-xs text-slate-400 mb-1.5 font-medium">Reasoning</label>
|
|
123
|
+
<textarea
|
|
124
|
+
name="reasoning"
|
|
125
|
+
rows="2"
|
|
126
|
+
class="w-full bg-slate-800 border border-slate-700 rounded-lg px-3 py-2 text-xs text-slate-200 focus:outline-none focus:ring-1 focus:ring-violet-500 resize-none placeholder-slate-500"
|
|
127
|
+
placeholder="Why this followup exists..."
|
|
128
|
+
></textarea>
|
|
129
|
+
</div>
|
|
130
|
+
<input type="hidden" name="type" id="modal-type">
|
|
131
|
+
<input type="hidden" name="edit_id" id="modal-edit-id">
|
|
132
|
+
<input type="hidden" name="read_token" id="modal-read-token">
|
|
133
|
+
<div class="flex items-center justify-end gap-2 pt-1">
|
|
134
|
+
<button type="button" onclick="closeModal()" class="text-xs px-3 py-1.5 rounded-lg bg-slate-800 text-slate-400 hover:bg-slate-700 hover:text-slate-200 transition-colors">
|
|
135
|
+
Cancel
|
|
136
|
+
</button>
|
|
137
|
+
<button type="submit" id="modal-submit-btn" class="text-xs px-3 py-1.5 rounded-lg bg-violet-600 text-white hover:bg-violet-500 transition-colors font-medium">
|
|
138
|
+
Create
|
|
139
|
+
</button>
|
|
140
|
+
</div>
|
|
141
|
+
</form>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<!-- CONFIRM MODAL -->
|
|
146
|
+
<div id="confirm-modal" class="hidden fixed inset-0 z-50 flex items-center justify-center">
|
|
147
|
+
<div class="absolute inset-0 bg-black/60 modal-backdrop" onclick="closeConfirm()"></div>
|
|
148
|
+
<div class="relative bg-slate-900 border border-slate-700/50 rounded-xl shadow-2xl w-full max-w-sm mx-4">
|
|
149
|
+
<div class="flex items-center justify-between px-5 py-4 border-b border-slate-800">
|
|
150
|
+
<h2 class="text-sm font-display font-semibold text-slate-100">Confirm</h2>
|
|
151
|
+
<button onclick="closeConfirm()" class="w-6 h-6 rounded-md flex items-center justify-center text-slate-500 hover:bg-slate-800 hover:text-slate-300 transition-colors text-lg leading-none">×</button>
|
|
152
|
+
</div>
|
|
153
|
+
<div class="px-5 py-4">
|
|
154
|
+
<p id="confirm-message" class="text-xs text-slate-300 mb-4">Are you sure?</p>
|
|
155
|
+
<div class="flex items-center justify-end gap-2">
|
|
156
|
+
<button onclick="closeConfirm()" class="text-xs px-3 py-1.5 rounded-lg bg-slate-800 text-slate-400 hover:bg-slate-700 hover:text-slate-200 transition-colors">
|
|
157
|
+
Cancel
|
|
158
|
+
</button>
|
|
159
|
+
<button id="confirm-btn" onclick="confirmAction()" class="text-xs px-3 py-1.5 rounded-lg bg-red-600 text-white hover:bg-red-500 transition-colors font-medium">
|
|
160
|
+
Delete
|
|
161
|
+
</button>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<!-- OPS TOAST (separate from base toast) -->
|
|
168
|
+
<div id="ops-toast" class="hidden fixed bottom-6 right-6 z-50 flex items-center gap-2.5 px-4 py-3 rounded-xl border shadow-lg text-xs font-medium toast-enter max-w-xs">
|
|
169
|
+
<span id="ops-toast-icon" class="flex-shrink-0"></span>
|
|
170
|
+
<span id="ops-toast-message"></span>
|
|
171
|
+
</div>
|
|
172
|
+
{% endblock %}
|
|
173
|
+
|
|
174
|
+
{% block scripts %}
|
|
175
|
+
<script>
|
|
176
|
+
// -----------------------------------------------------------------------
|
|
177
|
+
// State
|
|
178
|
+
// -----------------------------------------------------------------------
|
|
179
|
+
let allReminders = [];
|
|
180
|
+
let allFollowups = [];
|
|
181
|
+
let pendingConfirmAction = null;
|
|
182
|
+
|
|
183
|
+
// -----------------------------------------------------------------------
|
|
184
|
+
// Ops Toast (uses its own element to avoid conflict with base toast)
|
|
185
|
+
// -----------------------------------------------------------------------
|
|
186
|
+
function opsToast(message, type = 'success') {
|
|
187
|
+
const toast = document.getElementById('ops-toast');
|
|
188
|
+
const msg = document.getElementById('ops-toast-message');
|
|
189
|
+
const icon = document.getElementById('ops-toast-icon');
|
|
190
|
+
msg.textContent = message;
|
|
191
|
+
|
|
192
|
+
const styles = {
|
|
193
|
+
success: { bg: 'bg-slate-800', border: 'border-emerald-500/30', text: 'text-emerald-400', iconSvg: '\u2713' },
|
|
194
|
+
error: { bg: 'bg-slate-800', border: 'border-red-500/30', text: 'text-red-400', iconSvg: '\u2715' },
|
|
195
|
+
info: { bg: 'bg-slate-800', border: 'border-violet-500/30', text: 'text-violet-400', iconSvg: '\u00b7' },
|
|
196
|
+
};
|
|
197
|
+
const s = styles[type] || styles.info;
|
|
198
|
+
toast.className = `fixed bottom-6 right-6 z-50 flex items-center gap-2.5 px-4 py-3 rounded-xl border shadow-lg text-xs font-medium toast-enter max-w-xs ${s.bg} ${s.border}`;
|
|
199
|
+
icon.className = s.text;
|
|
200
|
+
icon.textContent = s.iconSvg;
|
|
201
|
+
msg.className = 'text-slate-200';
|
|
202
|
+
toast.classList.remove('hidden');
|
|
203
|
+
clearTimeout(toast._timer);
|
|
204
|
+
toast._timer = setTimeout(() => { toast.classList.add('hidden'); }, 3000);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// -----------------------------------------------------------------------
|
|
208
|
+
// Helpers
|
|
209
|
+
// -----------------------------------------------------------------------
|
|
210
|
+
function getToday() {
|
|
211
|
+
return new Date().toISOString().split('T')[0];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function getWeekEnd() {
|
|
215
|
+
const d = new Date();
|
|
216
|
+
d.setDate(d.getDate() + 7);
|
|
217
|
+
return d.toISOString().split('T')[0];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function opsRelativeDate(dateStr) {
|
|
221
|
+
if (!dateStr) return '';
|
|
222
|
+
const d = new Date(dateStr + 'T00:00:00'), now = new Date();
|
|
223
|
+
now.setHours(0,0,0,0);
|
|
224
|
+
const diff = Math.round((d - now) / 86400000);
|
|
225
|
+
if (diff < -1) return Math.abs(diff) + 'd ago';
|
|
226
|
+
if (diff === -1) return 'yesterday';
|
|
227
|
+
if (diff === 0) return 'today';
|
|
228
|
+
if (diff === 1) return 'tomorrow';
|
|
229
|
+
if (diff <= 7) return diff + 'd';
|
|
230
|
+
return d.toLocaleDateString('en', { month: 'short', day: 'numeric' });
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
async function fetchItemDetail(id, type) {
|
|
234
|
+
const url = type === 'reminder' ? '/api/reminders/' + id : '/api/followups/' + id;
|
|
235
|
+
const data = await fetchJSON(url);
|
|
236
|
+
if (!data || !data.success) {
|
|
237
|
+
throw new Error((data && (data.error || data.detail)) || 'Failed to read item history');
|
|
238
|
+
}
|
|
239
|
+
return type === 'reminder' ? data.reminder : data.followup;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async function fetchReadToken(id, type) {
|
|
243
|
+
const item = await fetchItemDetail(id, type);
|
|
244
|
+
const token = item.read_token;
|
|
245
|
+
if (!token) {
|
|
246
|
+
throw new Error('Missing read token for ' + id);
|
|
247
|
+
}
|
|
248
|
+
return { item, token };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// -----------------------------------------------------------------------
|
|
252
|
+
// Grouping
|
|
253
|
+
// -----------------------------------------------------------------------
|
|
254
|
+
function groupItems(items) {
|
|
255
|
+
const today = getToday();
|
|
256
|
+
const weekEnd = getWeekEnd();
|
|
257
|
+
return {
|
|
258
|
+
overdue: items.filter(i => i.date && i.date < today && i.status !== 'COMPLETED'),
|
|
259
|
+
today: items.filter(i => i.date === today),
|
|
260
|
+
week: items.filter(i => i.date && i.date > today && i.date <= weekEnd),
|
|
261
|
+
upcoming: items.filter(i => i.date && i.date > weekEnd),
|
|
262
|
+
noDate: items.filter(i => !i.date),
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// -----------------------------------------------------------------------
|
|
267
|
+
// Rendering
|
|
268
|
+
// -----------------------------------------------------------------------
|
|
269
|
+
function renderItem(item, type) {
|
|
270
|
+
const today = getToday();
|
|
271
|
+
const isOverdue = item.date && item.date < today && item.status !== 'COMPLETED';
|
|
272
|
+
const isToday = item.date === today;
|
|
273
|
+
const isCompleted = item.status === 'COMPLETED';
|
|
274
|
+
|
|
275
|
+
const dotColor = isCompleted ? 'bg-emerald-400' : isOverdue ? 'bg-red-400' : isToday ? 'bg-amber-400' : 'bg-slate-500';
|
|
276
|
+
const dateLabel = opsRelativeDate(item.date);
|
|
277
|
+
const dateClass = isOverdue ? 'text-red-400' : isToday ? 'text-amber-400' : 'text-slate-500';
|
|
278
|
+
|
|
279
|
+
const desc = escapeHtml(item.description || '');
|
|
280
|
+
const idLabel = escapeHtml(item.id || '');
|
|
281
|
+
const category = type === 'reminder' && item.category ? escapeHtml(item.category) : '';
|
|
282
|
+
|
|
283
|
+
const moveLabel = type === 'reminder' ? '\u2192 NEXO' : '\u2190 User';
|
|
284
|
+
const moveDir = type === 'reminder' ? 'to_followup' : 'to_reminder';
|
|
285
|
+
|
|
286
|
+
const runBtn = type === 'followup'
|
|
287
|
+
? `<button onclick="executeItem('${item.id}')" class="text-xs px-2.5 py-1 rounded bg-pink-500/10 text-pink-400 hover:bg-pink-500/20 transition-colors">\u25b6 Run</button>`
|
|
288
|
+
: '';
|
|
289
|
+
|
|
290
|
+
const completedOpacity = isCompleted ? 'opacity-50' : '';
|
|
291
|
+
|
|
292
|
+
return `
|
|
293
|
+
<div class="bg-slate-900/50 border border-slate-800/50 rounded-lg p-4 group hover:border-slate-700 transition-colors ${completedOpacity}" data-id="${idLabel}">
|
|
294
|
+
<div class="flex items-start gap-2">
|
|
295
|
+
<div class="w-2 h-2 rounded-full mt-1.5 flex-shrink-0 ${dotColor}"></div>
|
|
296
|
+
<div class="flex-1 min-w-0">
|
|
297
|
+
<p class="text-sm text-slate-200 leading-relaxed line-clamp-2">${desc}</p>
|
|
298
|
+
<div class="flex items-center gap-2 mt-1.5 flex-wrap">
|
|
299
|
+
<span class="text-xs font-mono text-slate-600">${idLabel}</span>
|
|
300
|
+
${dateLabel ? `<span class="text-xs font-mono ${dateClass}">${dateLabel}</span>` : ''}
|
|
301
|
+
${category ? `<span class="text-xs px-1.5 py-0.5 rounded bg-slate-800 text-slate-500">${category}</span>` : ''}
|
|
302
|
+
${isCompleted ? `<span class="text-xs px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-500">done</span>` : ''}
|
|
303
|
+
</div>
|
|
304
|
+
</div>
|
|
305
|
+
</div>
|
|
306
|
+
<div class="flex items-center gap-1 mt-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
|
307
|
+
${!isCompleted ? `<button onclick="completeItem('${item.id}','${type}')" class="text-xs px-2.5 py-1 rounded bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20 transition-colors">Done</button>` : ''}
|
|
308
|
+
<button onclick="editItem('${item.id}','${type}')" class="text-xs px-2.5 py-1 rounded bg-slate-800 text-slate-400 hover:bg-slate-700 transition-colors">Edit</button>
|
|
309
|
+
<button onclick="moveItem('${item.id}','${moveDir}')" class="text-xs px-2.5 py-1 rounded bg-violet-500/10 text-violet-400 hover:bg-violet-500/20 transition-colors">${moveLabel}</button>
|
|
310
|
+
${runBtn}
|
|
311
|
+
<button onclick="deleteItem('${item.id}','${type}')" class="text-xs px-2.5 py-1 rounded text-red-400/60 hover:bg-red-500/10 hover:text-red-400 transition-colors ml-auto">\u2715</button>
|
|
312
|
+
</div>
|
|
313
|
+
</div>
|
|
314
|
+
`;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function renderGroupedItems(items, type, containerId) {
|
|
318
|
+
const container = document.getElementById(containerId);
|
|
319
|
+
const g = groupItems(items);
|
|
320
|
+
|
|
321
|
+
const groups = [
|
|
322
|
+
{ key: 'overdue', label: 'Overdue', color: 'text-red-400' },
|
|
323
|
+
{ key: 'today', label: 'Today', color: 'text-amber-400' },
|
|
324
|
+
{ key: 'week', label: 'This Week', color: 'text-violet-400' },
|
|
325
|
+
{ key: 'upcoming', label: 'Upcoming', color: 'text-slate-400' },
|
|
326
|
+
{ key: 'noDate', label: 'No Date', color: 'text-slate-600' },
|
|
327
|
+
];
|
|
328
|
+
|
|
329
|
+
let html = '';
|
|
330
|
+
let first = true;
|
|
331
|
+
groups.forEach(({ key, label, color }) => {
|
|
332
|
+
const list = g[key];
|
|
333
|
+
if (!list || list.length === 0) return;
|
|
334
|
+
const marginClass = first ? '' : 'mt-4';
|
|
335
|
+
html += `<div class="text-xs uppercase tracking-wider ${color} font-medium mb-2 ${marginClass}">${label} <span class="opacity-50">(${list.length})</span></div>`;
|
|
336
|
+
html += '<div class="space-y-2">' + list.map(i => renderItem(i, type)).join('') + '</div>';
|
|
337
|
+
first = false;
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
if (!html) {
|
|
341
|
+
html = '<div class="text-xs text-slate-600 font-mono py-8 text-center">No items</div>';
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
container.innerHTML = html;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// -----------------------------------------------------------------------
|
|
348
|
+
// Data loading
|
|
349
|
+
// -----------------------------------------------------------------------
|
|
350
|
+
async function loadOpsData() {
|
|
351
|
+
const status = document.getElementById('ops-status').value;
|
|
352
|
+
const statusParam = status ? '?status=' + encodeURIComponent(status) : '';
|
|
353
|
+
|
|
354
|
+
const [remData, fupData] = await Promise.all([
|
|
355
|
+
fetchJSON('/api/reminders' + statusParam),
|
|
356
|
+
fetchJSON('/api/followups' + statusParam),
|
|
357
|
+
]);
|
|
358
|
+
|
|
359
|
+
if (remData) {
|
|
360
|
+
allReminders = remData.reminders || [];
|
|
361
|
+
document.getElementById('reminder-count').textContent = allReminders.length;
|
|
362
|
+
}
|
|
363
|
+
if (fupData) {
|
|
364
|
+
allFollowups = fupData.followups || [];
|
|
365
|
+
document.getElementById('followup-count').textContent = allFollowups.length;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
filterOps();
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function filterOps() {
|
|
372
|
+
const search = (document.getElementById('ops-search').value || '').toLowerCase();
|
|
373
|
+
|
|
374
|
+
const filteredReminders = allReminders.filter(r =>
|
|
375
|
+
!search ||
|
|
376
|
+
(r.description || '').toLowerCase().includes(search) ||
|
|
377
|
+
(r.id || '').toLowerCase().includes(search) ||
|
|
378
|
+
(r.category || '').toLowerCase().includes(search)
|
|
379
|
+
);
|
|
380
|
+
const filteredFollowups = allFollowups.filter(f =>
|
|
381
|
+
!search ||
|
|
382
|
+
(f.description || '').toLowerCase().includes(search) ||
|
|
383
|
+
(f.id || '').toLowerCase().includes(search)
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
renderGroupedItems(filteredReminders, 'reminder', 'reminders-list');
|
|
387
|
+
renderGroupedItems(filteredFollowups, 'followup', 'followups-list');
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// -----------------------------------------------------------------------
|
|
391
|
+
// Actions
|
|
392
|
+
// -----------------------------------------------------------------------
|
|
393
|
+
async function completeItem(id, type) {
|
|
394
|
+
try {
|
|
395
|
+
const { token } = await fetchReadToken(id, type);
|
|
396
|
+
const url = type === 'reminder' ? '/api/reminders/' + id : '/api/followups/' + id;
|
|
397
|
+
const res = await fetch(url, {
|
|
398
|
+
method: 'PUT',
|
|
399
|
+
headers: { 'Content-Type': 'application/json' },
|
|
400
|
+
body: JSON.stringify({ status: 'COMPLETED', read_token: token })
|
|
401
|
+
});
|
|
402
|
+
const data = await res.json();
|
|
403
|
+
if (data.success) {
|
|
404
|
+
opsToast('Completed ' + id);
|
|
405
|
+
loadOpsData();
|
|
406
|
+
} else {
|
|
407
|
+
opsToast(data.error || data.detail || 'Complete failed (HTTP ' + res.status + ')', 'error');
|
|
408
|
+
}
|
|
409
|
+
} catch (err) {
|
|
410
|
+
opsToast('Complete error: ' + err.message, 'error');
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
async function moveItem(id, direction) {
|
|
415
|
+
try {
|
|
416
|
+
const type = direction === 'to_followup' ? 'reminder' : 'followup';
|
|
417
|
+
const { token } = await fetchReadToken(id, type);
|
|
418
|
+
const res = await fetch('/api/ops/move', {
|
|
419
|
+
method: 'POST',
|
|
420
|
+
headers: { 'Content-Type': 'application/json' },
|
|
421
|
+
body: JSON.stringify({ id, direction, read_token: token })
|
|
422
|
+
});
|
|
423
|
+
const data = await res.json();
|
|
424
|
+
if (data.success) {
|
|
425
|
+
opsToast('Moved ' + id + ' to ' + (direction === 'to_followup' ? 'NEXO' : 'User'));
|
|
426
|
+
loadOpsData();
|
|
427
|
+
} else {
|
|
428
|
+
opsToast(data.error || data.detail || 'Move failed (HTTP ' + res.status + ')', 'error');
|
|
429
|
+
}
|
|
430
|
+
} catch (err) {
|
|
431
|
+
opsToast('Move error: ' + err.message, 'error');
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
async function executeItem(id) {
|
|
436
|
+
try {
|
|
437
|
+
const res = await fetch('/api/ops/execute/' + id, { method: 'POST' });
|
|
438
|
+
const data = await res.json();
|
|
439
|
+
if (data.success) {
|
|
440
|
+
opsToast('Executing ' + id, 'info');
|
|
441
|
+
} else {
|
|
442
|
+
opsToast(data.error || data.detail || 'Execute failed (HTTP ' + res.status + ')', 'error');
|
|
443
|
+
}
|
|
444
|
+
} catch (err) {
|
|
445
|
+
opsToast('Execute error: ' + err.message, 'error');
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function deleteItem(id, type) {
|
|
450
|
+
pendingConfirmAction = async () => {
|
|
451
|
+
try {
|
|
452
|
+
const url = type === 'reminder' ? '/api/reminders/' + id : '/api/followups/' + id;
|
|
453
|
+
const { token } = await fetchReadToken(id, type);
|
|
454
|
+
const res = await fetch(url + '?read_token=' + encodeURIComponent(token), { method: 'DELETE' });
|
|
455
|
+
const data = await res.json();
|
|
456
|
+
if (data.success) {
|
|
457
|
+
opsToast('Marked ' + id + ' as deleted');
|
|
458
|
+
loadOpsData();
|
|
459
|
+
} else {
|
|
460
|
+
opsToast(data.error || data.detail || 'Delete failed (HTTP ' + res.status + ')', 'error');
|
|
461
|
+
}
|
|
462
|
+
} catch (err) {
|
|
463
|
+
opsToast('Delete error: ' + err.message, 'error');
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
document.getElementById('confirm-message').textContent = 'Delete ' + id + '? This marks it as DELETED and keeps its history.';
|
|
467
|
+
document.getElementById('confirm-modal').classList.remove('hidden');
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function closeConfirm() {
|
|
471
|
+
document.getElementById('confirm-modal').classList.add('hidden');
|
|
472
|
+
pendingConfirmAction = null;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function confirmAction() {
|
|
476
|
+
if (pendingConfirmAction) pendingConfirmAction();
|
|
477
|
+
closeConfirm();
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// -----------------------------------------------------------------------
|
|
481
|
+
// Modal
|
|
482
|
+
// -----------------------------------------------------------------------
|
|
483
|
+
function openCreate(type) {
|
|
484
|
+
const form = document.getElementById('modal-form');
|
|
485
|
+
form.reset();
|
|
486
|
+
document.getElementById('modal-type').value = type;
|
|
487
|
+
document.getElementById('modal-edit-id').value = '';
|
|
488
|
+
document.getElementById('modal-read-token').value = '';
|
|
489
|
+
document.getElementById('modal-title').textContent = type === 'reminder' ? 'New Reminder' : 'New Followup';
|
|
490
|
+
document.getElementById('modal-submit-btn').textContent = 'Create';
|
|
491
|
+
document.getElementById('category-group').classList.toggle('hidden', type !== 'reminder');
|
|
492
|
+
document.getElementById('verification-group').classList.toggle('hidden', type !== 'followup');
|
|
493
|
+
document.getElementById('reasoning-group').classList.toggle('hidden', type !== 'followup');
|
|
494
|
+
document.getElementById('ops-modal').classList.remove('hidden');
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
async function editItem(id, type) {
|
|
498
|
+
let item;
|
|
499
|
+
try {
|
|
500
|
+
const detail = await fetchReadToken(id, type);
|
|
501
|
+
item = detail.item;
|
|
502
|
+
document.getElementById('modal-read-token').value = detail.token;
|
|
503
|
+
} catch (err) {
|
|
504
|
+
opsToast('Read history failed: ' + err.message, 'error');
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
const form = document.getElementById('modal-form');
|
|
508
|
+
form.reset();
|
|
509
|
+
document.getElementById('modal-type').value = type;
|
|
510
|
+
document.getElementById('modal-edit-id').value = id;
|
|
511
|
+
document.getElementById('modal-title').textContent = 'Edit ' + id;
|
|
512
|
+
document.getElementById('modal-submit-btn').textContent = 'Save';
|
|
513
|
+
document.getElementById('modal-read-token').value = item.read_token || '';
|
|
514
|
+
document.getElementById('category-group').classList.toggle('hidden', type !== 'reminder');
|
|
515
|
+
document.getElementById('verification-group').classList.toggle('hidden', type !== 'followup');
|
|
516
|
+
document.getElementById('reasoning-group').classList.toggle('hidden', type !== 'followup');
|
|
517
|
+
|
|
518
|
+
form.elements.description.value = item.description || '';
|
|
519
|
+
form.elements.date.value = item.date || '';
|
|
520
|
+
if (type === 'reminder' && item.category) {
|
|
521
|
+
form.elements.category.value = item.category;
|
|
522
|
+
}
|
|
523
|
+
if (type === 'followup') {
|
|
524
|
+
form.elements.verification.value = item.verification || '';
|
|
525
|
+
form.elements.reasoning.value = item.reasoning || '';
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
document.getElementById('ops-modal').classList.remove('hidden');
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function closeModal() {
|
|
532
|
+
document.getElementById('ops-modal').classList.add('hidden');
|
|
533
|
+
document.getElementById('modal-read-token').value = '';
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
async function submitForm(e) {
|
|
537
|
+
e.preventDefault();
|
|
538
|
+
const form = document.getElementById('modal-form');
|
|
539
|
+
const fd = new FormData(form);
|
|
540
|
+
const type = fd.get('type');
|
|
541
|
+
const editId = fd.get('edit_id');
|
|
542
|
+
const isEdit = !!editId;
|
|
543
|
+
const readToken = fd.get('read_token');
|
|
544
|
+
|
|
545
|
+
let url, method, body;
|
|
546
|
+
|
|
547
|
+
if (type === 'reminder') {
|
|
548
|
+
url = isEdit ? '/api/reminders/' + editId : '/api/reminders';
|
|
549
|
+
method = isEdit ? 'PUT' : 'POST';
|
|
550
|
+
body = {
|
|
551
|
+
description: fd.get('description'),
|
|
552
|
+
date: fd.get('date') || null,
|
|
553
|
+
category: fd.get('category') || 'general'
|
|
554
|
+
};
|
|
555
|
+
} else {
|
|
556
|
+
url = isEdit ? '/api/followups/' + editId : '/api/followups';
|
|
557
|
+
method = isEdit ? 'PUT' : 'POST';
|
|
558
|
+
body = {
|
|
559
|
+
description: fd.get('description'),
|
|
560
|
+
date: fd.get('date') || null,
|
|
561
|
+
verification: fd.get('verification') || null,
|
|
562
|
+
reasoning: fd.get('reasoning') || null
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
if (isEdit) {
|
|
566
|
+
body.read_token = readToken || '';
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
try {
|
|
570
|
+
const res = await fetch(url, {
|
|
571
|
+
method,
|
|
572
|
+
headers: { 'Content-Type': 'application/json' },
|
|
573
|
+
body: JSON.stringify(body)
|
|
574
|
+
});
|
|
575
|
+
const data = await res.json();
|
|
576
|
+
if (data.success) {
|
|
577
|
+
opsToast(isEdit ? 'Updated ' + editId : 'Created successfully');
|
|
578
|
+
closeModal();
|
|
579
|
+
loadOpsData();
|
|
580
|
+
} else {
|
|
581
|
+
opsToast(data.error || data.detail || 'Save failed (HTTP ' + res.status + ')', 'error');
|
|
582
|
+
}
|
|
583
|
+
} catch (err) {
|
|
584
|
+
opsToast('Save error: ' + err.message, 'error');
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// -----------------------------------------------------------------------
|
|
589
|
+
// Keyboard shortcuts
|
|
590
|
+
// -----------------------------------------------------------------------
|
|
591
|
+
document.addEventListener('keydown', function(e) {
|
|
592
|
+
if (e.key === 'Escape') {
|
|
593
|
+
closeModal();
|
|
594
|
+
closeConfirm();
|
|
595
|
+
}
|
|
596
|
+
if (e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
|
|
597
|
+
if (e.key === 'r') openCreate('reminder');
|
|
598
|
+
if (e.key === 'f') openCreate('followup');
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
// -----------------------------------------------------------------------
|
|
603
|
+
// Init
|
|
604
|
+
// -----------------------------------------------------------------------
|
|
605
|
+
loadOpsData();
|
|
606
|
+
setInterval(loadOpsData, 60000);
|
|
607
|
+
</script>
|
|
608
|
+
{% endblock %}
|