Add ProjectDashboardsScreen
This screen displays a table with a list of dasboards for the current project. Each dashboard entry is a link to the actual dashboard. The dashboards are grouped together in sections named after their refs. Change-Id: I3c88dc7771d381906f2f5e8575f18aa86859b465
This commit is contained in:
@@ -54,6 +54,7 @@ import com.google.gerrit.client.admin.GroupListScreen;
|
||||
import com.google.gerrit.client.admin.PluginListScreen;
|
||||
import com.google.gerrit.client.admin.ProjectAccessScreen;
|
||||
import com.google.gerrit.client.admin.ProjectBranchesScreen;
|
||||
import com.google.gerrit.client.admin.ProjectDashboardsScreen;
|
||||
import com.google.gerrit.client.admin.ProjectInfoScreen;
|
||||
import com.google.gerrit.client.admin.ProjectListScreen;
|
||||
import com.google.gerrit.client.admin.ProjectScreen;
|
||||
@@ -729,6 +730,10 @@ public class Dispatcher {
|
||||
if (ProjectScreen.ACCESS.equals(panel)) {
|
||||
return new ProjectAccessScreen(k);
|
||||
}
|
||||
|
||||
if (ProjectScreen.DASHBOARDS.equals(panel)) {
|
||||
return new ProjectDashboardsScreen(k);
|
||||
}
|
||||
}
|
||||
return new NotFoundScreen();
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ public interface AdminConstants extends Constants {
|
||||
String projectAdminTabBranches();
|
||||
String projectAdminTabAccess();
|
||||
String projectListQueryLink();
|
||||
String projectAdminTabDashboards();
|
||||
|
||||
String plugins();
|
||||
String pluginEnabled();
|
||||
|
||||
@@ -85,6 +85,7 @@ createProjectTitle = Create Project
|
||||
projectAdminTabGeneral = General
|
||||
projectAdminTabBranches = Branches
|
||||
projectAdminTabAccess = Access
|
||||
projectAdminTabDashboards = Dashboards
|
||||
projectListQueryLink = Search for changes on this project
|
||||
|
||||
plugins = Plugins
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// Copyright (C) 2012 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.admin;
|
||||
|
||||
import com.google.gerrit.client.dashboards.DashboardMap;
|
||||
import com.google.gerrit.client.dashboards.DashboardsTable;
|
||||
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
|
||||
public class ProjectDashboardsScreen extends ProjectScreen {
|
||||
private DashboardsTable dashes;
|
||||
|
||||
public ProjectDashboardsScreen(final Project.NameKey toShow) {
|
||||
super(toShow);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoad() {
|
||||
super.onLoad();
|
||||
DashboardMap.allOnProject(getProjectKey(),
|
||||
new ScreenLoadCallback<DashboardMap>(this) {
|
||||
@Override
|
||||
protected void preDisplay(final DashboardMap result) {
|
||||
dashes.display(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitUI() {
|
||||
super.onInitUI();
|
||||
dashes = new DashboardsTable();
|
||||
FlowPanel fp = new FlowPanel();
|
||||
fp.add(dashes);
|
||||
add(fp);
|
||||
dashes.setSavePointerId("dashboards/project/" + getProjectKey().get());
|
||||
display();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerKeys() {
|
||||
super.registerKeys();
|
||||
dashes.setRegisterKeys(true);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ public abstract class ProjectScreen extends MenuScreen {
|
||||
public static final String INFO = "info";
|
||||
public static final String BRANCH = "branches";
|
||||
public static final String ACCESS = "access";
|
||||
public static final String DASHBOARDS = "dashboards";
|
||||
|
||||
private final Project.NameKey name;
|
||||
|
||||
@@ -32,6 +33,7 @@ public abstract class ProjectScreen extends MenuScreen {
|
||||
link(Util.C.projectAdminTabGeneral(), toProjectAdmin(name, INFO));
|
||||
link(Util.C.projectAdminTabBranches(), toProjectAdmin(name, BRANCH));
|
||||
link(Util.C.projectAdminTabAccess(), toProjectAdmin(name, ACCESS));
|
||||
link(Util.C.projectAdminTabDashboards(), toProjectAdmin(name, DASHBOARDS));
|
||||
}
|
||||
|
||||
protected Project.NameKey getProjectKey() {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2012 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.dashboards;
|
||||
|
||||
import com.google.gwt.i18n.client.Constants;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface DashboardConstants extends Constants {
|
||||
String dashboardName();
|
||||
String dashboardDescription();
|
||||
String dashboardItem();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
dashboardName = Dashboard Name
|
||||
dashboardDescription = Dashboard Description
|
||||
dashboardItem = dashboard
|
||||
@@ -0,0 +1,112 @@
|
||||
// Copyright (C) 2012 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.dashboards;
|
||||
|
||||
import com.google.gerrit.client.ui.NavigationTable;
|
||||
import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gwt.user.client.History;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class DashboardsTable extends NavigationTable<DashboardInfo> {
|
||||
public DashboardsTable() {
|
||||
super(Util.C.dashboardItem());
|
||||
initColumnHeaders();
|
||||
}
|
||||
|
||||
protected void initColumnHeaders() {
|
||||
table.setText(0, 1, Util.C.dashboardName());
|
||||
table.setText(0, 2, Util.C.dashboardDescription());
|
||||
|
||||
final FlexCellFormatter fmt = table.getFlexCellFormatter();
|
||||
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().dataHeader());
|
||||
fmt.addStyleName(0, 2, Gerrit.RESOURCES.css().dataHeader());
|
||||
}
|
||||
|
||||
public void display(DashboardMap dashes) {
|
||||
while (1 < table.getRowCount()) {
|
||||
table.removeRow(table.getRowCount() - 1);
|
||||
}
|
||||
|
||||
List<DashboardInfo> list = dashes.values().asList();
|
||||
Collections.sort(list, new Comparator<DashboardInfo>() {
|
||||
@Override
|
||||
public int compare(DashboardInfo a, DashboardInfo b) {
|
||||
return a.id().compareTo(b.id());
|
||||
}
|
||||
});
|
||||
|
||||
String section = null;
|
||||
for(DashboardInfo d : list) {
|
||||
if (!d.refName().equals(section)) {
|
||||
section = d.refName();
|
||||
insertTitleRow(table.getRowCount(), section);
|
||||
}
|
||||
insert(table.getRowCount(), d);
|
||||
}
|
||||
|
||||
finishDisplay();
|
||||
}
|
||||
|
||||
protected void insertTitleRow(final int row, String section) {
|
||||
table.insertRow(row);
|
||||
|
||||
table.setText(row, 0, section);
|
||||
|
||||
final FlexCellFormatter fmt = table.getFlexCellFormatter();
|
||||
fmt.setColSpan(row, 0, 3);
|
||||
fmt.addStyleName(row, 0, Gerrit.RESOURCES.css().sectionHeader());
|
||||
}
|
||||
|
||||
protected void insert(final int row, final DashboardInfo k) {
|
||||
table.insertRow(row);
|
||||
|
||||
applyDataRowStyle(row);
|
||||
|
||||
final FlexCellFormatter fmt = table.getFlexCellFormatter();
|
||||
fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().dataCell());
|
||||
fmt.addStyleName(row, 2, Gerrit.RESOURCES.css().dataCell());
|
||||
|
||||
populate(row, k);
|
||||
}
|
||||
|
||||
protected void populate(final int row, final DashboardInfo k) {
|
||||
table.setWidget(row, 1, new Anchor(k.name(), "#" + link(k)));
|
||||
table.setText(row, 2, k.description());
|
||||
|
||||
setRowItem(row, k);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getRowItemKey(final DashboardInfo item) {
|
||||
return item.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onOpenRow(final int row) {
|
||||
if (row > 0) {
|
||||
movePointerTo(row);
|
||||
}
|
||||
History.newItem(link(getRowItem(row)));
|
||||
}
|
||||
|
||||
private String link(final DashboardInfo item) {
|
||||
return "/dashboard/?" + item.parameters();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2012 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.dashboards;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
||||
public class Util {
|
||||
public static final DashboardConstants C = GWT.create(DashboardConstants.class);
|
||||
}
|
||||
Reference in New Issue
Block a user