From f108148e5aca5e76ee348476bc803696d3d04b84 Mon Sep 17 00:00:00 2001 From: pepper Date: Sat, 21 Nov 2020 18:54:13 -0500 Subject: [PATCH] t --- src/components/root/Home.js | 1 - .../Pages/AllReports/GetSingleMigration.js | 62 ++++++++ .../root/Pages/AllReports/ShowMigrations.js | 150 ++++++++++++++++++ .../root/Pages/Forms/CPanelBooking.js | 2 +- src/components/root/Pages/Migrations.js | 6 +- .../root/Pages/Migrations/SideMigrations.js | 2 - src/components/root/Pages/Reports.js | 10 +- 7 files changed, 221 insertions(+), 12 deletions(-) create mode 100644 src/components/root/Pages/AllReports/GetSingleMigration.js create mode 100644 src/components/root/Pages/AllReports/ShowMigrations.js diff --git a/src/components/root/Home.js b/src/components/root/Home.js index e39b2b4..9015c85 100644 --- a/src/components/root/Home.js +++ b/src/components/root/Home.js @@ -2,7 +2,6 @@ import React, { Component } from "react"; import { callAPI } from "../actions/API"; import Migrations from "./Pages/Migrations"; -import Error from "../actions/Error"; import SideMigrations from "./Pages/Migrations/SideMigrations"; export class Home extends Component { diff --git a/src/components/root/Pages/AllReports/GetSingleMigration.js b/src/components/root/Pages/AllReports/GetSingleMigration.js new file mode 100644 index 0000000..23fdcc0 --- /dev/null +++ b/src/components/root/Pages/AllReports/GetSingleMigration.js @@ -0,0 +1,62 @@ +import React, { Component, useEffect, useState } from "react"; +import moment from "moment"; +import { Col, FormGroup, Row, Container, Label } from "reactstrap"; +import { Formik, Form } from "formik"; +import { Input, Submit } from "formstrap"; +import { callAPI } from "../../../actions/API"; +import ShowMigrations from "./ShowMigrations"; + +const initialValues = { + submit_time: moment().format("YYYY-MM-DD"), +}; +const onSubmit = async (values, { setSubmitting }) => { + callAPI + .get("/", values) + .then((response) => { + console.log(response.data); + this.setState({ + singlemigs: response.data, + }); + }) + .catch((error) => { + console.log(error); + }); + setSubmitting(false); +}; + +export default class GetSingleMigration extends Component { + constructor(props) { + super(props); + this.state = { + singlemigs: [], + e: false, + }; + } + render() { + return ( +
+ +
+ + + + + + + + + + Submit + +
+
+ +
+ ); + } +} diff --git a/src/components/root/Pages/AllReports/ShowMigrations.js b/src/components/root/Pages/AllReports/ShowMigrations.js new file mode 100644 index 0000000..acbdd50 --- /dev/null +++ b/src/components/root/Pages/AllReports/ShowMigrations.js @@ -0,0 +1,150 @@ +import React, { useState, useEffect } from "react"; +import { callAPI } from "../../../actions/API"; +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"; + +const ShowMigrations = () => { + const [list, setList] = useState([]); + const [loading, setLoading] = useState(false); + const { SearchBar } = Search; + const { ExportCSVButton } = CSVExport; + const sizePerPageRenderer = ({ + options, + currSizePerPage, + onSizePerPageChange, + }) => ( +
+ {options.map((option) => { + const isSelect = currSizePerPage === `${option.page}`; + return ( + + ); + })} +
+ ); + + const getListData = async () => { + try { + const data = await console.log(data); + setList(data.data); + 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 = [ + { dataField: "id", text: "ID", hidden: true }, + { dataField: "submit_time", text: "Submit Time", sort: true }, + { + dataField: "domain", + text: "Domain", + sort: true, + formatter: (cell, row) => {cell} , + }, + { dataField: "booked_date", text: "Booked Date", sort: true }, + { dataField: "booked_time", text: "Booked Time", sort: true }, + { dataField: "original_server", text: "Original Server", sort: true }, + { dataField: "new_server", text: "New Server", sort: true }, + { dataField: "username", text: "Username", sort: true }, + { dataField: "brand", text: "Brand", sort: true }, + { dataField: "ticket_id", text: "TicketID", sort: true }, + { dataField: "migration_status", text: "Status", sort: true }, + { dataField: "agent_booked", text: "Agent initials", sort: true }, + { dataField: "additional_domains", text: "Additional Domains", sort: true }, + { dataField: "migration_type", text: "Type", sort: true }, + { dataField: "term_date", text: "Termination Date", sort: true }, + { dataField: "notes", text: "Notes", sort: true }, + { + dataField: "report", + text: "Show Detailed Report", + formatter: (cell, row) => {cell} , + }, + ]; + + useEffect(() => { + getListData(); + }, []); + + return ( +
+ {loading ? ( + + {(props) => ( +
+
+

+ +
+ +
+ +
+ + Export CSV!! + +
+ )} +
+ ) : ( + + )} +
+ ); +}; + +export default ShowMigrations; diff --git a/src/components/root/Pages/Forms/CPanelBooking.js b/src/components/root/Pages/Forms/CPanelBooking.js index 6e75efc..523df0e 100644 --- a/src/components/root/Pages/Forms/CPanelBooking.js +++ b/src/components/root/Pages/Forms/CPanelBooking.js @@ -1,4 +1,4 @@ -import React, { Component } from "react"; +import React from "react"; import "bootstrap/dist/css/bootstrap.min.css"; import moment from "moment"; import { Col, FormGroup, Row, Container, Label } from "reactstrap"; diff --git a/src/components/root/Pages/Migrations.js b/src/components/root/Pages/Migrations.js index 170ae0b..af09e21 100644 --- a/src/components/root/Pages/Migrations.js +++ b/src/components/root/Pages/Migrations.js @@ -34,7 +34,7 @@ class Migrations extends Component { return (
-
+
{this.bookedMig()} @@ -45,7 +45,7 @@ class Migrations extends Component {
-
+

@@ -58,7 +58,7 @@ class Migrations extends Component {
-
+
{this.completedMig()} diff --git a/src/components/root/Pages/Migrations/SideMigrations.js b/src/components/root/Pages/Migrations/SideMigrations.js index f4ec683..cfd4bc3 100644 --- a/src/components/root/Pages/Migrations/SideMigrations.js +++ b/src/components/root/Pages/Migrations/SideMigrations.js @@ -1,8 +1,6 @@ import React, { Component } from "react"; -import { callAPI } from "../../../actions/API"; import { SingleSide } from "./SingleSide"; -import Error from "../../../actions/Error"; class SideMigrations extends Component { constructor(props) { diff --git a/src/components/root/Pages/Reports.js b/src/components/root/Pages/Reports.js index 716c7a1..27bf59f 100644 --- a/src/components/root/Pages/Reports.js +++ b/src/components/root/Pages/Reports.js @@ -1,9 +1,9 @@ -import React from 'react' +import React from "react"; + +import GetSingleMigration from "./AllReports/GetSingleMigration"; const Reports = () => { - return ( -

Reports

- ); -} + return ; +}; export default Reports;