Skip to content
Snippets Groups Projects
Verified Commit b87147e3 authored by Martin Weise's avatar Martin Weise
Browse files

Updated the filter

parent 353bf900
No related branches found
No related tags found
Loading
......@@ -5,6 +5,7 @@ import at.tuwien.api.error.ApiErrorDto;
import at.tuwien.entities.container.Container;
import at.tuwien.entities.database.Database;
import at.tuwien.entities.database.DatabaseAccess;
import at.tuwien.entities.identifier.IdentifierStatusType;
import at.tuwien.entities.user.User;
import at.tuwien.exception.*;
import at.tuwien.mapper.MetadataMapper;
......@@ -534,6 +535,10 @@ public class DatabaseEndpoint extends AbstractEndpoint {
log.trace("authenticated user {} is not owner: remove access list", principal.getName());
database.setAccesses(List.of());
}
database.setIdentifiers(database.getIdentifiers()
.stream()
.filter(i -> i.getStatus().equals(IdentifierStatusType.DRAFT) && i.getOwnedBy().equals(getId(principal)) || i.getStatus().equals(IdentifierStatusType.PUBLISHED))
.toList());
} else {
if (!database.getIsPublic() && !database.getIsSchemaPublic()) {
log.error("Failed to find database: not public and not authenticated");
......@@ -551,6 +556,10 @@ public class DatabaseEndpoint extends AbstractEndpoint {
.filter(v -> !v.getIsPublic() && !v.getIsSchemaPublic())
.toList());
database.setAccesses(List.of());
database.setIdentifiers(database.getIdentifiers()
.stream()
.filter(i -> i.getStatus().equals(IdentifierStatusType.PUBLISHED))
.toList());
}
final DatabaseDto dto = metadataMapper.databaseToDatabaseDto(database);
final HttpHeaders headers = new HttpHeaders();
......
......@@ -16,6 +16,8 @@
</template>
<script>
import {useCacheStore} from "~/stores/cache.js";
export default {
props: {
resource: {
......@@ -34,6 +36,11 @@ export default {
}
}
},
data () {
return {
cacheStore: useCacheStore()
}
},
computed: {
mode () {
if (!this.resource) {
......@@ -54,8 +61,17 @@ export default {
}
return this.$t(`pages.database.status.${this.mode}`)
},
cacheUser () {
return this.cacheStore.getUser
},
hasIdentifier () {
return this.resource.identifiers?.length > 0
if (!this.resource.identifiers) {
return false
}
if (!this.cacheUser) {
return this.resource.identifiers.filter(i => i.status === 'published').length
}
return this.resource.identifiers.filter(i => i.status === 'published' || i.owner.id === this.cacheUser.uid)
},
color () {
if (this.hasIdentifier) {
......
......@@ -82,8 +82,8 @@ export default defineNuxtConfig({
}
},
api: {
client: 'http://localhost',
server: 'http://gateway-service',
client: 'https://test.dbrepo.tuwien.ac.at',
server: 'https://test.dbrepo.tuwien.ac.at',
},
database: {
image: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment