Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F77468083
result.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Aug 14, 16:08
Size
1 KB
Mime Type
text/x-java
Expires
Fri, Aug 16, 16:08 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19875169
Attached To
R12546 Sesame - Configurator
result.js
View Options
import
axios
from
'axios'
;
import
{
defineStore
}
from
'pinia'
;
import
{
ref
,
computed
}
from
'vue'
;
import
{
upload
,
genericFetch
,
genericAdd
,
genericRemove
}
from
'./utils'
;
const
uploadResult
=
async
({
url
,
...
rest
})
=>
{
const
relPath
=
await
upload
(
'result'
,
'result'
,
url
);
return
{
...
rest
,
url
:
relPath
};
};
export
const
useResultStore
=
defineStore
(
'result'
,
()
=>
{
const
results
=
ref
([]);
const
experiences
=
ref
([]);
// not process.env because we use VITE and not vue cli
const
endpointURL
=
import
.
meta
.
env
.
VITE_API_URL
+
'/results'
;
const
expURL
=
import
.
meta
.
env
.
VITE_API_URL
+
'/experiences'
;
const
fetchResults
=
genericFetch
(
endpointURL
,
results
);
const
fetchExperiences
=
genericFetch
(
expURL
,
experiences
);
const
getResultsByExp
=
computed
(()
=>
(
expId
)
=>
results
.
value
.
filter
(
res
=>
res
.
ExperienceId
===
expId
)
);
const
getDateStirng
=
computed
(()
=>
id
=>
{
const
res
=
results
.
value
.
find
(
res
=>
res
.
id
===
id
);
if
(
!
res
)
return
''
return
(
new
Date
(
res
.
timestamp
))
.
toLocaleString
(
'fr-CH'
,{
dateStyle
:
'short'
,
timeStyle
:
'short'
})
}
);
return
{
results
,
experiences
,
fetchResults
,
fetchExperiences
,
getResultsByExp
,
getDateStirng
,
add
:
genericAdd
(
endpointURL
,
fetchResults
,
uploadResult
),
remove
:
genericRemove
(
endpointURL
,
fetchResults
)
};
});
Event Timeline
Log In to Comment