mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-22 17:49:08 +00:00
FIX: Data asset permission owner
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user