package com.perforce.spark.navigation; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; import spark.Request; import com.perforce.spark.ConnectionSession; public class NavBar { private static SortedMap<String, NavBarInterface> map = new TreeMap<>(); // private static List<NavBarInterface> items = new ArrayList<>(); static { add(new NavBarMenu("Browse", "browse")); add(new NavBarMenu("Search", "search")); add(new NavBarMenu("Deploy", "deploy")); add(new NavBarConfig("Configuration", "config")); } public static void add(NavBarInterface item) { String id = item.getPage(); map.put(id, item); } public static Map<String, Object> attributes(String selected, Request req) { Map<String, Object> attributes = new HashMap<>(); attributes.put("navBar", navBar(selected)); attributes.put("title", title(selected)); attributes.put("login", login(req)); attributes.put("config", map.get("config").isActive()); attributes.put("error_show", "none"); attributes.put("error_message", ""); return attributes; } private static String login(Request request) { if (ConnectionSession.isValid(request)) { return "nav-logout.html"; } else { return "nav-login.html"; } } private static ArrayList<NavBarMenu> navBar(String selected) { ArrayList<NavBarMenu> items = new ArrayList<>(); for (String id : map.keySet()) { NavBarInterface item = map.get(id); if (id.equals(selected)) { item.setActive(true); } else { item.setActive(false); } if (item instanceof NavBarMenu) { items.add((NavBarMenu) item); } } return items; } private static String title(String id) { String title = ""; if (map.containsKey(id)) { title = map.get(id).getTitle(); } return title; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 15012 | Paul Allen | Proxy configuration. | ||
#8 | 14883 | Paul Allen | Submit via preview and redirect to asset | ||
#7 | 14864 | Paul Allen | Depot Configuration and Site type | ||
#6 | 14863 | Paul Allen | Change File/Dir browse to support extended options | ||
#5 | 14725 | Paul Allen | Generic deploy/upload | ||
#4 | 14723 | Paul Allen | Tidy up deploy/upload | ||
#3 | 14228 | Paul Allen |
Moved View over to the new model. Retactor connection to package. |
||
#2 | 14226 | Paul Allen | Tidy up Browse elements over to micro MVC model | ||
#1 | 14181 | Paul Allen | Lots of updates and refactoring. | ||
//guest/paul_allen/p4am/src/main/java/com/perforce/spark/NavBar.java | |||||
#5 | 13869 | Paul Allen |
- Fix logout when testing cookie. - Refactor ftl->html - Add local bootstrap |
||
#4 | 13798 | Paul Allen | Basic file upload and login/logout cookie tidyup | ||
#3 | 13728 | Paul Allen | Error support | ||
#2 | 13722 | Paul Allen | Login UX | ||
#1 | 13720 | Paul Allen | Perforce Asset Manager (PAM or P4AM) -- ideas |