Skip to content

Instantly share code, notes, and snippets.

/limits Secret

Created December 18, 2017 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/34c0680ef2336e8fadaa027ae37a7e72 to your computer and use it in GitHub Desktop.
Save anonymous/34c0680ef2336e8fadaa027ae37a7e72 to your computer and use it in GitHub Desktop.
<apex:page showHeader="false" sidebar="false" controller="dailyLimitsController" standardStylesheets="false">
<head>
<title>Salesforce Limits Manager</title>
</head>
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"/>
<apex:includeScript value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"/>
<apex:stylesheet value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
<script src = "https://code.highcharts.com/highcharts.js"></script>
<script src = "https://code.highcharts.com/highcharts-more.js"></script>
<script src = "https://code.highcharts.com/modules/solid-gauge.js"></script>
<style>
.highcharts-yaxis-grid .highcharts-grid-line {
display: none;
}
</style>
<script type="text/javascript">
$(function () {
var chartype = {
type: 'solidgauge'
}
var chartitle = null
var chartpane = {
center: ['50%', '85%'],
size: '140%',
startAngle: -90,
endAngle: 90,
background: {
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
innerRadius: '60%',
outerRadius: '100%',
shape: 'arc'
}
}
var chartooltip = {
enabled: false
}
var chartyaxis = {
stops: [
[0.1, '#55BF3B'], // green
[0.5, '#DDDF0D'], // yellow
[0.9, '#DF5353'] // red
],
lineWidth: 0,
minorTickInterval: null,
//tickPixelInterval: 400,
tickWidth: 0,
title: {
y: -70
},
labels: {
y: 16
}
}
var chartplotoptions = {
solidgauge: {
dataLabels: {
y: 5,
borderWidth: 0,
useHTML: true
}
}
}
var gaugeOptions = {
chart:chartype,
title: chartitle,
pane: chartpane,
tooltip:chartooltip,
yAxis: chartyaxis,
plotOptions: chartplotoptions
};
$('#container-dailyAPI').highcharts(Highcharts.merge(gaugeOptions, {
title: {
text: 'Daily API Limit'
},
subtitle: {
text: 'Rolling 24 hours'
},
yAxis: {
min: 0,
max: {!dailyAPIMax},
endOnTick:false
},
credits: {
enabled: false
},
series: [{
name: 'Daily API',
data: [{!dailyAPIMax}-{!dailyAPIRem}],
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>'+
'<span style="font-size:12px;">{!dailyAPIMax} max</span></div>'+
'<span style="font-size:12px;">{!dailyAPIRem} remaining</span></div>'
},
}]
}));
$('#container-oData').highcharts(Highcharts.merge(gaugeOptions, {
title: {
text: 'Hourly oData Callout Limit'
},
subtitle: {
text: 'Salesforce \"Lightning Connect\" or External Object'
},
yAxis: {
min: 0,
max: {!oDataMax},
endOnTick:false
},
credits: {
enabled: false
},
series: [{
name: 'Hourly oData',
data: [{!oDataMax}-{!oDataRem}],
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>'+
'<span style="font-size:12px;">{!oDataMax} max</span></div>'+
'<span style="font-size:12px;">{!oDataRem} remaining</span></div>'
},
}]
}));
$('#container-async').highcharts(Highcharts.merge(gaugeOptions, {
title: {
text: 'Daily Asynchronous Apex'
},
subtitle: {
text: 'Rolling 24 hours'
},
yAxis: {
min: 0,
max: {!asyncMax},
endOnTick:false
},
credits: {
enabled: false
},
series: [{
name: 'Daily Async Apex',
data: [{!asyncMax}-{!asyncRem}],
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>'+
'<span style="font-size:12px;">{!asyncMax} max</span></div>'+
'<span style="font-size:12px;">{!asyncRem} remaining</span></div>'
},
}]
}));
$('#container-hourlyWF').highcharts(Highcharts.merge(gaugeOptions, {
title: {
text: 'Hourly Scheduled Workflow'
},
yAxis: {
min: 0,
max: {!wfMax},
endOnTick:false
},
credits: {
enabled: false
},
series: [{
name: 'Hourly Scheduled Workflow',
data: [{!wfMax}-{!wfRem}],
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>'+
'<span style="font-size:12px;">{!wfMax} max</span></div>'+
'<span style="font-size:12px;">{!wfRem} remaining</span></div>'
},
}]
}));
$('#container-dailyEmail').highcharts(Highcharts.merge(gaugeOptions, {
title: {
text: 'Daily Workflow Emails'
},
subtitle: {
text: 'Rolling 24 hours'
},
yAxis: {
min: 0,
max: {!wfeMax},
endOnTick:false
},
credits: {
enabled: false
},
series: [{
name: 'Daily WF Email',
data: [{!wfeMax}-{!wfeRem}],
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>'+
'<span style="font-size:12px;">{!wfeMax} max</span></div>'+
'<span style="font-size:12px;">{!wfeRem} remaining</span></div>'
},
}]
}));
$('#container-singleEmail').highcharts(Highcharts.merge(gaugeOptions, {
title: {
text: 'Daily Emails sent from Apex'
},
subtitle: {
text: 'Rolling 24 hours'
},
yAxis: {
min: 0,
max: {!singleMax},
endOnTick:false
},
credits: {
enabled: false
},
series: [{
name: 'Daily Single Email',
data: [{!singleMax}-{!singleRem}],
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>'+
'<span style="font-size:12px;">{!singleMax} max</span></div>'+
'<span style="font-size:12px;">{!singleRem} remaining</span></div>'
},
}]
}));
});
</script>
<apex:form >
<div class="container-fluid" style="padding-top: 10px;">
<div class="row" style="padding-left: 10px;">
<div class="col-md-3">
<img src="https://watchguard--c.na42.content.force.com/servlet/servlet.ImageServer?id=015F0000005rYrw&oid=00DA0000000KLks&lastMod=1465939806000"/>
</div>
<div class="col-md-6">
<center><h2>Salesforce Daily Limits</h2></center>
</div>
<div class="col-md-3" style="text-align: right;">
<apex:outputText value="Data Last Refreshed: {!nowTime}" />
</div>
</div>
</div>
<br/>
<div class="container-fluid">
<div class="row">
<apex:outputPanel id="dashboard">
<div class="col-md-4 col-md-6">
<div id="container-dailyAPI"></div>
<div id="container-singleEmail"></div>
</div>
<div class="col-md-4 col-md-6">
<div id="container-async"></div>
<div id="container-dailyEmail"></div>
</div>
<div class="col-lg-4 col-md-6">
<div id="container-oData"></div>
<div id="container-hourlyWF"></div>
</div>
</apex:outputPanel>
</div>
</div>
</apex:form>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment