Skip to content

Commit 10511e5

Browse files
committed
Merge branch '88-folder-browser' of https://github.com/maeisabelle/marklogic-data-hub into maeisabelle-88-folder-browser
# Conflicts: # quick-start/src/main/resources/static/app/services/dataHubService.js # quick-start/src/main/resources/static/css/quick-start.css
2 parents b0ad14c + dbfb8f5 commit 10511e5

39 files changed

+78121
-291
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.marklogic.hub.model;
2+
3+
public class SearchPathModel {
4+
5+
private String folder;
6+
private String path;
7+
8+
public SearchPathModel() {
9+
}
10+
11+
public SearchPathModel(String path) {
12+
this.path = path;
13+
}
14+
15+
public SearchPathModel(String path, String folder) {
16+
this.path = path;
17+
this.folder = folder;
18+
}
19+
20+
public String getFolder() {
21+
return folder;
22+
}
23+
24+
public void setFolder(String folder) {
25+
this.folder = folder;
26+
}
27+
28+
public String getPath() {
29+
return path;
30+
}
31+
32+
public void setPath(String path) {
33+
this.path = path;
34+
}
35+
36+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.marklogic.hub.web.controller.api;
2+
3+
import java.io.File;
4+
import java.util.ArrayList;
5+
import java.util.HashMap;
6+
import java.util.List;
7+
import java.util.Map;
8+
9+
import org.apache.commons.lang.StringUtils;
10+
import org.slf4j.Logger;
11+
import org.slf4j.LoggerFactory;
12+
import org.springframework.beans.factory.annotation.Autowired;
13+
import org.springframework.http.MediaType;
14+
import org.springframework.web.bind.annotation.RequestBody;
15+
import org.springframework.web.bind.annotation.RequestMapping;
16+
import org.springframework.web.bind.annotation.RequestMethod;
17+
import org.springframework.web.bind.annotation.RestController;
18+
19+
import com.marklogic.hub.config.EnvironmentConfiguration;
20+
import com.marklogic.hub.model.SearchPathModel;
21+
import com.marklogic.hub.util.FileUtil;
22+
import com.marklogic.hub.web.controller.BaseController;
23+
24+
@RestController
25+
@RequestMapping("/api/utils")
26+
public class UtilController extends BaseController {
27+
28+
private static final Logger LOGGER = LoggerFactory.getLogger(UtilController.class);
29+
30+
@Autowired
31+
private EnvironmentConfiguration environmentConfiguration;
32+
33+
@RequestMapping(value = "/searchPath", method = RequestMethod.POST, consumes = {
34+
MediaType.APPLICATION_JSON_UTF8_VALUE }, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE })
35+
public Map searchPath(@RequestBody SearchPathModel searchPathModel) {
36+
return searchPathUnix(searchPathModel.getPath());
37+
}
38+
39+
public Map searchPathUnix(String searchPath) {
40+
41+
LOGGER.debug("Search Path:" + searchPath);
42+
List<SearchPathModel> paths = new ArrayList<SearchPathModel>();
43+
if (StringUtils.isEmpty(searchPath)) {
44+
File[] roots = File.listRoots();
45+
for (int i = 0; i < roots.length; i++) {
46+
LOGGER.debug("Path:" + roots[i].getAbsolutePath());
47+
paths.add(new SearchPathModel(roots[i].getAbsolutePath(), roots[i].getAbsolutePath()));
48+
}
49+
} else {
50+
if (!searchPath.equals("/")) {
51+
searchPath = searchPath + java.io.File.separator;
52+
}
53+
54+
List<String> folders = FileUtil.listDirectFolders(searchPath);
55+
for (String folder : folders) {
56+
String path = searchPath + folder;
57+
LOGGER.debug("Path:" + path);
58+
paths.add(new SearchPathModel(path, folder));
59+
}
60+
}
61+
62+
Map returnValue = new HashMap();
63+
64+
returnValue.put("paths", paths);
65+
66+
return returnValue;
67+
}
68+
}

quick-start/src/main/resources/static/app/quickStartApp.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
'angularBootstrapNavTree',
1313
'ngAnimate',
1414
'ui.bootstrap',
15-
'ngMaterial'
15+
'ngMaterial',
16+
'treeControl'
17+
//'angucomplete-alt'
1618
];
1719
angular.module('quickStartApp', dependencies)
1820
.factory('$exceptionHandler', ExceptionHandler)

quick-start/src/main/resources/static/app/services/dataHubService.js

