mirror of
				https://gitlab.com/comunic/comunicconsole
				synced 2025-11-04 04:04:04 +00:00 
			
		
		
		
	Load the list of roles in memory
This commit is contained in:
		@@ -25,6 +25,12 @@
 | 
			
		||||
      Learn how to configure a non-root public URL by running `npm run build`.
 | 
			
		||||
    -->
 | 
			
		||||
		<title>Comunic Console</title>
 | 
			
		||||
 | 
			
		||||
		<style>
 | 
			
		||||
			body {
 | 
			
		||||
				background-color: #212121;
 | 
			
		||||
			}
 | 
			
		||||
		</style>
 | 
			
		||||
	</head>
 | 
			
		||||
	<body>
 | 
			
		||||
		<noscript>You need to enable JavaScript to run this app.</noscript>
 | 
			
		||||
@@ -38,6 +44,5 @@
 | 
			
		||||
 | 
			
		||||
      To begin the development, run `npm start` or `yarn start`.
 | 
			
		||||
      To create a production bundle, use `npm run build` or `yarn build`.
 | 
			
		||||
    -->
 | 
			
		||||
  </body>
 | 
			
		||||
    --></body>
 | 
			
		||||
</html>
 | 
			
		||||
 
 | 
			
		||||
@@ -133,7 +133,7 @@ export class AdminKeyHelper {
 | 
			
		||||
	 * @param adminID The id of the target administrator
 | 
			
		||||
	 */
 | 
			
		||||
	static async GetAdminKeys(adminID: number): Promise<AdminAccountKey[]> {
 | 
			
		||||
		return await serverRequest("keys/keys", {
 | 
			
		||||
		return await serverRequest("keys/list", {
 | 
			
		||||
			id: adminID,
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								src/helpers/AdminRolesHelper.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/helpers/AdminRolesHelper.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Admin roles helper
 | 
			
		||||
 *
 | 
			
		||||
 * @author Pierre Hubert
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import { serverRequest } from "./APIHelper";
 | 
			
		||||
 | 
			
		||||
export interface AdminRole {
 | 
			
		||||
	id: string;
 | 
			
		||||
	name: string;
 | 
			
		||||
	description: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
let RolesList: AdminRole[] = [];
 | 
			
		||||
 | 
			
		||||
export class AdminRolesHelper {
 | 
			
		||||
	/**
 | 
			
		||||
	 * Load the list of roles.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @throws In case of failure
 | 
			
		||||
	 */
 | 
			
		||||
	static async LoadRolesList() {
 | 
			
		||||
		RolesList = await serverRequest("roles/list");
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -6,6 +6,7 @@
 | 
			
		||||
 | 
			
		||||
import React from "react";
 | 
			
		||||
import { AccountHelper } from "../../helpers/AccountHelper";
 | 
			
		||||
import { AdminRolesHelper } from "../../helpers/AdminRolesHelper";
 | 
			
		||||
import { LoginRoute } from "../routes/LoginRoute";
 | 
			
		||||
import { MainRoute } from "../routes/MainRoute";
 | 
			
		||||
import { AsyncWidget } from "./AsyncWidget";
 | 
			
		||||
@@ -31,6 +32,9 @@ export class InitWidget extends React.Component<{}, InitWidgetState> {
 | 
			
		||||
 | 
			
		||||
		if (AccountHelper.hasAccessToken) {
 | 
			
		||||
			await AccountHelper.refreshCurrentAccountInfo();
 | 
			
		||||
 | 
			
		||||
			await AdminRolesHelper.LoadRolesList();
 | 
			
		||||
 | 
			
		||||
			this.setState({ signedIn: true });
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user