{t("TABLE.VIOLATIONS")}
@@ -61,7 +60,7 @@ const ViolationsOverview = ({ t, violationsId, violations }) => (
goToPage(VIOLATIONS_PAGE, violationsId)}
+ onClick={() => goToPageWithFilter(VIOLATIONS_PAGE, filter)}
>
diff --git a/src/components/photos/photos.component.js b/src/components/photos/photos.component.js
new file mode 100644
index 00000000..5e6d2a25
--- /dev/null
+++ b/src/components/photos/photos.component.js
@@ -0,0 +1,215 @@
+import React, { Component, Fragment } from "react";
+import { withTranslation } from "react-i18next";
+import moment from "moment";
+
+import LoadingPanel from "./../partials/loading-panel/loading-panel.component";
+import FilterPanel from "./../partials/filter-panel/filter-panel.component";
+import SearchPanel from "./../partials/search-panel/search-panel.component";
+import RiskIcon from "./../partials/risk-icon/risk-icon.component";
+
+import BoardingDataHelper from "../partials/boarding-data.helper.js";
+import OverviewService from "./../../services/overview.service";
+import { convertFilter } from "./../../helpers/get-data";
+
+// import UserPhoto from "../../components/partials/user-photo/user-photo.component";
+
+import './photos.css';
+
+const overviewService = OverviewService.getInstance();
+
+const filterConfiguration = {
+ Risk: [
+ {
+ name: "safetyLevel.red",
+ field: "inspection.summary.safetyLevel",
+ value: "Red",
+ title: "Red",
+ partTitle: "Risk: Red",
+ type: "risk",
+ },
+ {
+ name: "safetyLevel.amber",
+ field: "inspection.summary.safetyLevel",
+ value: "Amber",
+ title: "Amber",
+ partTitle: "Risk: Amber",
+ type: "risk",
+ },
+ {
+ name: "safetyLevel.green",
+ field: "inspection.summary.safetyLevel",
+ value: "Green",
+ title: "Green",
+ partTitle: "Risk: Green",
+ type: "risk",
+ },
+ ],
+ "Boarding Information": [
+ {
+ name: "date",
+ title: "Date",
+ type: "date",
+ },
+ {
+ name: "date-from",
+ title: "Date from",
+ type: "date",
+ },
+ {
+ name: "date-to",
+ title: "Date To",
+ type: "date",
+ },
+ {
+ name: "time",
+ field: "date",
+ title: "Time",
+ type: "time",
+ },
+ {
+ name: "location",
+ title: "Location",
+ type: "location",
+ },
+ ],
+ "Vessel Information": [
+ {
+ name: "vessel.permitNumber",
+ title: "Permit Number",
+ type: "string-equal",
+ },
+ {
+ name: "vessel.nationality",
+ title: "Nationality",
+ },
+ ],
+ "Crews": [
+ {
+ name: "crewLicense",
+ field: "crew.license",
+ title: "Crew License Number",
+ type: "string-equal",
+ },
+ {
+ name: "crewName",
+ field: "crew.name",
+ title: "Crew name",
+ },
+ {
+ name: "captainLicense",
+ field: "captain.license",
+ title: "Captain license Number",
+ type: "string-equal",
+ },
+ {
+ name: "captainName",
+ field: "captain.lastName",
+ title: "Captain name",
+ },
+ ],
+};
+
+class PhotosPage extends Component {
+ state = {
+ photos: [],
+ loading: false,
+ mounted: false
+ };
+
+ componentDidMount() {
+ const filter = JSON.parse(this.props.match.params.filter);
+
+ this.setState({ loading: true, mounted: true, filter: convertFilter(filter) }, () => {
+ const licenseNumber = filter["crew.license"];
+
+ overviewService
+ .getBoardingsByFilter(filter)
+ .then((data) => {
+ const dataHelper = new BoardingDataHelper(data);
+
+ const newState = {
+ loading: false,
+ photos: dataHelper.getPhotos(licenseNumber),
+ };
+ this.setState(newState);
+ })
+ .catch((error) => {
+ console.error(error);
+ });
+ });
+ }
+
+ render() {
+ const { photos, loading, filter, mounted } = this.state;
+ const { t } = this.props;
+
+ return mounted && (
+
+
+ {!loading ? (
+
+
+
+
+ {t("BOARDING_PAGE.VIEW_BOARDING.PHOTOS")}
+
+
{`${photos.length} ${t(
+ "BOARDING_PAGE.VIEW_BOARDING.PHOTOS"
+ )}`}
+
+
+
+
+ {t("BOARDING_PAGE.ALL_DATES")} ⯆
+
+
+
+
+
+
+
+ {t("TABLE.PHOTO")} |
+ {t("BOARDING_PAGE.VIEW_BOARDING.BOARDING")} |
+ |
+ {t("TABLE.VESSEL")} |
+ {t("TABLE.BOARDED_BY")} |
+
+
+
+ {photos.map((photo, ind) => (
+
+
+ {/* */}
+
+
+
+ |
+ {moment(photo.date).format("LLL")} |
+
+
+ |
+ {photo.vessel} |
+ {photo.boardedBy} |
+
+ ))}
+
+
+
+
+ ) : (
+
+ )}
+
+ );
+ }
+}
+
+export default withTranslation("translation")(PhotosPage);
diff --git a/src/components/photos/photos.css b/src/components/photos/photos.css
new file mode 100644
index 00000000..b14bda52
--- /dev/null
+++ b/src/components/photos/photos.css
@@ -0,0 +1,3 @@
+.photos-overview .photo-icon {
+ width: 75px;
+}
diff --git a/src/components/vessels/vessel-data.helper.js b/src/components/vessels/vessel-data.helper.js
index a3e94011..def2b194 100644
--- a/src/components/vessels/vessel-data.helper.js
+++ b/src/components/vessels/vessel-data.helper.js
@@ -17,13 +17,13 @@ export default class VesselDataHelper {
}
getVesselNames() {
- const collection = {};
+ const collection = [];
this.boardings.forEach((boarding) => {
if (boarding.vessel && boarding.vessel.name) {
- collection[boarding.vessel.name] = null;
+ collection.push(boarding.vessel.name);
}
});
- return Object.keys(collection);
+ return collection;
}
getBoardings() {
diff --git a/src/components/vessels/vessel-view/vessel-view.component.js b/src/components/vessels/vessel-view/vessel-view.component.js
index 67c8ccc2..b36ff42e 100644
--- a/src/components/vessels/vessel-view/vessel-view.component.js
+++ b/src/components/vessels/vessel-view/vessel-view.component.js
@@ -1,6 +1,7 @@
import React, { Component, Fragment } from "react";
import { withTranslation } from "react-i18next";
import moment from "moment";
+import { NavLink } from "react-router-dom";
import SeeLink from "../../partials/see-all-link/see-all-link";
@@ -14,6 +15,8 @@ import LoadingPanel from "./../../partials/loading-panel/loading-panel.component
import VesselDataHelper from "../vessel-data.helper";
import OverviewService from "./../../../services/overview.service";
+import { CREW_PAGE } from "../../../root/root.constants.js";
+
import "./vessel-view.css";
const overviewService = OverviewService.getInstance();
@@ -33,70 +36,38 @@ class VesselViewPage extends Component {
homePorts: [],
captains: [],
nationalities: [],
+ filter: null
};
componentDidMount() {
- const id = this.props.match.params.id;
-
- if (!id || id === "no_permit_number") return;
-
- if (id.indexOf("pn") === 0) {
- this.setState({ loading: true }, () => {
- const permitNumber = id.substring(2);
-
- overviewService
- .getBoardingsByPermitNumber(permitNumber)
- .then((data) => {
- const dataHelper = new VesselDataHelper(permitNumber, data);
-
- const newState = {
- permitNumbers: dataHelper.getPermitNumbers(),
- vesselNames: dataHelper.getVesselNames(),
- boardings: dataHelper.getBoardings(),
- nationalities: dataHelper.getNationalities(),
- homePorts: dataHelper.getHomePorts(),
- captains: dataHelper.getCaptains(),
- crew: dataHelper.getCrew(),
- deliveries: dataHelper.getDeliveries(),
- photos: dataHelper.getPhotos(),
- notes: dataHelper.getNotes(),
- violations: dataHelper.getViolations(),
- loading: false,
- };
- this.setState(newState);
- })
- .catch((error) => {
- console.error(error);
- });
- });
- } else if (id.indexOf("in") === 0) {
- this.setState({ loading: true }, () => {
- const itemName = id.substring(2);
- overviewService
- .getBoardingsByVesselName(itemName)
- .then((data) => {
- const dataHelper = new VesselDataHelper(itemName, data);
- const newState = {
- permitNumbers: dataHelper.getPermitNumbers(),
- vesselNames: dataHelper.getVesselNames(),
- boardings: dataHelper.getBoardings(),
- nationalities: dataHelper.getNationalities(),
- homePorts: dataHelper.getHomePorts(),
- captains: dataHelper.getCaptains(),
- crew: dataHelper.getCrew(),
- deliveries: dataHelper.getDeliveries(),
- photos: dataHelper.getPhotos(),
- notes: dataHelper.getNotes(),
- violations: dataHelper.getViolations(),
- loading: false,
- };
- this.setState(newState);
- })
- .catch((error) => {
- console.error(error);
- });
- });
- }
+ const filter = JSON.parse(this.props.match.params.filter);
+ if (!filter) return;
+ this.setState({ loading: true, filter }, () => {
+ const permitNumber = filter["vessel.permitNumber"]
+ overviewService
+ .getBoardingsByFilter(filter)
+ .then((data) => {
+ const dataHelper = new VesselDataHelper(permitNumber, data);
+ const newState = {
+ permitNumbers: dataHelper.getPermitNumbers(),
+ vesselNames: dataHelper.getVesselNames(),
+ boardings: dataHelper.getBoardings(),
+ nationalities: dataHelper.getNationalities(),
+ homePorts: dataHelper.getHomePorts(),
+ captains: dataHelper.getCaptains(),
+ crew: dataHelper.getCrew(),
+ deliveries: dataHelper.getDeliveries(),
+ photos: dataHelper.getPhotos(),
+ notes: dataHelper.getNotes(),
+ violations: dataHelper.getViolations(),
+ loading: false,
+ };
+ this.setState(newState);
+ })
+ .catch((error) => {
+ console.error(error);
+ });
+ });
}
render() {
@@ -113,6 +84,7 @@ class VesselViewPage extends Component {
violations,
photos,
notes,
+ filter
} = this.state;
const { t } = this.props;
@@ -129,26 +101,26 @@ class VesselViewPage extends Component {
-
+
@@ -170,7 +142,7 @@ class VesselViewPage extends Component {