Skip to content
Snippets Groups Projects
Commit ae7d5a44 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Renamed recallFromTape to AsyncRecall, handled icons and button visibility

parent 85b0e02d
No related branches found
No related tags found
No related merge requests found
Pipeline #897 passed
...@@ -13,24 +13,25 @@ public class NodeInfo { ...@@ -13,24 +13,25 @@ public class NodeInfo {
private final String authority; private final String authority;
private final Node node;
private final String path; private final String path;
private final String name; private final String name;
private final String size; private final String size;
private final String type;
private final String groupRead; private final String groupRead;
private final String groupWrite; private final String groupWrite;
private final boolean isPublic; private final boolean isPublic;
private final boolean asyncTrans;
public NodeInfo(Node node, String authority) { public NodeInfo(Node node, String authority) {
this.authority = authority; this.authority = authority;
this.node = node;
this.path = getPath(node); this.path = getPath(node);
this.name = path.substring(path.lastIndexOf("/") + 1); this.name = path.substring(path.lastIndexOf("/") + 1);
this.size = getSize(node); this.size = getSize(node);
this.type = node.getType();
this.groupRead = getGroupRead(node); this.groupRead = getGroupRead(node);
this.groupWrite = getGroupWrite(node); this.groupWrite = getGroupWrite(node);
this.isPublic = isPublic(node); this.isPublic = isPublic(node);
this.asyncTrans = isAsyncTrans(node);
} }
private String getPath(Node node) { private String getPath(Node node) {
...@@ -55,7 +56,11 @@ public class NodeInfo { ...@@ -55,7 +56,11 @@ public class NodeInfo {
} }
private boolean isPublic(Node node) { private boolean isPublic(Node node) {
return Boolean.parseBoolean(getProperty(node, "ivo://ivoa.net/vospace/core#ispublic").orElse("false")); return getProperty(node, "ivo://ivoa.net/vospace/core#ispublic").map(value -> "t".equals(value)).orElse(false);
}
private boolean isAsyncTrans(Node node) {
return getProperty(node, "urn:async_trans").map(value -> "t".equals(value)).orElse(false);
} }
private Optional<String> getProperty(Node node, String uri) { private Optional<String> getProperty(Node node, String uri) {
...@@ -97,8 +102,12 @@ public class NodeInfo { ...@@ -97,8 +102,12 @@ public class NodeInfo {
return String.format("%.1f %cB", bytes / 1024f, " kMGTPE".charAt(u)); return String.format("%.1f %cB", bytes / 1024f, " kMGTPE".charAt(u));
} }
public String getType() { public boolean isFolder() {
return node.getType(); return "vos:ContainerNode".equals(type);
}
public boolean isFile() {
return !"vos:ContainerNode".equals(type);
} }
public String getPath() { public String getPath() {
...@@ -124,4 +133,8 @@ public class NodeInfo { ...@@ -124,4 +133,8 @@ public class NodeInfo {
public boolean isPublic() { public boolean isPublic() {
return isPublic; return isPublic;
} }
public boolean isAsyncTrans() {
return asyncTrans;
}
} }
...@@ -54,7 +54,11 @@ public class NodesService { ...@@ -54,7 +54,11 @@ public class NodesService {
} }
String html = "<tr>"; String html = "<tr>";
html += "<td><input type=\"checkbox\" data-node=\"" + nodeInfo.getPath() + "\" /></td>"; html += "<td><input type=\"checkbox\" data-node=\"" + nodeInfo.getPath() + "\" ";
if (nodeInfo.isAsyncTrans()) {
html += "class=\"async\"";
}
html += "/></td>";
html += "<td>" + getIcon(nodeInfo) + getLink(nodeInfo) + "</td>"; html += "<td>" + getIcon(nodeInfo) + getLink(nodeInfo) + "</td>";
html += "<td>" + nodeInfo.getSize() + "</td>"; html += "<td>" + nodeInfo.getSize() + "</td>";
html += "<td>" + nodeInfo.getGroupRead() + "</td>"; html += "<td>" + nodeInfo.getGroupRead() + "</td>";
...@@ -65,18 +69,21 @@ public class NodesService { ...@@ -65,18 +69,21 @@ public class NodesService {
private String getIcon(NodeInfo nodeInfo) { private String getIcon(NodeInfo nodeInfo) {
String html = "<span class=\"icon "; String html = "<span class=\"icon ";
if ("vos:ContainerNode".equals(nodeInfo.getType())) { if (nodeInfo.isFolder()) {
html += "folder"; html += "folder";
} else { } else {
html += "file"; html += "file";
} }
if (nodeInfo.isAsyncTrans()) {
html += "-x";
}
html += "-icon\"></span>&nbsp;"; html += "-icon\"></span>&nbsp;";
return html; return html;
} }
private String getLink(NodeInfo nodeInfo) { private String getLink(NodeInfo nodeInfo) {
if (isDownloadable(nodeInfo)) { if (isDownloadable(nodeInfo)) {
if ("vos:ContainerNode".equals(nodeInfo.getType())) { if (nodeInfo.isFolder()) {
return "<a href=\"#/nodes" + nodeInfo.getPath() + "\">" + nodeInfo.getName() + "</a>"; return "<a href=\"#/nodes" + nodeInfo.getPath() + "\">" + nodeInfo.getName() + "</a>";
} else { } else {
return "<a href=\"download" + nodeInfo.getPath() + "\" target=\"blank_\">" + nodeInfo.getName() + "</a>"; return "<a href=\"download" + nodeInfo.getPath() + "\" target=\"blank_\">" + nodeInfo.getName() + "</a>";
...@@ -86,6 +93,9 @@ public class NodesService { ...@@ -86,6 +93,9 @@ public class NodesService {
} }
private boolean isDownloadable(NodeInfo nodeInfo) { private boolean isDownloadable(NodeInfo nodeInfo) {
if (nodeInfo.isFile() && nodeInfo.isAsyncTrans()) {
return false;
}
if (nodeInfo.isPublic()) { if (nodeInfo.isPublic()) {
return true; return true;
} }
......
<tbody id="nodes"> <tbody id="nodes">
<tr> <tr>
<td><input type="checkbox" class="tape" data-node="/folder1/folder2" /></td> <td><input type="checkbox" class="async" data-node="/folder1/folder2" /></td>
<td> <td>
<span class="icon folder-x-icon"></span> <span class="icon folder-x-icon"></span>
<a href="#/nodes/folder1/folder2">folder2</a> <a href="#/nodes/folder1/folder2">folder2</a>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<td>group2</td> <td>group2</td>
</tr> </tr>
<tr> <tr>
<td><input type="checkbox" class="tape" data-node="/folder1/file3" /></td> <td><input type="checkbox" class="async" data-node="/folder1/file3" /></td>
<td> <td>
<span class="icon file-x-icon"></span> <span class="icon file-x-icon"></span>
file3 file3
......
<tbody id="nodes"> <tbody id="nodes">
<tr> <tr>
<td><input type="checkbox" class="tape" data-node="/folder1/folder2/file4" /></td> <td><input type="checkbox" class="async" data-node="/folder1/folder2/file4" /></td>
<td> <td>
<span class="icon file-x-icon"></span> <span class="icon file-x-icon"></span>
file4 file4
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<td>group2</td> <td>group2</td>
</tr> </tr>
<tr> <tr>
<td><input type="checkbox" class="tape" data-node="/folder1/folder2/file5" /></td> <td><input type="checkbox" class="async" data-node="/folder1/folder2/file5" /></td>
<td> <td>
<span class="icon file-x-icon"></span> <span class="icon file-x-icon"></span>
file5 file5
......
...@@ -37,7 +37,7 @@ export default { ...@@ -37,7 +37,7 @@ export default {
} }
return fetch(response); return fetch(response);
}, },
startRecallFromTapeJob() { startAsyncRecallJob() {
return fetch(job); return fetch(job);
}, },
loadJobs() { loadJobs() {
......
...@@ -73,7 +73,7 @@ export default { ...@@ -73,7 +73,7 @@ export default {
} }
}, false, false); }, false, false);
}, },
startRecallFromTapeJob(paths) { startAsyncRecallJob(paths) {
let url = BASE_API_URL + 'recall'; let url = BASE_API_URL + 'recall';
return apiRequest({ return apiRequest({
method: 'POST', method: 'POST',
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="mb-3"> <div class="mb-3">
<b-button variant="success" class="mr-2" :disabled="false" v-b-modal.create-folder-modal>New folder</b-button> <b-button variant="success" class="mr-2" :disabled="false" v-b-modal.create-folder-modal>New folder</b-button>
<b-button variant="success" class="mr-2" :disabled="false" v-b-modal.upload-files-modal>Upload files</b-button> <b-button variant="success" class="mr-2" :disabled="false" v-b-modal.upload-files-modal>Upload files</b-button>
<b-button variant="primary" class="mr-2" v-if="tapeButtonEnabled" @click="startRecallFromTapeJob">Recall from tape</b-button> <b-button variant="primary" class="mr-2" v-if="asyncButtonEnabled" @click="startAsyncRecallJob">Async recall</b-button>
</div> </div>
<b-card> <b-card>
<table class="table b-table table-striped table-hover"> <table class="table b-table table-striped table-hover">
...@@ -62,8 +62,8 @@ export default { ...@@ -62,8 +62,8 @@ export default {
} }
return items; return items;
}, },
tapeButtonEnabled() { asyncButtonEnabled() {
return this.$store.state.tapeButtonEnabled || true; // temporary always true return this.$store.state.asyncButtonEnabled;
} }
}, },
created() { created() {
...@@ -88,8 +88,8 @@ export default { ...@@ -88,8 +88,8 @@ export default {
this.$store.dispatch('computeButtonVisibility'); this.$store.dispatch('computeButtonVisibility');
}); });
}, },
startRecallFromTapeJob() { startAsyncRecallJob() {
this.$store.dispatch('startRecallFromTapeJob'); this.$store.dispatch('startAsyncRecallJob');
} }
} }
} }
......
...@@ -11,7 +11,7 @@ export default new Vuex.Store({ ...@@ -11,7 +11,7 @@ export default new Vuex.Store({
state: { state: {
path: '', path: '',
loading: true, loading: true,
tapeButtonEnabled: false, asyncButtonEnabled: false,
jobs: [], jobs: [],
user: 'anonymous' user: 'anonymous'
}, },
...@@ -25,8 +25,8 @@ export default new Vuex.Store({ ...@@ -25,8 +25,8 @@ export default new Vuex.Store({
} }
state.path = value; state.path = value;
}, },
setTapeButtonEnabled(state, value) { setAsyncButtonEnabled(state, value) {
state.tapeButtonEnabled = value; state.asyncButtonEnabled = value;
}, },
setJobs(state, jobs) { setJobs(state, jobs) {
// empty the array // empty the array
...@@ -59,15 +59,15 @@ export default new Vuex.Store({ ...@@ -59,15 +59,15 @@ export default new Vuex.Store({
}); });
}, },
computeButtonVisibility({ commit }) { computeButtonVisibility({ commit }) {
commit('setTapeButtonEnabled', document.querySelectorAll('#nodes input.tape:checked').length > 0); commit('setAsyncButtonEnabled', document.querySelectorAll('#nodes input.async:checked').length > 0);
}, },
startRecallFromTapeJob({ commit }) { startAsyncRecallJob({ commit }) {
let tapeCheckboxes = document.querySelectorAll('#nodes input:checked'); // temporary: it should be input.tape let asyncCheckboxes = document.querySelectorAll('#nodes input.async:checked');
let paths = []; let paths = [];
for (let i = 0; i < tapeCheckboxes.length; i++) { for (let i = 0; i < asyncCheckboxes.length; i++) {
paths.push(tapeCheckboxes[i].getAttribute('data-node')); paths.push(asyncCheckboxes[i].getAttribute('data-node'));
} }
client.startRecallFromTapeJob(paths) client.startAsyncRecallJob(paths)
.then(job => { .then(job => {
main.showInfo('Job started'); main.showInfo('Job started');
commit('addJob', job); commit('addJob', job);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment