Skip to content

Commit 7b03796

Browse files
committed
added the directory picker on the Load Data Form
1 parent 0bc6982 commit 7b03796

38 files changed

+78060
-193
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: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
69+
/*
70+
71+
public static void main(String[] args) {
72+
new UtilController().searchPathUnix("/");
73+
new UtilController().searchPathUnix("/Users");
74+
new UtilController().searchPathUnix("");
75+
}
76+
*/
77+
}

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: 83 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function () {
1+
(function() {
22

33
'use strict';
44

@@ -27,42 +27,43 @@
2727
runInputFlow: runInputFlow,
2828
testFlow: testFlow,
2929
saveFlow: saveFlow,
30-
displayMessage: displayMessage
30+
displayMessage: displayMessage,
31+
searchPath: searchPath
3132
});
3233

3334
function login(loginForm) {
3435
return $http.post('api/data-hub/login', loginForm)
35-
.success(function (data) {
36-
self.status = data;
37-
if(!self.status.installed) {
38-
self.action.type = 'Install';
39-
self.action.message = 'Install is in progress...';
40-
self.action.progressType = 'success';
41-
}
42-
})
43-
.error(function () {
44-
self.status = null;
45-
});
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+
});
4647
}
4748

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

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

6869
function reloadRoute() {
@@ -71,17 +72,17 @@
7172

7273
function install() {
7374
return $http.post('api/data-hub/install')
74-
.success(function (status) {
75-
self.status = status;
76-
self.action.type = null;
77-
self.displayMessage('Install is successful.', 'success', 'notification', false);
78-
self.reloadRoute();
79-
})
80-
.error(function () {
81-
self.action.message = 'Install is unsuccessful.';
82-
self.action.progressType = 'danger';
83-
//self.displayMessage('Install is unsuccessful.', 'error', 'notification', false);
84-
});
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+
});
8586
}
8687

8788
function preUninstall() {
@@ -93,37 +94,37 @@
9394

9495
function uninstall() {
9596
return $http.post('api/data-hub/uninstall')
96-
.success(function (status) {
97-
self.status = status;
98-
self.action.type = 'Uninstall';
99-
self.action.message = 'Uninstall is successful.';
100-
//self.displayMessage('Uninstall is successful.', 'success', 'notification', false);
101-
//self.reloadRoute();
102-
})
103-
.error(function () {
104-
self.action.message = 'Uninstall is unsuccessful.';
105-
self.action.progressType = 'danger';
106-
//self.displayMessage('Uninstall is unsuccessful.', 'error', 'notification', false);
107-
});
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+
});
108109
}
109110

110111
function installUserModules() {
111112
return $http.post('api/data-hub/install-user-modules')
112-
.success(function (data) {
113-
self.status = data;
114-
self.displayMessage('Deploy to server is successful.', 'success', 'notification', false);
115-
})
116-
.error(function () {
117-
self.displayMessage('Deploy to server is unsuccessful.', 'error', 'notification', false);
118-
});
113+
.success(function(data) {
114+
self.status = data;
115+
self.displayMessage('Deploy to server is successful.', 'success', 'notification', false);
116+
})
117+
.error(function() {
118+
self.displayMessage('Deploy to server is unsuccessful.', 'error', 'notification', false);
119+
});
119120
}
120121

121122
function saveEntity(entityForm) {
122123
return $http.post('api/entities', entityForm)
123-
.success(function (status) {
124-
self.status = status;
125-
self.displayMessage('New entity is created successfully.', 'success', 'notification', false);
126-
});
124+
.success(function(status) {
125+
self.status = status;
126+
self.displayMessage('New entity is created successfully.', 'success', 'notification', false);
127+
});
127128
}
128129

129130
function displayEntity(entityName) {
@@ -163,33 +164,41 @@
163164

164165
function saveFlow(flowForm) {
165166
return $http.post('api/flows', flowForm)
166-
.success(function (selectedEntity) {
167-
self.status.selectedEntity = selectedEntity;
168-
self.displayMessage('New flow is created successfully.', 'success', 'notification', false);
169-
});
167+
.success(function(selectedEntity) {
168+
self.status.selectedEntity = selectedEntity;
169+
self.displayMessage('New flow is created successfully.', 'success', 'notification', false);
170+
});
170171
}
171172

172-
function displayMessage(message,messageType,elementId,isModal) {
173-
if(typeof elementId === 'undefined') {
173+
function searchPath(pathPrefix) {
174+
var data = {
175+
path: pathPrefix
176+
};
177+
178+
return $http.post('api/utils/searchPath', data);
179+
}
180+
181+
function displayMessage(message, messageType, elementId, isModal) {
182+
if (typeof elementId === 'undefined') {
174183
elementId = 'messageDiv';
175184
}
176185
var messageClass = 'alert';
177-
if(messageType === 'error') {
186+
if (messageType === 'error') {
178187
messageClass += ' alert-error alert-danger';
179188
} else if (messageType === 'success') {
180189
messageClass += ' alert-success';
181190
} else if (messageType === 'warning') {
182191
messageClass += ' alert-warning';
183192
}
184-
$('#'+elementId).html('<div class="'+messageClass+'">'+
185-
'<a href="dismiss" class="close" data-dismiss="alert">&times;</a>'+message+'</div>');
193+
$('#' + elementId).html('<div class="' + messageClass + '">' +
194+
'<a href="dismiss" class="close" data-dismiss="alert">&times;</a>' + message + '</div>');
186195

187-
if(isModal) {
196+
if (isModal) {
188197
$('.modal-body').scrollTop(0);
189198
} else {
190-
$('#'+elementId).scrollTop(0);
199+
$('#' + elementId).scrollTop(0);
191200
}
192-
setTimeout(function () {
201+
setTimeout(function() {
193202
$('.alert').fadeOut();
194203
}, 5000);
195204
}
@@ -206,7 +215,9 @@
206215
var params = {
207216
'taskId': taskId
208217
};
209-
return $http.get('api/task/wait', {'params': params});
218+
return $http.get('api/task/wait', {
219+
'params': params
220+
});
210221
}
211222

212223
function cancelTask(taskId) {

0 commit comments

Comments
 (0)