Integrate mkube storageclass api with UI (#156)
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -28,7 +28,6 @@ import CheckboxWrapper from "../../Common/FormComponents/CheckboxWrapper/Checkbo
|
||||
import SelectWrapper from "../../Common/FormComponents/SelectWrapper/SelectWrapper";
|
||||
import { k8sfactorForDropdown } from "../../../../common/utils";
|
||||
import ZonesMultiSelector from "./ZonesMultiSelector";
|
||||
import { storageClasses } from "../utils";
|
||||
|
||||
interface IAddTenantProps {
|
||||
open: boolean;
|
||||
@@ -76,6 +75,11 @@ const AddTenant = ({
|
||||
const [enableMCS, setEnableMCS] = useState<boolean>(false);
|
||||
const [enableSSL, setEnableSSL] = useState<boolean>(false);
|
||||
const [sizeFactor, setSizeFactor] = useState<string>("Gi");
|
||||
const [storageClasses, setStorageClassesList] = useState<string[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchStorageClassList();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (addSending) {
|
||||
@@ -87,7 +91,7 @@ const AddTenant = ({
|
||||
}
|
||||
|
||||
api
|
||||
.invoke("POST", `/api/v1/tenants`, {
|
||||
.invoke("POST", `/api/v1/mkube/tenants`, {
|
||||
name: tenantName,
|
||||
service_name: tenantName,
|
||||
image: imageName,
|
||||
@@ -124,6 +128,26 @@ const AddTenant = ({
|
||||
setVolumeConfiguration(volumeCopy);
|
||||
};
|
||||
|
||||
const fetchStorageClassList = () => {
|
||||
api
|
||||
.invoke("GET", `/api/v1/mkube/storage-classes`)
|
||||
.then((res: string[]) => {
|
||||
let classes: string[] = [];
|
||||
if (res !== null) {
|
||||
classes = res;
|
||||
}
|
||||
setStorageClassesList(classes);
|
||||
})
|
||||
.catch((err: any) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
|
||||
const storageClassesList = storageClasses.map((s: string) => ({
|
||||
label: s,
|
||||
value: s,
|
||||
}));
|
||||
|
||||
return (
|
||||
<ModalWrapper
|
||||
title="Create Tenant"
|
||||
@@ -255,7 +279,7 @@ const AddTenant = ({
|
||||
}}
|
||||
label="Storage Class"
|
||||
value={volumeConfiguration.storage_class}
|
||||
options={storageClasses}
|
||||
options={storageClassesList}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
|
||||
@@ -54,7 +54,7 @@ const DeleteTenant = ({
|
||||
useEffect(() => {
|
||||
if (deleteLoading) {
|
||||
api
|
||||
.invoke("DELETE", `/api/v1/tenants/${selectedTenant}`)
|
||||
.invoke("DELETE", `/api/v1/mkube/tenants/${selectedTenant}`)
|
||||
.then(() => {
|
||||
setDeleteLoading(false);
|
||||
setDeleteError("");
|
||||
|
||||
@@ -150,7 +150,7 @@ const ListTenants = ({ classes }: ITenantsList) => {
|
||||
api
|
||||
.invoke(
|
||||
"GET",
|
||||
`/api/v1/tenants?offset=${offset}&limit=${rowsPerPage}`
|
||||
`/api/v1/mkube/tenants?offset=${offset}&limit=${rowsPerPage}`
|
||||
)
|
||||
.then((res: ITenantsResponse) => {
|
||||
if (res === null) {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2020 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
export const storageClasses = [
|
||||
{ label: "Standard", value: "STANDARD" },
|
||||
{ label: "Reduced Redundancy", value: "REDUCED_REDUNDANCY" },
|
||||
];
|
||||
@@ -164,7 +164,7 @@ func FileServerMiddleware(next http.Handler) http.Handler {
|
||||
switch {
|
||||
case strings.HasPrefix(r.URL.Path, "/ws"):
|
||||
serveWS(w, r)
|
||||
case strings.HasPrefix(r.URL.Path, "/api/v1/tenants"):
|
||||
case strings.HasPrefix(r.URL.Path, "/api/v1/mkube"):
|
||||
client := &http.Client{}
|
||||
serverMkube(client, w, r)
|
||||
case strings.HasPrefix(r.URL.Path, "/api"):
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
// serverMkube handles calls for mkube
|
||||
func serverMkube(client *http.Client, w http.ResponseWriter, req *http.Request) {
|
||||
// destination of the request, the mkube server
|
||||
req.URL.Path = strings.Replace(req.URL.Path, "/mkube", "", 1)
|
||||
targetURL := fmt.Sprintf("%s%s", getM3Host(), req.URL.String())
|
||||
|
||||
// set the HTTP method, url, and m3Req body
|
||||
|
||||
Reference in New Issue
Block a user