]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - settings/add-plugin.php
settings/plugins: add install button and show plugin info when clicked
[irc/unrealircd/unrealircd-webpanel.git] / settings / add-plugin.php
1 <?php
2
3 require_once "../inc/common.php";
4 require_once "../inc/header.php";
5 require_once "../Classes/class-plugin-git.php";
6
7 if (!current_user_can(PERMISSION_MANAGE_PLUGINS))
8 die("Access denied");
9
10 $p = new PluginRepo();
11 ?>
12
13 <h2>Add New Plugin</h2>
14 <br>
15
16 <?php
17 if ($p) {
18 echo "
19 Welcome to our lively plugins hub, where creativity takes center stage.<br>
20 We've got two fantastic plugins to kick things off (one practical, one for a playful twist).<br>
21 Join us on this exciting journey and unlock new possibilities for your website!<br><br>";
22 $p->do_list();
23 } else {
24 echo "Oops! Could not find plugins list. This is an upstream error, which means there is nothing wrong<br>
25 on your panel, it just means we can't check the plugins information webpage for some reason.<br>
26 Nothing to worry about! Try again later!";
27 }
28 require_once "../inc/footer.php";
29
30 ?>
31
32 <script>
33
34 const ibtns = document.querySelectorAll(".btn-install-plugin");
35 ibtns.forEach((ib) => {
36 ib.addEventListener('click', (e) => {
37 if (ib.innerHTML !== "Install" && ib.innerHTML !== "Uninstall") // some point between, don't do anything
38 {}
39 else if (ib.innerHTML == "Install") // install button pressed!
40 {
41 let req = requestInstall(ib.id.slice(0,-7))
42 if (req == true)
43 {
44 ib.classList.replace("btn-primary", "btn-secondary");
45 ib.innerHTML = "Installing...";
46 }
47 else
48 {
49 let uhoh = new bsModal("Error", "Could not install: "+req, "", null, false, true);
50 }
51 }
52 else if (ib.innerHTML == "Uninstall")
53 {
54 let req = requestInstall(ib.id.slice(0,-7), true); // true = uninstall
55 if (req == true)
56 {
57 ib.classList.replace("btn-outline-danger", "btn-secondary");
58 ib.innerHTML = "Uninstalling...";
59 }
60 else
61 {
62 let uhoh = new bsModal("Error", "Could not uninstall: "+req, "", null, false, true);
63 }
64 }
65 });
66 })
67 const installed = document.querySelectorAll(".installed");
68 installed.forEach((el) => {
69 let btn = document.getElementById(el.id + 'install');
70 btn.classList.replace("btn-primary", "btn-outline-danger");
71 btn.innerHTML = "Uninstall";
72 });
73
74
75
76 const infoButtons = document.querySelectorAll('.more-info');
77 infoButtons.forEach((el) => {
78 el.addEventListener('click', (event) => {
79 create_plugin_info_modal(el.id);
80
81 });
82 });
83 </script>