Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / admin / client / ui / VisualizationPanel.java @ 0a37ac21

History | View | Annotate | Download (6.7 kB)

1
/*
2
 * Copyright 2010 Electronic Business Systems Ltd.
3
 *
4
 * This file is part of GSS.
5
 *
6
 * GSS is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * GSS is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
package gr.ebs.gss.admin.client.ui;
20

    
21
import gr.ebs.gss.server.domain.dto.SystemStatsDTO;
22
import gr.ebs.gss.server.domain.dto.UserClassDTO;
23

    
24
import com.google.gwt.user.client.ui.Composite;
25
import com.google.gwt.user.client.ui.HorizontalPanel;
26
import com.google.gwt.user.client.ui.VerticalPanel;
27
import com.google.gwt.visualization.client.DataTable;
28
import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
29
import com.google.gwt.visualization.client.visualizations.PieChart;
30

    
31

    
32
/**
33
 * @author kman
34
 *
35
 */
36
public class VisualizationPanel extends Composite{
37

    
38
        PieChart userCountChart;
39
        PieChart fileCountChart;
40
        PieChart fileSizeChart;
41

    
42
        PieChart lastWeekChart;
43
        PieChart lastMonthChart;
44
        PieChart bandwithChart;
45

    
46
        /**
47
         *
48
         */
49
        public VisualizationPanel() {
50
                final VerticalPanel vp = new VerticalPanel();
51
            vp.getElement().getStyle().setPropertyPx("margin", 15);
52
            userCountChart = new PieChart();
53
            userCountChart.addStyleName("stats");
54
            fileCountChart = new PieChart();
55
            fileCountChart.addStyleName("stats");
56
            fileSizeChart = new PieChart();
57
            fileSizeChart.addStyleName("stats");
58

    
59
            lastWeekChart = new PieChart();
60
            lastWeekChart.addStyleName("stats");
61
            lastMonthChart = new PieChart();
62
            lastMonthChart.addStyleName("stats");
63
            bandwithChart = new PieChart();
64
            bandwithChart.addStyleName("stats");
65
            HorizontalPanel row1 = new HorizontalPanel();
66
            HorizontalPanel row2 = new HorizontalPanel();
67

    
68
            row1.add(userCountChart);
69
            row1.add(fileCountChart);
70
            row1.add(fileSizeChart);
71

    
72
            row2.add(lastWeekChart);
73
            row2.add(lastMonthChart);
74
            row2.add(bandwithChart);
75
            vp.add(row1);
76
            vp.add(row2);
77
            initWidget(vp);
78
          }
79

    
80
        public void updateData(SystemStatsDTO stats){
81
                DataTable data = DataTable.create();
82
            data.addColumn(ColumnType.STRING, "UserClass");
83
            data.addColumn(ColumnType.NUMBER, "UserCount");
84
            data.addRows(stats.getUserClasses().size());
85
            for(int i=0;i<stats.getUserClasses().size();i++){
86
                    UserClassDTO dto = stats.getUserClasses().get(i);
87
                    data.setValue(i, 0, dto.getName()+":"+dto.getStatistics().getUserCount()+ " users");
88
                    data.setValue(i, 1, dto.getStatistics().getUserCount());
89
            }
90

    
91
            PieChart.Options options = PieChart.Options.create();
92
            options.setWidth(350);
93
            options.setHeight(240);
94
            options.set3D(true);
95
            options.setColors("green","red","blue");
96
            options.setTitle("User Count:"+stats.getUserCount()+ " users");
97
            userCountChart.draw(data, options);
98

    
99
            data = DataTable.create();
100
            data.addColumn(ColumnType.STRING, "UserClass");
101
            data.addColumn(ColumnType.NUMBER, "FileCount");
102
            data.addRows(stats.getUserClasses().size());
103
            for(int i=0;i<stats.getUserClasses().size();i++){
104
                    UserClassDTO dto = stats.getUserClasses().get(i);
105
                    data.setValue(i, 0, dto.getName()+":"+dto.getStatistics().getFileCount()+" files");
106
                    data.setValue(i, 1, dto.getStatistics().getFileCount());
107
            }
108

    
109
            options = PieChart.Options.create();
110
            options.setWidth(350);
111
            options.setHeight(240);
112
            options.set3D(true);
113
            options.setColors("red","green","blue");
114
            options.setTitle("File Count:"+stats.getFileCount()+" files");
115
            fileCountChart.draw(data, options);
116

    
117
            data = DataTable.create();
118
            data.addColumn(ColumnType.STRING, "UserClass");
119
            data.addColumn(ColumnType.NUMBER, "FileSize");
120
            data.addRows(stats.getUserClasses().size());
121
            for(int i=0;i<stats.getUserClasses().size();i++){
122
                    UserClassDTO dto = stats.getUserClasses().get(i);
123
                    data.setValue(i, 0, dto.getName()+":"+dto.getStatistics().getFileSizeAsString());
124
                    data.setValue(i, 1, dto.getStatistics().getFileSize());
125
            }
126

    
127
            options = PieChart.Options.create();
128
            options.setWidth(350);
129
            options.setHeight(240);
130
            options.set3D(true);
131
            options.setColors("blue","red","green");
132
            options.setTitle("Total File Size:"+stats.getFileSizeAsString());
133
            fileSizeChart.draw(data, options);
134

    
135
            data = DataTable.create();
136
            data.addColumn(ColumnType.STRING, "UserClass");
137
            data.addColumn(ColumnType.NUMBER, "Active Last Month");
138
            data.addRows(2);
139
            data.setValue(0, 0, "Active"+":"+stats.getLastMonthUsers()+" users");
140
                data.setValue(0, 1, stats.getLastMonthUsers());
141
                data.setValue(1, 0, "Inactive"+":"+(stats.getUserCount()-stats.getLastMonthUsers())+" users");
142
                data.setValue(1, 1, (stats.getUserCount()-stats.getLastMonthUsers()));
143

    
144

    
145
            options = PieChart.Options.create();
146
            options.setWidth(350);
147
            options.setHeight(240);
148
            options.set3D(true);
149
            options.setTitle("Last Month Users:"+stats.getLastMonthUsers());
150
            lastMonthChart.draw(data, options);
151

    
152
            data = DataTable.create();
153
            data.addColumn(ColumnType.STRING, "UserClass");
154
            data.addColumn(ColumnType.NUMBER, "Last Week Users");
155
            data.addRows(2);
156
            data.setValue(0, 0, "Active"+":"+stats.getLastWeekUsers() +" users");
157
                data.setValue(0, 1, stats.getLastWeekUsers());
158
                data.setValue(1, 0, "Inactive"+":"+(stats.getUserCount()-stats.getLastWeekUsers())+" users");
159
                data.setValue(1, 1, (stats.getUserCount()-stats.getLastWeekUsers()));
160

    
161
            options = PieChart.Options.create();
162
            options.setWidth(350);
163
            options.setHeight(240);
164
            options.set3D(true);
165
            options.setTitle("Last Week Users:"+stats.getLastWeekUsers());
166
            lastWeekChart.draw(data, options);
167

    
168
            data = DataTable.create();
169
            data.addColumn(ColumnType.STRING, "UserClass");
170
            data.addColumn(ColumnType.NUMBER, "Bandwith Used");
171
            data.addRows(stats.getUserClasses().size());
172
            for(int i=0;i<stats.getUserClasses().size();i++){
173
                    UserClassDTO dto = stats.getUserClasses().get(i);
174
                    data.setValue(i, 0, dto.getName()+":"+dto.getStatistics().getBandwithUsedAsString());
175
                    data.setValue(i, 1, dto.getStatistics().getBandwithUsed());
176
            }
177

    
178
            options = PieChart.Options.create();
179
            options.setWidth(350);
180
            options.setHeight(240);
181
            options.set3D(true);
182
            options.setTitle("Bandwith Used:"+stats.getBandwithUsedAsString());
183
            bandwithChart.draw(data, options);
184
        }
185

    
186
}