Lines changed: 76 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function () {
1+
(function() {
22

33
'use strict';
44

@@ -28,42 +28,43 @@
2828
runInputFlow: runInputFlow,
2929
testFlow: testFlow,
3030
saveFlow: saveFlow,
31-
displayMessage: displayMessage
31+
displayMessage: displayMessage,
32+
searchPath: searchPath
3233
});
3334

3435
function login(loginForm) {
3536
return $http.post('api/data-hub/login', loginForm)
36-
.success(function (data) {
37-
self.status = data;
38-
if(!self.status.installed) {
39-
self.action.type = 'Install';
40-
self.action.message = 'Install is in progress...';
41-
self.action.progressType = 'success';
42-
}
43-
})
44-
.error(function () {
45-
self.status = null;
46-
});
37+
.success(function(data) {
38+
self.status = data;
39+
if (!self.status.installed) {
40+
self.action.type = 'Install';
41+
self.action.message = 'Install is in progress...';
42+
self.action.progressType = 'success';
43+
}
44+
})
45+
.error(function() {
46+
self.status = null;
47+
});
4748
}
4849

4950
function getLoginStatus() {
5051
return $http.get('api/data-hub/login')
51-
.success(function (data) {
52-
self.status = data;
53-
})
54-
.error(function () {
55-
self.status = null;
56-
});
52+
.success(function(data) {
53+
self.status = data;
54+
})
55+
.error(function() {
56+
self.status = null;
57+
});
5758
}
5859

5960
function logout() {
6061
return $http.post('api/data-hub/logout')
61-
.success(function (data) {
62-
self.status = data;
63-
})
64-
.error(function () {
65-
self.status = null;
66-
});
62+
.success(function(data) {
63+
self.status = data;
64+
})
65+
.error(function() {
66+
self.status = null;
67+
});
6768
}
6869

6970
function reloadRoute() {
@@ -72,17 +73,17 @@
7273

7374
function install() {
7475
return $http.post('api/data-hub/install')
75-
.success(function (status) {
76-
self.status = status;
77-
self.action.type = null;
78-
self.displayMessage('Install is successful.', 'success', 'notification', false);
79-
self.reloadRoute();
80-
})
81-
.error(function () {
82-
self.action.message = 'Install is unsuccessful.';
83-
self.action.progressType = 'danger';
84-
//self.displayMessage('Install is unsuccessful.', 'error', 'notification', false);
85-
});
76+
.success(function(status) {
77+
self.status = status;
78+
self.action.type = null;
79+
self.displayMessage('Install is successful.', 'success', 'notification', false);
80+
self.reloadRoute();
81+
})
82+
.error(function() {
83+
self.action.message = 'Install is unsuccessful.';
84+
self.action.progressType = 'danger';
85+
//self.displayMessage('Install is unsuccessful.', 'error', 'notification', false);
86+
});
8687
}
8788

8889
function preUninstall() {
@@ -94,18 +95,18 @@
9495

9596
function uninstall() {
9697
return $http.post('api/data-hub/uninstall')
97-
.success(function (status) {
98-
self.status = status;
99-
self.action.type = 'Uninstall';
100-
self.action.message = 'Uninstall is successful.';
101-
//self.displayMessage('Uninstall is successful.', 'success', 'notification', false);
102-
//self.reloadRoute();
103-
})
104-
.error(function () {
105-
self.action.message = 'Uninstall is unsuccessful.';
106-
self.action.progressType = 'danger';
107-
//self.displayMessage('Uninstall is unsuccessful.', 'error', 'notification', false);
108-
});
98+
.success(function(status) {
99+
self.status = status;
100+
self.action.type = 'Uninstall';
101+
self.action.message = 'Uninstall is successful.';
102+
//self.displayMessage('Uninstall is successful.', 'success', 'notification', false);
103+
//self.reloadRoute();
104+
})
105+
.error(function() {
106+
self.action.message = 'Uninstall is unsuccessful.';
107+
self.action.progressType = 'danger';
108+
//self.displayMessage('Uninstall is unsuccessful.', 'error', 'notification', false);
109+
});
109110
}
110111

111112
function installUserModules() {
@@ -129,10 +130,10 @@
129130

130131
function saveEntity(entityForm) {
131132
return $http.post('api/entities', entityForm)
132-
.success(function (status) {
133-
self.status = status;
134-
self.displayMessage('New entity is created successfully.', 'success', 'notification', false);
135-
});
133+
.success(function(status) {
134+
self.status = status;
135+
self.displayMessage('New entity is created successfully.', 'success', 'notification', false);
136+
});
136137
}
137138

138139
function displayEntity(entityName) {
@@ -172,33 +173,41 @@
172173

173174
function saveFlow(flowForm) {
174175
return $http.post('api/flows', flowForm)
175-
.success(function (selectedEntity) {
176-
self.status.selectedEntity = selectedEntity;
177-
self.displayMessage('New flow is created successfully.', 'success', 'notification', false);
178-
});
176+
.success(function(selectedEntity) {
177+
self.status.selectedEntity = selectedEntity;
178+
self.displayMessage('New flow is created successfully.', 'success', 'notification', false);
179+
});
179180
}
180181

181-
function displayMessage(message,messageType,elementId,isModal) {
182-
if(typeof elementId === 'undefined') {
182+
function searchPath(pathPrefix) {
183+
var data = {
184+
path: pathPrefix
185+
};
186+
187+
return $http.post('api/utils/searchPath', data);
188+
}
189+
190+
function displayMessage(message, messageType, elementId, isModal) {
191+
if (typeof elementId === 'undefined') {
183192
elementId = 'messageDiv';
184193
}
185194
var messageClass = 'alert';
186-
if(messageType === 'error') {
195+
if (messageType === 'error') {
187196
messageClass += ' alert-error alert-danger';
188197
} else if (messageType === 'success') {
189198
messageClass += ' alert-success';
190199
} else if (messageType === 'warning') {
191200
messageClass += ' alert-warning';
192201
}
193-
$('#'+elementId).html('<div class="'+messageClass+'">'+
194-
'<a href="dismiss" class="close" data-dismiss="alert">&times;</a>'+message+'</div>');
202+
$('#' + elementId).html('<div class="' + messageClass + '">' +
203+
'<a href="dismiss" class="close" data-dismiss="alert">&times;</a>' + message + '</div>');
195204

196-
if(isModal) {
205+
if (isModal) {
197206
$('.modal-body').scrollTop(0);
198207
} else {
199-
$('#'+elementId).scrollTop(0);
208+
$('#' + elementId).scrollTop(0);
200209
}
201-
setTimeout(function () {
210+
setTimeout(function() {
202211
$('.alert').fadeOut();
203212
}, 5000);
204213
}
@@ -215,7 +224,9 @@
215224
var params = {
216225
'taskId': taskId
217226
};
218-
return $http.get('api/task/wait', {'params': params});
227+
return $http.get('api/task/wait', {
228+
'params': params
229+
});
219230
}
220231

221232
function cancelTask(taskId) {

0 commit comments

Comments
 (0)