2 * Copyright 2010 Electronic Business Systems Ltd.
4 * This file is part of GSS.
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.
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.
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/>.
19 package gr.ebs.gss.admin.client.ui;
21 import gr.ebs.gss.server.domain.dto.SystemStatsDTO;
22 import gr.ebs.gss.server.domain.dto.UserClassDTO;
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;
36 public class VisualizationPanel extends Composite{
38 PieChart userCountChart;
39 PieChart fileCountChart;
40 PieChart fileSizeChart;
42 PieChart lastWeekChart;
43 PieChart lastMonthChart;
44 PieChart bandwithChart;
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");
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();
68 row1.add(userCountChart);
69 row1.add(fileCountChart);
70 row1.add(fileSizeChart);
72 row2.add(lastWeekChart);
73 row2.add(lastMonthChart);
74 row2.add(bandwithChart);
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());
91 PieChart.Options options = PieChart.Options.create();
92 options.setWidth(350);
93 options.setHeight(240);
95 options.setColors("green","red","blue");
96 options.setTitle("User Count:"+stats.getUserCount()+ " users");
97 userCountChart.draw(data, options);
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());
109 options = PieChart.Options.create();
110 options.setWidth(350);
111 options.setHeight(240);
113 options.setColors("red","green","blue");
114 options.setTitle("File Count:"+stats.getFileCount()+" files");
115 fileCountChart.draw(data, options);
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());
127 options = PieChart.Options.create();
128 options.setWidth(350);
129 options.setHeight(240);
131 options.setColors("blue","red","green");
132 options.setTitle("Total File Size:"+stats.getFileSizeAsString());
133 fileSizeChart.draw(data, options);
135 data = DataTable.create();
136 data.addColumn(ColumnType.STRING, "UserClass");
137 data.addColumn(ColumnType.NUMBER, "Active Last Month");
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()));
145 options = PieChart.Options.create();
146 options.setWidth(350);
147 options.setHeight(240);
149 options.setTitle("Last Month Users:"+stats.getLastMonthUsers());
150 lastMonthChart.draw(data, options);
152 data = DataTable.create();
153 data.addColumn(ColumnType.STRING, "UserClass");
154 data.addColumn(ColumnType.NUMBER, "Last Week Users");
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()));
161 options = PieChart.Options.create();
162 options.setWidth(350);
163 options.setHeight(240);
165 options.setTitle("Last Week Users:"+stats.getLastWeekUsers());
166 lastWeekChart.draw(data, options);
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());
178 options = PieChart.Options.create();
179 options.setWidth(350);
180 options.setHeight(240);
182 options.setTitle("Bandwith Used:"+stats.getBandwithUsedAsString());
183 bandwithChart.draw(data, options);