mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
Added filter logic for preview apps
This commit is contained in:
parent
59cac14f4d
commit
1d6d807720
8 changed files with 19 additions and 12 deletions
|
|
@ -374,7 +374,7 @@ const useAppData = (appId, moduleId, darkMode, mode = 'edit', { environmentId, v
|
|||
const queryData =
|
||||
isPublicAccess || (mode !== 'edit' && appData.is_public)
|
||||
? appData
|
||||
: await dataqueryService.getAll(appData.editing_version?.id || appData.current_version_id);
|
||||
: await dataqueryService.getAll(appData.editing_version?.id || appData.current_version_id, mode);
|
||||
const dataQueries = queryData.data_queries || queryData?.editing_version?.data_queries;
|
||||
dataQueries.forEach((query) => normalizeQueryTransformationOptions(query));
|
||||
setQueries(dataQueries);
|
||||
|
|
@ -547,7 +547,7 @@ const useAppData = (appId, moduleId, darkMode, mode = 'edit', { environmentId, v
|
|||
setSecrets(orgSecrets);
|
||||
}
|
||||
|
||||
const queryData = await dataqueryService.getAll(currentVersionId);
|
||||
const queryData = await dataqueryService.getAll(currentVersionId, mode);
|
||||
const dataQueries = queryData.data_queries;
|
||||
dataQueries.forEach((query) => normalizeQueryTransformationOptions(query));
|
||||
setQueries(dataQueries);
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ export const dataqueryService = {
|
|||
bulkUpdateQueryOptions,
|
||||
};
|
||||
|
||||
function getAll(appVersionId) {
|
||||
function getAll(appVersionId, mode) {
|
||||
const requestOptions = { method: 'GET', headers: authHeader(), credentials: 'include' };
|
||||
return fetch(`${config.apiUrl}/data-queries/${appVersionId}`, requestOptions).then(handleResponse);
|
||||
return fetch(`${config.apiUrl}/data-queries/${appVersionId}?mode=${mode}`, requestOptions).then(handleResponse);
|
||||
}
|
||||
|
||||
function create(app_id, app_version_id, name, kind, options, data_source_id, plugin_id) {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit e9288fca3afc0d9064300e30dc5279b3c851be82
|
||||
Subproject commit 4f421094fe70a51b964d5d664029e08c9eccb5be
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { Controller, Get, Param, Body, Post, Patch, Delete, UseGuards, Put, Res } from '@nestjs/common';
|
||||
import { Controller, Get, Param, Body, Post, Patch, Delete, UseGuards, Put, Res, Query } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '@modules/session/guards/jwt-auth.guard';
|
||||
import { DataQueriesService } from './service';
|
||||
import { User, UserEntity } from '@modules/app/decorators/user.decorator';
|
||||
|
|
@ -30,8 +30,8 @@ export class DataQueriesController implements IDataQueriesController {
|
|||
@InitFeature(FEATURE_KEY.GET)
|
||||
@UseGuards(JwtAuthGuard, ValidateAppVersionGuard, ValidateQueryAppGuard, AppFeatureAbilityGuard)
|
||||
@Get(':versionId')
|
||||
index(@Param('versionId') versionId: string) {
|
||||
return this.dataQueriesService.getAll(versionId);
|
||||
index(@User() user: UserEntity, @Param('versionId') versionId: string, @Query('mode') mode?: string) {
|
||||
return this.dataQueriesService.getAll(user, versionId, mode);
|
||||
}
|
||||
|
||||
@InitFeature(FEATURE_KEY.CREATE)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { App } from '@entities/app.entity';
|
|||
import { UpdateSourceDto } from '../dto';
|
||||
import { Response } from 'express';
|
||||
export interface IDataQueriesController {
|
||||
index(versionId: string): Promise<object>;
|
||||
index(user: UserEntity, versionId: string, mode?: string): Promise<object>;
|
||||
|
||||
create(
|
||||
user: UserEntity,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { CreateDataQueryDto, IUpdatingReferencesOptions, UpdateDataQueryDto } fr
|
|||
import { DataQuery } from '@entities/data_query.entity';
|
||||
|
||||
export interface IDataQueriesService {
|
||||
getAll(versionId: string): Promise<{ data_queries: object[] }>;
|
||||
getAll(user: User, versionId: string, mode?: string): Promise<{ data_queries: object[] }>;
|
||||
|
||||
create(user: User, dataSource: DataSource, dataQueryDto: CreateDataQueryDto): Promise<object>;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import { FeatureAbilityFactory as AppFeatureAbilityFactory } from './ability/app
|
|||
import { FeatureAbilityFactory as DataSourceFeatureAbilityFactory } from './ability/data-source';
|
||||
import { AppsRepository } from '@modules/apps/repository';
|
||||
import { OrganizationRepository } from '@modules/organizations/repository';
|
||||
import { LicenseModule } from '@modules/licensing/module';
|
||||
import { AppPermissionsModule } from '@modules/app-permissions/module';
|
||||
|
||||
export class DataQueriesModule {
|
||||
static async register(configs?: { IS_GET_CONTEXT: boolean }): Promise<DynamicModule> {
|
||||
|
|
@ -19,7 +21,12 @@ export class DataQueriesModule {
|
|||
|
||||
return {
|
||||
module: DataQueriesModule,
|
||||
imports: [await AppEnvironmentsModule.register(configs), await DataSourcesModule.register(configs)],
|
||||
imports: [
|
||||
await AppEnvironmentsModule.register(configs),
|
||||
await DataSourcesModule.register(configs),
|
||||
await LicenseModule.forRoot(configs),
|
||||
await AppPermissionsModule.register(configs),
|
||||
],
|
||||
providers: [
|
||||
DataQueryRepository,
|
||||
VersionRepository,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export class DataQueriesService implements IDataQueriesService {
|
|||
protected readonly dataSourceRepository: DataSourcesRepository
|
||||
) { }
|
||||
|
||||
async getAll(versionId: string) {
|
||||
async getAll(user: User, versionId: string, mode?: string) {
|
||||
const queries = await this.dataQueryRepository.getAll(versionId);
|
||||
const serializedQueries = [];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue