mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
- Created NotFound.ejs for 404 error page with user-friendly messaging and navigation. - Added ServerError.ejs for 500 error handling with retry and documentation links. - Introduced Content.ejs partial for structured article content display. - Developed Head.ejs partial for consistent head elements across pages. - Implemented Header.ejs partial for navigation and branding. - Created Nav.ejs partial for sidebar navigation with dynamic links. - Added OpenSourceCommitment.ejs partial to highlight open-source contributions. - Implemented Pagination.ejs partial for navigation between documentation sections.
74 lines
2.3 KiB
TypeScript
74 lines
2.3 KiB
TypeScript
import { ViewsPath } from "../Utils/Config";
|
|
import ResourceUtil, { ModelDocumentation } from "../Utils/Resources";
|
|
import DataTypeUtil, { DataTypeDocumentation } from "../Utils/DataTypes";
|
|
import {
|
|
PermissionGroup,
|
|
PermissionHelper,
|
|
PermissionProps,
|
|
} from "Common/Types/Permission";
|
|
import { ExpressRequest, ExpressResponse } from "Common/Server/Utils/Express";
|
|
import { IsBillingEnabled } from "Common/Server/EnvironmentConfig";
|
|
import Dictionary from "Common/Types/Dictionary";
|
|
|
|
const Resources: Array<ModelDocumentation> = ResourceUtil.getResources();
|
|
const DataTypes: Array<DataTypeDocumentation> = DataTypeUtil.getDataTypes();
|
|
|
|
export default class ServiceHandler {
|
|
public static async executeResponse(
|
|
req: ExpressRequest,
|
|
res: ExpressResponse,
|
|
): Promise<void> {
|
|
// Initialize page title and description
|
|
let pageTitle: string = "";
|
|
let pageDescription: string = "";
|
|
|
|
// Get the requested page
|
|
const page: string | undefined = req.params["page"];
|
|
const pageData: Dictionary<unknown> = {};
|
|
|
|
// Set page title and description
|
|
pageTitle = "Permissions";
|
|
pageDescription = "Learn how permissions work with OneUptime";
|
|
|
|
// Filter permissions to only include those assignable to tenants
|
|
const tenantPermissions: Array<PermissionProps> =
|
|
PermissionHelper.getAllPermissionProps().filter((i: PermissionProps) => {
|
|
return i.isAssignableToTenant;
|
|
});
|
|
|
|
// Group permissions by PermissionGroup
|
|
const permissionGroups: Array<{
|
|
group: string;
|
|
permissions: Array<PermissionProps>;
|
|
}> = [];
|
|
|
|
for (const group of Object.values(PermissionGroup)) {
|
|
const groupPermissions: Array<PermissionProps> = tenantPermissions.filter(
|
|
(p: PermissionProps) => {
|
|
return p.group === group;
|
|
},
|
|
);
|
|
|
|
if (groupPermissions.length > 0) {
|
|
permissionGroups.push({
|
|
group: group,
|
|
permissions: groupPermissions,
|
|
});
|
|
}
|
|
}
|
|
|
|
pageData["permissionGroups"] = permissionGroups;
|
|
|
|
// Render the page
|
|
return res.render(`${ViewsPath}/pages/index`, {
|
|
page: page,
|
|
resources: Resources,
|
|
dataTypes: DataTypes,
|
|
pageTitle: pageTitle,
|
|
enableGoogleTagManager: IsBillingEnabled,
|
|
pageDescription: pageDescription,
|
|
pageData: pageData,
|
|
});
|
|
}
|
|
}
|