forked from Countly/countly-code-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.html
173 lines (160 loc) · 7.32 KB
/
helpers.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="images/favicon.png">
<title>Countly Code Generator</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/style.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="jumbotron top">
<div class="container">
<div id="logo">
<span class="image"></span>
<span class="text">Helpers</span>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<p><a href="index.html" id="back" class="btn btn-default">← Back</a></p>
<h2 class="text-center">Countly Helpers</h2>
</div>
</div>
<div class='section'>
<span class='label'>Calculate server specs</span>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for='dp'>Datapoints (millions per month):</label>
<input type="url" class="form-control" id='dp' placeholder="10" value="10">
</div>
</div><!-- /.col-lg-6 -->
<div class="col-md-4">
<label>You should have:</label>
<ul>
<li id="dp-node"></li>
<li id="dp-mongo"></li>
<li id="dp-disk"></li>
</ul>
</div><!-- /.col-lg-6 -->
<div class="col-md-4">
<label>With evenly distributed:</label>
<ul>
<li id="dp-per-day"></li>
<li id="dp-per-hour"></li>
<li id="dp-per-min"></li>
</ul>
</div><!-- /.col-lg-6 -->
</div>
</div>
<div class='section'>
<span class='label'>Calculate database connections</span>
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label for='con-cores'>Server Cores:</label>
<input type="url" class="form-control" id='con-cores' placeholder="1" value="1">
</div>
</div><!-- /.col-lg-6 -->
<div class="col-md-2">
<div class="form-group">
<label for='con-api'>API poolsize:</label>
<input type="url" class="form-control" id='con-api' placeholder="100" value="100">
</div>
</div><!-- /.col-lg-6 -->
<div class="col-md-2">
<div class="form-group">
<label for='con-frontend'>Frontend poolsize:</label>
<input type="url" class="form-control" id='con-frontend' placeholder="10" value="10">
</div>
</div><!-- /.col-lg-6 -->
<div class="col-md-2">
<div class="form-group">
<label for='con-server'>Amount of Servers:</label>
<input type="url" class="form-control" id='con-server' placeholder="1" value="1">
</div>
</div><!-- /.col-lg-6 -->
<div class="col-md-4">
<label>Maximum MongoDB connections:</label>
<ul>
<li id="con-db"></li>
</ul>
</div><!-- /.col-lg-6 -->
</div>
</div>
<footer>
<p><a href='http://count.ly'>Count.ly</a></p>
</footer>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')</script>
<script src="https://global.localizecdn.com/localize.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
<script src="js/sdks.js"></script>
<script src="js/common.js"></script>
<script>
$( document ).ready(function() {
function validateNumber(val){
val = parseInt(val);
if(isNaN(val))
return 1;
return val;
}
function calculateDp(){
var dp = Math.max(Math.ceil(validateNumber($("#dp").val())/10), 1);
$("#dp-node").text(dp+" core(s) "+(2*dp)+"GB RAM for NodeJS");
$("#dp-mongo").text(dp+" core(s) "+(4*dp)+"GB RAM for MongoDB");
$("#dp-disk").text((10*dp) + "Gb of disk space per month");
$("#dp-per-day").text(Math.round((dp*10000000)/30) + " datapoints per day");
$("#dp-per-hour").text(Math.round((dp*10000000)/720) + " datapoints per hour");
$("#dp-per-min").text(Math.round((dp*10000000)/43200) + " datapoints per minute");
}
function calculateCon(){
var cores = Math.max(validateNumber($("#con-cores").val()), 1),
api = Math.max(validateNumber($("#con-api").val()), 1),
frontend = Math.max(validateNumber($("#con-frontend").val()), 1),
servers = Math.max(validateNumber($("#con-server").val()), 1);
$("#con-db").text(((3 * api + 1) * cores + (3 * frontend + 1) + 2 * frontend) * servers);
}
if (location.search) {
var parts = location.search.substring(1).split("&");
for (i = 0; i < parts.length; i++) {
var nv = parts[i].split("=");
if($("#"+nv[0]).hasClass("form-control")){
$("#"+nv[0]).val(nv[1]);
}
}
}
calculateCon();
calculateDp();
$("#dp").on("keyup paste", calculateDp);
$("#con-cores").on("keyup paste", calculateCon);
$("#con-api").on("keyup paste", calculateCon);
$("#con-frontend").on("keyup paste", calculateCon);
$("#con-server").on("keyup paste", calculateCon);
});
</script>
</body>
</html>