Skip to content

Commit

Permalink
WIP #1245 Update ArtifactIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
brollb committed Oct 10, 2019
1 parent 9014cee commit 80872f4
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/visualizers/panels/ArtifactIndex/ArtifactIndexControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
/*jshint browser: true*/

define([
'deepforge/storage/index',
'blob/BlobClient',
'js/Constants'
], function (
Storage,
BlobClient,
CONSTANTS
) {
Expand Down Expand Up @@ -88,30 +90,27 @@ define([
};

// This next function retrieves the relevant node information for the widget
ArtifactIndexControl.prototype._getObjectDescriptor = function (nodeId) {
var node = this._client.getNode(nodeId),
type,
hash,
objDescriptor;
ArtifactIndexControl.prototype._getObjectDescriptor = async function (nodeId) {
const node = this._client.getNode(nodeId);

if (node) {
type = node.getAttribute('type');
hash = node.getAttribute('data');
objDescriptor = {
const type = node.getAttribute('type');
const dataInfo = JSON.parse(node.getAttribute('data'));
const metadata = await Storage.getMetadata(this._logger, dataInfo);
const url = await Storage.getDownloadURL(this._logger, dataInfo);
const size = this._humanFileSize(metadata.size);

return {
id: node.getId(),
type: type,
name: node.getAttribute('name'),
createdAt: node.getAttribute('createdAt'),
dataURL: this.blobClient.getDownloadURL(hash),
parentId: node.getParentId()
dataURL: url,
parentId: node.getParentId(),
size: size
};
}

return this.blobClient.getMetadata(hash)
.then(metadata => {
objDescriptor.size = this._humanFileSize(metadata.size);
return objDescriptor;
});
};

ArtifactIndexControl.prototype._humanFileSize = function (bytes, si) {
Expand Down

0 comments on commit 80872f4

Please sign in to comment.