Browse Source

refactor: ui updates

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4134/head
Pranav C 2 years ago
parent
commit
4a0ad304c8
  1. 6
      packages/nc-gui/components/admin/License.vue
  2. 11
      packages/nc-gui/components/admin/ResetPassword.vue
  3. 6
      packages/nc-gui/components/admin/UserManagement.vue
  4. 18
      packages/nocodb/src/lib/meta/api/ee/index.ts
  5. 22
      packages/nocodb/src/lib/meta/api/ee/orgTokenApis.ts
  6. 9
      packages/nocodb/src/lib/meta/api/orgTokenApis.ts
  7. 16
      packages/nocodb/src/lib/meta/helpers/getHandler.ts

6
packages/nc-gui/components/admin/License.vue

@ -29,12 +29,12 @@ loadLicense()
</script>
<template>
<div class="h-full overflow-y-scroll scrollbar-thin-dull pt-2">
<div class="h-full overflow-y-scroll scrollbar-thin-dull">
<div class="text-xl mt-4">License</div>
<a-divider class="!my-3" />
<div class="">
<a-textarea v-model:value="key" placeholder="License key" class="!mt-4 !max-w-[600px]"></a-textarea>
</div>
<a-textarea v-model:value="key" placeholder="License key" class="!mt-2 !max-w-[600px]"></a-textarea>
</div>
<a-button class="mt-4" @click="setLicense" type="primary">Save license key</a-button>
</div>
</template>

11
packages/nc-gui/components/admin/ResetPassword.vue

@ -67,18 +67,9 @@ const resetError = () => {
</script>
<template>
<div class="relative flex flex-col justify-center gap-2 w-full p-8 md:(bg-white rounded-lg border-1 border-gray-200 shadow)">
<LazyGeneralNocoIcon class="color-transition hover:(ring ring-accent)" :animate="isLoading" />
<div
class="color-transition transform group absolute top-5 left-5 text-4xl rounded-full cursor-pointer"
@click="() => router.back()"
>
<MdiChevronLeft class="text-black group-hover:(text-accent scale-110)" />
</div>
<div class="relative flex flex-col justify-center gap-2 w-full p-8 md:(bg-white) max-w-[900px]">
<h1 class="prose-2xl font-bold self-center my-4">{{ $t('activity.changePwd') }}</h1>
<a-form
ref="formValidator"
data-cy="nc-user-settings-form"

6
packages/nc-gui/components/admin/UserManagement.vue

@ -28,13 +28,13 @@ const selectedTabKey = ref(tabs[0].key)
</a-tab-pane>
</a-tabs>
<template v-if="selectedTabKey === 'users'">
<LazyAdminUserList class="mt-10" />
<LazyAdminUserList />
</template>
<template v-else-if="selectedTabKey === 'settings'">
<LazyAdminSignupSettings class="mt-10" />
<LazyAdminSignupSettings />
</template>
<template v-else-if="selectedTabKey === 'password-reset'">
<LazyAdminResetPassword class="mt-10" />
<LazyAdminResetPassword />
</template>
</div>
</template>

18
packages/nocodb/src/lib/meta/api/ee/index.ts

@ -1,18 +0,0 @@
import { Router } from 'express';
import { LICENSE_KEY } from '../../../constants';
import Store from '../../../models/Store';
export const validateEE = async (_req, res, next) => {
const key = await Store.get(LICENSE_KEY);
if (!key?.value) {
return res.status(403).json({ msg: 'Not available' });
}
next();
};
const router = Router({ mergeParams: true });
// verify key
// router.use((_req, _res, next) => {});
export default router;

22
packages/nocodb/src/lib/meta/api/ee/orgTokenApis.ts

@ -0,0 +1,22 @@
import { OrgUserRoles } from '../../../../enums/OrgUserRoles';
import ApiToken from '../../../models/ApiToken';
import { PagedResponseImpl } from '../../helpers/PagedResponse';
export async function apiTokenListEE(req, res) {
let fk_user_id = req.user.id;
// if super admin get all tokens
if (req.user.roles.includes(OrgUserRoles.SUPER)) {
fk_user_id = undefined;
}
res.json(
new PagedResponseImpl(
await ApiToken.listWithCreatedBy({ ...req.query, fk_user_id }),
{
...req.query,
count: await ApiToken.count(),
}
)
);
}

9
packages/nocodb/src/lib/meta/api/orgTokenApis.ts

@ -4,17 +4,14 @@ import ApiToken from '../../models/ApiToken';
import { Tele } from '../../utils/Tele';
import { metaApiMetrics } from '../helpers/apiMetrics';
import { NcError } from '../helpers/catchError';
import getHandler from '../helpers/getHandler';
import ncMetaAclMw from '../helpers/ncMetaAclMw';
import { PagedResponseImpl } from '../helpers/PagedResponse';
import { apiTokenListEE } from './ee/orgTokenApis';
async function apiTokenList(req, res) {
let fk_user_id = req.user.id;
// if super admin get all tokens
if (req.user.roles.includes(OrgUserRoles.SUPER)) {
fk_user_id = undefined;
}
res.json(
new PagedResponseImpl(
await ApiToken.listWithCreatedBy({ ...req.query, fk_user_id }),
@ -49,7 +46,7 @@ const router = Router({ mergeParams: true });
router.get(
'/api/v1/tokens',
metaApiMetrics,
ncMetaAclMw(apiTokenList, 'apiTokenList', {
ncMetaAclMw(getHandler(apiTokenList, apiTokenListEE), 'apiTokenList', {
// allowedRoles: [OrgUserRoles.SUPER],
blockApiTokenAccess: true,
})

16
packages/nocodb/src/lib/meta/helpers/getHandler.ts

@ -0,0 +1,16 @@
import express from 'express';
import { LICENSE_KEY } from '../../constants';
import Store from '../../models/Store';
export default function getHandler(
defaultHandler: express.Handler,
eeHandler: express.Handler
): express.Handler {
return async (...args) => {
const key = await Store.get(LICENSE_KEY);
if (!key?.value) {
return defaultHandler(...args);
}
return eeHandler(...args);
};
}
Loading…
Cancel
Save