Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CloWM UI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computational Metagenomics
CloWM
CloWM UI
Merge requests
!85
Resolve "Add UI for viewing and managing Resources"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Add UI for viewing and managing Resources"
feature/88-add-ui-for-viewing-and-managing-resources
into
main
Overview
0
Commits
13
Pipelines
0
Changes
122
Merged
Daniel Göbel
requested to merge
feature/88-add-ui-for-viewing-and-managing-resources
into
main
1 year ago
Overview
0
Commits
13
Pipelines
0
Changes
2
Expand
Closes
#88 (closed)
0
0
Merge request reports
Compare
version 6
version 12
42339a48
1 year ago
version 11
7e30aae7
1 year ago
version 10
5b061e98
1 year ago
version 9
a4f7ad06
1 year ago
version 8
7f52f44d
1 year ago
version 7
cc4fd30e
1 year ago
version 6
7675fe35
1 year ago
version 5
b2a4f374
1 year ago
version 4
a73d2ca1
1 year ago
version 3
adcfd484
1 year ago
version 2
ef04796d
1 year ago
version 1
1bd797d5
1 year ago
main (base)
and
version 7
latest version
cf520d15
13 commits,
1 year ago
version 12
42339a48
12 commits,
1 year ago
version 11
7e30aae7
11 commits,
1 year ago
version 10
5b061e98
10 commits,
1 year ago
version 9
a4f7ad06
9 commits,
1 year ago
version 8
7f52f44d
8 commits,
1 year ago
version 7
cc4fd30e
7 commits,
1 year ago
version 6
7675fe35
6 commits,
1 year ago
version 5
b2a4f374
5 commits,
1 year ago
version 4
a73d2ca1
4 commits,
1 year ago
version 3
adcfd484
3 commits,
1 year ago
version 2
ef04796d
2 commits,
1 year ago
version 1
1bd797d5
1 commit,
1 year ago
Show latest version
2 files
+
136
−
26
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/stores/resources.ts
0 → 100644
+
272
−
0
Options
import
{
defineStore
}
from
"
pinia
"
;
import
type
{
ResourceIn
,
ResourceOut
,
ResourceVersionIn
,
ResourceVersionOut
,
}
from
"
@/client/resource
"
;
import
{
ResourceService
,
ResourceVersionService
,
Status
,
}
from
"
@/client/resource
"
;
import
{
useAuthStore
}
from
"
@/stores/users
"
;
import
{
useNameStore
}
from
"
@/stores/names
"
;
export
const
useResourceStore
=
defineStore
({
id
:
"
resources
"
,
state
:
()
=>
({
resourceMapping
:
{},
ownResourceMapping
:
{},
reviewableResourceMapping
:
{},
})
as
{
resourceMapping
:
Record
<
string
,
ResourceOut
>
;
ownResourceMapping
:
Record
<
string
,
ResourceOut
>
;
reviewableResourceMapping
:
Record
<
string
,
ResourceOut
>
;
},
getters
:
{
resources
():
ResourceOut
[]
{
return
Object
.
values
(
this
.
resourceMapping
);
},
ownResources
():
ResourceOut
[]
{
return
Object
.
values
(
this
.
ownResourceMapping
);
},
reviewableResources
():
ResourceOut
[]
{
return
Object
.
values
(
this
.
reviewableResourceMapping
);
},
},
actions
:
{
fetchResource
(
resource_id
:
string
,
versionStatus
?:
Status
[],
):
Promise
<
ResourceOut
>
{
return
ResourceService
.
resourceGetResource
(
resource_id
,
versionStatus
,
).
then
((
resource
)
=>
{
const
nameStore
=
useNameStore
();
nameStore
.
addNameToMapping
(
resource
.
resource_id
,
resource
.
name
);
for
(
const
version
of
resource
.
versions
)
{
nameStore
.
addNameToMapping
(
version
.
resource_version_id
,
version
.
release
,
);
}
return
resource
;
});
},
fetchResources
(
maintainerId
?:
string
,
versionStatus
?:
Status
[],
searchString
?:
string
,
):
Promise
<
ResourceOut
[]
>
{
return
ResourceService
.
resourceListResources
(
maintainerId
,
versionStatus
,
searchString
,
).
then
((
resources
)
=>
{
const
nameStore
=
useNameStore
();
for
(
const
resource
of
resources
)
{
nameStore
.
addNameToMapping
(
resource
.
resource_id
,
resource
.
name
);
for
(
const
version
of
resource
.
versions
)
{
nameStore
.
addNameToMapping
(
version
.
resource_version_id
,
version
.
release
,
);
}
}
return
resources
;
});
},
fetchReviewableResources
(
onFinally
?:
()
=>
void
):
Promise
<
ResourceOut
[]
>
{
if
(
Object
.
keys
(
this
.
reviewableResourceMapping
).
length
>
0
)
{
onFinally
?.();
}
return
this
.
fetchResources
(
undefined
,
[
Status
.
SYNC_REQUESTED
,
Status
.
SYNCHRONIZING
,
])
.
then
((
resources
)
=>
{
const
newMapping
:
Record
<
string
,
ResourceOut
>
=
{};
for
(
const
resource
of
resources
)
{
newMapping
[
resource
.
resource_id
]
=
resource
;
}
this
.
reviewableResourceMapping
=
newMapping
;
return
resources
;
})
.
finally
(
onFinally
);
},
fetchPublicResources
(
onFinally
?:
()
=>
void
):
Promise
<
ResourceOut
[]
>
{
if
(
this
.
resources
.
length
>
0
)
{
onFinally
?.();
}
return
this
.
fetchResources
()
.
then
((
resources
)
=>
{
const
newMapping
:
Record
<
string
,
ResourceOut
>
=
{};
for
(
const
resource
of
resources
)
{
newMapping
[
resource
.
resource_id
]
=
resource
;
}
this
.
resourceMapping
=
newMapping
;
return
resources
;
})
.
finally
(
onFinally
);
},
fetchOwnResource
(
resource_id
:
string
,
onFinally
?:
()
=>
void
,
):
Promise
<
ResourceOut
>
{
if
(
this
.
ownResourceMapping
[
resource_id
])
{
onFinally
?.();
}
return
this
.
fetchResource
(
resource_id
,
Object
.
values
(
Status
))
.
then
((
resource
)
=>
{
this
.
ownResourceMapping
[
resource
.
resource_id
]
=
resource
;
return
resource
;
})
.
finally
(
onFinally
);
},
fetchOwnResources
(
onFinally
?:
()
=>
void
):
Promise
<
ResourceOut
[]
>
{
const
authStore
=
useAuthStore
();
if
(
this
.
ownResources
.
length
>
0
)
{
onFinally
?.();
}
return
this
.
fetchResources
(
authStore
.
currentUID
,
Object
.
values
(
Status
))
.
then
((
resources
)
=>
{
const
newMapping
:
Record
<
string
,
ResourceOut
>
=
{};
for
(
const
resource
of
resources
)
{
newMapping
[
resource
.
resource_id
]
=
resource
;
}
this
.
ownResourceMapping
=
newMapping
;
return
resources
;
})
.
finally
(
onFinally
);
},
async
createResource
(
resource
:
ResourceIn
):
Promise
<
ResourceOut
>
{
const
createdResource
=
await
ResourceService
.
resourceCreateResource
(
resource
);
this
.
ownResourceMapping
[
createdResource
.
resource_id
]
=
createdResource
;
const
nameStore
=
useNameStore
();
nameStore
.
addNameToMapping
(
createdResource
.
resource_id
,
createdResource
.
name
,
);
nameStore
.
addNameToMapping
(
createdResource
.
versions
[
0
].
resource_version_id
,
createdResource
.
versions
[
0
].
release
,
);
return
createdResource
;
},
requestSynchronization
(
resourceVersion
:
ResourceVersionOut
,
):
Promise
<
ResourceVersionOut
>
{
return
ResourceVersionService
.
resourceVersionRequestResourceVersionSync
(
resourceVersion
.
resource_id
,
resourceVersion
.
resource_version_id
,
).
then
((
changedResourceVersion
)
=>
{
if
(
this
.
ownResourceMapping
[
changedResourceVersion
.
resource_id
]
==
undefined
)
{
this
.
fetchOwnResource
(
resourceVersion
.
resource_id
);
return
changedResourceVersion
;
}
const
versionIndex
=
this
.
ownResourceMapping
[
changedResourceVersion
.
resource_id
].
versions
.
findIndex
(
(
version
)
=>
version
.
resource_version_id
==
changedResourceVersion
.
resource_version_id
,
);
if
(
versionIndex
>
-
1
)
{
this
.
ownResourceMapping
[
changedResourceVersion
.
resource_id
].
versions
[
versionIndex
]
=
changedResourceVersion
;
}
else
{
this
.
ownResourceMapping
[
changedResourceVersion
.
resource_id
].
versions
.
push
(
changedResourceVersion
);
}
return
changedResourceVersion
;
});
},
updateResource
(
resource_id
:
string
,
version
:
ResourceVersionIn
,
):
Promise
<
ResourceVersionOut
>
{
return
ResourceVersionService
.
resourceVersionRequestResourceVersion
(
resource_id
,
version
,
).
then
((
versionOut
)
=>
{
if
(
this
.
ownResourceMapping
[
versionOut
.
resource_id
]
==
undefined
)
{
this
.
fetchOwnResource
(
versionOut
.
resource_id
);
return
versionOut
;
}
useNameStore
().
addNameToMapping
(
versionOut
.
resource_version_id
,
versionOut
.
release
,
);
this
.
ownResourceMapping
[
versionOut
.
resource_id
].
versions
.
push
(
versionOut
,
);
return
versionOut
;
});
},
syncResource
(
resourceVersion
:
ResourceVersionOut
,
):
Promise
<
ResourceVersionOut
>
{
return
ResourceVersionService
.
resourceVersionResourceVersionSync
(
resourceVersion
.
resource_id
,
resourceVersion
.
resource_version_id
,
).
then
((
changedVersion
)
=>
{
if
(
this
.
reviewableResourceMapping
[
changedVersion
.
resource_id
]
==
undefined
)
{
return
changedVersion
;
}
const
versionIndex
=
this
.
reviewableResourceMapping
[
changedVersion
.
resource_id
].
versions
.
findIndex
(
(
version
)
=>
version
.
resource_version_id
==
changedVersion
.
resource_version_id
,
);
if
(
versionIndex
>
-
1
)
{
this
.
reviewableResourceMapping
[
changedVersion
.
resource_id
].
versions
[
versionIndex
]
=
changedVersion
;
}
else
{
this
.
reviewableResourceMapping
[
changedVersion
.
resource_id
].
versions
.
push
(
changedVersion
);
}
return
changedVersion
;
});
},
setLatestResource
(
resourceVersion
:
ResourceVersionOut
,
):
Promise
<
ResourceVersionOut
>
{
return
ResourceVersionService
.
resourceVersionResourceVersionLatest
(
resourceVersion
.
resource_id
,
resourceVersion
.
resource_version_id
,
);
},
deleteOnCluster
(
resourceVersion
:
ResourceVersionOut
,
):
Promise
<
ResourceVersionOut
>
{
return
ResourceVersionService
.
resourceVersionDeleteResourceVersionCluster
(
resourceVersion
.
resource_id
,
resourceVersion
.
resource_version_id
,
);
},
deleteInS3
(
resourceVersion
:
ResourceVersionOut
,
):
Promise
<
ResourceVersionOut
>
{
return
ResourceVersionService
.
resourceVersionDeleteResourceVersionS3
(
resourceVersion
.
resource_id
,
resourceVersion
.
resource_version_id
,
);
},
},
});
Loading