mgmt.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>OCB Management Panel</title>
  5. <link rel="icon" type="image/x-icon" href="/static/img/favicon.ico">
  6. <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
  7. </head>
  8. <script src="/static/mgmtpanel.js"></script>
  9. <div class="navbar">
  10. <div class="tab">
  11. <button class="tablinks" data-tab="queue" onclick="openTab(event, 'queue')">Queue</button>
  12. <button class="tablinks" data-tab="balances" onclick="openTab(event, 'balances')">Points Balances</button>
  13. <button class="tablinks" data-tab="managerewards" onclick="openTab(event, 'managerewards')">Rewards</button>
  14. <button class="tablinks" data-tab="categories" onclick="openTab(event, 'categories')">Categories</button>
  15. <button class="tablinks" data-tab="settings" onclick="openTab(event, 'settings')">Settings</button>
  16. </div>
  17. <img src="/static/img/ownchatbotwide.png">
  18. </div>
  19. <div id='queue' class="tabcontent">
  20. <body>
  21. {% if votes %}
  22. <table>
  23. <thead>
  24. <tr>
  25. <th style="width: 20%;">Active Votes</th>
  26. <th style="width: 40%;">Description</th>
  27. <th style="width: 20%;">Price</th>
  28. <th style="width: 20%;">Current Tally</th>
  29. <th></th>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. {% for vote in votes %}
  34. <tr>
  35. <td> {{ prefix }}{{ vote[0] }} </td>
  36. <td> {{ vote[2] }} </td>
  37. {% set points_label = 'point' if rewards[vote[0]]["price"] == 1 else 'points' %}
  38. <td> {{ rewards[vote[0]]["price"] }} {{ points_label }}</td>
  39. {% set votes_label = 'vote' if vote[1] == 1 else 'votes' %}
  40. <td> {{ vote[1] }} {{ votes_label }}</td>
  41. <td></td>
  42. </tr>
  43. {% endfor %}
  44. </tbody>
  45. </table>
  46. {% else %}
  47. <h3> You currently have no active votes. </h3>
  48. {% endif %}
  49. <br>
  50. <hr>
  51. {% if goals %}
  52. <table>
  53. <thead>
  54. <tr>
  55. <th style="width: 20%;">Active Goals</th>
  56. <th style="width: 40%;">Description</th>
  57. <th style="width: 25%;">Progress</th>
  58. <th></th>
  59. </tr>
  60. </thead>
  61. <tbody>
  62. {% for goal in goals %}
  63. <tr>
  64. <td> {{ prefix }}{{ goal[0] }} </td>
  65. <td> {{ goal[3] }} </td>
  66. {% set progress = goal[1] / goal[2] * 100 %}
  67. <td><div class="bar-light-grey bar-tiny bar-round">
  68. <div class="bar-round bar-blue" style="text-align: center; width:{{ goal[1] / goal[2] * 100 }}%;">{{ '%0.0f'| format(progress| float) }}%</div></td>
  69. {% if goal[1] == goal[2] %}
  70. <td> {{ goal[1] }} / {{ goal[2] }} <img src=/static/img/tada.png style="width: 24px; height: 24px;"></td>
  71. {% else %}
  72. <td> {{ goal[1] }} / {{ goal[2] }} </td>
  73. {% endif %}
  74. </tr>
  75. {% endfor %}
  76. </tbody>
  77. </table>
  78. {% else %}
  79. <h3> You currently have no active goals. </h3>
  80. {% endif %}
  81. <br>
  82. <hr>
  83. <h3>Redeems Queue</h3>
  84. {% if queue %}
  85. <a href="/mgmt/clearfulfilled"><button class="button button2" onclick="openTab(event, 'queue')">Clear Fullfilled Rewards</button></a>&nbsp;&nbsp;<a href="/mgmt/clearqueue"><button class="button button2" onclick="openTab(event, 'queue')">Clear All Rewards</button></a>
  86. <table>
  87. <thead>
  88. <tr>
  89. <th>Time</th>
  90. <th>Reward</th>
  91. <th>User</th>
  92. <th></th>
  93. </tr>
  94. </thead>
  95. <tbody>
  96. {% for row in queue %}
  97. <tr>
  98. <td>{{ row[1].replace(tzinfo=utc_timezone).astimezone().strftime("%H:%M") }}</td>
  99. {% if row[4] %}
  100. <td><s>{{ rewards[row[2]]["info"] }}</s></td>
  101. {% else %}
  102. <td>{{ rewards[row[2]]["info"] }}</td>
  103. {% endif %}
  104. <td>{{ row[6] }}</td>
  105. {% if row[4] %}
  106. {% if row[5] %}
  107. <td>Refunded</td>
  108. {% else %}
  109. <td><a href="/mgmt/refund?reward={{ row[2] }}&username={{ row[6] }}&rewarder_id={{ row[3] }}&reward_id={{ row[0] }} "><button class="button button2" onclick="openTab(event, 'queue')">Refund</button></a></td>
  110. {% endif %}
  111. {% else %}
  112. <td><a href="/mgmt/fulfill?reward_id={{ row[0] }}&username={{ row[6] }}"><button class="button button2" onclick="openTab(event, 'queue')">Fulfill</button></a></td>
  113. {% endif %}
  114. </tr>
  115. {% endfor %}
  116. </tbody>
  117. </table>
  118. {% else %}
  119. <p>There are currently no rewards waiting in the queue.</p>
  120. {% endif %}
  121. </body>
  122. </div>
  123. <div id='balances' class="tabcontent">
  124. <body>
  125. <h3>Viewer points balances</h3>
  126. {% if users %}
  127. <table>
  128. <thead>
  129. <tr>
  130. <th>User</th>
  131. <th>Points balance</th>
  132. <th></th>
  133. </tr>
  134. </thead>
  135. <tbody>
  136. {% for user in users %}
  137. <tr>
  138. <td> {{ user[0] }} </td>
  139. {% set points_label = 'point' if user[1] == 1 else 'points' %}
  140. <td>{{ user[1] }} {{ points_label }}</td>
  141. <td> <a href="/mgmt/adjust/{{ user[2] }}?name={{ user[0] }}&points={{ user[1] }}"><button class="button button2" onclick="openTab(event, 'panel')">Adjust Points</button></a> </td>
  142. </tr>
  143. {% endfor %}
  144. </tbody>
  145. </table>
  146. {% endif %}
  147. </body>
  148. </div>
  149. <div id='managerewards' class="tabcontent">
  150. <h3>Manage rewards</h3>
  151. <body>
  152. <div>
  153. <h4>Reward Types:</h4>
  154. <ul>
  155. <li><u>Redeems</u> are standard stream point redeems. They get added to the queue for the streamer to fulfill.</li>
  156. <li><u>Specials</u> are redeems, but they run system commands and scripts. This enables you to integrate a lot of other fun things, such as letting your viewers control lighting, activate devices, trigger webhooks, etc. Specials do not go into the queue, because they happen automagically.</li>
  157. <ul>
  158. <li>Be careful with this one. It does require some more advanced scripting/command line knowledge. Make sure you test your specials before letting viewers use them.</li>
  159. </ul>
  160. <li><u>Votes</u> are just that, votes. Your viewers can vote on them.</li>
  161. <li><u>Goals</u> are rewards that everyone in chat can contribute to. The streamer fulfills the reward when the goal is reached.</li>
  162. <li>Add rewards to categories to enable and disable groups of rewards.</li>
  163. <li>Rewards with no categories are inactive.</li>
  164. </ul>
  165. </div>
  166. <table>
  167. <tr>
  168. <td>
  169. </td>
  170. <td>
  171. </td>
  172. <td>
  173. </td>
  174. <td>
  175. </td>
  176. </tr>
  177. <tr>
  178. <td>
  179. <a href="{{ url_for('web_panels.add', reward_type='redeem') }}"><button class="button button2" onclick="openTab(event, 'managerewards')">Create a Redeem</button></a><br>
  180. </td>
  181. <td>
  182. <a href="{{ url_for('web_panels.add', reward_type='special') }}"><button class="button button2" onclick="openTab(event, 'managerewards')">Create a Special</button></a><br>
  183. </td>
  184. <td>
  185. <a href="{{ url_for('web_panels.add', reward_type='vote') }}"><button class="button button2" onclick="openTab(event, 'managerewards')">Create a Vote</button></a><br>
  186. </td>
  187. <td>
  188. <a href="{{ url_for('web_panels.add', reward_type='goal') }}"><button class="button button2" onclick="openTab(event, 'managerewards')">Create a Goal</button></a><br>
  189. </td>
  190. </tr>
  191. </table>
  192. <br>
  193. {% if rewards %}
  194. Rewards in <span style="color: red !important;">red</span> are inactive. To activate a reward, add it to an active category.
  195. <table>
  196. <thead>
  197. <tr>
  198. <th style="width:15%">Name</th>
  199. <th>Target</th>
  200. <th>Price</th>
  201. <th>Type</th>
  202. <th>Info</th>
  203. <th>Cool down</th>
  204. <th>Category</th>
  205. <th style="width:15%">Actions</th>
  206. </tr>
  207. </thead>
  208. <tbody>
  209. {% for reward, reward_info in rewards.items() %}
  210. {% if reward in active_rewards %}
  211. <tr>
  212. {% else %}
  213. <tr style="color: red;">
  214. {% endif %}
  215. <td>{{ prefix }}{{ reward }}</td>
  216. {% if reward_info["type"] == "goal" %}
  217. <td>{{ reward_info["target"] }}</td>
  218. {% else %}
  219. <td>N/A</td>
  220. {% endif %}
  221. {% if reward_info["type"] == "goal" %}
  222. <td>N/A</td>
  223. {% else %}
  224. <td>{{ reward_info["price"] }}</td>
  225. {% endif %}
  226. <td>{{ reward_info["type"] }}</td>
  227. <td>{{ reward_info["info"] }}</td>
  228. {% if reward_info["cooldown"] > 0 %}
  229. {% set minutes_label = 'minute' if reward_info["cooldown"] == 1 else 'minutes' %}
  230. <td>{{ reward_info["cooldown"] }} {{ minutes_label }}</td>
  231. {% else %}
  232. <td>None</td>
  233. {% endif %}
  234. <td>{{ reward_info["categories"] | join(', ') }}</td>
  235. <td>
  236. <a href="{{ url_for('web_panels.edit', reward_name=reward) }}"><button class="button button2" onclick="openTab(event, 'managerewards')"><span style="color: green;">Edit</span></button></a>&nbsp
  237. <a href="{{ url_for('web_panels.delete', reward_name=reward) }}"><button class="button button2" onclick="openTab(event, 'managerewards')"><span style="color: red;">Delete</span></button></a>&nbsp
  238. {% if reward_info["type"] == "goal" or reward_info["type"] == "vote" %}
  239. <a href="{{ url_for('web_panels.reset', reward_name=reward, reward_type=reward_info["type"]) }}"><button class="button button2" onclick="openTab(event, 'managerewards')"><span style="color: orange;">Reset</span></button></a>
  240. {% endif %}
  241. </td>
  242. </tr>
  243. {% endfor %}
  244. </tbody>
  245. </table>
  246. {% endif %}
  247. </body>
  248. </div>
  249. <div id='categories' class="tabcontent">
  250. <body>
  251. <h3>Manage Categories</h3>
  252. <div>
  253. &nbsp;&nbsp;<a href="{{ url_for('web_panels.add', reward_type='category') }}"><button class="button button2" onclick="openTab(event, 'categories')">Create a new category</button></a><br>
  254. <table>
  255. <thead>
  256. <tr>
  257. <th style="width: 50%;"><h3>Active Categories</h3></th>
  258. <th style="width: 50%;"><h3>Inactive Categories</h3></th>
  259. </tr>
  260. </thead>
  261. <tbody>
  262. <tr>
  263. <td>
  264. {% for cat in active_categories %}
  265. &nbsp;&nbsp;{{ cat }} - <a href="/mgmt/deactivate/{{ cat }}"><span style="color: green;">Deactivate</span></a>&nbsp;<a href="/mgmt/delcat/{{ cat }}/active"><span style="color: red;">Delete</span></a><br>
  266. {% endfor %}
  267. </td>
  268. <td>
  269. {% for cat in inactive_categories %}
  270. &nbsp;&nbsp;{{ cat }} - <a href="/mgmt/activate/{{ cat }}"><span style="color: green;">Activate</span></a>&nbsp;<a href="/mgmt/delcat/{{ cat }}/inactive"><span style="color: red;">Delete</span></a><br>
  271. {% endfor %}
  272. </td>
  273. </tr>
  274. </tbody>
  275. </table>
  276. </div>
  277. </body>
  278. </div>
  279. <div id='settings' class="tabcontent">
  280. <body style="text-align: left;">
  281. <form method="POST" method="POST" action="/mgmt/settings">
  282. <table>
  283. <h3>OwnchatBot Settings</h3>
  284. <thead>
  285. <tr style="border-bottom: none;">
  286. <th style="width: 20%;"></th>
  287. <th></th>
  288. <th style="width: 50%;"></th>
  289. </tr>
  290. </thead>
  291. <tr>
  292. <td> <label for="mgmt_auth">Management Auth Code:</label> </td>
  293. <td style="padding: 5px;"> <input type="textr" name="mgmt_auth" value="{{ settings_info[0] }}" size="30" required> </td>
  294. <td>Pregenerated during install. Goes in your management panel URL. Keep it secret. Keep it safe.<br>
  295. http://localhost:5000/mgmt?auth={{ settings_info[0] }}</td>
  296. </tr>
  297. <tr>
  298. <td> <label for="points_interval">Points Interval:</label> </td>
  299. <td> <input type="number" name="points_interval" value="{{ settings_info[1] }}" size="5" required> minutes</td>
  300. <td>How often do you want to award your viewers points?</td>
  301. </tr>
  302. <tr>
  303. <td> <label for="points_award">Points Award:</label> </td>
  304. <td> <input type="number" name="points_award" value="{{ settings_info[2] }}" size="5" required> points</td>
  305. <td>How many points do you want to award them?</td>
  306. </tr>
  307. <tr>
  308. <td> <label for="gunicorn_logging">Gunicorn Logging:</label> </td>
  309. {% if settings_info[3] %}
  310. <td> <input type="checkbox" name="gunicorn_logging" value="{{ settings_info[3] }}" checked> </td>
  311. {% else %}
  312. <td> <input type="checkbox" name="gunicorn_logging" value="{{ settings_info[3] }}"> </td>
  313. {% endif %}
  314. <td>Enable Gunicorn logging integration.</td>
  315. </tr>
  316. <tr>
  317. <td> <label for="prefix">Chat Command Prefix:</label> </td>
  318. <td> <input type="text" name="prefix" maxlength="1" size="1" value="{{ settings_info[4] }}" required> </td>
  319. <td>Character that preceeds chat commands, so OwnchatBot knows what to look for.<br>Example: "{{ settings_info[4] }}points"</td>
  320. </tr>
  321. </table>
  322. <h3>Owncast Integration</h3>
  323. <table>
  324. <thead>
  325. <tr style="border-bottom: none;">
  326. <th style="width: 20%;"></th>
  327. <th></th>
  328. <th style="width: 50%;"></th>
  329. </tr>
  330. </thead>
  331. <tr>
  332. <td> <label for="access_token">Access Token:</label> </td>
  333. <td style="padding: 5px;"> <input type="text" name="access_token" value="{{ settings_info[5] }}" size="30" required> </td>
  334. <td>Create in Owncast Admin panel. Integrations -> Access Tokens</td>
  335. </tr>
  336. <tr>
  337. <td> <label for="owncast_url">Your Owncast URL:</label> </td>
  338. <td> <input type="text" name="owncast_url" value="{{ settings_info[6] }}" size="30" required> </td>
  339. <td>The address of your Owncast instance. Can be an internal address, such as "localhost" if that's the case.</td>
  340. </tr>
  341. </table>
  342. <br><button class="button button2" type="submit">Save Changes</button><br>
  343. </form>
  344. <br><br>
  345. </body>
  346. </div>
  347. </html>