Skip to content

Commit

Permalink
#27 info dataprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
Hetal Patel committed Jan 18, 2018
1 parent 19df664 commit 470f9a2
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ public String getFileInfo(final Model model, final String path)
dataGridObj.setNumberOfReplicas(cs.getTotalNumberOfReplsForDataObject(path));
dataGridObj.setReplicaNumber(String.valueOf(cs.getReplicationNumber(path)));
permissionsService.resolveMostPermissiveAccessForUser(dataGridObj,
loggedUserUtils.getLoggedDataGridUser());
loggedUserUtils.getLoggedDataGridUser());


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.irods.jargon.core.connection.IRODSAccount;
import org.irods.jargon.core.exception.JargonException;
import org.irods.jargon.core.pub.domain.IRODSDomainObject;
import org.irods.jargon.extensions.dataprofiler.DataProfile;
import org.irods.jargon.extensions.dataprofiler.DataProfilerFactory;
import org.irods.jargon.extensions.dataprofiler.DataProfilerService;
Expand All @@ -17,6 +18,7 @@
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.bind.annotation.SessionAttributes;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.HandlerMapping;
Expand Down Expand Up @@ -58,11 +60,40 @@ public class CollectionInfoController {
public String getTestCollectionInfo(final Model model, HttpServletRequest request)
throws DataGridException, DataGridConnectionRefusedException {

logger.info("------CollectionInfoController getTestCollectionInfo() starts !!");
logger.info("CollectionInfoController getTestCollectionInfo() starts !!");
final String path = "/" + extractFilePath(request);
logger.info("path ::" + path);
model.addAttribute("summary", "This is comming from the CollectionInfoController() - Test the main controller");

@SuppressWarnings("rawtypes")
DataProfile dataProfile = getCollectionDataProfile(path);

model.addAttribute("dataProfile", dataProfile);
return "collections/info"; //:: mainPage(page='collections/collectionInfo', fragment='collectionInfo')";

//"main :: mainPage(page='some-page', fragment='somePage')";
//return "collections/collectionInfo";


/*
* DataGridCollectionAndDataObject dgColObj = null;
*
* try { dgColObj = collectionService.findByName(path);
* permissionsService.resolveMostPermissiveAccessForUser(dgColObj,
* loggedUserUtils.getLoggedDataGridUser()); } catch (DataGridException e) {
* logger.error("Could not retrieve collection/dataobject from path: {}", path);
* } model.addAttribute("currentPath", path);
* model.addAttribute("collectionAndDataObject", dgColObj); if (dgColObj !=
* null) model.addAttribute("flag", true); else { model.addAttribute("flag",
* false); }
*/

}

@SuppressWarnings("unchecked")
public DataProfile<IRODSDomainObject> getCollectionDataProfile(String path) throws DataGridException {


IRODSAccount irodsAccount = irodsServices.getUserAO().getIRODSAccount();
logger.debug("got irodsAccount:{}", irodsAccount);

Expand All @@ -77,49 +108,39 @@ public String getTestCollectionInfo(final Model model, HttpServletRequest reques
DataProfile dataProfile = dataProfilerService.retrieveDataProfile(path);
logger.info("------CollectionInfoController getTestCollectionInfo() ends !!");
logger.info("data profile retrieved:{}", dataProfile);


/*
* TODO: after this do an if test and send to right view with the DataProfile in
* the model
*/

return "collections/info";
return dataProfile;

} catch (JargonException e) {
logger.error("Could not retrieve collection/dataobject from path: {}", path, e);
throw new DataGridException(e.getMessage());
}

/*
* DataGridCollectionAndDataObject dgColObj = null;
*
* try { dgColObj = collectionService.findByName(path);
* permissionsService.resolveMostPermissiveAccessForUser(dgColObj,
* loggedUserUtils.getLoggedDataGridUser()); } catch (DataGridException e) {
* logger.error("Could not retrieve collection/dataobject from path: {}", path);
* } model.addAttribute("currentPath", path);
* model.addAttribute("collectionAndDataObject", dgColObj); if (dgColObj !=
* null) model.addAttribute("flag", true); else { model.addAttribute("flag",
* false); }
*/

}

/*
* @RequestMapping(value = "/collectionFileInfo/", method = RequestMethod.POST)
* public String getCollectionFileInfo(final Model model, @RequestParam("path")
* final String path) throws DataGridConnectionRefusedException {
*
* logger.
* info("------CollectionInfoController getCollectionFileInfo() starts :: "
* +path); DataGridUser loggedUser = LoggedUserUtils.getLoggedDataGridUser();
*
*
* logger.info("User First Name :: " +loggedUser.getUsername());
*
* model.addAttribute("infoName", "This is Info !!"); return "collections/info";
*
* }
*/



@RequestMapping(value = "/collectionFileInfo/", method = RequestMethod.POST)
public String getCollectionFileInfo(final Model model, @RequestParam("path")
final String path) throws DataGridException {

logger.
info("------CollectionInfoController getCollectionFileInfo() starts :: "
+path);

@SuppressWarnings("rawtypes")
DataProfile dataProfile = getCollectionDataProfile(path);


model.addAttribute("dataProfile", dataProfile);
return "collections/collectionInfo";
}


/*
* @RequestMapping(value = "/collectionMetadata/", method = RequestMethod.POST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ function getCollectionSummary(path){
}

function displayCollectionSummary(data){
alert("displayTestDetails()");
console.log("displayTestDetails()");
$("#summary").html(data);
//alert([[${ currentPath }]]);
getInfoDetails(path);
//getInfoDetails(path);
displayInfoDetails(data);
//$("#info").html(data);
}


Expand All @@ -19,7 +21,8 @@ function getInfoDetails(path){
window.location.hash = "info";
console.log("Path :: " +path);
//var url = "/emc-metalnx-web/collectionInfo/collectionFileInfo/";
var url = "/emc-metalnx-web/collections/info/";
//var url = "/emc-metalnx-web/collections/info/";
var url = "/emc-metalnx-web/collectionInfo/collectionFileInfo/";
//getBreadcrumb(path);
ajaxEncapsulation(url, "POST", {path: path}, displayInfoDetails, null, null, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,145 +17,53 @@
<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">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" th:text="#{collections.replica.delete}"></h4>
</div>
<div class="modal-body">
<input type="hidden" name="path" id="deleteReplicaPath"/>
<input type="hidden" name="fileName" id="deleteReplicaFileName"/>
<input type="hidden" name="replicaNumber" id="deleteReplicaNumber"/>
<p th:text="#{collections.replica.delete.confirm}"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" th:text="#{text.close}"></button>
<button type="button" class="btn btn-primary" onclick="deleteReplica();" th:text="#{text.delete}"></button>
</div>
</div>
</div>
</div>


<!-- Replica deletion success message -->
<div class="alert alert-success" role="alert" th:if="${delReplReturn} == 'success'">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<p class="text-center" th:text="#{collections.replica.delete.success}"></p>
</div>
<!-- Replica deletion fail message -->
<div class="alert alert-danger" role="alert" th:if="${delReplReturn} == 'failure'">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<p class="text-center" th:text="#{collections.replica.delete.failure}"></p>
</div>
<!-- Permission none -->
<div th:if="${collectionAndDataObject == null}">
<div class="panel property">
<div class="text-center" role="alert">
<span th:text="#{collections.error.no.permissions}"></span>
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#" onclick="javascript:goBackHistory('1');">
<span th:text="#{text.back}"></span>
</a>
</div>
</div>
</div>



<div class="col-md-12" th:unless="${collectionAndDataObject == null}" th:fragment="collectionInfo">
<div class="col-md-12" th:unless="${dataProfile == 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>
<div class="col-md-12 col-sm-12"><div class="col-md-12 col-sm-12 collLesserInfo divider"></div></div>
</div>
<div class="panel-info">
<div class="name">
<i th:if="${collectionAndDataObject.isCollection()}" class="fa fa-folder folder-icon"></i>
<i th:unless="${collectionAndDataObject.isCollection()}"
th:class="${ collectionAndDataObject.getIconToDisplay()}"></i>
<span><b th:text="${ currentCollection.getName() }"></b></span>
<span class="resulting-permission" th:text="${ '[' + collectionAndDataObject.getMostPermissiveAccessForCurrentUser() + ' access]'}"></span>
<i th:unless="${dataProfile.file}" class="fa fa-folder folder-icon"></i>
<i th:if="${dataProfile.file}"
th:class="${ dataProfile.getIconToDisplay()}"></i>
<span><b th:text="${ dataProfile.getDomainObject().getCollectionName() }"></b></span>
<!-- <span class="resulting-permission" th:text="${ '[' + collectionAndDataObject.getMostPermissiveAccessForCurrentUser() + ' access]'}"></span> -->
<a id="breadcrumbStar" class="btn-favorite" href="#"
data-toggle="popover" data-placement="left" data-trigger="manual" data-content="" th:title="${dataProfile.starred}?#{collections.favorite.unmark.button.tooltip}:#{collections.favorite.button.tooltip}" >
<i th:class="true? 'fa fa-star bm-checked' : 'fa fa-star bm-unchecked'" aria-hidden="true"></i>
</a>
</div>


<div class="row">
<div class="text-right col-md-1 col-sm-4 col-xs-4"><label th:text="#{collections.management.table.owner.label}"></label></div>
<div class="col-md-9 col-sm-8 col-xs-8"><span th:text="${ currentCollection.getOwner() }"></span></div>
<!-- <div class="col-md-9 col-sm-8 col-xs-8"><span th:text="${ currentCollection.getOwner() }"></span></div> -->
</div>
<div class="row">
<div class="text-right col-md-1 col-sm-4 col-xs-4"><label th:text="#{collections.management.table.created.label}"></label></div>
<div class="col-md-9 col-sm-8 col-xs-8"><span th:text="${ currentCollection.getCreatedAtFormatted() }"></span></div>
<div class="col-md-9 col-sm-8 col-xs-8"><span th:text="${ dataProfile.getDomainObject().getCreatedAt() }"></span></div>
</div>
<div class="row">
<!-- collection has different name, keep same name?? <div class="row">
<div class="text-right col-md-1 col-sm-4 col-xs-4"><label th:text="#{collections.management.table.modified.label}"></label></div>
<div class="col-md-9 col-sm-8 col-xs-8"><span th:text="${ currentCollection.getModifiedAtFormatted() }"></span></div>
</div>
<div class="row">
<div class="col-md-9 col-sm-8 col-xs-8"><span th:text="${ dataProfile.getDomainObject().getModifiedAt() }"></span></div>
</div> -->
<!-- Will we have checksum on collection??? <div class="row">
<div class="text-right col-md-1 col-sm-4 col-xs-4"><label th:text="#{collections.management.checksum.label}"></label></div>
<div class="col-md-9 col-sm-8 col-xs-8"><span th:text="${ currentCollection.getChecksum() }"></span></div>
</div>
</div>

<div id="replicaAndChecksumInfo" th:if="${!currentCollection.isCollection()}">
<table class="table table-hover">
<thead>
<tr>
<th th:text="#{collections.management.table.replica.number.label}"></th>
<th th:text="#{collections.management.table.created.label}"></th>
<th th:text="#{collections.management.table.modified.label}"></th>
<th th:text="#{collections.management.table.size.label}"></th>
<th th:text="#{collections.management.table.resource.label}"></th>
<th th:text="#{collections.management.table.path.label}"></th>
<th></th>
</tr>
</thead>

<tbody>
<tr th:each="replica : ${replicasMap}">
<td><span th:text="${replica.key.replicaNumber}"></span></td>
<td><span th:text="${replica.key.createdAtFormatted}"></span></td>
<td><span th:text="${replica.key.modifiedAtFormatted}"></span></td>
<td><span th:text="${replica.key.displaySize}"></span></td>
<td><span th:text="${replica.value.name}"></span></td>
<td><span th:text="${replica.value.path}"></span></td>
<td th:if="${replicasMap.size() > 1}">
<button class="btn btn-default btn-xs"
th:onclick="'javascript:displayDeleteReplicaModal(\'' + ${currentCollection.getPath()} + '\', \'' + ${currentCollection.getName()} + '\', \'' + ${replica.key.replicaNumber} + '\');'"
type="button">
<span class="glyphicon glyphicon-trash"> </span>
</button>
</td>
</tr>
</tbody>
</table>
<div class="col-md-9 col-sm-8 col-xs-8"><span th:text="${ dataProfile.getChecksum() }"></span></div>
</div> -->
</div>
</div>
</div>

<script>
function displayDeleteReplicaModal(path, fileName, replicaNumber) {
$('#deleteReplicaPath').val(path);
$('#deleteReplicaFileName').val(fileName);
$('#deleteReplicaNumber').val(replicaNumber);
$('#deleteReplicaModal').modal('show');
}

function deleteReplica(path, fileName, replicaNumber) {
var path = $('#deleteReplicaPath').val();
var fileName = $('#deleteReplicaFileName').val();
var replicaNumber = $('#deleteReplicaNumber').val();
$("#table-loader").show();
$("#table-loader").nextAll().remove();
$(".nav-tabs a[href='#info-collection']").tab("show");
$('#deleteReplicaModal').modal('hide');
$('.modal-backdrop.fade.in').remove();
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");
Expand Down
Loading

0 comments on commit 470f9a2

Please sign in to comment.