Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.

Commit bd27a35

Browse files
committed
Fix #7
1 parent e29dc04 commit bd27a35

File tree

4 files changed

+48
-14
lines changed

4 files changed

+48
-14
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
latest
2-
0.4.2
2+
0.4.3
33
0.4
44
0

php/core/Stats.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313

1414
class Stats {
1515

16-
// max plain data elements for plots
17-
const MAX_PLAIN_ELEMENTS = 2000;
16+
// max and default plain data elements for plots
17+
const MAX_PLAIN_ELEMENTS = 200000;
18+
const DEFAULT_PLAIN_ELEMENTS = 2000;
1819

1920
private Template $temp;
2021
private Login $login;
@@ -64,9 +65,22 @@ public function __construct( Template $temp, Login $login ) {
6465
}
6566

6667
private function displayContent(array $data) : void {
68+
if(!empty($_POST['plainlimit']) ){
69+
$plainLimit = intval($_POST['plainlimit']);
70+
if( $plainLimit < self::DEFAULT_PLAIN_ELEMENTS ){
71+
$plainLimit = self::DEFAULT_PLAIN_ELEMENTS;
72+
}
73+
else if( $plainLimit > self::MAX_PLAIN_ELEMENTS ){
74+
$plainLimit = self::MAX_PLAIN_ELEMENTS;
75+
}
76+
}
77+
else {
78+
$plainLimit = self::DEFAULT_PLAIN_ELEMENTS;
79+
}
80+
6781
$this->temp->setContent('COMBIDATA', json_encode($data['combi']));
68-
$this->temp->setContent('PLAINDATA', json_encode(array_slice($data['plain'], 0, self::MAX_PLAIN_ELEMENTS)));
69-
if(count($data['plain']) > self::MAX_PLAIN_ELEMENTS){
82+
$this->temp->setContent('PLAINDATA', json_encode(array_slice($data['plain'], 0, $plainLimit)));
83+
if(count($data['plain']) > $plainLimit){
7084
$this->temp->setContent('LESSDATADISABLE', '');
7185
}
7286
$this->temp->setContent('TABLEA', $this->arrayToTable($data['table']));
@@ -245,6 +259,8 @@ function ($s) {
245259
)
246260
))
247261
));
262+
263+
$this->temp->setContent('DEFAULT_PLAIN_ELEMENTS', self::DEFAULT_PLAIN_ELEMENTS );
248264
}
249265

250266
}

php/core/templates/stats.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
"%%PLAINDATA%%" : "[]",
2222
"%%SINGLEDAYDATA%%" : "false",
2323
"%%CMD%%" : "",
24-
"%%GRAPHES%%" : ""
24+
"%%GRAPHES%%" : "",
25+
"%%DEFAULT_PLAIN_ELEMENTS%%" : ""
2526
}

php/core/templates/stats_en.html

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,24 @@ <h3>Select data</h3>
6363
</div>
6464
<div class="form-group row %%SHARESDIABLE%%">
6565
<label for="shares" class="col-sm-2 col-form-label">Include shares</label>
66-
<div class="col-sm-10">
66+
<div class="col-sm-8">
6767
<select name="shares[]" id="shares" class="custom-select" size=4 multiple>
6868
<!--MULTIPLE-Shares-BEGIN-->
6969
<option value="%%VALUE%%">%%NAME%%</option>
7070
<!--MULTIPLE-Shares-END-->
7171
</select>
7272
</div>
73+
<div class="col-sm-2">
74+
<button type="button" id="deselectall" class="btn btn-light">Deselect</button>
75+
</div>
7376
</div>
7477
<div class="form-group row">
7578
<div class="col-sm-2">&nbsp;</div>
7679
<div class="col-sm-10">
7780
<input type="submit" value="Show" class="btn btn-secondary">
7881
</div>
7982
</div>
83+
<input type="hidden" name="plainlimit" id="plainlimit" value="%%DEFAULT_PLAIN_ELEMENTS%%">
8084
</form>
8185
<input type="hidden" id="datepickerFrom">
8286
<input type="hidden" id="datepickerTo">
@@ -93,12 +97,10 @@ <h3>Select data</h3>
9397
$("form").on("submit", () => {
9498
var values = {};
9599
$("input, select").each((k,v) => {
96-
if($(v).attr('id') !== 'shares' ){
97-
values[$(v).attr("name")] = {
98-
value : $(v).val(),
99-
tag : $(v).prop("tagName")
100-
};
101-
}
100+
values[$(v).attr("name")] = {
101+
value : $(v).val(),
102+
tag : $(v).prop("tagName")
103+
};
102104
});
103105
localStorage.setItem( 'lastServerStats', JSON.stringify(values));
104106
});
@@ -137,6 +139,9 @@ <h3>Select data</h3>
137139
minLength: 1,
138140
delay: 50
139141
});
142+
$( "button#deselectall").click( () => {
143+
$("select#shares option").prop("selected", false);
144+
});
140145
</script>
141146

142147
<h3>Tables</h3>
@@ -163,7 +168,8 @@ <h3>Graph</h3>
163168
<button id="displaygraph" class="btn btn-secondary">Display Graph</button>
164169
</div>
165170
<div class="alert alert-danger %%LESSDATADISABLE%% m-2" role="alert">
166-
The selected timespan contains a huge amount of data, some graphs may not display all data!
171+
<p>The selected timespan contains a huge amount of data, some graphs may not display all data!</p>
172+
<button type="button" id="increaselimit" class="btn btn-warning">Increase the limit</button>
167173
</div>
168174

169175
</div> <!-- opened in main.html -->
@@ -209,4 +215,15 @@ <h3>Graph</h3>
209215
});
210216
$("select[name=time]").trigger('change');
211217
}
218+
219+
if(!sessionStorage.hasOwnProperty( 'lastPlainDataLimit' )){
220+
sessionStorage.setItem('lastPlainDataLimit', "%%DEFAULT_PLAIN_ELEMENTS%%");
221+
$("input#plainlimit").val( "%%DEFAULT_PLAIN_ELEMENTS%%" );
222+
}
223+
$("button#increaselimit").click( () => {
224+
$("button#increaselimit").prop("disabled", true);
225+
sessionStorage.setItem('lastPlainDataLimit', parseInt(sessionStorage.getItem('lastPlainDataLimit')) * 2 )
226+
$("input#plainlimit").val( sessionStorage.getItem('lastPlainDataLimit') )
227+
$("form").submit()
228+
});
212229
</script>

0 commit comments

Comments
 (0)