1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Wialon Playground - Execute report</title>
6
    <script type="text/javascript" src="//code.jquery.com/jquery-latest.min.js"></script>
7
    <script type="text/javascript" src="//hst-api.wialon.com/wsdk/script/wialon.js"></script>
8
</head>
9
<body>
10
11
<table>
12
    <tr><td>Select resource and template:</td><td><select id="res"></select><select id="templ"></select></td></tr>
13
    <tr><td>Select unit:</td><td><select id="units"></select></td></tr>
14
    <tr>
15
        <td>Select time interval:</td>
16
        <td><select id="interval">
17
            <option value="86400" title="60 sec * 60 minutes * 24 hours = 86400 sec = 1 day">Last day</option> 
18
            <option value="604800" title="86400 sec * 7 days = 604800 sec = 1 week">Last week</option>
19
            <option value="2592000" title="86400 sec * 30 days = 2592000 sec = 1 month">Last month</option>    
20
        </select></td>
21
    </tr>
22
    <tr><td colspan="2" style="text-align:center;"><input type="button" value="Execute report" id="exec_btn"/></td></tr>
23
</table>
24
<div id="log"></div>
25
26
</body>
27
</html>
HTML
3
 
1
td, th{ border: 1px solid #c6c6c6; }
2
.wrap{ max-height:150px; overflow-y: auto; }
3
.odd, th{ background:#EEE; border: 1px solid #c6c6c6; }
CSS
126
 
1
// Print message to log
2
function msg(text) { $("#log").prepend(text + "<br/>"); }
3
4
function init() {// Execute after login succeed
5
    // specify what kind of data should be returned
6
    var res_flags = wialon.item.Item.dataFlag.base | wialon.item.Resource.dataFlag.reports;
7
    var unit_flags = wialon.item.Item.dataFlag.base;
8
    
9
    var sess = wialon.core.Session.getInstance(); // get instance of current Session
10
    sess.loadLibrary("resourceReports"); // load Reports Library
11
    sess.updateDataFlags( // load items to current session
12
        [{type: "type", data: "avl_resource", flags:res_flags , mode: 0}, // 'avl_resource's specification
13
         {type: "type", data: "avl_unit", flags: unit_flags, mode: 0}], // 'avl_unit's specification
14
        function (code) { // updateDataFlags callback
15
            if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } // exit if error code
16
17
            var res = sess.getItems("avl_resource"); // get loaded 'avl_resource's items
JS
Result
Source code of example Close ✕
1
 
1
/*source*/