Browse Source

feat: grid view column apis

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5444/head
Pranav C 2 years ago
parent
commit
1637a48b4b
  1. 3
      packages/nocodb-nest/src/app.module.ts
  2. 20
      packages/nocodb-nest/src/modules/grid-columns/grid-columns.controller.spec.ts
  3. 33
      packages/nocodb-nest/src/modules/grid-columns/grid-columns.controller.ts
  4. 9
      packages/nocodb-nest/src/modules/grid-columns/grid-columns.module.ts
  5. 18
      packages/nocodb-nest/src/modules/grid-columns/grid-columns.service.spec.ts
  6. 26
      packages/nocodb-nest/src/modules/grid-columns/grid-columns.service.ts

3
packages/nocodb-nest/src/app.module.ts

@ -23,9 +23,10 @@ import { GridsModule } from './modules/grids/grids.module';
import { KanbansModule } from './modules/kanbans/kanbans.module';
import { GalleriesModule } from './modules/galleries/galleries.module';
import { FormColumnsModule } from './modules/form-columns/form-columns.module';
import { GridColumnsModule } from './modules/grid-columns/grid-columns.module';
@Module({
imports: [AuthModule, UsersModule, UtilsModule, ProjectsModule, TablesModule, ViewsModule, FiltersModule, SortsModule, ColumnsModule, ViewColumnsModule, BasesModule, HooksModule, SharedBasesModule, FormsModule, GridsModule, KanbansModule, GalleriesModule, FormColumnsModule],
imports: [AuthModule, UsersModule, UtilsModule, ProjectsModule, TablesModule, ViewsModule, FiltersModule, SortsModule, ColumnsModule, ViewColumnsModule, BasesModule, HooksModule, SharedBasesModule, FormsModule, GridsModule, KanbansModule, GalleriesModule, FormColumnsModule, GridColumnsModule],
controllers: [],
providers: [Connection, MetaService, JwtStrategy, ExtractProjectIdMiddleware],
exports: [Connection, MetaService],

20
packages/nocodb-nest/src/modules/grid-columns/grid-columns.controller.spec.ts

@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { GridColumnsController } from './grid-columns.controller';
import { GridColumnsService } from './grid-columns.service';
describe('GridColumnsController', () => {
let controller: GridColumnsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [GridColumnsController],
providers: [GridColumnsService],
}).compile();
controller = module.get<GridColumnsController>(GridColumnsController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

33
packages/nocodb-nest/src/modules/grid-columns/grid-columns.controller.ts

@ -0,0 +1,33 @@
import { Body, Controller, Get, Param, Patch, UseGuards } from '@nestjs/common';
import { GridColumnReqType } from 'nocodb-sdk';
import {
Acl,
ExtractProjectIdMiddleware,
} from '../../middlewares/extract-project-id/extract-project-id.middleware';
import { GridColumnsService } from './grid-columns.service';
import { AuthGuard } from '@nestjs/passport';
@Controller('grid-columns')
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt'))
export class GridColumnsController {
constructor(private readonly gridColumnsService: GridColumnsService) {}
@Get('/api/v1/db/meta/grids/:gridViewId/grid-columns')
@Acl('columnList')
async columnList(@Param('gridViewId') gridViewId: string) {
return await this.gridColumnsService.columnList({
gridViewId,
});
}
@Patch('/api/v1/db/meta/grid-columns/:gridViewColumnId')
@Acl('gridColumnUpdate')
async gridColumnUpdate(
@Param('gridViewColumnId') gridViewColumnId: string,
@Body() body: GridColumnReqType,
) {
return this.gridColumnsService.gridColumnUpdate({
gridViewColumnId,
grid: body,
});
}
}

9
packages/nocodb-nest/src/modules/grid-columns/grid-columns.module.ts

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { GridColumnsService } from './grid-columns.service';
import { GridColumnsController } from './grid-columns.controller';
@Module({
controllers: [GridColumnsController],
providers: [GridColumnsService]
})
export class GridColumnsModule {}

18
packages/nocodb-nest/src/modules/grid-columns/grid-columns.service.spec.ts

@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { GridColumnsService } from './grid-columns.service';
describe('GridColumnsService', () => {
let service: GridColumnsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [GridColumnsService],
}).compile();
service = module.get<GridColumnsService>(GridColumnsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

26
packages/nocodb-nest/src/modules/grid-columns/grid-columns.service.ts

@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { GridColumnReqType } from 'nocodb-sdk';
import { validatePayload } from '../../helpers';
import { GridViewColumn } from '../../models';
import { T } from 'nc-help';
@Injectable()
export class GridColumnsService {
async columnList(param: { gridViewId: string }) {
return await GridViewColumn.list(param.gridViewId);
}
async gridColumnUpdate(param: {
gridViewColumnId: string;
grid: GridColumnReqType;
}) {
validatePayload(
'swagger.json#/components/schemas/GridColumnReq',
param.grid,
);
T.emit('evt', { evt_type: 'gridViewColumn:updated' });
return await GridViewColumn.update(param.gridViewColumnId, param.grid);
}
}
Loading…
Cancel
Save