Skip to content

Commit

Permalink
#27 collection info view
Browse files Browse the repository at this point in the history
  • Loading branch information
Hetal Patel committed Jan 9, 2018
1 parent dd24b45 commit 5349a80
Show file tree
Hide file tree
Showing 13 changed files with 413 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public void init() throws DataGridException {
public String index(final Model model, final HttpServletRequest request,
@RequestParam(value = "uploadNewTab", required = false) final boolean uploadNewTab)
throws DataGridConnectionRefusedException {
logger.info("index()");
try {
sourcePaths.clear();

Expand Down Expand Up @@ -223,7 +224,7 @@ public String index(final Model model, final HttpServletRequest request,
logger.error("Could not respond to request for collections: {}", e);
model.addAttribute("unexpectedError", true);
}

logger.info("returning to collections/collectionManagement");
return "collections/collectionManagement";
}

Expand Down Expand Up @@ -331,14 +332,18 @@ public String getSubDirectories(final Model model, @RequestParam("path") String
while (path.endsWith("/") && !"/".equals(path)) {
path = path.substring(0, path.lastIndexOf("/"));
}

logger.info("Get subdirectories of {}", path);


System.out.println("In GetSubdirectories!!");
System.out.println("path :: " +path);

// put old path in collection history stack
addPathToHistory(path);

return getCollBrowserView(model, path);
}


/**
* Goes back in collection historic stack
Expand Down Expand Up @@ -457,6 +462,8 @@ public String getFileInfo(final Model model, @RequestParam("path") final String
Map<DataGridCollectionAndDataObject, DataGridResource> replicasMap = null;

try {
System.out.println("Path = " +path);

dataGridObj = cs.findByName(path);

if (dataGridObj != null && !dataGridObj.isCollection()) {
Expand All @@ -465,7 +472,8 @@ public String getFileInfo(final Model model, @RequestParam("path") final String
dataGridObj.setNumberOfReplicas(cs.getTotalNumberOfReplsForDataObject(path));
dataGridObj.setReplicaNumber(String.valueOf(cs.getReplicationNumber(path)));
permissionsService.resolveMostPermissiveAccessForUser(dataGridObj,
loggedUserUtils.getLoggedDataGridUser());
loggedUserUtils.getLoggedDataGridUser());

}

} catch (DataGridConnectionRefusedException e) {
Expand All @@ -477,9 +485,15 @@ public String getFileInfo(final Model model, @RequestParam("path") final String

model.addAttribute("collectionAndDataObject", dataGridObj);
model.addAttribute("currentCollection", dataGridObj);
model.addAttribute("replicasMap", replicasMap);

return "collections/collectionInfo";
model.addAttribute("replicasMap", replicasMap);
model.addAttribute("infoFlag", true);


System.out.println("permissionOnCurrentPath =======" + cs.getPermissionsForPath(path));
System.out.println("currentCollection.getName() == "+ dataGridObj.getName());

//return "collections/collectionInfo";
return "collections/info";
}

/**
Expand Down Expand Up @@ -562,6 +576,7 @@ public String getDirectoriesAndFilesForUser(final Model model, @RequestParam("pa
@RequestParam("username") final String username,
@RequestParam("retrievePermissions") final boolean retrievePermissions)
throws DataGridConnectionRefusedException, FileNotFoundException, JargonException {

List<DataGridCollectionAndDataObject> list = new ArrayList<DataGridCollectionAndDataObject>();
Set<String> readPermissions = new HashSet<String>();
Set<String> writePermissions = new HashSet<String>();
Expand Down Expand Up @@ -745,6 +760,7 @@ private boolean applyTemplatesToPath(final MetadataTemplateForm template)
@RequestMapping(value = "/home/")
public String homeCollection(final Model model) throws DataGridException {
// cleaning session variables
logger.info("homeCollection()");
sourcePaths.clear();
currentPath = cs.getHomeDirectyForCurrentUser();
parentPath = currentPath;
Expand Down Expand Up @@ -1087,10 +1103,9 @@ private String getCollBrowserView(final Model model, String path) throws DataGri
model.addAttribute("inheritanceDisabled", inheritanceDisabled);
model.addAttribute("requestMapping", "/collections/add/action/");
model.addAttribute("parentPath", parentPath);

setBreadcrumbToModel(model, dataGridObj);

return "collections/collectionsBrowser";
return "collections/collectionsBrowser";
//return "collections/info";
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.emc.metalnx.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.HandlerMapping;

import com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException;


@Controller
@Scope(WebApplicationContext.SCOPE_SESSION)
@RequestMapping(value = "/collectionInfo")
public class CollectionInfoController {

@Autowired
private CollectionController collectionController;

@Autowired
private MetadataController metadataController;

@Autowired
private PermissionsController permissionsController;

private static final Logger logger = LoggerFactory.getLogger(MetadataController.class);


@RequestMapping(value = "/**", method = RequestMethod.GET)
public String getTestCollectionInfo(final Model model, HttpServletRequest request)
throws DataGridConnectionRefusedException {


logger.info("------CollectionInfoController getTestCollectionInfo() starts !!");
final String path = "/"+extractFilePath(request);

logger.info("path ::" + path) ;
model.addAttribute("name", "This is comming from the CollectionInfoController() - Test the main controller");
logger.info("------CollectionInfoController getTestCollectionInfo() ends !!");
return metadataController.getMetadata(model, path);

}

@RequestMapping(value = "/collectionFileInfo/**", method = RequestMethod.GET)
public String getCollectionFileInfo(final Model model, @RequestParam("path") final String path)
throws DataGridConnectionRefusedException {
System.out.println("------CollectionInfoController getCollectionFileInfo() starts :: " +path);

model.addAttribute("name", "Info");
return "collections/info";
}

@RequestMapping(value = "/collectionMetadata/**", method = RequestMethod.GET)
public String getCollectionMetadata(final Model model, @RequestParam("path") final String path)
throws DataGridConnectionRefusedException {

System.out.println("------CollectionInfoController collectionMetadata() starts :: " +path);

model.addAttribute("name", "Metadata");
return "collections/info";
}

@RequestMapping(value = "/collectionPermisssionDetails/", method = RequestMethod.GET)
public String getCollectionPermissionDetails(final Model model, @RequestParam("path") final String path)
throws DataGridConnectionRefusedException {

System.out.println("------CollectionInfoController collectionPermisssionDetails() starts :: " +path);

model.addAttribute("name", "Permission");

return "collections/info";
}

private static String extractFilePath(HttpServletRequest request) {
String path = (String) request.getAttribute(
HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
String bestMatchPattern = (String) request.getAttribute(
HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
AntPathMatcher apm = new AntPathMatcher();
return apm.extractPathWithinPattern(bestMatchPattern, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ public void exportSearchResultsToCSVFile(final HttpServletResponse response)
}

@RequestMapping(value = "/getMetadata/")
public String getMetadata(final Model model, @RequestParam("path") final String path)
public String getMetadata(final Model model, final String path)
throws DataGridConnectionRefusedException {

System.out.println("MetadataController getMetadata() starts !!");
List<DataGridMetadata> metadataList = metadataService.findMetadataValuesByPath(path);
DataGridCollectionAndDataObject dgColObj = null;

Expand All @@ -263,11 +263,19 @@ public String getMetadata(final Model model, @RequestParam("path") final String
logger.error("Could not retrieve collection/dataobject from path: {}", path);
}

System.out.println("CurrentPath =======" +path);
System.out.println("dgColObj =======" +dgColObj);
System.out.println("permissionOnCurrentPath =======" +collectionService.getPermissionsForPath(path));

model.addAttribute("permissionOnCurrentPath", collectionService.getPermissionsForPath(path));
model.addAttribute("dataGridMetadataList", metadataList);
model.addAttribute("currentPath", path);
model.addAttribute("collectionAndDataObject", dgColObj);
return "metadata/metadataTable";
model.addAttribute("metadataFlag",true);

System.out.println("MetadataController getMetadata() ends !!");
//return "metadata/metadataTable";
return "collections/info";
}

@RequestMapping(value = "/addMetadata/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ private String findMostRestrictivePermission(@RequestParam("paths[]") final Stri
* @throws FileNotFoundException
*/
@RequestMapping(value = "/getPermissionDetails/")
public String getPermissionDetails(final Model model, @RequestParam("path") final String path) {
public String getPermissionDetails(final Model model, @RequestParam("path") final String path) throws DataGridConnectionRefusedException {

logger.debug("Getting permission info for {}", path);

DataGridCollectionAndDataObject obj = null;
Expand Down Expand Up @@ -183,8 +184,14 @@ public String getPermissionDetails(final Model model, @RequestParam("path") fina
model.addAttribute("permissionsWithoutNone", PERMISSIONS_WITHOUT_NONE);
model.addAttribute("collectionAndDataObject", obj);
model.addAttribute("isCollection", isCollection);

return "permissions/permissionDetails :: permissionDetails";
model.addAttribute("permissionOnCurrentPath", cs.getPermissionsForPath(path));
model.addAttribute("permissionFlag", true);

System.out.println("permissionOnCurrentPath =======" + cs.getPermissionsForPath(path));
System.out.println("------Permission Conroller - /getPermissionDetail/ ends------");
//return "permissions/permissionDetails :: permissionDetails";
//return "permissions/permissionDetails";
return "collections/info";
}

@RequestMapping(value = "/changePermissionForGroup/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class URLMap {
public static final String URL_GROUPS_CSV_REPORT = "/groups/groupsToCSVFile/";
public static final String URL_GROUPS_BOOKMARKS = "/groupBookmarks/groups/";

public static final String URL_COLLECTIONS_INFO = "/info/";
public static final String URL_COLLECTIONS_MANAGEMENT = "/collections/";
public static final String URL_ADD_COLLECTION = "/emc-metalnx-web/collections/add/";
public static final String URL_MODIFY_COLLECTION = "/emc-metalnx-web/fileOperation/modify/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ login.username=Username
login.password=Password
login.page.title=EMC Metalnx

#Home
home.menu.title=Home

# Dashboard
dashboard.menu.title=Dashboard
dashboard.page.title=Dashboard
Expand Down
76 changes: 76 additions & 0 deletions src/emc-metalnx-shared/src/main/resources/static/js/collection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
function getTestInfo(path){
console.log(" In getTestInfo() " +path);

var url = "/emc-metalnx-web/collectionInfo"+path;
getBreadcrumb(path);
console.log("URL :: " +url);
ajaxEncapsulation(url, "GET", {path: path}, displayTestDetails, null, null);
}

function displayTestDetails(data){
console.log("displayTestDetails()");
$('#table-loader').hide();
$('#table-loader').after(data);
}
function getPermDetails(path){
console.log("Collection getPermDetails() :: " +path);
var url = "/emc-metalnx-web/collectionInfo"+path;
console.log("URL :: " +url);
ajaxEncapsulation(url, "GET", {path: path}, displayPermDetails, null, null);
}

function getInfoDetails(path){
console.log("Collection getInfoDetails() :: " +path);

var url = "/emc-metalnx-web/collectionInfo/collectionFileInfo"+path;
console.log("URL :: " +url);
getBreadcrumb(path);
ajaxEncapsulation(url, "GET", {path: path}, displayInfoDetails, null, null, null);
}

function getMetadata(path){
console.log("Collection getMetadata() :: " +path);
window.location.hash = "metadata";
console.log("window.location.hash :: " +window.location.hash);
var url = "/emc-metalnx-web/collectionInfo/collectionMetadata"+path;
console.log(1);
getBreadcrumb(path);
ajaxEncapsulation(url, "GET", {path: path}, displayTestDetails, null, null);
}

/*function getInfoDetails(path){
console.log("Collection getInfoDetails() :: " +path);
window.location.hash = "info";
console.log("window.location.hash :: " +window.location.hash);
var url = "/emc-metalnx-web/collectionInfo/collectionFileInfo"+path;
getBreadcrumb(path);
console.log("URL :: " +url);
ajaxEncapsulation(url, "GET", {path: path}, displayTestDetails, null, null);
}
function getPermDetails(path){
console.log("Collection getPermDetails() :: " +path);
window.location.hash = "permission";
console.log("window.location.hash :: " +window.location.hash);
var url = "/emc-metalnx-web/collectionInfo/collectionPermisssionDetails"+path;
getBreadcrumb(path);
console.log("URL :: " +url);
ajaxEncapsulation(url, "GET", {path: path}, displayTestDetails, null, null);
}
function ChangeUrl(title, urlVal) {
console.log("ChangeUrl()");
var str1 = "emc-metalnx-web/collections";
var url = str1.concat(urlVal);
console.log("url :: " +url);
if (typeof (history.pushState) != "undefined") {
var obj = { Title: title, Url: url };
history.pushState(obj, obj.Title, obj.Url);
} else {
alert("Browser does not support HTML5.");
}
}*/
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
~ limitations under the License.
-->

<th:block th:fragment="treeView">
<th:block th:fragment="treeView">
<!-- <div class="col-md-12" th:fragment="treeView" xmlns:th="http://www.w3.org/1999/xhtml"> -->

<!-- Confirmation modal for the delete operation -->
<div class="modal fade" id="deleteReplicaModal" tabindex="-1" role="dialog" aria-hidden="true">
Expand Down Expand Up @@ -68,7 +69,7 @@ <h4 class="modal-title" th:text="#{collections.replica.delete}"></h4>
</div>


<div class="col-md-12" th:unless="${collectionAndDataObject == null}">
<div class="col-md-12" th:unless="${collectionAndDataObject == null}" th:fragment="collectionInfo">
<div class="panel property">
<div class="row">
<h4 class="property-title" th:text="#{text.info}"><i class="fa fa-info-circle"></i></h4>
Expand Down Expand Up @@ -135,6 +136,7 @@ <h4 class="property-title" th:text="#{text.info}"><i class="fa fa-info-circle"><
</div>
</div>
</div>

<script>
function displayDeleteReplicaModal(path, fileName, replicaNumber) {
$('#deleteReplicaPath').val(path);
Expand All @@ -155,8 +157,10 @@ <h4 class="property-title" th:text="#{text.info}"><i class="fa fa-info-circle"><
ajaxEncapsulation("/emc-metalnx-web/fileOperation/deleteReplica/", "POST", {path: path, fileName: fileName, replicaNumber: replicaNumber}, displayInfoDetails, null, null, null);
}
$(document).ready(function(){
console.log("CollectionInfo");
$("#collection-content").removeClass("collections-table");
$("#collection-content").addClass("property");
});
</script>
</th:block>
<!-- </div> -->
Loading

0 comments on commit 5349a80

Please sign in to comment.