timeline output
This commit is contained in:
parent
05413ad9f8
commit
c5dc81d363
101 changed files with 13735 additions and 0 deletions
73
app/static/timeline/index.js
Normal file
73
app/static/timeline/index.js
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
async function api(action, data) {
|
||||
var url = prefix + '/api/'
|
||||
var key = JSON.stringify([action, data])
|
||||
if (!cache[key]) {
|
||||
var response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({
|
||||
action: action,
|
||||
data: data
|
||||
})
|
||||
})
|
||||
cache[key] = await response.json()
|
||||
}
|
||||
return cache[key]
|
||||
}
|
||||
|
||||
async function getCase(value) {
|
||||
var conditions = [
|
||||
{'key': 'case', 'operator': '==', 'value': value}
|
||||
]
|
||||
return await api('findDocuments', {
|
||||
"query":{
|
||||
"conditions":conditions,
|
||||
"operator":"&"
|
||||
},
|
||||
"range":[0, 10000],
|
||||
"keys": ["title", "date", "case", "id"]
|
||||
}).then(response => {
|
||||
var documents = response.data.items
|
||||
var events = documents.map(data => {
|
||||
var date = data.date.split('-')
|
||||
var event = {
|
||||
"start_date": {
|
||||
"year": date[0],
|
||||
"month": date[1],
|
||||
"day": date[2],
|
||||
"hour": "",
|
||||
"minute": "",
|
||||
"second": "",
|
||||
"millisecond": "",
|
||||
"format": ""
|
||||
},
|
||||
"end_date": {
|
||||
"year": date[0],
|
||||
"month": date[1],
|
||||
"day": date[2],
|
||||
"hour": "",
|
||||
"minute": "",
|
||||
"second": "",
|
||||
"millisecond": "",
|
||||
"format": ""
|
||||
},
|
||||
"media": {
|
||||
"caption": data['title'],
|
||||
"credit": "",
|
||||
"url": mediaPrefix + "/documents/" + data.id + "/512p.jpg"
|
||||
},
|
||||
"text": {
|
||||
"headline": data.title,
|
||||
"text": data.description || data.title
|
||||
},
|
||||
"unique_id": data.id
|
||||
};
|
||||
return event
|
||||
})
|
||||
return {'events': events}
|
||||
})
|
||||
}
|
||||
|
||||
async function loadData(value) {
|
||||
return await getCase(value)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue