Skip to content

Commit

Permalink
feat(dashboard): add filter to some pages (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusualhashash authored Oct 15, 2024
2 parents d5c178a + 89d4ce0 commit e867023
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 31 deletions.
189 changes: 165 additions & 24 deletions apps/web/src/app/[lang]/app/[type]/management/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
$Volo_Abp_OpenIddict_Scopes_Dtos_ScopeDto,
$Volo_Abp_OpenIddict_Scopes_Dtos_UpdateScopeInput,
} from "@ayasofyazilim/saas/IdentityService";
import type { GetApiSaasEditionsResponse } from "@ayasofyazilim/saas/SaasService";
import {
$Volo_Saas_Host_Dtos_EditionCreateDto,
$Volo_Saas_Host_Dtos_EditionDto,
Expand All @@ -43,7 +44,7 @@ export const dataConfig: Record<string, any> = {
applications: {
title: "Application",
detailedFilters: [
{ name: "filter", displayName: "Search", type: "string", value: "" },
{ name: "filter", displayName: "Client Id", type: "string", value: "" },
],
createFormSchema: {
formPositions: [
Expand Down Expand Up @@ -284,7 +285,14 @@ export const dataConfig: Record<string, any> = {
default: "edition",
edition: {
title: "Edition",
detailedFilters: [],
detailedFilters: [
{
name: "filter",
displayName: "Display Name",
type: "string",
value: "",
},
],
createFormSchema: {
formPositions: ["displayName"],
schema: $Volo_Saas_Host_Dtos_EditionCreateDto,
Expand All @@ -294,14 +302,55 @@ export const dataConfig: Record<string, any> = {
schema: $Volo_Saas_Host_Dtos_EditionUpdateDto,
},
tableSchema: {
excludeList: ["planId", "id", "planId", "concurrencyStamp"],
excludeList: ["planId", "id", "planId", "planName", "concurrencyStamp"],
schema: $Volo_Saas_Host_Dtos_EditionDto,
},
},
tenant: {
title: "Tenant",
detailedFilters: [
{ name: "filter", displayName: "Search", type: "string", value: "" },
{ name: "filter", displayName: "Name", type: "string", value: "" },
{
name: "ActivationState",
displayName: "Activation State",
type: "select",
value: "",
options: [
{ label: "Active", value: "0" },
{ label: "Active with limited time", value: "1" },
{ label: "Passive", value: "2" },
],
},
{
name: "GetEditionNames",
displayName: "Get Edition Name",
type: "boolean",
value: "true",
},
{
name: "ExpirationDateMin",
displayName: "Expiration Date Min",
type: "string",
value: "",
},
{
name: "ExpirationDateMax",
displayName: "Expiration Date Max",
type: "string",
value: "",
},
{
name: "ActivationEndDateMin",
displayName: "Activation End Date Min",
type: "string",
value: "",
},
{
name: "ActivationEndDateMax",
displayName: "Activation End Date Max",
type: "string",
value: "",
},
],
createFormSchema: {
formPositions: [
Expand All @@ -320,9 +369,9 @@ export const dataConfig: Record<string, any> = {
},
editionId: {
data: () => {
return fetch(getBaseLink("api/admin/edition")).then((data) =>
data.json(),
);
return fetch(getBaseLink("api/admin/edition?maxResultCount=1000"))
.then((data) => data.json())
.then((jsonData: GetApiSaasEditionsResponse) => jsonData.items);
},
get: "displayName",
post: "id",
Expand All @@ -348,10 +397,10 @@ export const dataConfig: Record<string, any> = {
type: "enum",
},
editionId: {
data: async () => {
return fetch(getBaseLink("api/admin/edition")).then((data) =>
data.json(),
);
data: () => {
return fetch(getBaseLink("api/admin/edition?maxResultCount=1000"))
.then((data) => data.json())
.then((jsonData: GetApiSaasEditionsResponse) => jsonData.items);
},
covertTo: "editionName",
get: "displayName",
Expand All @@ -374,10 +423,10 @@ export const dataConfig: Record<string, any> = {
type: "enum",
},
editionId: {
data: async () => {
return fetch(getBaseLink("api/admin/edition")).then((data) =>
data.json(),
);
data: () => {
return fetch(getBaseLink("api/admin/edition?maxResultCount=1000"))
.then((data) => data.json())
.then((jsonData: GetApiSaasEditionsResponse) => jsonData.items);
},
covertTo: "editionName",
get: "displayName",
Expand All @@ -403,7 +452,14 @@ export const dataConfig: Record<string, any> = {
default: "role",
role: {
title: "Role",
detailedFilters: [],
detailedFilters: [
{
name: "filter",
displayName: "Name",
type: "string",
value: "",
},
],
createFormSchema: {
formPositions: ["name", "isDefault", "isPublic"],
schema: $Volo_Abp_Identity_IdentityRoleCreateDto,
Expand All @@ -422,6 +478,84 @@ export const dataConfig: Record<string, any> = {
title: "User",
detailedFilters: [
{ name: "filter", displayName: "Search", type: "string", value: "" },
{
name: "UserName",
displayName: "User Name",
type: "string",
value: "",
},
{
name: "Name",
displayName: "Name",
type: "string",
value: "",
},
{
name: "Surname",
displayName: "Surname",
type: "string",
value: "",
},
{
name: "EmailAddress",
displayName: "Email Address",
type: "string",
value: "",
},
{
name: "PhoneNumber",
displayName: "Phone Number",
type: "string",
value: "",
},
{
name: "IsLockedOut",
displayName: "Is Locked Out",
type: "boolean",
value: "true",
},
{
name: "NotActive",
displayName: "Not Active",
type: "boolean",
value: "true",
},
{
name: "EmailConfirmed",
displayName: "Email Confirmed",
type: "boolean",
value: "true",
},
{
name: "IsExternal",
displayName: "Is External",
type: "boolean",
value: "true",
},
{
name: "MaxCreationTime",
displayName: "Max Creation Time",
type: "string",
value: "",
},
{
name: "MinCreationTime",
displayName: "Min Creation Time",
type: "string",
value: "",
},
{
name: "MaxModifitionTime",
displayName: "Max Modifition Time",
type: "string",
value: "",
},
{
name: "MinModifitionTime",
displayName: "Min Modifition Time",
type: "string",
value: "",
},
],
createFormSchema: {
formPositions: ["email", "password", "userName"],
Expand All @@ -434,19 +568,18 @@ export const dataConfig: Record<string, any> = {
tableSchema: {
excludeList: [
"id",
"deleterId",
"isDeleted",
"deletionTime",
"tenantId",
"extraProperties",
"concurrencyStamp",
"creationTime",
"creatorId",
"lastModificationTime",
"lastModifierId",
"lastPasswordChangeTime",
"twoFactorEnabled",
"supportTwoFactor",
"shouldChangePasswordOnNextLogin",
"emailConfirmed",
"isLockedOut",
"phoneNumberConfirmed",
"accessFailedCount",
"lastModificationTime",
"lastModifierId",
"lockoutEnabled",
"lockoutEnd",
],
Expand Down Expand Up @@ -647,6 +780,14 @@ export const dataConfig: Record<string, any> = {
default: "text-templates",
"text-templates": {
title: "Text Templates",
detailedFilters: [
{
name: "FilterText",
displayName: "Display Name",
type: "string",
value: "",
},
],
tableSchema: {
excludeList: ["name", "additionalProperties"],
schema:
Expand Down
71 changes: 65 additions & 6 deletions apps/web/src/app/api/admin/[data]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ const clients: Clients = {
const client = await getIdentityServiceClient();
const role = client.role;
return {
get: async () => role.getApiIdentityRolesAll(),
get: async (page: number, _filter: string) => {
const parsedFilter = JSON.parse(_filter || "{}");
const filter = parsedFilter?.filter;
return role.getApiIdentityRoles({
maxResultCount: 10,
skipCount: page * 10,
filter,
});
},
post: async (requestBody: unknown) => {
return role.postApiIdentityRoles({ requestBody } as {
requestBody: Volo_Abp_Identity_IdentityRoleCreateDto;
Expand All @@ -39,12 +47,39 @@ const clients: Clients = {
get: async (page: number, _filter: string) => {
const parsedFilter = JSON.parse(_filter || "{}");
const filter = parsedFilter?.filter;
const userName = parsedFilter?.UserName;
const name = parsedFilter?.Name;
const surname = parsedFilter?.Surname;
const emailAddress = parsedFilter?.EmailAddress;
const phoneNumber = parsedFilter?.PhoneNumber;
const isLockedOut = parsedFilter?.IsLockedOut;
const notActive = parsedFilter?.NotActive;
const emailConfirmed = parsedFilter?.EmailConfirmed;
const isExternal = parsedFilter?.IsExternal;
const maxCreationTime = parsedFilter?.MaxCreationTime;
const minCreationTime = parsedFilter?.MinCreationTime;
const maxModifitionTime = parsedFilter?.MaxModifitionTime;
const minModifitionTime = parsedFilter?.MinModifitionTime;
return user.getApiIdentityUsers({
maxResultCount: 10,
skipCount: page * 10,
filter,
userName,
name,
surname,
emailAddress,
phoneNumber,
isLockedOut,
notActive,
emailConfirmed,
isExternal,
maxCreationTime,
minCreationTime,
maxModifitionTime,
minModifitionTime,
});
},

post: async (requestBody: any) =>
user.postApiIdentityUsers({ requestBody }),
put: async ({ id, requestBody }: { id: string; requestBody: any }) =>
Expand All @@ -56,7 +91,16 @@ const clients: Clients = {
const client = await getSaasServiceClient();
const edition = client.edition;
return {
get: async () => edition.getApiSaasEditionsAll(),
get: async (page: number, _filter: string, _maxResultCount: unknown) => {
const maxResultCount = Number(_maxResultCount) || 10;
const parsedFilter = JSON.parse(_filter || "{}");
const filter = parsedFilter?.filter;
return edition.getApiSaasEditions({
maxResultCount: maxResultCount || 10,
skipCount: page * 10,
filter,
});
},
post: async (requestBody: any) =>
edition.postApiSaasEditions({ requestBody }),
put: async ({ id, requestBody }: { id: string; requestBody: any }) =>
Expand All @@ -72,10 +116,22 @@ const clients: Clients = {
get: async (page: number, _filter: string) => {
const parsedFilter = JSON.parse(_filter || "{}");
const filter = parsedFilter?.filter;
const getEditionNames = parsedFilter?.GetEditionNames;
const expirationDateMin = parsedFilter?.ExpirationDateMin;
const expirationDateMax = parsedFilter?.ExpirationDateMax;
const activationState = parsedFilter?.ActivationState;
const activationEndDateMin = parsedFilter?.ActivationEndDateMin;
const activationEndDateMax = parsedFilter?.ActivationEndDateMax;
return tenant.getApiSaasTenants({
maxResultCount: 10,
skipCount: page * 10,
filter,
getEditionNames,
expirationDateMin,
expirationDateMax,
activationState,
activationEndDateMin,
activationEndDateMax,
});
},
post: async (requestBody: any) =>
Expand Down Expand Up @@ -264,12 +320,15 @@ const clients: Clients = {
const client = await getAdministrationServiceClient();
const textTemplates = client.textTemplateDefinitions;
return {
get: async (page: number) =>
textTemplates.getApiTextTemplateManagementTemplateDefinitions({
get: async (page: number, filter: string) => {
const parsedFilter = JSON.parse(filter || "{}");
const filterText = parsedFilter?.FilterText;
return textTemplates.getApiTextTemplateManagementTemplateDefinitions({
maxResultCount: 10,
skipCount: page * 10,
//filter: filter,
}),
filterText,
});
},
};
},

Expand Down

0 comments on commit e867023

Please sign in to comment.