channels table sort and style

This commit is contained in:
Lem Smyth 2022-02-20 09:53:14 -06:00
parent 04ad7a8746
commit c6f28b18ac
3 changed files with 40 additions and 29 deletions

View file

@ -61,10 +61,10 @@
margin-right: 1em; margin-right: 1em;
} }
.post-lbry-display-before { .post-lbry-display-before {
color: darkgreen; color: green;
} }
.post-lbry-display { .post-lbry-display {
color: green; color: #135548;
} }
.lbry-pub-metabox { .lbry-pub-metabox {
@ -86,38 +86,36 @@
.lbry-meta-bx-content-last { .lbry-meta-bx-content-last {
padding: .2em .8em 1em .1em; padding: .2em .8em 1em .1em;
} }
/*---------------------
Channels Table
-------------------*/
table.lbry-channel-table { table.lbry-channel-table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
font-family: Georgia; font-family: Georgia;
} }
.lbry-channel-table th, .lbry-channel-table td { .lbry-channel-table th, .lbry-channel-table td {
padding: .4em 1.6em; padding: .4em 1.6em;
border: 2px solid #fff; border: 2px solid #fff;
background: #fbd7b4; background: #97eb9d;
font-size: 1em; font-size: 1em;
} }
.lbry-channel-table thead th { .lbry-channel-table thead th {
padding: .5em 2em; padding: .5em 2em;
background: #f69546; background: #135548;
text-align: left; text-align: left;
font-weight: normal; font-weight: normal;
font-size: 1.2em; font-size: 1.2em;
color: #fff; color: #fff;
} }
.lbry-channel-table tbody tr:nth-child(odd) *:nth-child(even), .lbry-channel-table tbody tr:nth-child(even) *:nth-child(odd) { .lbry-channel-table tbody tr:nth-child(odd) td {
background: #f3eddd; background: #e1fafa;
} }
.lbry-channel-table tfoot th { .lbry-channel-table tfoot th {
padding: .5em 2em; padding: .5em 1.8em;
background: #f69546; background: #175248;
text-align: left; text-align: left;
font-weight: normal; font-weight: normal;
font-size: .9em; font-size: .9em;
color: #fff; color: #fff;
} }
.lbry-channel-table tr *:nth-child(3), .lbry-channel-table tr *:nth-child(4) {
/* text-align: right; */
}

View file

@ -1,8 +1,8 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
var compare = { var compare = {
name: function(a, b) { channel: function(a, b) {
a = a.replace(/^@/, '') && a.replace(/-/g, ''); a = a.replace(/^@/i, '') && a.replace(/[-]/gi, '');
b = b.replace(/^@/, '') && b.replace(/-/g, ''); b = b.replace(/^@/i, '') && b.replace(/[-]/gi, '');
if (a < b) { if (a < b) {
return -1; return -1;
@ -20,16 +20,23 @@ jQuery(document).ready(function($) {
return a > b ? 1 : 0; return a > b ? 1 : 0;
} }
}, },
amount: function(a, b) { claim: function(a, b) {
a = a.split('.'); if (a < b) {
b = b.split('.'); return -1;
} else {
a = Number(a[0]) + Number(a[1]); return a > b ? 1 : 0;
b = Number(b[0]) + Number(b[1]); }
},
posts: function(a, b) {
a = Number(a);
b = Number(b);
return a - b; return a - b;
}, },
number: function(a, b) { support: function(a, b) {
a = a.replace(/,/g, '');
b = b.replace(/,/g, '');
a = Number(a); a = Number(a);
b = Number(b); b = Number(b);

View file

@ -52,7 +52,7 @@ class LBRY_Admin
} }
add_action( 'admin_enqueue_scripts', 'load_admin_stylesheet' ); add_action( 'admin_enqueue_scripts', 'load_admin_stylesheet' );
// Admin JS enqueue // Admin channel sort JS enqueue
function load_admin_script() { function load_admin_script() {
if ( ( $_GET['page'] == 'lbrypress') && ( $_GET['tab'] == 'channels' ) ) { if ( ( $_GET['page'] == 'lbrypress') && ( $_GET['tab'] == 'channels' ) ) {
wp_enqueue_script( wp_enqueue_script(
@ -272,10 +272,12 @@ class LBRY_Admin
<table class="lbry-channel-table"> <table class="lbry-channel-table">
<thead> <thead>
<tr> <tr>
<th data-sort="name">Channel</th> <th data-sort="channel">Channel</th>
<th data-sort="lbryurl">LBRY URL</th> <th data-sort="lbryurl">LBRY URL</th>
<th data-sort="number">Posts</th> <th data-sort="claim">Claim ID</th>
<th data-sort="amount" colspan="2">Supports</th> <th data-sort="date">~ Date Created</th>
<th data-sort="posts">Posts</th>
<th data-sort="support" colspan="2">Supports</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -286,6 +288,8 @@ class LBRY_Admin
if ( $lbry_url ) { if ( $lbry_url ) {
$open_url = str_replace( 'lbry://', 'open.lbry.com/', $lbry_url ); $open_url = str_replace( 'lbry://', 'open.lbry.com/', $lbry_url );
} }
$timestamp = $results->items[0]->meta->creation_timestamp;
$created_date = date( 'm-d-y', $timestamp );
$support_amount = $results->items[0]->meta->support_amount; $support_amount = $results->items[0]->meta->support_amount;
$claims_published = $results->items[0]->meta->claims_in_channel; $claims_published = $results->items[0]->meta->claims_in_channel;
if ( ( $support_amount < 0.001 ) ) { if ( ( $support_amount < 0.001 ) ) {
@ -303,14 +307,16 @@ class LBRY_Admin
<tr> <tr>
<td><a href="<?php echo esc_url( $open_url, 'lbrypress' ); ?>"><?php esc_html_e( $channel->name, 'lbrypress' ); ?></a></td> <td><a href="<?php echo esc_url( $open_url, 'lbrypress' ); ?>"><?php esc_html_e( $channel->name, 'lbrypress' ); ?></a></td>
<td><?php esc_html_e( $lbry_url, 'lbrypress' ); ?></td> <td><?php esc_html_e( $lbry_url, 'lbrypress' ); ?></td>
<td><?php esc_html_e( $claim_id, 'lbrypress' ); ?></td>
<td><?php esc_html_e( $created_date, 'lbrypress' ); ?></td>
<td><?php esc_html_e( $claims_published, 'lbrypress' ); ?></td> <td><?php esc_html_e( $claims_published, 'lbrypress' ); ?></td>
<td><span title="Initial Bid Amount: <?php esc_html_e( $init_bid, 'lbrypress' ); ?>"><img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc bid-icon-lbc channel-bid-icon-lbc"><?php esc_html_e( $support_amount, 'lbrypress' ); ?></span></td> <td><span title="Initial Bid Amount: <?php esc_html_e( $init_bid, 'lbrypress' ); ?>"><img src="<?php echo esc_url( plugin_dir_url( LBRY_PLUGIN_FILE ) . 'admin/images/lbc.png' ) ?>" class="icon icon-lbc bid-icon-lbc channel-bid-icon-lbc"><?php esc_html_e( $support_amount, 'lbrypress' ); ?></span></td>
<td><a href="<?php echo admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'supports', 'claim_id' => $claim_id, 'current_support' => $support_amount, 'init_bid' => $init_bid ), 'admin.php' ) ); ?>">Add</a></td> <td><a href="<?php echo admin_url( add_query_arg( array( 'page' => 'lbrypress', 'tab' => 'supports', 'claim_id' => $claim_id, 'current_support' => $support_amount, 'init_bid' => $init_bid, 'lbry_url' => urlencode($lbry_url), 'return_page' => 'channels' ), 'admin.php' ) ); ?>">Add</a></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
<tfoot> <tfoot>
<tr><th colspan="5">LBRYPress</th></tr> <tr><th colspan="7">LBRYPress</th></tr>
</tfoot> </tfoot>
</table> </table>
<?php } else { ?> <?php } else { ?>