index.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>ArduPilot Overlay Manager</title>
  6. <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  7. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
  8. <style>
  9. html, body { height: 100%; }
  10. body {
  11. display: flex;
  12. flex-direction: column;
  13. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  14. background-color: #f4f6f9;
  15. }
  16. .content-wrapper { flex: 1 0 auto; }
  17. .navbar-brand { font-size: 25px; }
  18. .card { border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); border: none;}
  19. .table-light { background-color: #f8f9fa; }
  20. footer { flex-shrink: 0; }
  21. .profile-list-item.active {
  22. background-color: #0d6efd;
  23. border-color: #0d6efd;
  24. color: white;
  25. }
  26. .profile-list-item.active .text-muted, .profile-list-item.active .text-secondary {
  27. color: rgba(255,255,255,0.8) !important;
  28. }
  29. .dropdown-item i { width: 20px; text-align: center; }
  30. </style>
  31. </head>
  32. <body>
  33. <div class="content-wrapper">
  34. <nav class="navbar navbar-dark bg-dark shadow-sm py-2">
  35. <div class="container-fluid px-4">
  36. <div class="d-flex align-items-center">
  37. <a class="navbar-brand d-flex align-items-center" href="/">
  38. <img src="/static/images/ardupilot_logo.png" alt="ArduPilot" height="24" class="d-inline-block align-text-top me-2">
  39. <span class="text-white">Overlay Manager</span>
  40. </a>
  41. </div>
  42. <div class="ms-auto d-flex align-items-center">
  43. <a href="javascript:void(0);" onclick="window.location.href = window.location.protocol + '//' + window.location.hostname;" class="btn btn-outline-light">
  44. <i class="bi bi-arrow-left me-2"></i>Back to Main App
  45. </a>
  46. </div>
  47. </div>
  48. </nav>
  49. <div class="container-fluid px-4 mt-4">
  50. {% if success_msg %}
  51. <div class="alert alert-success alert-dismissible fade show shadow-sm" role="alert">
  52. <i class="bi bi-check-circle-fill me-2"></i>{{ success_msg }}
  53. <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  54. </div>
  55. {% endif %}
  56. {% if error_msg %}
  57. <div class="alert alert-danger alert-dismissible fade show shadow-sm" role="alert">
  58. <i class="bi bi-exclamation-triangle-fill me-2"></i>{{ error_msg }}
  59. <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  60. </div>
  61. {% endif %}
  62. <div class="row g-4">
  63. <div class="col-md-3">
  64. <div class="card mb-4">
  65. <div class="card-header bg-white py-3 d-flex justify-content-between align-items-center">
  66. <h6 class="mb-0 fw-bold text-dark"><i class="bi bi-diagram-3-fill me-2 text-primary"></i>Profiles / Loadouts</h6>
  67. </div>
  68. <div class="list-group list-group-flush">
  69. {% for p in profiles %}
  70. <div class="list-group-item d-flex justify-content-between align-items-center profile-list-item {% if p.is_active %}active{% endif %}">
  71. <form action="/patch-manager/profile/activate" method="post" class="m-0 p-0 flex-grow-1 cursor-pointer" style="cursor: pointer;">
  72. <input type="hidden" name="profile_id" value="{{ p.id }}">
  73. <div onclick="this.parentNode.submit();" class="w-100 fw-bold">
  74. {{ p.name }}
  75. {% if p.is_readonly %}<i class="bi bi-lock-fill ms-1" title="Read-Only"></i>{% endif %}
  76. {% if p.is_active %}<i class="bi bi-check-circle-fill ms-2"></i>{% endif %}
  77. </div>
  78. </form>
  79. <div class="dropdown">
  80. <button class="btn btn-sm btn-link p-0 text-decoration-none {% if p.is_active %}text-white{% else %}text-secondary{% endif %}" type="button" data-bs-toggle="dropdown" aria-expanded="false" title="Profile Options">
  81. <i class="bi bi-three-dots-vertical fs-5"></i>
  82. </button>
  83. <ul class="dropdown-menu shadow-sm dropdown-menu-end">
  84. {% if not p.is_readonly %}
  85. <li>
  86. <a class="dropdown-item" href="javascript:void(0)" onclick="openRenameModal({{ p.id }}, '{{ p.name|escape }}')">
  87. <i class="bi bi-pencil-square me-2 text-primary"></i>Rename Profile
  88. </a>
  89. </li>
  90. {% endif %}
  91. <li>
  92. <form action="/patch-manager/profile/duplicate" method="post" class="m-0 p-0">
  93. <input type="hidden" name="profile_id" value="{{ p.id }}">
  94. <button type="submit" class="dropdown-item"><i class="bi bi-copy me-2 text-success"></i>Clone Profile</button>
  95. </form>
  96. </li>
  97. {% if not p.is_active and not p.is_readonly %}
  98. <li><hr class="dropdown-divider"></li>
  99. <li>
  100. <form action="/patch-manager/profile/delete" method="post" class="m-0 p-0" onsubmit="return confirm('Delete this profile completely?');">
  101. <input type="hidden" name="profile_id" value="{{ p.id }}">
  102. <button type="submit" class="dropdown-item text-danger"><i class="bi bi-trash me-2"></i>Delete Profile</button>
  103. </form>
  104. </li>
  105. {% endif %}
  106. </ul>
  107. </div>
  108. </div>
  109. {% endfor %}
  110. </div>
  111. <div class="card-footer bg-light p-3">
  112. <form action="/patch-manager/profile/create" method="post" class="input-group">
  113. <input type="text" class="form-control form-control-sm" name="name" placeholder="New profile name..." required>
  114. <button class="btn btn-primary btn-sm" type="submit"><i class="bi bi-plus"></i> Add</button>
  115. </form>
  116. </div>
  117. </div>
  118. <div class="card bg-dark text-white shadow">
  119. <div class="card-body text-center p-4">
  120. <i class="bi bi-rocket-takeoff-fill display-4 text-warning mb-3 d-block"></i>
  121. <h5 class="fw-bold">Ready to Compile?</h5>
  122. <p class="small text-white-50">Pushing to the builder will wipe the staging directory and write the currently active profile.</p>
  123. <form action="/patch-manager/deploy" method="post" onsubmit="return confirm('This will deploy {{ active_profile.name }} to the builder. Are you sure?');">
  124. <button type="submit" class="btn btn-warning fw-bold w-100 py-2 fs-5">
  125. DEPLOY TO BUILDER
  126. </button>
  127. </form>
  128. </div>
  129. </div>
  130. </div>
  131. <div class="col-md-9">
  132. <div class="card shadow-sm border-0 mb-4">
  133. <div class="card-header bg-white py-3">
  134. <h6 class="card-title mb-0 fw-bold text-dark"><i class="bi bi-card-text text-warning me-2"></i>Profile Notes & Annotations</h6>
  135. </div>
  136. <div class="card-body p-3 bg-light">
  137. <form action="/patch-manager/profile/annotate" method="post" class="d-flex flex-column gap-2">
  138. <input type="hidden" name="profile_id" value="{{ active_profile.id }}">
  139. <textarea class="form-control" name="description" rows="3" {% if active_profile.is_readonly %}disabled{% endif %} placeholder="Add notes about this loadout (e.g., 'Aggressive PID tune, experimental VTX settings')">{{ active_profile.description }}</textarea>
  140. {% if not active_profile.is_readonly %}
  141. <div class="text-end">
  142. <button type="submit" class="btn btn-warning btn-sm fw-bold"><i class="bi bi-save me-1"></i> Save Notes</button>
  143. </div>
  144. {% endif %}
  145. </form>
  146. </div>
  147. </div>
  148. <div class="card shadow-sm border-0 mb-4">
  149. <div class="card-header bg-white py-3">
  150. <h6 class="card-title mb-0 fw-bold text-dark"><i class="bi bi-cloud-arrow-up text-success me-2"></i>Upload File to Profile</h6>
  151. </div>
  152. {% if active_profile.is_readonly %}
  153. <div class="card-body p-4 bg-light text-center text-muted">
  154. <i class="bi bi-lock-fill fs-3 d-block mb-2"></i>
  155. <p class="mb-0">This is a locked, unmodified base profile. You cannot upload files here.<br><strong>Clone this profile</strong> from the menu on the left to start making changes.</p>
  156. </div>
  157. {% else %}
  158. <div class="card-body p-3 bg-light">
  159. <form action="/patch-manager/file/upload" method="post" enctype="multipart/form-data" class="row g-3 align-items-end">
  160. <input type="hidden" name="profile_id" value="{{ active_profile.id }}">
  161. <div class="col-md-4">
  162. <label class="form-label small fw-bold text-muted mb-1">1. Select File</label>
  163. <input class="form-control form-control-sm" type="file" name="file" required>
  164. </div>
  165. <div class="col-md-3">
  166. <label class="form-label small fw-bold text-muted mb-1">2. Existing Folder</label>
  167. <select class="form-select form-select-sm" name="existing_path" onchange="document.getElementById('new_path').value=''">
  168. <option value="">/ (Root Directory)</option>
  169. {% for d in dirs %}
  170. <option value="{{ d }}">{{ d }}</option>
  171. {% endfor %}
  172. </select>
  173. </div>
  174. <div class="col-md-3">
  175. <label class="form-label small fw-bold text-muted mb-1">...Or Create New Folder</label>
  176. <input type="text" class="form-control form-control-sm font-monospace" name="new_path" id="new_path" placeholder="e.g. libraries/AP_HAL" oninput="document.getElementsByName('existing_path')[0].value=''">
  177. </div>
  178. <div class="col-md-2">
  179. <button type="submit" class="btn btn-success btn-sm fw-bold w-100"><i class="bi bi-upload me-1"></i> Upload</button>
  180. </div>
  181. </form>
  182. </div>
  183. {% endif %}
  184. </div>
  185. <div class="card mb-5 border-0 shadow-sm">
  186. <div class="card-header bg-white py-3 d-flex justify-content-between align-items-center border-bottom-0">
  187. <h5 class="card-title mb-0 fw-bold text-dark">
  188. <i class="bi bi-folder2-open me-2 text-info"></i>Files for: <span class="text-primary">{{ active_profile.name }}</span>
  189. </h5>
  190. </div>
  191. <div class="card-body p-0">
  192. <div class="table-responsive">
  193. <table class="table table-hover align-middle mb-0">
  194. <thead class="table-light">
  195. <tr>
  196. <th class="ps-4 py-3">Target Path</th>
  197. <th class="text-end pe-4 py-3">Actions</th>
  198. </tr>
  199. </thead>
  200. <tbody>
  201. {% for file in files %}
  202. <tr>
  203. <td class="ps-4 font-monospace text-dark" style="font-size: 0.95rem;">
  204. <i class="bi bi-file-code me-2 text-secondary"></i>{{ file.filepath }}
  205. </td>
  206. <td class="text-end pe-4">
  207. <a href="/patch-manager/download?file_id={{ file.id }}" class="btn btn-sm btn-outline-info me-2" title="Download">
  208. <i class="bi bi-download"></i>
  209. </a>
  210. <a href="/patch-manager/edit?file_id={{ file.id }}" class="btn btn-sm btn-outline-primary me-2">
  211. <i class="bi bi-pencil me-1"></i> Edit
  212. </a>
  213. <form action="/patch-manager/file/delete" method="post" class="d-inline" onsubmit="return confirm('Remove this file from the profile?');">
  214. <input type="hidden" name="file_id" value="{{ file.id }}">
  215. <button type="submit" class="btn btn-sm btn-outline-danger">
  216. <i class="bi bi-trash"></i>
  217. </button>
  218. </form>
  219. </td>
  220. </tr>
  221. {% else %}
  222. <tr>
  223. <td colspan="2" class="text-center py-5 text-muted">
  224. <i class="bi bi-inbox fs-1 d-block mb-3 text-black-50"></i>
  225. <h5>This profile is empty.</h5>
  226. <p>Deploying this profile will result in a clean, vanilla build.<br>Upload a file above to start creating overlays.</p>
  227. </td>
  228. </tr>
  229. {% endfor %}
  230. </tbody>
  231. </table>
  232. </div>
  233. </div>
  234. </div>
  235. </div>
  236. </div>
  237. </div>
  238. </div>
  239. <div class="modal fade" id="renameModal" tabindex="-1" aria-hidden="true">
  240. <div class="modal-dialog">
  241. <div class="modal-content">
  242. <form action="/patch-manager/profile/rename" method="post">
  243. <div class="modal-header bg-light">
  244. <h5 class="modal-title fw-bold text-dark"><i class="bi bi-pencil-square me-2"></i>Rename Profile</h5>
  245. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  246. </div>
  247. <div class="modal-body p-4">
  248. <input type="hidden" name="profile_id" id="rename-profile-id">
  249. <div class="mb-3">
  250. <label class="form-label text-muted small fw-bold">Profile Name</label>
  251. <input type="text" class="form-control" name="new_name" id="rename-new-name" required>
  252. </div>
  253. </div>
  254. <div class="modal-footer bg-light d-flex justify-content-between">
  255. <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
  256. <button type="submit" class="btn btn-primary fw-bold"><i class="bi bi-check-lg me-1"></i>Save Name</button>
  257. </div>
  258. </form>
  259. </div>
  260. </div>
  261. </div>
  262. <footer class="py-3 bg-dark text-white-50 mt-auto">
  263. <div class="container-fluid px-4 d-flex justify-content-between">
  264. <div>
  265. <span class="mx-2">Credits:
  266. <a href="https://github.com/ArduPilot/CustomBuild/graphs/contributors" style="text-decoration: underline; color: white;">See Contributors</a>
  267. </span>|
  268. <span class="mx-2">Source:
  269. <a href="https://git.equalmass.com/Equalmass/ArdupilotCustomFirmwareBuilder" style="text-decoration: underline; color: white;">Ardupilot/CustomBuild</a>
  270. </span>
  271. </div>
  272. <span>ArduPilot Overlay Manager</span>
  273. </div>
  274. </footer>
  275. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  276. <script>
  277. function openRenameModal(profileId, profileName) {
  278. document.getElementById('rename-profile-id').value = profileId;
  279. document.getElementById('rename-new-name').value = profileName;
  280. new bootstrap.Modal(document.getElementById('renameModal')).show();
  281. }
  282. </script>
  283. </body>
  284. </html>