mirror of https://github.com/perkeep/perkeep.git
newui: BlobItemContainer can show results from ServerConnection recent blobs
Change-Id: I9784dc6462309a08fe7cb0a6ff8fe9283f9967ef
This commit is contained in:
parent
0c02bc194a
commit
dd5e72cb27
|
@ -112,6 +112,11 @@ camlistore.BlobItemContainer.prototype.showRecent_ = function() {
|
|||
* @param {Object} result JSON response to this request.
|
||||
*/
|
||||
camlistore.BlobItemContainer.prototype.showRecentDone_ = function(result) {
|
||||
console.log('Done getting blobs');
|
||||
console.log(result);
|
||||
this.removeChildren(true);
|
||||
|
||||
for (var i = 0, n = result.recent.length; i < n; i++) {
|
||||
var blobRef = result.recent[i].blobref;
|
||||
var item = new camlistore.BlobItem(blobRef, result);
|
||||
this.addChild(item, true);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -13,32 +13,90 @@
|
|||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var blobRef = 'sha1-5660088af0aa0d4f2294088f41284002a1baaa29';
|
||||
var metaBag = {
|
||||
'sha1-5660088af0aa0d4f2294088f41284002a1baaa29': {
|
||||
'blobRef': 'sha1-5660088af0aa0d4f2294088f41284002a1baaa29',
|
||||
'camliType': 'permanode',
|
||||
'mimeType': 'application/json; camliType=permanode',
|
||||
'permanode': {
|
||||
'attr': {
|
||||
'camliContent': ['sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725']
|
||||
// Mock response from:
|
||||
// http://127.0.0.1:3179/my-search/camli/search/recent?thumbnails=100
|
||||
var recentBlobResponse = {
|
||||
"recent": [
|
||||
{
|
||||
"blobref": "sha1-5660088af0aa0d4f2294088f41284002a1baaa29",
|
||||
"modtime": "2012-12-23T19:53:32Z",
|
||||
"owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4"
|
||||
},
|
||||
{
|
||||
"blobref": "sha1-3ced53f0a11115e98d6e40ca4558680f2768f23e",
|
||||
"modtime": "2012-12-23T19:19:37Z",
|
||||
"owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4"
|
||||
},
|
||||
{
|
||||
"blobref": "sha1-19236d4922116d03738f1c8c6d9f14debbab798b",
|
||||
"modtime": "2012-12-23T19:19:37Z",
|
||||
"owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4"
|
||||
}
|
||||
],
|
||||
"sha1-19236d4922116d03738f1c8c6d9f14debbab798b": {
|
||||
"blobRef": "sha1-19236d4922116d03738f1c8c6d9f14debbab798b",
|
||||
"camliType": "permanode",
|
||||
"mimeType": "application/json; camliType=permanode",
|
||||
"permanode": {
|
||||
"attr": {
|
||||
"camliRoot": [
|
||||
"dev-pics-root"
|
||||
],
|
||||
"title": [
|
||||
"Publish root node for dev-pics-root"
|
||||
]
|
||||
}
|
||||
},
|
||||
'size': 556,
|
||||
'thumbnailHeight': 100,
|
||||
'thumbnailSrc': 'thumbnail/sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725/leisure-suit-tony.gif?mw=100&mh=100',
|
||||
'thumbnailWidth': 100
|
||||
"size": 562,
|
||||
"thumbnailHeight": 100,
|
||||
"thumbnailSrc": "node.png",
|
||||
"thumbnailWidth": 100
|
||||
},
|
||||
'sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725': {
|
||||
'blobRef': 'sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725',
|
||||
'camliType': 'file',
|
||||
'file': {
|
||||
'size': 37741,
|
||||
'fileName': 'leisure-suit-tony.gif',
|
||||
'mimeType': 'image/gif'
|
||||
"sha1-3ced53f0a11115e98d6e40ca4558680f2768f23e": {
|
||||
"blobRef": "sha1-3ced53f0a11115e98d6e40ca4558680f2768f23e",
|
||||
"camliType": "permanode",
|
||||
"mimeType": "application/json; camliType=permanode",
|
||||
"permanode": {
|
||||
"attr": {
|
||||
"camliRoot": [
|
||||
"dev-blog-root"
|
||||
],
|
||||
"title": [
|
||||
"Publish root node for dev-blog-root"
|
||||
]
|
||||
}
|
||||
},
|
||||
'mimeType': 'application/json; camliType=file',
|
||||
'size': 198
|
||||
"size": 562,
|
||||
"thumbnailHeight": 100,
|
||||
"thumbnailSrc": "node.png",
|
||||
"thumbnailWidth": 100
|
||||
},
|
||||
"sha1-5660088af0aa0d4f2294088f41284002a1baaa29": {
|
||||
"blobRef": "sha1-5660088af0aa0d4f2294088f41284002a1baaa29",
|
||||
"camliType": "permanode",
|
||||
"mimeType": "application/json; camliType=permanode",
|
||||
"permanode": {
|
||||
"attr": {
|
||||
"camliContent": [
|
||||
"sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725"
|
||||
]
|
||||
}
|
||||
},
|
||||
"size": 556,
|
||||
"thumbnailHeight": 100,
|
||||
"thumbnailSrc": "thumbnail/sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725/leisure-suit-tony.gif?mw=100&mh=100",
|
||||
"thumbnailWidth": 100
|
||||
},
|
||||
"sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725": {
|
||||
"blobRef": "sha1-c2379bcf77848c90d2c83709aaf7f628a21ff725",
|
||||
"camliType": "file",
|
||||
"file": {
|
||||
"size": 37741,
|
||||
"fileName": "leisure-suit-tony.gif",
|
||||
"mimeType": "image/gif"
|
||||
},
|
||||
"mimeType": "application/json; camliType=file",
|
||||
"size": 198
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -51,19 +109,12 @@
|
|||
|
||||
var container = new camlistore.BlobItemContainer(connection);
|
||||
container.render(document.body);
|
||||
for (var i = 0; i < 10; i++) {
|
||||
container.addChild(new camlistore.BlobItem(blobRef, metaBag), true);
|
||||
}
|
||||
|
||||
goog.events.dispatchEvent(
|
||||
container, camlistore.BlobItemContainer.EventType.SHOW_RECENT);
|
||||
|
||||
var request = goog.testing.net.XhrIo.getSendInstances().pop();
|
||||
request.simulateResponse(
|
||||
200,
|
||||
JSON.stringify({
|
||||
foo: 123
|
||||
}));
|
||||
request.simulateResponse(200, JSON.stringify(recentBlobResponse));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue