Browse Source

refcator: handler to service-controller - metadiff and map view (WIP)

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5239/head
Pranav C 2 years ago
parent
commit
3af09aacb2
  1. 27
      packages/nocodb/src/lib/controllers/mapViewController.ts
  2. 1091
      packages/nocodb/src/lib/controllers/metaDiffController.ts
  3. 2
      packages/nocodb/src/lib/meta/api/helpers/populateMeta.ts
  4. 578
      packages/nocodb/src/lib/models/Model.ts
  5. 2
      packages/nocodb/src/lib/services/index.ts
  6. 34
      packages/nocodb/src/lib/services/mapViewService.ts
  7. 1105
      packages/nocodb/src/lib/services/metaDiffService.ts

27
packages/nocodb/src/lib/controllers/mapViewController.ts

@ -1,29 +1,30 @@
import { Request, Response, Router } from 'express';
import { MapType, ViewTypes } from 'nocodb-sdk';
import View from '../models/View';
import { MapType } from 'nocodb-sdk';
import ncMetaAclMw from '../meta/helpers/ncMetaAclMw';
import { Tele } from 'nc-help';
import { metaApiMetrics } from '../meta/helpers/apiMetrics';
import MapView from '../models/MapView';
import { mapViewService } from '../services';
export async function mapViewGet(req: Request, res: Response<MapType>) {
res.json(await MapView.get(req.params.mapViewId));
res.json(
await mapViewService.mapViewGet({ mapViewId: req.params.mapViewId })
);
}
export async function mapViewCreate(req: Request<any, any>, res) {
Tele.emit('evt', { evt_type: 'vtable:created', show_as: 'map' });
const view = await View.insert({
...req.body,
// todo: sanitize
fk_model_id: req.params.tableId,
type: ViewTypes.MAP,
const view = await mapViewService.mapViewCreate({
tableId: req.params.tableId,
map: req.body,
});
res.json(view);
}
export async function mapViewUpdate(req, res) {
Tele.emit('evt', { evt_type: 'view:updated', type: 'map' });
res.json(await MapView.update(req.params.mapViewId, req.body));
res.json(
await mapViewService.mapViewUpdate({
mapViewId: req.params.mapViewId,
map: req.body,
})
);
}
const router = Router({ mergeParams: true });

1091
packages/nocodb/src/lib/controllers/metaDiffController.ts

File diff suppressed because it is too large Load Diff

2
packages/nocodb/src/lib/meta/api/helpers/populateMeta.ts

@ -11,7 +11,7 @@ import getTableNameAlias, {
import LinkToAnotherRecordColumn from '../../../models/LinkToAnotherRecordColumn';
import getColumnUiType from '../../helpers/getColumnUiType';
import mapDefaultDisplayValue from '../../helpers/mapDefaultDisplayValue';
import { extractAndGenerateManyToManyRelations } from '../../../controllers/metaDiffController';
import { extractAndGenerateManyToManyRelations } from '../../../services/metaDiffService';
import { ModelTypes, UITypes, ViewTypes } from 'nocodb-sdk';
import { IGNORE_TABLES } from '../../../utils/common/BaseApiBuilder';

578
packages/nocodb/src/lib/models/Model.ts

File diff suppressed because it is too large Load Diff

2
packages/nocodb/src/lib/services/index.ts

@ -16,3 +16,5 @@ export * as galleryViewService from './galleryViewService';
export * as kanbanViewService from './kanbanViewService';
export * as gridViewColumnService from './gridViewColumnService';
export * as viewColumnService from './viewColumnService';
export * as metaDiffService from './metaDiffService';
export * as mapViewService from './mapViewService';

34
packages/nocodb/src/lib/services/mapViewService.ts

@ -0,0 +1,34 @@
import { MapType, ViewTypes } from 'nocodb-sdk';
import View from '../models/View';
import { Tele } from 'nc-help';
import MapView from '../models/MapView';
export async function mapViewGet(param:{mapViewId: string}) {
return await MapView.get(param.mapViewId)
}
export async function mapViewCreate(param:{
tableId: string,
// todo: add MapReq in schema
map: MapType
}) {
Tele.emit('evt', { evt_type: 'vtable:created', show_as: 'map' });
const view = await View.insert({
...param.map,
// todo: sanitize
fk_model_id: param.tableId,
type: ViewTypes.MAP,
});
return view;
}
export async function mapViewUpdate(param:{
mapViewId: string,
// todo: add MapReq in schema
map: MapType
}) {
Tele.emit('evt', { evt_type: 'view:updated', type: 'map' });
// todo: type correction
return await MapView.update(param.mapViewId, param.map as any)
}

1105
packages/nocodb/src/lib/services/metaDiffService.ts

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save