| 1 |
<?php |
| 2 |
|
| 3 |
if(class_exists('RabbitLoader_21_Tab_Usage')){ |
| 4 |
#it seems we have a conflict |
| 5 |
return; |
| 6 |
} |
| 7 |
|
| 8 |
final class RabbitLoader_21_Tab_Usage extends RabbitLoader_21_Tab_Init{ |
| 9 |
|
| 10 |
public static function init(){ |
| 11 |
add_settings_section( |
| 12 |
'rabbitloader_section_usage', |
| 13 |
' ', |
| 14 |
'', |
| 15 |
'rabbitloader-usage' |
| 16 |
); |
| 17 |
$start_date = date("Y-m-d", strtotime('-30 days')); |
| 18 |
$end_date = date("Y-m-d"); |
| 19 |
$tbl = "RLUsageData.initV2(rabbitloader_local_vars.hostname, `".RabbitLoader_21_Core::getRLDomain()."`, `".RabbitLoader_21_Core::getWpOptVal('api_token')."`, `".$start_date."`, `".$end_date."`);"; |
| 20 |
|
| 21 |
wp_enqueue_script('rabbitloader-luxon', RABBITLOADER_PLUG_URL . 'admin/js/luxon.min.v2.1.1.js', [], RABBITLOADER_PLUG_VERSION); |
| 22 |
wp_enqueue_script('rabbitloader-echarts', RABBITLOADER_PLUG_URL . 'admin/js/echarts.min.js', [], RABBITLOADER_PLUG_VERSION); |
| 23 |
wp_enqueue_script('rabbitloader-usage-js', RabbitLoader_21_Core::getRLDomain().'account/common/js/ec_area_stacked.js', ['rabbitloader-echarts', 'rabbitloader-luxon'], RABBITLOADER_PLUG_VERSION); |
| 24 |
wp_add_inline_script('rabbitloader-usage-js', $tbl); |
| 25 |
} |
| 26 |
|
| 27 |
public static function echoMainContent(){ |
| 28 |
|
| 29 |
do_settings_sections( 'rabbitloader-usage' ); |
| 30 |
$overview = self::getOverviewData($apiError, $apiMessage); |
| 31 |
|
| 32 |
?> |
| 33 |
<div class="" style="max-width: 1160px; margin:40px auto;"> |
| 34 |
<div class="row mb-4"> |
| 35 |
<div class="col-sm-12 col-md-4"> |
| 36 |
<?php self::quota_used_box($overview, false);?> |
| 37 |
</div> |
| 38 |
<div class="col-sm-12 col-md-4"> |
| 39 |
<?php self::quota_remaining_box($overview);?> |
| 40 |
</div> |
| 41 |
<div class="col-sm-12 col-md-4"> |
| 42 |
<div class="bg-white rounded p-4 tpopup" title="<?php RabbitLoader_21_Util_WP::_e(sprintf('Your usage cycle will be reset on %s', date('jS M, Y', strtotime($overview['plan_end_date']))));?>"> |
| 43 |
<h4 class=""> |
| 44 |
<?php echo date('jS', strtotime($overview['plan_end_date']));?> <small style="font-size:14px;"><?php echo date('M', strtotime($overview['plan_end_date']));?></small> |
| 45 |
</h4> |
| 46 |
<span class="text-secondary mt-2"><?php RabbitLoader_21_Util_WP::_e('Next Reset');?></span> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
</div> |
| 50 |
|
| 51 |
<div class="row mb-4"> |
| 52 |
<div class="col"> |
| 53 |
<div class="bg-white rounded py-4"> |
| 54 |
<div class="row"> |
| 55 |
<div class="col-12 text-secondary"> |
| 56 |
<h5 class="px-4">CDN Usage</h5> |
| 57 |
<span class="d-block px-4">Bandwidth usage pattern in last 30 days.</span> |
| 58 |
</div> |
| 59 |
</div> |
| 60 |
<div class="p-4"> |
| 61 |
<div class="chart has-fixed-height" id="d3-area-stacked-nest-bandwidth" style="height:400px; width:100%;"></div> |
| 62 |
</div> |
| 63 |
</div> |
| 64 |
</div> |
| 65 |
</div> |
| 66 |
|
| 67 |
<div class="row mb-4"> |
| 68 |
<div class="col"> |
| 69 |
<div class="bg-white rounded py-4"> |
| 70 |
<div class="row"> |
| 71 |
<div class="col-12 text-secondary"> |
| 72 |
<h5 class="px-4">Assets Request</h5> |
| 73 |
<span class="d-block px-4">Assets request pattern in last 30 days. This includes the number of times asset files such as CSS, JavaScript, Images, Font files etc were requested from CDN server nodes.</span> |
| 74 |
</div> |
| 75 |
</div> |
| 76 |
<div class="p-4"> |
| 77 |
<div class="chart has-fixed-height" id="d3-area-stacked-nest-requests" style="height:400px; width:100%;"></div> |
| 78 |
</div> |
| 79 |
</div> |
| 80 |
</div> |
| 81 |
</div> |
| 82 |
</div> |
| 83 |
<?php |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
?> |