]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - channels/index.php
Add a `Plugins` overview card
[irc/unrealircd/unrealircd-webpanel.git] / channels / index.php
index bf02085c281afbcd51a9e1b0d8287653df003fef..82a60d19b41b9303eb4572bbdd42a5ebd658db55 100644 (file)
@@ -1,6 +1,6 @@
 <?php
-require_once "../common.php";
-require_once UPATH . "/header.php";
+require_once "../inc/common.php";
+require_once "../inc/header.php";
 
 if (!empty($_POST))
 {
@@ -10,31 +10,81 @@ if (!empty($_POST))
 
 }
 
-$channels = $rpc->channel()->getAll();
-
 ?>
 <h4>Channels Overview</h4><br>
-<table class="container-xxl table table-responsive caption-top table-striped">
-       <thead class="table-primary">
-       <th>Name</th>
-       <th>Users</th>
-       <th>Modes</th>
-       <th>Topic</th>
-       <th>Created</th>
+
+<!-- The channel list -->
+<table id="data_list" class="table-striped display responsive nowrap" style="width:100%">
+<thead class="table-primary">
+       <th scope="col">Name</th>
+       <th scope="col">Users</th>
+       <th scope="col">Modes</th>
+       <th scope="col">Topic</th>
+       <th scope="col">Created</th>
 </thead>
-<tbody>
-       <?php
-               foreach($channels as $channel)
-               {
-                       echo "<tr>";
-                       echo "<td>".$channel->name."</td>";
-                       echo "<td>".$channel->num_users."</td>";
-                       $modes = (isset($channel->modes)) ? "+" . $channel->modes : "<none>";
-                       echo "<td>".$modes."</td>";
-                       $topic = (isset($channel->topic)) ? $channel->topic : "";
-                       echo "<td>".$topic."</td>";
-                       echo "<td>".$channel->creation_time."</td>";
-               }
-       ?>
-</tbody>
 </table>
+
+<script>
+let data_list_table = null;
+
+$(document).ready( function () {
+       args = {
+               'responsive': true,
+               'fixedHeader': {
+                       header: true,
+                       headerOffset: 53
+               },
+               'ajax': {
+                       'url': '<?php echo get_config("base_url"); ?>api/channels.php',
+                       dataSrc: ''
+               },
+               'pageLength':100,
+               'order':[[1,'desc']],
+               'columns': [
+                       { 'data': 'Name', 'responsivePriority': 1, 'className':'virtuallink' },
+                       { 'data': 'Users', 'responsivePriority': 2 },
+                       { 'data': 'Modes', 'responsivePriority': 3 },
+                       { 'data': 'Topic', 'responsivePriority': 5, 'className':'tdwrap' },
+                       { 'data': 'Created', 'responsivePriority': 4 },
+               ],
+       };
+       /* Hide on mobile */
+       if (window.innerWidth > 8000)
+       {
+               args['dom'] = 'Pfrtip';
+               args['searchPanes'] = {
+                       'initCollapsed': 'true',
+                       'columns': [1,3],
+                       'dtOpts': {
+                               select: { style: 'multi'},
+                               order: [[ 1, "desc" ]]
+                       },
+               }
+       }
+
+       data_list_table = $('#data_list').DataTable(args);
+
+       $('#data_list').on( 'click', 'td', function () {
+               show_channel(this);
+       } );
+} );
+
+function show_channel(e)
+{
+       /* The first column is the 'Select' column */
+       // not on this page, or not yet ;)
+       //if (data_list_table.cell(e).index().column == 0)
+       //      return;
+
+       /* For all the other columns we show the view screen */
+       var data = data_list_table.row(e).data();
+       channel = data['Name'];
+       window.location = '<?php echo get_config('base_url'); ?>channels/details.php?chan=' +
+                         encodeURIComponent(channel);
+       // not working: still expands on mobile: e.stopImmediatePropagation();
+       return true;
+}
+
+</script>
+
+<?php require_once UPATH.'/inc/footer.php'; ?>