IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
瀏覽代碼

Added WBCommonFields.

pull/1/head
父節點
當前提交
0b1afd95de
共有 5 個文件被更改,包括 117 次插入1 次删除
  1. +92
    -0
      frontend/src/js/component/wb-common-fields.js
  2. +11
    -0
      frontend/src/js/misc/arvados-object-name.js
  3. +4
    -1
      frontend/src/js/misc/arvados-type-name.js
  4. +6
    -0
      frontend/src/js/misc/wb-format-date.js
  5. +4
    -0
      frontend/src/js/page/wb-process-view.js

+ 92
- 0
frontend/src/js/component/wb-common-fields.js 查看文件

@@ -0,0 +1,92 @@
import { h, Component } from 'preact';
import WBTable from 'wb-table';
import makeArvadosRequest from 'make-arvados-request';
import arvadosTypeName from 'arvados-type-name';
import arvadosObjectName from 'arvados-object-name';
import urlForObject from 'url-for-object';
import wbFormatDate from 'wb-format-date';
class WBCommonFields extends Component {
componentDidMount() {
this.prepareRows();
}
componentWillReceiveProps(nextProps) {
this.props = nextProps;
// this.setState({ 'rows': null });
this.prepareRows();
}
prepareRows() {
let { uuid, app } = this.props;
let { arvHost, arvToken } = app.state;
let item;
let owner;
let modifiedByUser;
let prom = makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/' + arvadosTypeName(uuid) +
's/' + uuid);
prom = prom.then(xhr => (item = xhr.response));
prom = prom.then(() => makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/' + arvadosTypeName(item.owner_uuid) +
's/' + item.owner_uuid));
prom = prom.then(xhr => (owner = xhr.response));
prom = prom.then(() => makeArvadosRequest(arvHost, arvToken,
'/arvados/v1/users/' + item.modified_by_user_uuid));
prom = prom.then(xhr => (modifiedByUser = xhr.response));
prom = prom.then(() => {
let rows = [
[ 'UUID', item.uuid ],
[ 'Kind', item.kind ],
[ 'Owner', (
<div>
<div>
<a href={ urlForObject(owner) }>{ arvadosObjectName(owner) }</a>
</div>
<div>
{ item.owner_uuid }
</div>
</div>
) ],
[ 'Created at', wbFormatDate(item.created_at) ],
[ 'Modified at', wbFormatDate(item.modified_at) ],
[ 'Modified by User', (
<div>
<div>
<a href={ urlForObject(modifiedByUser) }>{ arvadosObjectName(modifiedByUser) }</a>
</div>
<div>
{ item.modified_by_user_uuid }
</div>
</div>
) ],
[ 'Modified by Client', item.modified_by_client_uuid ],
[ 'API Url', 'https://' + app.state.arvHost + '/arvados/v1' + item.href ],
[ 'ETag', item.etag ]
];
this.setState({ 'rows': rows });
});
}
render({}, { rows }) {
return (
<div>
<h1>Common Fields</h1>
{ rows ? (
<WBTable columns={ [ "Name", "Value" ] }
rows={ rows } />
) : <div>Loading...</div> }
</div>
);
}
}
export default WBCommonFields;

+ 11
- 0
frontend/src/js/misc/arvados-object-name.js 查看文件

@@ -0,0 +1,11 @@
import arvadosTypeName from 'arvados-type-name';
function arvadosObjectName(item) {
let typeName = arvadosTypeName(item['uuid']);
if (typeName === 'user')
return (item.first_name + ' ' + item.last_name);
else
return item.name;
}
export default arvadosObjectName;

+ 4
- 1
frontend/src/js/misc/arvados-type-name.js 查看文件

@@ -9,7 +9,10 @@ const typeIdToName = {
};
function arvadosTypeName(id) {
return typeIdToName[id];
if (id.length === 5)
return typeIdToName[id];
else
return typeIdToName[id.split('-')[1]];
}
export default arvadosTypeName;

+ 6
- 0
frontend/src/js/misc/wb-format-date.js 查看文件

@@ -0,0 +1,6 @@
function wbFormatDate(dateStr) {
let date = new Date(dateStr);
return date.toLocaleString();
}
export default wbFormatDate;

+ 4
- 0
frontend/src/js/page/wb-process-view.js 查看文件

@@ -6,6 +6,7 @@ import detectUuids from 'detect-uuids';
import arvadosTypeName from 'arvados-type-name';
import urlForObject from 'url-for-object';
import detectHashes from 'detect-hashes';
import WBCommonFields from 'wb-common-fields';
class WBProcessView extends Component {
constructor(...args) {
@@ -86,6 +87,9 @@ class WBProcessView extends Component {
<div class="my-2">
This is the process view for { uuid }
</div>
<WBCommonFields app={ app } uuid={ uuid } />
<div>
<a href="/browse">Click here</a>
</div>


Loading…
取消
儲存