Skip to content

Commit

Permalink
adding Config from env file and removing json file
Browse files Browse the repository at this point in the history
  • Loading branch information
ooemperor committed Nov 21, 2024
1 parent c00478d commit e75938a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
9 changes: 4 additions & 5 deletions src/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
* Reads the config out of the .env file
* @author ooemperor
*/
import configData from "./config.sec.json"

/**
* Class for the config object used in total
*/
export class Config{
proxmoxApi: string;
proxmoxApiKey: string;
proxmoxApi: string | undefined;
proxmoxApiKey: string | undefined;

/**
* Constructor of the config
*/
constructor() {

this.proxmoxApi = configData.proxmox.api;
this.proxmoxApiKey = configData.proxmox.apiKey;
this.proxmoxApi = process.env.REACT_APP_PROXMOX_API;
this.proxmoxApiKey = process.env.REACT_APP_PROXMOX_API_KEY;
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/config.json

This file was deleted.

8 changes: 4 additions & 4 deletions src/services/ProxmoxService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import {NodesResponse} from "../models/proxmox/Node";
import {config} from "../Config";

class ProxmoxService {
apiToken: string;
baseUrl: string;
apiToken: string | undefined;
baseUrl: string | undefined;

/**
* Constructor of ProxmoxService
* @param apiToken the token for authentication
* @param baseUrl the base url for the proxmox server
*/
constructor(apiToken: string, baseUrl: string) {
constructor(apiToken: string | undefined, baseUrl: string | undefined) {
this.apiToken = apiToken;
this.baseUrl = baseUrl;
}
Expand All @@ -39,7 +39,7 @@ class ProxmoxService {
return nodeResponse;
}
const raw_json = await response.json();
nodeResponse.isRiding = await raw_json['data'];
nodeResponse.nodes = await raw_json['data'];
nodeResponse.success = true;
} catch (error: any) {
nodeResponse.message = error;
Expand Down
1 change: 0 additions & 1 deletion src/views/Proxmox/Nodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default function Nodes() {
const nodesData = await getNodes();
setNodes(nodesData.nodes);
}

loadNodes();

}, []);
Expand Down

0 comments on commit e75938a

Please sign in to comment.