aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/web/client/Traccar.java
blob: 68f633cfc58a5ee0b57f57d8aa62faca16e32bed (plain)
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
package org.traccar.web.client;

import java.util.LinkedList;
import java.util.List;

import org.traccar.web.client.login.LoginController;
import org.traccar.web.client.view.ArchivePanel;
import org.traccar.web.client.view.DevicePanel;
import org.traccar.web.client.view.MapPanel;
import org.traccar.web.shared.model.Device;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;

/**
 * Entry point class
 */
public class Traccar implements EntryPoint, LoginController.LoginHandler {

    private DevicePanel devicePanel;
    private ArchivePanel archivePanel;
    private MapPanel mapPanel;

    /**
     * Entry point method
     */
    @Override
    public void onModuleLoad() {
        //new LoginController().login(this);
        onLogin(); // TODO: remove from production

        /*try {
            GlobalDatabaseService.getInstance().getPositions(
                    new Device(1), new Date(1325430000000L), new Date(1325437200000L),
                    new AsyncCallback<List<Position>>() {
                        @Override
                        public void onFailure(Throwable throwable) {
                            SC.warn("onFailure");
                        }
                        @Override
                        public void onSuccess(List<Position> positions) {
                            SC.warn("onSuccess");
                        }
                    });
        } catch (Exception error) {
            SC.warn(error.getMessage());
        }*/

    }

    private List<Device> testDevices() {
        List<Device> devices = new LinkedList<Device>();

        Device device = new Device(1);
        device.setName("test1");
        device.setUniqueId("11111");
        devices.add(device);

        device = new Device(2);
        device.setName("test2");
        device.setUniqueId("22222");
        devices.add(device);

        return devices;
    }

    @Override
    public void onLogin() {
        devicePanel = new DevicePanel();
        devicePanel.setWidth("20%");
        devicePanel.setShowResizeBar(true);

        devicePanel.updateDevices(testDevices()); // TODO: remove from production

        mapPanel = new MapPanel();
        mapPanel.setWidth("80%");

        HLayout hLayout = new HLayout();
        hLayout.setHeight("70%");
        hLayout.addMember(devicePanel);
        hLayout.addMember(mapPanel);
        hLayout.setShowResizeBar(true);
        hLayout.setResizeBarTarget("next");

        archivePanel = new ArchivePanel();
        archivePanel.setHeight("30%");

        VLayout mainLayout = new VLayout();
        mainLayout.setWidth100();
        mainLayout.setHeight100();
        mainLayout.addMember(hLayout);
        mainLayout.addMember(archivePanel);
        mainLayout.draw();
    }
}