| | |
| | |
|
| | | /**
|
| | | * A client-side filterable rich project list which uses Freemarker, Wicket,
|
| | | * and AngularJS. |
| | | * |
| | | * and AngularJS.
|
| | | *
|
| | | * @author James Moger
|
| | | *
|
| | | */
|
| | |
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | private final List<ProjectModel> projects;
|
| | | |
| | |
|
| | | private String title;
|
| | | |
| | |
|
| | | private String iconClass;
|
| | | |
| | |
|
| | | public FilterableProjectList(String id, List<ProjectModel> projects) {
|
| | | super(id);
|
| | | this.projects = projects;
|
| | | }
|
| | | |
| | |
|
| | | public void setTitle(String title, String iconClass) {
|
| | | this.title = title;
|
| | | this.iconClass = iconClass;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected void onInitialize() {
|
| | | super.onInitialize();
|
| | |
| | | String id = getId();
|
| | | String ngCtrl = id + "Ctrl";
|
| | | String ngList = id + "List";
|
| | | |
| | |
|
| | | Map<String, Object> values = new HashMap<String, Object>();
|
| | | values.put("ngCtrl", ngCtrl);
|
| | | values.put("ngList", ngList);
|
| | | |
| | |
|
| | | // use Freemarker to setup an AngularJS/Wicket html snippet
|
| | | FreemarkerPanel panel = new FreemarkerPanel("listComponent", "FilterableProjectList.fm", values);
|
| | | panel.setParseGeneratedMarkup(true);
|
| | | panel.setRenderBodyOnly(true);
|
| | | add(panel);
|
| | | |
| | | // add the Wicket controls that are referenced in the snippet |
| | |
|
| | | // add the Wicket controls that are referenced in the snippet
|
| | | String listTitle = StringUtils.isEmpty(title) ? getString("gb.projects") : title;
|
| | | panel.add(new Label(ngList + "Title", MessageFormat.format("{0} ({1})", listTitle, projects.size())));
|
| | | if (StringUtils.isEmpty(iconClass)) {
|
| | |
| | | WicketUtils.setCssClass(icon, iconClass);
|
| | | panel.add(icon);
|
| | | }
|
| | | |
| | |
|
| | | String format = GitBlit.getString(Keys.web.datestampShortFormat, "MM/dd/yy");
|
| | | final DateFormat df = new SimpleDateFormat(format);
|
| | | df.setTimeZone(getTimeZone());
|
| | |
| | | item.c = proj.repositories.size();
|
| | | list.add(item);
|
| | | }
|
| | | |
| | |
|
| | | // inject an AngularJS controller with static data
|
| | | NgController ctrl = new NgController(ngCtrl);
|
| | | ctrl.addVariable(ngList, list);
|
| | |
| | | protected class ProjectListItem implements Serializable {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | |
|
| | | String p; // path
|
| | | String n; // name
|
| | | String t; // time ago
|