Skip to content

Commit

Permalink
#33 Display Images
Browse files Browse the repository at this point in the history
  • Loading branch information
spuliaiev-sfdc committed Jul 26, 2018
1 parent 9e24620 commit bb730af
Show file tree
Hide file tree
Showing 34 changed files with 218 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import gallerymine.model.mvc.PageHierarchyImpl;
import gallerymine.model.mvc.SourceCriteria;
import gallerymine.model.support.DateStats;
import gallerymine.model.support.PictureGrade;
import gallerymine.model.support.SourceFolderStats;
import gallerymine.model.support.SourceKind;
import gallerymine.backend.utils.RegExpHelper;
Expand All @@ -19,8 +20,6 @@
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Metric;
import org.springframework.data.geo.Metrics;
import org.springframework.data.geo.Point;
import org.springframework.data.geo.format.DistanceFormatter;
import org.springframework.data.mongodb.core.MongoTemplate;
Expand Down Expand Up @@ -71,6 +70,12 @@ public Page<Source> fetchCustom(SourceCriteria sourceCriteria) {

@Override
public Page<FolderStats> fetchPathCustom(SourceCriteria sourceCriteria) {
PictureGrade grade = sourceCriteria.getGrade();
if (grade == null) {
grade = PictureGrade.GALLERY;
}
Class entityClass = grade.getEntityClass();

sourceCriteria.setSortByField("filePath");
sourceCriteria.setSortDescending(false);
String sourcePath = sourceCriteria.getPath();
Expand Down Expand Up @@ -98,9 +103,9 @@ public Page<FolderStats> fetchPathCustom(SourceCriteria sourceCriteria) {
pipelineCount.add(group(fields()).sum("count").as("count"));
pipelineCount.add(project().and("$_id.name").as("name").and("$count").as("filesCount").and("$_id.filePath").as("fullPath"));

Aggregation aggregationCount = newAggregation(Source.class, (AggregationOperation[]) pipelineCount.toArray(new AggregationOperation[]{}));
Aggregation aggregationCount = newAggregation(entityClass, (AggregationOperation[]) pipelineCount.toArray(new AggregationOperation[]{}));
// List<FolderStats> countStatse = template.aggregate(aggregationCount, Source.class, FolderStats.class).getMappedResults();
FolderStats countStats = template.aggregate(aggregationCount, Source.class, FolderStats.class).getUniqueMappedResult();
FolderStats countStats = template.aggregate(aggregationCount, entityClass, FolderStats.class).getUniqueMappedResult();

long totalCount = (countStats == null || countStats.getFilesCount() == null) ? 0 : countStats.getFilesCount();
int newOffset = sourceCriteria.getOffset();
Expand All @@ -118,10 +123,10 @@ public Page<FolderStats> fetchPathCustom(SourceCriteria sourceCriteria) {
pipeline.add(Aggregation.skip(newOffset));
pipeline.add(Aggregation.limit(sourceCriteria.getSize()));

Aggregation aggregation = newAggregation(Source.class, (AggregationOperation[]) pipeline.toArray(new AggregationOperation[]{}));
Aggregation aggregation = newAggregation(entityClass, (AggregationOperation[]) pipeline.toArray(new AggregationOperation[]{}));

// get distinct path, but before we need to cut the original path - and everything starting from first slash /
AggregationResults<FolderStats> output = template.aggregate(aggregation, Source.class, FolderStats.class);
AggregationResults<FolderStats> output = template.aggregate(aggregation, entityClass, FolderStats.class);

return new PageHierarchyImpl<>(output.getMappedResults(), pager, totalCount, sourcePath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public PictureInformation settlePicture(PictureInformation source) throws ImageA

return picture;
} catch (Exception e) {
throw new ImageApproveException("Failed to copy file");
throw new ImageApproveException("Failed to copy file", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public String prepareImportFolder(boolean enforce, Process process) throws Impor
public <T extends PictureInformation> Path moveToSiblingPath(T info, String siblingFolder) throws IOException {
Path targetSubPath = Paths.get(info.getRootPath()).getParent().resolve(siblingFolder);
Path targetPath = appConfig.getImportRootFolderPath().resolve(targetSubPath);
Path fullTargetPath = targetPath.resolve(info.getFileName()).getParent();
Path fullTargetPath = targetPath.resolve(info.getFileWithPath()).getParent();

Path file = calcCompleteFilePath(info);
FileUtils.moveFileToDirectory(file.toFile(), fullTargetPath.toFile(), true);
Expand Down
56 changes: 56 additions & 0 deletions docs/database/listGallery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

db.picture.aggregate([
{
"$match": {
"$and": [
{
"filePath": {
"$regex": "^[^/]*$"
}
}
]
}
},
{
"$project": {
"filePath": 1,
"name": {
"$arrayElemAt": [
{
"$split": [
"$filePath",
"/"
]
},
0
]
}
}
},
{
"$group": {
"_id": {
"name": "$name",
"filePath": "$filePath"
},
"count": {
"$sum": 1
}
}
},
{
"$group": {
"_id": null,
"count": {
"$sum": "$count"
}
}
},
{
"$project": {
"name": "$_id.name",
"filesCount": "$count",
"fullPath": "$_id.filePath"
}
}
])
7 changes: 7 additions & 0 deletions ui/web/src/main/resources/static/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#sourceViewSwitcher {
margin-top: 12px;
float: left;
}
.paginatorContainer .pagination {
margin: 9px;
}
4 changes: 2 additions & 2 deletions ui/web/src/main/resources/static/importRequest.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<link rel="stylesheet" href="lib/bootstrap-3.3.7-dist/css/bootstrap-theme.css"/>

<!-- Latest compiled and minified JavaScript -->
<script src="js/jquery-1.10.2.js" type="application/javascript"></script>
<script src="js/jquery-ui-1.11.1.min.js" type="application/javascript"></script>
<script src="/lib/jquery/jquery-1.10.2.js" type="application/javascript"></script>
<script src="/lib/jquery/jquery-ui-1.11.1.min.js" type="application/javascript"></script>
<script src="lib/bootstrap-3.3.7-dist/js/bootstrap.min.js" type="application/javascript"></script>
<script src="lib/bootstrap-datepicker-1.6.4/js/bootstrap-datepicker.js" type="application/javascript"></script>
<script src="lib/jstree-3.3.4-dist/jstree.js" type="application/javascript"></script>
Expand Down
16 changes: 8 additions & 8 deletions ui/web/src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" type="text/css" href="lib/jstree-3.3.4-dist/themes/default/style.min.css" id="csstree"/>
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css" id="cssui" />
<link rel="stylesheet" type="text/css" href="css/common.css" id="cssCommon" />
<link rel="stylesheet" type="text/css" href="css/sourceList.css" id="css" />
<link rel="stylesheet" type="text/css" href="css/cmp/sourceList.css" id="css" />

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="lib/bootstrap-3.3.7-dist/css/bootstrap.css" />
Expand All @@ -17,18 +17,18 @@
<link rel="stylesheet" href="lib/bootstrap-3.3.7-dist/css/bootstrap-theme.css"/>

<!-- Latest compiled and minified JavaScript -->
<script type="application/javascript" src="js/jquery-1.10.2.js"></script>
<script type="application/javascript" src="js/jquery-ui-1.11.1.min.js"></script>
<script type="application/javascript" src="lib/jquery/jquery-1.10.2.js"></script>
<script type="application/javascript" src="lib/jquery/jquery-ui-1.11.1.min.js"></script>
<script type="application/javascript" src="lib/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script type="application/javascript" src="lib/bootstrap-datepicker-1.6.4/js/bootstrap-datepicker.js"></script>
<script type="application/javascript" src="lib/jstree-3.3.4-dist/jstree.js"></script>
<script type="application/javascript" src="js/common.js"></script>
<script type="application/javascript" src="js/error.js"></script>
<script type="application/javascript" src="js/sourceBlock.js"></script>
<script type="application/javascript" src="js/pager.js"></script>
<script type="application/javascript" src="js/sourceList.js"></script>
<script type="application/javascript" src="js/TreePath.js"></script>
<script type="application/javascript" src="js/TreeDates.js"></script>
<script type="application/javascript" src="js/cmp/sourceBlock.js"></script>
<script type="application/javascript" src="js/cmp/pager.js"></script>
<script type="application/javascript" src="js/cmp/sourceList.js"></script>
<script type="application/javascript" src="js/cmp/TreePath.js"></script>
<script type="application/javascript" src="js/cmp/TreeDates.js"></script>
</head>
<body>
<div id="pageHeader">
Expand Down
4 changes: 2 additions & 2 deletions ui/web/src/main/resources/static/indexRequest.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<link rel="stylesheet" href="lib/bootstrap-3.3.7-dist/css/bootstrap-theme.css"/>

<!-- Latest compiled and minified JavaScript -->
<script src="js/jquery-1.10.2.js" type="application/javascript"></script>
<script src="js/jquery-ui-1.11.1.min.js" type="application/javascript"></script>
<script src="/lib/jquery/jquery-1.10.2.js" type="application/javascript"></script>
<script src="/lib/jquery/jquery-ui-1.11.1.min.js" type="application/javascript"></script>
<script src="lib/bootstrap-3.3.7-dist/js/bootstrap.min.js" type="application/javascript"></script>
<script src="lib/bootstrap-datepicker-1.6.4/js/bootstrap-datepicker.js" type="application/javascript"></script>
<script src="lib/jstree-3.3.4-dist/jstree.js" type="application/javascript"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ var TreeDates = {
return "/sources/findDates";
},
"data" : function (node, cb, par2) {
var criteria = this.prepareCriteria(this, node);
var criteria = treeObject.prepareCriteria(this, node);
return JSON.stringify(criteria, null, 2);
},
"postprocessor": function (node, data, par2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var TreePath = {
return "/sources/findPath";
},
"data" : function (node, cb, par2) {
var criteria = this.prepareCriteria(this, node);
var criteria = treeObject.prepareCriteria(this, node);
return JSON.stringify(criteria, null, 2);
},
"postprocessor": function (node, data, par2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ var SourceList = {
prepareCriteria: function (path) {
var starting = $("#datepicker input[name='start']").val();
var ending = $("#datepicker input[name='end']").val();
if (starting === "") {
starting = null;
}
if (ending === "") {
ending = null;
}

if (this.treeDates) {
var selectedDate = this.treeDates.getCurrent();
Expand Down Expand Up @@ -278,10 +284,16 @@ var SourceList = {
object.responseData = null;

if (typeof TreePath != "undefined" && object.options.treePath) {
object.treeFolderPath = TreePath.create($('#folderTree'), this.clickFoldersTreeNode, this.prepareCriteriaPath);
object.treeFolderPath = TreePath.create($('#folderTree'),
function(e, data, tree) {return object.clickFoldersTreeNode(e, data, tree);},
function (treeElement, node) { return object.prepareCriteriaPath(treeElement, node);}
);
}
if (typeof TreePath != "undefined" && object.options.treeDates) {
object.treeDates = TreeDates.create($('#datesTree'), this.clickDatesTreeNode, this.prepareCriteriaCurrent);
object.treeDates = TreeDates.create($('#datesTree'),
function(e, data, tree) {object.clickDatesTreeNode(e, data, tree);},
function (treeElement, node) { return object.prepareCriteriaCurrent(treeElement, node);}
);
}
if (typeof Gallery != "undefined" && object.options.gallery) {
object.gallery = new Gallery({
Expand All @@ -302,7 +314,7 @@ var SourceList = {
object.initialized = true;
return object;
} catch (e) {
console.log("Failed to init SourceList ");
console.log("Failed to init SourceList "+e);
}
}
};
Expand Down
39 changes: 39 additions & 0 deletions ui/web/src/main/resources/static/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var GalleryManager = {

init: function () {
GalleryManager.viewSwitcher = initViewSwitcher("#sourceViewSwitcher");
GalleryManager.sourceList = SourceList.init({
showDecisionBlock: true,
sourceDataProvider: "/sources/uni",
breadcrumb: "#breadcrumblist",
gallery: '#slideshow',
treePath: '#folderTree',
treeDates: '#datesTree',
pagerBar: "#sourcesNav",
sourcesRootDiv: "div#sources",
criteriaContributor: GalleryManager.criteriaContributor,
viewSwitcher: GalleryManager.viewSwitcher,
grade: "GALLERY",
onClick: GalleryManager.onClickImportBlock
});
GalleryManager.viewSwitcher.setSourceList(GalleryManager.sourceList);
},
setSelectedPicture: function (block) {
GalleryManager.selectedBlock = block;
},
getSelectedPicture: function () {
return GalleryManager.selectedBlock;
},
onClickImportBlock: function (block) {
GalleryManager.setSelectedPicture(block);
},
criteriaContributor: function(sourceList, criteria) {
// criteria.requestId = GalleryManager.getSelectedPicture();
criteria.path = "";
return criteria;
},
};

$(document).ready(function() {
GalleryManager.init();
});
18 changes: 9 additions & 9 deletions ui/web/src/main/resources/static/sourceList.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" type="text/css" href="lib/jstree-3.3.4-dist/themes/default/style.min.css" id="csstree"/>
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css" id="cssui" />
<link rel="stylesheet" type="text/css" href="css/common.css" id="cssCommon" />
<link rel="stylesheet" type="text/css" href="css/sourceList.css" id="css" />
<link rel="stylesheet" type="text/css" href="css/cmp/sourceList.css" id="css" />
<link rel="stylesheet" type="text/css" href="lib/gallery/css/slideshow.css" id="cssSlideshow" />

<!-- Latest compiled and minified CSS -->
Expand All @@ -18,20 +18,20 @@
<link rel="stylesheet" href="lib/bootstrap-3.3.7-dist/css/bootstrap-theme.css"/>

<!-- Latest compiled and minified JavaScript -->
<script type="application/javascript" src="js/jquery-1.10.2.js"></script>
<script type="application/javascript" src="js/jquery-ui-1.11.1.min.js"></script>
<script type="application/javascript" src="lib/jquery/jquery-1.10.2.js"></script>
<script type="application/javascript" src="lib/jquery/jquery-ui-1.11.1.min.js"></script>
<script type="application/javascript" src="lib/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script type="application/javascript" src="lib/bootstrap-datepicker-1.6.4/js/bootstrap-datepicker.js"></script>
<script type="application/javascript" src="lib/jstree-3.3.4-dist/jstree.js"></script>
<script type="application/javascript" src="lib/gallery/js/gallery.js"></script>
<script type="application/javascript" src="js/common.js"></script>
<script type="application/javascript" src="js/error.js"></script>
<script type="application/javascript" src="js/sourceBlock.js"></script>
<script type="application/javascript" src="js/sourceProperties.js"></script>
<script type="application/javascript" src="js/pager.js"></script>
<script type="application/javascript" src="js/sourceList.js"></script>
<script type="application/javascript" src="js/TreePath.js"></script>
<script type="application/javascript" src="js/TreeDates.js"></script>
<script type="application/javascript" src="js/cmp/sourceBlock.js"></script>
<script type="application/javascript" src="js/cmp/sourceProperties.js"></script>
<script type="application/javascript" src="js/cmp/pager.js"></script>
<script type="application/javascript" src="js/cmp/sourceList.js"></script>
<script type="application/javascript" src="js/cmp/TreePath.js"></script>
<script type="application/javascript" src="js/cmp/TreeDates.js"></script>
</head>
<body>
<div id="slideshow">
Expand Down
8 changes: 4 additions & 4 deletions ui/web/src/main/resources/static/sourceMatch.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<link rel="stylesheet" href="/lib/bootstrap-3.3.7-dist/css/bootstrap-theme.css"/>

<!-- Latest compiled and minified JavaScript -->
<script src="/js/jquery-1.10.2.js"></script>
<script src="/js/jquery-ui-1.11.1.min.js"></script>
<script src="/lib/jquery/jquery-1.10.2.js"></script>
<script src="/lib/jquery/jquery-ui-1.11.1.min.js"></script>
<script src="/lib/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="/lib/bootstrap-datepicker-1.6.4/js/bootstrap-datepicker.js"></script>
<script src="/lib/jstree-3.3.4-dist/jstree.js"></script>
<script src="/js/common.js"></script>
<script src="/js/error.js"></script>
<script src="/js/sourceBlock.js"></script>
<script src="/js/sourceMatch.js"></script>
<script src="/js/cmp/sourceBlock.js"></script>
<script src="/js/cmp/sourceMatch.js"></script>
</head>
<body>
<div id="pageHeader">
Expand Down
2 changes: 1 addition & 1 deletion ui/web/src/main/resources/templates/main/files.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<title>GalleryMine</title>
<link rel="stylesheet" type="text/css" href="lib/gallery/css/slideshow.css" id="cssSlideshow" />
<script type="application/javascript" src="js/sourceProperties.js"></script>
<script type="application/javascript" src="js/cmp/sourceProperties.js"></script>

<script type="application/javascript" src="lib/gallery/js/gallery.js"></script>
</head>
Expand Down
Loading

0 comments on commit bb730af

Please sign in to comment.