Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@
"typescript": "~5.7.3",
"valid-url": "^1.0.9"
},
"type": "module"
"type": "module",
"dependencies": {
"prismjs": "^1.29.0"
}
}
22 changes: 22 additions & 0 deletions src/lib/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ async function invoke (fn, args, fetch) {
return body
}

/**
* @template T
* @param {string} indexId
* @param {string} fn
* @param {Object} args
* @param {fetch} fetch
* @returns {Promise<Api.ResponseLog<T>>}
*/
async function invokeLog (indexId, fn, args, fetch) {
const url = `${indexId}${fn ? ('/' + fn) : ''}${args ? ('?' + args) : ''}`
const resp = await fetch(`${endpoint}/log/${encodeURIComponent(url)}`, {
method: 'POST',
headers: {
'content-type': 'application/json'
}
})

const body = await resp.json()
return body
}

/**
* @param {Function} callback
*/
Expand Down Expand Up @@ -90,6 +111,7 @@ function intervalInvalidate (callback, interval) {

export default {
invoke,
invokeLog,
setOnUnauth,
invalidate: wrapInvalidate,
intervalInvalidate
Expand Down
11 changes: 11 additions & 0 deletions src/lib/format/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ export function datetime (v) {
return dayjs(v).format('YYYY-MM-DD HH:mm:ss')
}

/**
* @param {string} v
* @returns {number}
*/
export function unixDatetime (v) {
if (!v) {
return 0
}
return dayjs(v).unix()
}

/**
* @param {string} project
* @param {string} name
Expand Down
15 changes: 15 additions & 0 deletions src/lib/use-action/clickAway.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default function clickAway (node) {
const handleClick = (event) => {
if (node && !node.contains(event.target) && !event.defaultPrevented) {
node.dispatchEvent(new CustomEvent('clickAway'))
}
}

document.addEventListener('click', handleClick, true)

return {
destroy () {
document.removeEventListener('click', handleClick, true)
}
}
}
17 changes: 17 additions & 0 deletions src/routes/(auth)/(project)/log/+page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export async function load ({ url }) {
const duration = url.searchParams.get('duration') || ''
const startDate = url.searchParams.get('startDate') || ''
const endDate = url.searchParams.get('endDate') || ''
const query = url.searchParams.get('query') || ''
const indexId = url.searchParams.get('indexId') || ''
const endpoint = url.searchParams.get('endpoint') || ''

return {
duration,
startDate,
endDate,
query,
indexId,
endpoint
}
}
Loading
Loading