Commit ae7d5a44 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Renamed recallFromTape to AsyncRecall, handled icons and button visibility

parent 85b0e02d
Loading
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -13,24 +13,25 @@ public class NodeInfo {

    private final String authority;

    private final Node node;

    private final String path;
    private final String name;
    private final String size;
    private final String type;
    private final String groupRead;
    private final String groupWrite;
    private final boolean isPublic;
    private final boolean asyncTrans;

    public NodeInfo(Node node, String authority) {
        this.authority = authority;
        this.node = node;
        this.path = getPath(node);
        this.name = path.substring(path.lastIndexOf("/") + 1);
        this.size = getSize(node);
        this.type = node.getType();
        this.groupRead = getGroupRead(node);
        this.groupWrite = getGroupWrite(node);
        this.isPublic = isPublic(node);
        this.asyncTrans = isAsyncTrans(node);
    }

    private String getPath(Node node) {
@@ -55,7 +56,11 @@ public class NodeInfo {
    }

    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) {
@@ -97,8 +102,12 @@ public class NodeInfo {
        return String.format("%.1f %cB", bytes / 1024f, " kMGTPE".charAt(u));
    }

    public String getType() {
        return node.getType();
    public boolean isFolder() {
        return "vos:ContainerNode".equals(type);
    }

    public boolean isFile() {
        return !"vos:ContainerNode".equals(type);
    }

    public String getPath() {
@@ -124,4 +133,8 @@ public class NodeInfo {
    public boolean isPublic() {
        return isPublic;
    }

    public boolean isAsyncTrans() {
        return asyncTrans;
    }
}
+13 −3
Original line number Diff line number Diff line
@@ -54,7 +54,11 @@ public class NodesService {
        }

        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>" + nodeInfo.getSize() + "</td>";
        html += "<td>" + nodeInfo.getGroupRead() + "</td>";
@@ -65,18 +69,21 @@ public class NodesService {

    private String getIcon(NodeInfo nodeInfo) {
        String html = "<span class=\"icon ";
        if ("vos:ContainerNode".equals(nodeInfo.getType())) {
        if (nodeInfo.isFolder()) {
            html += "folder";
        } else {
            html += "file";
        }
        if (nodeInfo.isAsyncTrans()) {
            html += "-x";
        }
        html += "-icon\"></span>&nbsp;";
        return html;
    }

    private String getLink(NodeInfo nodeInfo) {
        if (isDownloadable(nodeInfo)) {
            if ("vos:ContainerNode".equals(nodeInfo.getType())) {
            if (nodeInfo.isFolder()) {
                return "<a href=\"#/nodes" + nodeInfo.getPath() + "\">" + nodeInfo.getName() + "</a>";
            } else {
                return "<a href=\"download" + nodeInfo.getPath() + "\" target=\"blank_\">" + nodeInfo.getName() + "</a>";
@@ -86,6 +93,9 @@ public class NodesService {
    }

    private boolean isDownloadable(NodeInfo nodeInfo) {
        if (nodeInfo.isFile() && nodeInfo.isAsyncTrans()) {
            return false;
        }
        if (nodeInfo.isPublic()) {
            return true;
        }
+2 −2
Original line number Diff line number Diff line
<tbody id="nodes">
  <tr>
    <td><input type="checkbox" class="tape" data-node="/folder1/folder2" /></td>
    <td><input type="checkbox" class="async" data-node="/folder1/folder2" /></td>
    <td>
      <span class="icon folder-x-icon"></span>
      <a href="#/nodes/folder1/folder2">folder2</a>
@@ -20,7 +20,7 @@
    <td>group2</td>
  </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>
      <span class="icon file-x-icon"></span>
      file3
+2 −2
Original line number Diff line number Diff line
<tbody id="nodes">
  <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>
      <span class="icon file-x-icon"></span>
      file4
@@ -10,7 +10,7 @@
    <td>group2</td>
  </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>
      <span class="icon file-x-icon"></span>
      file5
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ export default {
    }
    return fetch(response);
  },
  startRecallFromTapeJob() {
  startAsyncRecallJob() {
    return fetch(job);
  },
  loadJobs() {
Loading