Compare commits

..

6 Commits

12 changed files with 93 additions and 186 deletions

View File

@ -26,6 +26,7 @@ npm run build
The development server will start on `http://localhost:3000` The development server will start on `http://localhost:3000`
Get css docs here https://materializecss.com/ Get css docs here https://materializecss.com/
react-tables docs here https://react-bootstrap-table.github.io/react-bootstrap-table2/
Default .htaccess file Default .htaccess file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -1,16 +1,20 @@
a.white-link:link { a.white-link:link {
color: azure; color: azure;
font-size: large; font-size: large;
} }
a.white-link:hover { a.white-link:hover {
color: azure; color: azure;
font-size: large; font-size: large;
} }
a.white-link:visited { a.white-link:visited {
color: azure; color: azure;
font-size: large; font-size: large;
} }
a.white-link:active { a.white-link:active {
color: azure; color: azure;
font-size: large; font-size: large;
}
.react-bootstrap-table {
overflow-x: auto !important;
} }

View File

@ -5,9 +5,6 @@ import Cards from "./Pages/Cards";
import GenericList from "../root/Pages/GenericList"; import GenericList from "../root/Pages/GenericList";
import TimeSlotHelper from "./Pages/TimeSlotHelper"; import TimeSlotHelper from "./Pages/TimeSlotHelper";
import { UList } from "../root/common/Functionality/UnorderedList";
import { builfArrayFromObject } from "../actions/Error";
// Homepage/Cards, first API call here to pass down to cards // Homepage/Cards, first API call here to pass down to cards
// and the pending migration list, if there's no data, nothing will show // and the pending migration list, if there's no data, nothing will show
// This would benefit from an error/notification if there is no data // This would benefit from an error/notification if there is no data
@ -66,7 +63,7 @@ export class Home extends Component {
<div className="col s8 12"> <div className="col s8 12">
{/* <p>Current availability for {Date()}</p> {/* <p>Current availability for {Date()}</p>
<UList listItems={builfArrayFromObject(this.state.timeslots)} /> */} <UList listItems={builfArrayFromObject(this.state.timeslots)} /> */}
{/* <TimeSlotHelper /> */} <TimeSlotHelper />
</div> </div>
<div className="row"> <div className="row">
<div className="col s12"> <div className="col s12">

View File

