package com.perforce.spark; import java.util.ArrayList; import java.util.List; import java.util.Map; import spark.ModelAndView; import spark.Spark; import spark.template.freemarker.FreeMarkerEngine; import com.perforce.p4java.core.file.FileSpecBuilder; import com.perforce.p4java.core.file.IFileSpec; import com.perforce.p4java.option.server.GetDirectoriesOptions; import com.perforce.p4java.server.IOptionsServer; public class Main { public static void main(String[] args) throws Exception { ConnectionConfig config; config = new ConnectionConfig("public.perforce.com:1666", false); IOptionsServer p4 = ConnectionFactory.getConnection(config); p4.connect(); p4.setUserName("guest"); NavBar navBar = new NavBar(); navBar.add(new NavBarItem("Browse", "browse")); navBar.add(new NavBarItem("Search", "search")); navBar.add(new NavBarItem("Deploy", "deploy")); Spark.get("/", (req, response) -> { response.redirect("/browse/"); return ""; }); Spark.get("/browse", (request, response) -> { response.redirect("/browse/"); return ""; }); Spark.get( "/browse/*", (request, response) -> { String path = request.pathInfo(); List<String> list = new ArrayList<>(); try { String depotPath = "//guest" + path.substring(7, path.length()) + "/*"; List<IFileSpec> fileSpecs = FileSpecBuilder .makeFileSpecList(depotPath); GetDirectoriesOptions opts = new GetDirectoriesOptions(); List<IFileSpec> dirs = p4.getDirectories(fileSpecs, opts); for (IFileSpec dir : dirs) { list.add(dir.toString()); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } Map<String, Object> attributes = navBar.getAttributes( "browse", request); attributes.put("path", list.get(0)); return new ModelAndView(attributes, "nav.ftl"); }, new FreeMarkerEngine()); Spark.get( "/search", (request, response) -> { Map<String, Object> attributes = navBar.getAttributes( "search", request); return new ModelAndView(attributes, "nav.ftl"); }, new FreeMarkerEngine()); Spark.get( "/deploy", (request, response) -> { Map<String, Object> attributes = navBar.getAttributes( "deploy", request); return new ModelAndView(attributes, "nav.ftl"); }, new FreeMarkerEngine()); Spark.post("/login", (request, response) -> { String user = request.queryParams(ConnectionSession.USER); String pass = request.queryParams(ConnectionSession.PASS); if (user != null) { // TODO login to Perforce request.session().attribute(ConnectionSession.TICKET, user); } response.redirect("/deploy"); return null; }); Spark.get("/logout", (request, response) -> { request.session().removeAttribute(ConnectionSession.TICKET); response.redirect("/"); return null; }); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#30 | 15807 | Paul Allen | Browse (list/grid view) | ||
#29 | 15782 | Paul Allen |
Update to UX - deploy has 3 process steps (including a submit report) |
||
#28 | 15252 | Paul Allen | Added create/edit support for repo configs. | ||
#27 | 15118 | Paul Allen | Added P4Search | ||
#26 | 15012 | Paul Allen | Proxy configuration. | ||
#25 | 14884 | Paul Allen | Moved create depot type into path and not a param. | ||
#24 | 14883 | Paul Allen | Submit via preview and redirect to asset | ||
#23 | 14866 | Paul Allen |
Create different Depot types. - Display site types |
||
#22 | 14864 | Paul Allen | Depot Configuration and Site type | ||
#21 | 14863 | Paul Allen | Change File/Dir browse to support extended options | ||
#20 | 14741 | Paul Allen | Fix upload for multiple files. | ||
#19 | 14726 | Paul Allen | Limit deploy control path, and remove AssetHelper | ||
#18 | 14725 | Paul Allen | Generic deploy/upload | ||
#17 | 14723 | Paul Allen | Tidy up deploy/upload | ||
#16 | 14228 | Paul Allen |
Moved View over to the new model. Retactor connection to package. |
||
#15 | 14226 | Paul Allen | Tidy up Browse elements over to micro MVC model | ||
#14 | 14181 | Paul Allen | Lots of updates and refactoring. | ||
#13 | 14048 | Paul Allen | Convert to Gradle with FatJar and updated splash screen. | ||
#12 | 14017 | Paul Allen | Proxy caching to Perforce and SLF4J logging. | ||
#11 | 14013 | Paul Allen | Basic proxy | ||
#10 | 13969 | Paul Allen | Depot list/create for Assets | ||
#9 | 13869 | Paul Allen |
- Fix logout when testing cookie. - Refactor ftl->html - Add local bootstrap |
||
#8 | 13863 | Paul Allen | Minor fix to session vs cookie for login check. | ||
#7 | 13862 | Paul Allen | Submit uploads to Perforce | ||
#6 | 13798 | Paul Allen | Basic file upload and login/logout cookie tidyup | ||
#5 | 13746 | Paul Allen | Basic File/Dir browsing and Cookie management. | ||
#4 | 13728 | Paul Allen | Error support | ||
#3 | 13727 | Paul Allen | Cover page and local CSS | ||
#2 | 13722 | Paul Allen | Login UX | ||
#1 | 13720 | Paul Allen | Perforce Asset Manager (PAM or P4AM) -- ideas |