FIX: Data asset permission owner

This commit is contained in:
Victor Radael
2022-09-30 11:11:59 -03:00
parent 96a485afd1
commit 7e8f5c49b5
3 changed files with 46 additions and 8 deletions
+18 -2
View File
@@ -155,14 +155,30 @@ export class CatalogController {
}
@Get('dashboard-metabase/:id')
async getOneDashboardMetabase(@Body() body, @Param() params) {
async getOneDashboardMetabase(
@Body() body,
@Param() params,
@User() user: RequestUser,
) {
const { id } = params;
this.logger.info(`/catalog - ON GET ONE DASHBOARD METABASE ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
});
const res = await this.catalogService.getOneDashboardMetabase(id, body);
const { username, user_id, customer_id, customer_name } = user;
const metadata = PackTheMetadata({
username,
user_id,
customer_id,
customer_name,
});
const res = await this.catalogService.getOneDashboardMetabase(
id,
body,
metadata,
);
return res;
}
+27 -5
View File
@@ -142,17 +142,32 @@ class CatalogService implements OnModuleInit {
return { data_assets: response };
}
async getOneDashboardMetabase(id, body) {
async getOneDashboardMetabase(id, body, metadata) {
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/dashboard-metabase/${id}`,
);
// const [, path] = data.iframe_url.split('.dadosfera');
// const host = `httpss://metabase-${body.info.customer.toLowerCase()}.dadosfera.ai`;
// data.iframe_url = host + path;
const { data_asset } = await lastValueFrom(
this.catalogReadService.GetOneDataAsset(
{ id, type: 'dashboard' },
metadata,
),
);
const opensearchTable = JSON.parse(data_asset);
console.log(opensearchTable);
const result = opensearchTable.user_id
? await this.userService.findOneById(opensearchTable.owner)
: null;
return data;
const owner = result !== null ? result.user.username : null;
return {
...data,
tags: opensearchTable.tags,
description: opensearchTable.description || null,
owner,
};
}
async getAllTableMetadata(body) {
@@ -177,11 +192,18 @@ class CatalogService implements OnModuleInit {
),
);
const opensearchTable = JSON.parse(data_asset);
const result = opensearchTable.user_id
? await this.userService.findOneById(opensearchTable.owner)
: null;
const owner = result !== null ? result.user.username : null;
return [
{
...data[0],
tags: opensearchTable.tags,
table_description: opensearchTable.description,
owner,
},
];
}