@ -21,7 +21,7 @@ export default class Reports extends Component {
match: { params }, match: { params },
} = this.props; } = this.props;
const urlID = callAPI callAPI
.get(`/${params.migrationId}/`) .get(`/${params.migrationId}/`)
.then((response) => .then((response) =>
this.setState({ this.setState({
@ -31,14 +31,9 @@ export default class Reports extends Component {
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
}); });
console.log(urlID);
} }
render() { render() {
// const urlID = ({ migrationId }) => {
// console.log(migrationId.migrationId);
// };
return ( return (
<div> <div>
{/* {this.state.migs} */} {/* {this.state.migs} */}

View File

@ -1,7 +1,6 @@
import React, { Component } from "react"; import React, { Component } from "react";
import ReportSingleMigration from "../common/Forms/ReportSingleMigration"; import ReportSingleMigration from "../common/Forms/ReportSingleMigration";
import { callAPI } from "../../actions/API";
// /migrations in the address bar, // /migrations in the address bar,
// Allows the modification of migrations, and also populating a form // Allows the modification of migrations, and also populating a form
@ -9,35 +8,10 @@ import { callAPI } from "../../actions/API";
// ReportSingleMigration is the actual form, witha PUT API request on that page. // ReportSingleMigration is the actual form, witha PUT API request on that page.
export default class Migrations extends Component { export default class Migrations extends Component {
constructor(props) {
super(props);
this.state = {
migs: [],
redirect: false,
};
}
render() { render() {
const onSubmit = async (migrationId, { setSubmitting }) => {
callAPI
.get(`/${migrationId.migrationId}/`)
.then((response) =>
this.setState({
redirect: true,
migs: response.data,
})
)
.catch(function (error) {
console.log(error);
});
setSubmitting(false);
};
return ( return (
<div> <div>
<ReportSingleMigration <ReportSingleMigration />
key={this.state.migs.id}
item={this.state.migs}
/>
</div> </div>
); );
} }

View File

@ -14,15 +14,15 @@ class GenericList extends Component {
super(props); super(props);
this.state = { this.state = {
error: false, error: false,
timeslots: [],
bookedslots: [], bookedslots: [],
}; };
} }
componentDidMount() { componentDidMount() {
callAPI.get("/gettimeslots/").then((response) => { callAPI.get("/bookedslots/").then((response) => {
this.setState({ this.setState({
timeslots: response.data, bookedslots: response.data,
}); });
}); });
} }
@ -30,11 +30,7 @@ class GenericList extends Component {
renderItems() { renderItems() {
if (!this.state.error) { if (!this.state.error) {
return ( return (
<TimeSlots <TimeSlots booked={this.state.bookedslots} key={this.state.error} />
timeSlots={this.state.timeslots}
bookedSlots={this.state.bookedslots}
key={this.state.timeslots}
/>
); );
} else { } else {
return <Error />; return <Error />;
@ -46,9 +42,3 @@ class GenericList extends Component {
} }
} }
export default GenericList; export default GenericList;
// if (this.state.timeslots > 0) {
// else {
// return <Error />;
// }
// }

View File

@ -2,7 +2,7 @@ import React, { useState } from "react";
import "bootstrap/dist/css/bootstrap.min.css"; import "bootstrap/dist/css/bootstrap.min.css";
import moment from "moment"; import moment from "moment";
import { Col, FormGroup, Row, Container, Label } from "reactstrap"; import { Col, FormGroup, Row, Container, Label } from "reactstrap";
import { Formik, Form, Field } from "formik"; import { Formik, Form } from "formik";
import * as Yup from "yup"; import * as Yup from "yup";
import { Input, Submit } from "formstrap"; import { Input, Submit } from "formstrap";
import { callAPI } from "../../../actions/API"; import { callAPI } from "../../../actions/API";
@ -22,10 +22,8 @@ const InputValidation = Yup.object().shape({
) )
.required("Please enter a domain"), .required("Please enter a domain"),
username: Yup.string().min(2, "Too Short!").required("Required"), username: Yup.string().min(2, "Too Short!").required("Required"),
original_server: Yup.string() original_server: Yup.string().required("Please enter a valid IPv4 or domain"),
.required("Please enter a valid IPv4 or domain"), new_server: Yup.string().required("Please enter a valid IPv4 or domain"),
new_server: Yup.string()
.required("Please enter a valid IPv4 or domain"),
agent_booked: Yup.string() agent_booked: Yup.string()
.min(2, "Too short!") .min(2, "Too short!")
.required("Please enter your name!"), .required("Please enter your name!"),
@ -101,7 +99,9 @@ export const CPanelBooking = (timeslots) => {
className="has-success" className="has-success"
> >
<option>Select</option> <option>Select</option>
{timeslots.timeslots.map((slot) => <option>{slot}</option>)} {timeslots.timeslots.map((slot) => (
<option>{slot}</option>
))}
</Input> </Input>
</FormGroup> </FormGroup>
</Col> </Col>

View File

@ -99,6 +99,7 @@ const CompTable = (props) => {
: null : null
} }
target="_blank" target="_blank"
rel="noreferrer"
> >
{" "} {" "}
{cell}{" "} {cell}{" "}
@ -118,7 +119,7 @@ const CompTable = (props) => {
{ dataField: "migration_type", text: "Type", sort: true }, { dataField: "migration_type", text: "Type", sort: true },
{ dataField: "original_server", text: "Original Server", sort: true }, { dataField: "original_server", text: "Original Server", sort: true },
{ dataField: "new_server", text: "New Server", sort: true }, { dataField: "new_server", text: "New Server", sort: true },
{ dataField: "notes", text: "Notes", sort: true }, // { dataField: "notes", text: "Notes", sort: true },
]; ];
useEffect(() => { useEffect(() => {
@ -135,6 +136,7 @@ const CompTable = (props) => {
search search
exportCSV exportCSV
key={columns.id} key={columns.id}
width="100%"
> >
{(props) => ( {(props) => (
<div> <div>
@ -153,6 +155,8 @@ const CompTable = (props) => {
condensed condensed
key={columns.id} key={columns.id}
keyField="id" keyField="id"
wrapperClasses="table-responsive"
rowClasses="text-nowrap"
/> />
</div> </div>
<ExportCSVButton {...props.csvProps} key={columns}> <ExportCSVButton {...props.csvProps} key={columns}>

View File

@ -1,132 +1,74 @@
import React, { useState, useEffect } from "react"; import React from "react";
import BootstrapTable from "react-bootstrap-table-next"; import BootstrapTable from "react-bootstrap-table-next";
import paginationFactory from "react-bootstrap-table2-paginator";
import * as ReactBootstrap from "react-bootstrap";
import filterFactory from "react-bootstrap-table2-filter";
import ToolkitProvider, {
Search,
CSVExport,
} from "react-bootstrap-table2-toolkit";
// notes import ToolkitProvider from "react-bootstrap-table2-toolkit";
//
// Main table for the Historical migrations tab,
// receives all API information and displays as a table with a searchbox
const TimeSlots = (props) => { const TimeSlots = (props) => {
const [list, setList, setTimeSlots, setBookedSlots] = useState([]); let date = new Date(); // today
const [loading, setLoading] = useState(false); let yesterday =
const { SearchBar } = Search; date.getDate() - 1 + date.toLocaleDateString("en-AU").slice(2);
const { ExportCSVButton } = CSVExport; let today = date.getDate() + date.toLocaleDateString("en-AU").slice(2);
const sizePerPageRenderer = ({ let tomorrow = date.getDate() + 1 + date.toLocaleDateString("en-AU").slice(2);
options, let dayafter = date.getDate() + 2 + date.toLocaleDateString("en-AU").slice(2);
currSizePerPage, let dayafter2 =
onSizePerPageChange, date.getDate() + 3 + date.toLocaleDateString("en-AU").slice(2);
}) => (
<div className="btn-group" role="group">
{options.map((option) => {
const isSelect = currSizePerPage === `${option.page}`;
return (
<button
key={option.text}
type="button"
onClick={() => onSizePerPageChange(option.page)}
className={`btn ${isSelect ? "btn-secondary" : "btn-success"}`}
>
{option.text}
</button>
);
})}
</div>
);
const getListData = async () => {
try {
const setList = await props.setList;
setList();
setLoading(true);
} catch (e) {
console.log(e);
}
};
const options = {
// paginationSize: 4,
// pageStartIndex: 0,
// alwaysShowAllBtns: true, // Always show next and previous button
// withFirstAndLast: false, // Hide the going to First and Last page button
// hideSizePerPage: true, // Hide the sizePerPage dropdown always
// hidePageListOnlyOnePage: true, // Hide the pagination list when only one page
// firstPageText: "First",
// prePageText: "Back",
nextPageText: "Next",
lastPageText: "Last",
// nextPageTitle: "First page",
// prePageTitle: "Pre page",
// firstPageTitle: "Next page",
// lastPageTitle: "Last page",
// showTotal: true,
// disablePageTitle: true,
// sizePerPageList: [
// {
// text: "50",
// value: 50,
// },
// {
// text: "100",
// value: 100,
// },
// ],
sizePerPageRenderer, // A numeric array is also available. the purpose of above example is custom the text
};
const columns = [ const columns = [
{ dataField: "bookedSlots", text: "bookedslots", sort: true }, {
{ dataField: "timeSlots", text: "timeslots", sort: true }, dataField: "timeslot",
text: "timeslot/date",
},
{
dataField: "yesterday",
text: yesterday,
},
{
dataField: "today",
text: "TODAY",
style: { backgroundColor: "#9e9e9e" },
},
{
dataField: "tomorrow",
text: tomorrow,
},
{
dataField: "2days",
text: dayafter,
},
{
dataField: "3days",
text: dayafter2,
},
]; ];
useEffect(() => {
getListData();
}, []);
return ( return (
<div> <ToolkitProvider
{loading ? ( data={props.booked}
<ToolkitProvider keyField="timeslot"
keyField="name" key={columns.text}
data={list} columns={columns}
columns={columns} >
search {(props) => (
exportCSV <div className="py-4">
key={columns.id} <div
keyField="id" id="datatable-basic_filter"
> className="dataTables_filter px-4 pb-1"
{(props) => ( ></div>
<div> <BootstrapTable
<div className="serSec"> {...props.baseProps}
<h3 className="hdrOne"></h3> bootstrap4={true}
<SearchBar {...props.searchProps} key={columns} /> bordered={false}
</div> loading={true}
striped
<div className="table-responsive"> bordered
<BootstrapTable hover
{...props.baseProps} />
filter={filterFactory()} </div>
pagination={paginationFactory(options)}
striped
hover
condensed
key={columns.id}
/>
</div>
<ExportCSVButton {...props.csvProps} key={columns}>
Export CSV!!
</ExportCSVButton>
</div>
)}
</ToolkitProvider>
) : (
<ReactBootstrap.Spinner animation="border" />
)} )}
</div> </ToolkitProvider>
); );
}; };