Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • fair-data-austria-db-repository/fda-services
1 result
Select Git revision
Loading items
Show changes

Commits on Source 2

Showing
with 405 additions and 306 deletions
......@@ -16,6 +16,7 @@ import at.tuwien.entities.database.table.columns.TableColumn;
import at.tuwien.entities.database.table.columns.TableColumnType;
import at.tuwien.entities.database.table.constraints.foreignKey.ForeignKey;
import at.tuwien.entities.database.table.constraints.foreignKey.ForeignKeyReference;
import at.tuwien.entities.identifier.Identifier;
import at.tuwien.exception.ImageNotSupportedException;
import at.tuwien.exception.QueryMalformedException;
import at.tuwien.exception.QueryStoreException;
......@@ -70,6 +71,12 @@ public interface QueryMapper {
})
QueryBriefDto queryToQueryBriefDto(Query data);
@Mappings({
@Mapping(target = "id", source = "queryId"),
@Mapping(target = "isPersisted", expression = "java(true)"),
})
Query identifierToQuery(Identifier data);
@Named("internalMapping")
default String nameToInternalName(String data) {
if (data == null || data.length() == 0) {
......
......@@ -6,9 +6,11 @@ import at.tuwien.api.database.query.ExecuteStatementDto;
import at.tuwien.api.database.query.QueryResultDto;
import at.tuwien.api.error.ApiErrorDto;
import at.tuwien.entities.database.Database;
import at.tuwien.entities.identifier.Identifier;
import at.tuwien.exception.*;
import at.tuwien.querystore.Query;
import at.tuwien.service.DatabaseService;
import at.tuwien.service.IdentifierService;
import at.tuwien.service.QueryService;
import at.tuwien.service.StoreService;
import at.tuwien.utils.PrincipalUtil;
......@@ -35,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
import java.util.List;
@Log4j2
@RestController
......@@ -171,8 +174,8 @@ public class QueryEndpoint {
AccessDeniedException, QueryNotFoundException {
log.debug("endpoint re-execute query, databaseId={}, queryId={}, page={}, size={}, sortDirection={}, sortColumn={}, {}",
databaseId, queryId, page, size, sortDirection, sortColumn, PrincipalUtil.formatForDebug(principal));
final Database database = databaseService.findById(databaseId);
endpointValidator.validateDataParams(page, size, sortDirection, sortColumn);
endpointValidator.validateOnlyAccessOrPublic(databaseId, principal);
/* execute */
final Query query = storeService.findOne(databaseId, queryId, principal);
final Long count = queryService.reExecuteCount(databaseId, query, principal);
......
......@@ -6,16 +6,15 @@ import at.tuwien.api.database.query.QueryPersistDto;
import at.tuwien.api.error.ApiErrorDto;
import at.tuwien.api.identifier.IdentifierDto;
import at.tuwien.api.user.UserDto;
import at.tuwien.entities.database.Database;
import at.tuwien.entities.identifier.Identifier;
import at.tuwien.entities.identifier.IdentifierType;
import at.tuwien.exception.*;
import at.tuwien.mapper.IdentifierMapper;
import at.tuwien.mapper.QueryMapper;
import at.tuwien.mapper.UserMapper;
import at.tuwien.querystore.Query;
import at.tuwien.service.AccessService;
import at.tuwien.service.IdentifierService;
import at.tuwien.service.StoreService;
import at.tuwien.service.UserService;
import at.tuwien.service.*;
import at.tuwien.utils.PrincipalUtil;
import at.tuwien.utils.UserUtil;
import at.tuwien.validation.EndpointValidator;
......@@ -54,19 +53,21 @@ public class StoreEndpoint {
private final UserService userService;
private final StoreService storeService;
private final AccessService accessService;
private final DatabaseService databaseService;
private final IdentifierMapper identifierMapper;
private final EndpointValidator endpointValidator;
private final IdentifierService identifierService;
@Autowired
public StoreEndpoint(UserMapper userMapper, QueryMapper queryMapper, UserService userService, StoreService storeService,
AccessService accessService, IdentifierMapper identifierMapper,
AccessService accessService, DatabaseService databaseService, IdentifierMapper identifierMapper,
EndpointValidator endpointValidator, IdentifierService identifierService) {
this.userMapper = userMapper;
this.queryMapper = queryMapper;
this.userService = userService;
this.storeService = storeService;
this.accessService = accessService;
this.databaseService = databaseService;
this.identifierMapper = identifierMapper;
this.endpointValidator = endpointValidator;
this.identifierService = identifierService;
......@@ -125,14 +126,23 @@ public class StoreEndpoint {
DatabaseConnectionException, TableMalformedException, UserNotFoundException, NotAllowedException,
AccessDeniedException {
log.debug("endpoint list queries, databaseId={}, persisted={}, {}", databaseId, persisted, PrincipalUtil.formatForDebug(principal));
endpointValidator.validateOnlyAccessOrPublic(databaseId, principal);
final Database database = databaseService.findById(databaseId);
/* find all from data database */
final List<Query> queries = storeService.findAll(databaseId, persisted, principal);
/* add identifiers and creator from metadata database */
final List<IdentifierDto> identifiers = identifierService.findAllSubsetIdentifiers()
.stream()
.map(identifierMapper::identifierToIdentifierDto)
.toList();
final List<Query> queries;
if (!database.getIsPublic() && principal == null) {
queries = identifierService.findAllSubsetIdentifiers()
.stream()
.filter(i -> i.getType().equals(IdentifierType.SUBSET))
.map(queryMapper::identifierToQuery)
.toList();
} else {
queries = storeService.findAll(databaseId, persisted, principal);
}
/* add identifiers and creator from metadata database */
final List<UserDto> users = userService.findAll()
.stream()
.map(userMapper::userToUserDto)
......
......@@ -34,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
......@@ -83,15 +84,26 @@ public class TableEndpoint {
schema = @Schema(implementation = ApiErrorDto.class))}),
})
public ResponseEntity<List<TableBriefDto>> list(@NotNull @PathVariable("databaseId") Long databaseId,
Principal principal)
Principal principal,
@RequestParam(required = false) String internalName)
throws DatabaseNotFoundException, NotAllowedException, AccessDeniedException {
log.debug("endpoint list tables, databaseId={}, {}", databaseId, PrincipalUtil.formatForDebug(principal));
log.debug("endpoint list tables, databaseId={}, internalName={} {}", databaseId, internalName,
PrincipalUtil.formatForDebug(principal));
endpointValidator.validateOnlyPrivateAccess(databaseId, principal);
endpointValidator.validateOnlyPrivateHasRole(databaseId, principal, "list-tables");
final List<TableBriefDto> dto = tableService.findAll(databaseId)
List<TableBriefDto> dto = new LinkedList<>();
if (internalName != null) {
try {
dto = List.of(tableMapper.tableToTableBriefDto(tableService.find(databaseId, internalName)));
} catch (TableNotFoundException e) {
/* ignore */
}
} else {
dto = tableService.findAll(databaseId)
.stream()
.map(tableMapper::tableToTableBriefDto)
.collect(Collectors.toList());
}
log.trace("list tables resulted in tables {}", dto);
return ResponseEntity.ok(dto);
}
......
......@@ -291,7 +291,8 @@ public class ViewEndpoint {
/* check */
endpointValidator.validateDataParams(page, size);
final Database database = databaseService.find(databaseId);
if (!database.getIsPublic()) {
final View view = viewService.findById(databaseId, viewId, principal);
if (!database.getIsPublic() && !view.getIsPublic()) {
if (principal == null) {
log.error("Failed to view data of private view: principal is null");
throw new NotAllowedException("Failed to view data of private view: principal is null");
......@@ -312,7 +313,6 @@ public class ViewEndpoint {
}
/* find */
log.debug("find view data for database with id {}", databaseId);
final View view = viewService.findById(databaseId, viewId, principal);
final Long count = queryService.viewCount(databaseId, view, principal);
final HttpHeaders headers = new HttpHeaders();
headers.set("X-Count", "" + count);
......
......@@ -66,7 +66,66 @@ public class TableEndpointUnitTest extends BaseUnitTest {
at.tuwien.exception.AccessDeniedException {
/* test */
generic_list(DATABASE_3_ID, DATABASE_3, null, null, null);
final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_3_ID, DATABASE_3, null, null, null,
true, null);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertNotNull(response.getBody());
final List<TableBriefDto> body = response.getBody();
assertEquals(1, body.size());
}
@Test
@WithAnonymousUser
public void list_publicAnonymousFilter_succeeds() throws NotAllowedException, DatabaseNotFoundException,
at.tuwien.exception.AccessDeniedException, TableNotFoundException {
/* mock */
when(tableService.find(eq(DATABASE_3_ID), anyString()))
.thenReturn(TABLE_8);
/* test */
final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_3_ID, DATABASE_3, null, null, null,
true, TABLE_8_INTERNAL_NAME);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertNotNull(response.getBody());
final List<TableBriefDto> body = response.getBody();
assertEquals(1, body.size());
}
@Test
@WithAnonymousUser
public void list_publicAnonymousFilter_fails() throws NotAllowedException, DatabaseNotFoundException,
at.tuwien.exception.AccessDeniedException, TableNotFoundException {
/* mock */
doThrow(TableNotFoundException.class)
.when(tableService)
.find(eq(DATABASE_3_ID), anyString());
/* test */
final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_3_ID, DATABASE_3, null, null, null,
true, "i_do_not_exist");
assertEquals(HttpStatus.OK, response.getStatusCode());
assertNotNull(response.getBody());
final List<TableBriefDto> body = response.getBody();
assertEquals(0, body.size());
}
@Test
@WithAnonymousUser
public void list_publicAnonymousFilterHead_fails() throws NotAllowedException, DatabaseNotFoundException,
at.tuwien.exception.AccessDeniedException, TableNotFoundException {
/* mock */
doThrow(TableNotFoundException.class)
.when(tableService)
.find(eq(DATABASE_3_ID), anyString());
/* test */
final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_3_ID, DATABASE_3, null, null, null,
false, "i_do_not_exist");
assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
assertNull(response.getBody());
}
@Test
......@@ -75,7 +134,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
/* test */
assertThrows(DatabaseNotFoundException.class, () -> {
generic_list(DATABASE_3_ID, null, USER_1_ID, USER_1_PRINCIPAL, DATABASE_3_USER_1_READ_ACCESS);
generic_list(DATABASE_3_ID, null, USER_1_ID, USER_1_PRINCIPAL, DATABASE_3_USER_1_READ_ACCESS, true, null);
});
}
......@@ -85,7 +144,8 @@ public class TableEndpointUnitTest extends BaseUnitTest {
at.tuwien.exception.AccessDeniedException {
/* test */
final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_3_ID, DATABASE_3, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_3_ID, DATABASE_3, USER_1_ID,
USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS, true, null);
assertEquals(HttpStatus.OK, response.getStatusCode());
final List<TableBriefDto> body = response.getBody();
assertNotNull(body);
......@@ -97,7 +157,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
public void list_publicNoRole_succeeds() throws NotAllowedException, DatabaseNotFoundException, at.tuwien.exception.AccessDeniedException {
/* test */
generic_list(DATABASE_3_ID, DATABASE_3, USER_4_ID, USER_4_PRINCIPAL, null);
generic_list(DATABASE_3_ID, DATABASE_3, USER_4_ID, USER_4_PRINCIPAL, null, true, null);
}
@Test
......@@ -312,7 +372,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
/* test */
assertThrows(NotAllowedException.class, () -> {
generic_list(DATABASE_1_ID, DATABASE_1, null, null, null);
generic_list(DATABASE_1_ID, DATABASE_1, null, null, null, true, null);
});
}
......@@ -322,7 +382,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
/* test */
assertThrows(DatabaseNotFoundException.class, () -> {
generic_list(DATABASE_1_ID, null, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
generic_list(DATABASE_1_ID, null, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS, true, null);
});
}
......@@ -332,7 +392,8 @@ public class TableEndpointUnitTest extends BaseUnitTest {
at.tuwien.exception.AccessDeniedException {
/* test */
final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_1_ID, DATABASE_1, USER_1_ID, USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS);
final ResponseEntity<List<TableBriefDto>> response = generic_list(DATABASE_1_ID, DATABASE_1, USER_1_ID,
USER_1_PRINCIPAL, DATABASE_1_USER_1_READ_ACCESS, true, null);
assertEquals(HttpStatus.OK, response.getStatusCode());
final List<TableBriefDto> body = response.getBody();
assertNotNull(body);
......@@ -345,7 +406,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
/* test */
assertThrows(AccessDeniedException.class, () -> {
generic_list(DATABASE_1_ID, DATABASE_1, USER_4_ID, USER_4_PRINCIPAL, null);
generic_list(DATABASE_1_ID, DATABASE_1, USER_4_ID, USER_4_PRINCIPAL, null, true, null);
});
}
......@@ -505,7 +566,8 @@ public class TableEndpointUnitTest extends BaseUnitTest {
/* ################################################################################################### */
protected ResponseEntity<List<TableBriefDto>> generic_list(Long databaseId, Database database, UUID userId,
Principal principal, DatabaseAccess access)
Principal principal, DatabaseAccess access,
boolean isGet, String internalName)
throws DatabaseNotFoundException, NotAllowedException, at.tuwien.exception.AccessDeniedException {
/* mock */
......@@ -533,7 +595,7 @@ public class TableEndpointUnitTest extends BaseUnitTest {
}
/* test */
return tableEndpoint.list(databaseId, principal);
return tableEndpoint.list(databaseId, principal, internalName);
}
protected ResponseEntity<TableDto> generic_create(Long databaseId, Database database, TableCreateDto data,
......
......@@ -625,7 +625,7 @@ public class PrometheusEndpointMvcTest extends BaseUnitTest {
/* mock */
try {
tableEndpoint.list(DATABASE_1_ID, USER_1_PRINCIPAL);
tableEndpoint.list(DATABASE_1_ID, USER_1_PRINCIPAL, null);
} catch (Exception e) {
/* ignore */
}
......
......@@ -3,6 +3,7 @@ package at.tuwien.service.impl;
import at.tuwien.api.database.query.ExecuteStatementDto;
import at.tuwien.api.database.query.QueryPersistDto;
import at.tuwien.entities.database.Database;
import at.tuwien.entities.identifier.Identifier;
import at.tuwien.entities.user.User;
import at.tuwien.exception.*;
import at.tuwien.mapper.StoreMapper;
......
......@@ -1061,7 +1061,7 @@ public abstract class BaseTest {
.name(DATABASE_3_NAME)
.internalName(DATABASE_3_INTERNALNAME)
.exchangeName(DATABASE_3_EXCHANGE)
.tables(List.of()) /* TABLE_3, TABLE_3, TABLE_3 */
.tables(List.of()) /* TABLE_8 */
.views(List.of())
.build();
......
......@@ -24,7 +24,7 @@
color="primary"
variant="flat"
:loading="loading"
:disabled="!formValid || loading"
:disabled="!formValid || !validPublicationMonth || !validPublicationDay || loading"
:text="($vuetify.display.xl ? $t('toolbars.identifier.update.xl') + ' ' : '') + $t('toolbars.identifier.update.permanent')"
@click="save" />
</v-toolbar>
......@@ -57,11 +57,9 @@
:label="$t('pages.identifier.subpages.create.creators.identifier.label')"
clearable
:variant="inputVariant"
name="name-identifier"
:hint="$t('pages.identifier.subpages.create.creators.identifier.hint')"
:loading="creator.name_loading"
persistent-hint
required
@focusout="retrieveCreator(creator)" />
</v-col>
<v-col cols="4">
......@@ -100,7 +98,9 @@
</v-row>
<v-row dense>
<v-col cols="8">
<v-radio-group v-model="creator.name_type" row>
<v-radio-group
v-model="creator.name_type"
row>
<v-radio
:label="$t('pages.identifier.subpages.create.creators.person.label')"
value="Personal" />
......@@ -121,7 +121,6 @@
:variant="inputVariant"
:hint="$t('pages.identifier.subpages.create.creators.given-name.hint')"
persistent-hint
required
@focusout="suggestName(creator)" />
</v-col>
</v-row>
......@@ -136,7 +135,6 @@
:variant="inputVariant"
:hint="$t('pages.identifier.subpages.create.creators.family-name.hint')"
persistent-hint
required
@focusout="suggestName(creator)" />
</v-col>
</v-row>
......@@ -158,7 +156,6 @@
<v-text-field
v-model="creator.affiliation_identifier"
:label="$t('pages.identifier.subpages.create.creators.affiliation-identifier.label')"
name="affiliation-identifier"
:variant="inputVariant"
:loading="creator.affiliation_loading"
:hint="$t('pages.identifier.subpages.create.creators.affiliation-identifier.hint')"
......@@ -172,7 +169,6 @@
<v-text-field
v-model="creator.affiliation"
:label="$t('pages.identifier.subpages.create.creators.affiliation.label')"
name="affiliation"
:variant="inputVariant"
clearable
:hint="$t('pages.identifier.subpages.create.creators.affiliation.hint')"
......@@ -248,8 +244,7 @@
variant="underlined"
:items="titleType"
item-title="value"
item-value="value"
required />
item-value="value" />
</v-col>
</v-row>
<v-row dense>
......@@ -263,8 +258,7 @@
variant="underlined"
:items="languages"
item-title="name"
item-value="code"
required />
item-value="code" />
</v-col>
</v-row>
</v-container>
......@@ -337,8 +331,7 @@
variant="underlined"
:items="descriptionType"
item-title="value"
item-value="value"
required />
item-value="value" />
</v-col>
</v-row>
<v-row dense>
......@@ -352,8 +345,7 @@
variant="underlined"
:items="languages"
item-title="name"
item-value="code"
required />
item-value="code" />
</v-col>
</v-row>
</v-container>
......@@ -384,7 +376,6 @@
<v-col cols="8">
<v-text-field
v-model="identifier.publisher"
name="publisher"
:variant="inputVariant"
:label="$t('pages.identifier.subpages.create.publisher.label')"
:hint="$t('pages.identifier.subpages.create.publisher.hint')"
......@@ -454,7 +445,6 @@
<v-col cols="4">
<v-text-field
v-model="related.value"
name="related"
:variant="inputVariant"
:label="$t('pages.identifier.subpages.create.related-identifiers.identifier.label')"
:hint="$t('pages.identifier.subpages.create.related-identifiers.identifier.hint')"
......@@ -578,8 +568,7 @@
persistent-hint
:items="languages"
item-title="name"
item-value="code"
required />
item-value="code" />
</v-col>
</v-row>
</v-container>
......@@ -609,12 +598,10 @@
<v-text-field
v-model="funder.funder_identifier"
:label="$t('pages.identifier.subpages.create.funders.identifier.label')"
name="funder-identifier"
:hint="$t('pages.identifier.subpages.create.funders.identifier.hint')"
:loading="funder.loading"
persistent-hint
:variant="inputVariant"
required
clearable
@focusout="retrieveFunder(funder)" />
</v-col>
......
......@@ -37,7 +37,6 @@
<v-card-text>
<v-form
ref="formView"
v-model="valid"
@submit.prevent="prevent">
<v-row
v-if="isView"
......@@ -347,7 +346,6 @@ export default {
],
tableDetails: null,
resultId: null,
valid: false,
errorKeyword: null,
query: {
raw: null,
......
<template>
<div>
<v-data-table
<v-data-table-server
flat
:headers="headers"
:items="result.rows"
:loading="loading > 0"
:options.sync="options"
:options="options"
:items="result.rows"
:items-length="total"
:footer-props="footerProps"
:server-items-length="total" />
@update:options="updateOptions" />
</div>
</template>
......@@ -42,7 +43,7 @@ export default {
showFirstLastPage: true,
itemsPerPageOptions: [10, 25, 50, 100]
},
total: null
total: null,
}
},
computed: {
......@@ -150,6 +151,11 @@ export default {
})
console.debug('query result', data)
this.result.rows = data.result
},
updateOptions ({ page, itemsPerPage, sortBy }) {
this.options.page = page
this.options.itemsPerPage = itemsPerPage
this.reExecute(this.id)
}
}
}
......
......@@ -66,6 +66,7 @@
:text="$t('navigation.info')"
:to="`/database/${$route.params.database_id}/subset/${$route.params.subset_id}/info`" />
<v-tab
v-if="canViewData"
:text="$t('navigation.data')"
:to="`/database/${$route.params.database_id}/subset/${$route.params.subset_id}/data`" />
</v-tabs>
......@@ -120,6 +121,12 @@ export default {
}
return this.database.subsets.filter(s => s.query_id === Number(this.$route.params.subset_id))
},
canViewData () {
if (!this.database) {
return false
}
return this.database.is_public
},
identifier () {
/* mount pid */
if (this.pid) {
......
......@@ -23,10 +23,16 @@
required
clearable
persistent-hint
:base-color="suggestedAnalyseSeparator && providedSeparator !== analysedSeparator ? 'warning' : ''"
:variant="inputVariant"
:hint="$t('pages.table.subpages.import.separator.hint')"
:label="$t('pages.table.subpages.import.separator.label')"/>
:label="$t('pages.table.subpages.import.separator.label')">
<template
v-if="suggestedAnalyseSeparator && providedSeparator !== analysedSeparator"
v-slot:prepend>
<v-icon
color="warning">mdi-alert-outline</v-icon>
</template>
</v-select>
</v-col>
</v-row>
<v-row dense>
......@@ -64,14 +70,20 @@
<v-select
v-model="tableImport.line_termination"
:items="lineTerminationItems"
:base-color="suggestedAnalyseLineTerminator && providedTerminator !== analysedTerminator ? 'warning' : ''"
item-title="name"
item-value="value"
clearable
persistent-hint
:variant="inputVariant"
:hint="$t('pages.table.subpages.import.terminator.hint')"
:label="$t('pages.table.subpages.import.terminator.label')"/>
:label="$t('pages.table.subpages.import.terminator.label')">
<template
v-if="suggestedAnalyseLineTerminator && providedTerminator !== analysedTerminator"
v-slot:prepend>
<v-icon
color="warning">mdi-alert-outline</v-icon>
</template>
</v-select>
</v-col>
</v-row>
<v-row dense>
......
......@@ -8,8 +8,7 @@
color="info" />
<v-form
ref="form"
v-model="valid"
:disabled="disabled">
v-model="valid">
<v-row
v-for="(c, idx) in columns"
:key="`r-${idx}`"
......@@ -27,7 +26,7 @@
:hint="$t('pages.table.subpages.schema.name.hint')" />
</v-col>
<v-col cols="2">
<v-select
<v-autocomplete
v-model="c.type"
:items="columnTypes"
item-title="text"
......@@ -156,19 +155,12 @@
</v-row>
<v-row>
<v-col>
<v-btn
:color="disabled ? '' : 'tertiary'"
:variant="buttonVariant"
size="small"
class="mr-2"
:disabled="disabled"
:text="$t('navigation.back')"
@click="back" />
<v-btn
color="secondary"
variant="flat"
size="small"
:disabled="disabled"
:loading="loading"
:disabled="submitDisabled"
:text="submitText"
@click="submit" />
</v-col>
......@@ -188,13 +180,19 @@ export default {
return []
}
},
back: {
disabled: {
type: Boolean,
default () {
return false
}
},
disabled: {
submitDisabled: {
type: Boolean,
default () {
return false
}
},
loading: {
type: Boolean,
default () {
return false
......@@ -380,5 +378,3 @@ export default {
}
}
</script>
<style scoped>
</style>
......@@ -111,7 +111,7 @@ export const useQueryService = (): any => {
axios.head<void>(`/api/database/${databaseId}/query/${queryId}/data`)
.then((response) => {
const count: number = Number(response.headers['x-count'])
console.info('Re-executed query in database with id', databaseId)
console.info('Found', count, 'tuples for query', queryId, 'in database with id', databaseId)
resolve(count)
})
.catch((error) => {
......
......@@ -2,11 +2,11 @@ import type {AxiosRequestConfig, AxiosResponse} from 'axios'
export const useTableService = (): any => {
function findAll(databaseId: number): Promise<TableBriefDto> {
function findAll(databaseId: number, internalName: string): Promise<TableBriefDto[]> {
const axios = useAxiosInstance()
console.debug('find tables')
return new Promise<TableBriefDto>((resolve, reject) => {
axios.get<TableBriefDto>(`/api/database/${databaseId}/table`)
return new Promise<TableBriefDto[]>((resolve, reject) => {
axios.get<TableBriefDto[]>(`/api/database/${databaseId}/table`, {params: (internalName && {internal_name: internalName})})
.then((response) => {
console.info('Found tables(s)')
resolve(response.data)
......@@ -68,7 +68,7 @@ export const useTableService = (): any => {
async function getData(databaseId: number, tableId: number, page: number, size: number, timestamp: Date): Promise<QueryResultDto> {
const axios = useAxiosInstance()
console.debug('get data for table with id', tableId, 'in database with id', databaseId);
console.debug('get data for table with id', tableId, 'in database with id', databaseId, 'page', page, 'size', size);
return new Promise<QueryResultDto>((resolve, reject) => {
axios.get<QueryResultDto>(`/api/database/${databaseId}/table/${tableId}/data`, {params: mapFilter(timestamp, page, size)})
.then((response) => {
......@@ -143,9 +143,9 @@ export const useTableService = (): any => {
console.debug('delete table with id', tableId, 'in database with id', databaseId)
return new Promise<void>((resolve, reject) => {
axios.delete<void>(`/api/database/${databaseId}/table/${tableId}`)
.then((response) => {
.then(() => {
console.info('Deleted table with id', tableId, 'in database with id', databaseId)
resolve(response.data)
resolve()
})
.catch((error) => {
console.error('Failed to delete table', error)
......@@ -219,12 +219,12 @@ export const useTableService = (): any => {
}
function mapFilter(timestamp: Date | null, page: number | null, size: number | null) {
if (page !== null && size !== null) {
if (!timestamp) {
if (!page || !size) {
return null
}
return {page, size}
}
return {page, size, timestamp}
}
if (!page || !size) {
return {timestamp}
}
......
......@@ -54,7 +54,7 @@ export const useViewService = (): any => {
axios.head<number>(`/api/database/${databaseId}/view/${viewId}/data`)
.then((response) => {
const count: number = Number(response.headers['x-count'])
console.info('Re-executed view with id', viewId, 'in database with id', databaseId)
console.info('Found', count, 'tuples for view with id', viewId, 'in database with id', databaseId)
resolve(count)
})
.catch((error) => {
......
This diff is collapsed.
This diff is collapsed.