Skip to content

Commit

Permalink
Merge pull request #50 from SJVAir/feat/display-all-calibrators
Browse files Browse the repository at this point in the history
Feat Display All Calibrators
  • Loading branch information
alexandermccormick authored Jul 25, 2024
2 parents 8ab7eae + 77f8d94 commit 434d3a2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 31 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"files": [
"dist"
],
"version": "1.9.4",
"version": "1.9.5",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
43 changes: 26 additions & 17 deletions src/DisplayOptions/MonitorMarkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ const monitorMarkersVisibility: DisplayOptionRecord<Checkbox> = Checkbox.defineO
model: true,
label: "Private PurpleAir"
},
Calibrators: {
label: "Collocation Sites",
displayInactive: {
containerClass: "has-text-grey-light",
icon: {
id: "square"
},
model: false,
svg: "crosshairs-svg"
label: "Inactive monitors"
},
PurpleAirInside: {
containerClass: "icon-border has-text-success",
Expand All @@ -70,13 +73,10 @@ const monitorMarkersVisibility: DisplayOptionRecord<Checkbox> = Checkbox.defineO
model: false,
label: "Inside monitors"
},
displayInactive: {
containerClass: "has-text-grey-light",
icon: {
id: "square"
},
Calibrators: {
label: "Collocation Sites",
model: false,
label: "Inactive monitors"
svg: "crosshairs-svg"
},
});

Expand Down Expand Up @@ -210,7 +210,10 @@ function isVisible(monitor: Monitor | Calibrator): boolean {
// showAirNow

if ("data" in monitor) {
if (!monitorMarkersVisibility.displayInactive.model.value && !monitor.data.is_active) {
if (monitorMarkersVisibility.Calibrators.model.value && monitorIsCalibrator(monitor)) {
return true;

} else if (!monitorMarkersVisibility.displayInactive.model.value && !monitor.data.is_active) {
return false;
}

Expand All @@ -225,7 +228,9 @@ function isVisible(monitor: Monitor | Calibrator): boolean {
return visibleByNetwork && visibleByLocation;

case "Central California Asthma Collaborative":
return monitorMarkersVisibility.SJVAirBAM.model.value;
return (monitorIsCalibrator(monitor))
? monitorMarkersVisibility.Calibrators.model.value || monitorMarkersVisibility.SJVAirBAM.model.value
: monitorMarkersVisibility.SJVAirBAM.model.value;

case "AirNow.gov":
return (monitorIsCalibrator(monitor))
Expand All @@ -238,23 +243,27 @@ function isVisible(monitor: Monitor | Calibrator): boolean {
: monitorMarkersVisibility.AQview.model.value;
}
} else if ("id" in monitor && isCalibratorObject(monitor.id)) {
const ref = getMonitor(monitor.reference_id);

if (!monitorMarkersVisibility.displayInactive.model.value && !ref.data.is_active) {
return false;
}
// NOTE: This commented out block hides inactive calibrator sites if the reference_id
// monitor is inactive. Feature removed by request
//
//const ref = getMonitor(monitor.reference_id);

//if (!monitorMarkersVisibility.displayInactive.model.value && !ref.data.is_active) {
// return false;
//}
return monitorMarkersVisibility.Calibrators.model.value;
}

return false;
}

function genCalibratorMapMarker(calibrator: Calibrator) {
const ref = getMonitor(calibrator.reference_id);
const [lng, lat] = calibrator.position.coordinates;
const icon = L.divIcon({
className: "is-flex is-justify-content-center is-align-items-center",
iconAnchor: new L.Point(6, 11),
html: "<div class='crosshairs-svg-lg is-flex-grow-0 is-flex-shrink-0'>Hello</div>"
html: `<div class='crosshairs-svg-lg ${ref.data.is_active ? "" : "disabled-monitor"} is-flex-grow-0 is-flex-shrink-0'>Hello</div>`
});
return L.marker(L.latLng(lat, lng), {
icon,
Expand Down
22 changes: 11 additions & 11 deletions src/modules/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import type { IColorLevel } from "../types";
export { darken, mix, toHex, readableColor } from "color2k";

export const Colors = {
white: 'ffffff',
gray: '969696',
black: '000000',
blue: '0000FF',
green: '00e400',
yellow: 'ffff00',
orange: 'ff7e00',
red: 'ff0000',
purple: '8f3f97',
maroon: '7e0023'
white: "ffffff",
gray: "969696",
black: "000000",
blue: "0000FF",
green: "00e400",
yellow: "ffff00",
orange: "ff7e00",
red: "ff0000",
purple: "8f3f97",
maroon: "7e0023"
} as const;

export function valueToColor(value: number, colors: Array<IColorLevel>) {
Expand All @@ -28,7 +28,7 @@ export function valueToColor(value: number, colors: Array<IColorLevel>) {
for (let i = 0; i <= colors.length - 1; i++) {
if (colors[i].min > value) {
// Level for current value
const min = colors[i-1];
const min = colors[i - 1];
// Level threshold for current value
const max = colors[i];
// Difference between max and min values => total steps in level
Expand Down
4 changes: 4 additions & 0 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@
height: 80px;
}

.disabled-monitor {
background-color: #7d7d7d;
}

.marker-selected {
/*
shadow
Expand Down

0 comments on commit 434d3a2

Please sign in to comment.