Skip to content

Commit

Permalink
Merge branch 'minor' into firebase-as-object-store
Browse files Browse the repository at this point in the history
  • Loading branch information
RobAndrewHurst authored Nov 1, 2024
2 parents ae29df2 + dd2d7ee commit dfc8923
Show file tree
Hide file tree
Showing 59 changed files with 673 additions and 388 deletions.
17 changes: 0 additions & 17 deletions .eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [ "main" ]
branches: [ "main", "major", "minor", "patch" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches: [ "main", "major", "minor", "patch" ]
schedule:
- cron: '40 1 * * 2'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: ESLint

on:
push:
branches: [ "main", "major", "minor", "patch" ]
pull_request:
branches: [ "main", "major", "minor", "patch" ]

jobs:
eslint:
name: Run ESLint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Run ESLint
run: npx eslint . --max-warnings=0
4 changes: 2 additions & 2 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Codi unit tests

on:
push:
branches: [ main ]
branches: [ "main", "major", "minor", "patch" ]
pull_request:
branches: [ main ]
branches: [ "main", "major", "minor", "patch" ]

jobs:
build:
Expand Down
17 changes: 17 additions & 0 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ ESBuild must also be used to compile the CSS supporting the MAPP and MAPP.UI ele

npx esbuild --bundle public/css/_ui.css --outfile=public/css/ui.css --loader:.svg=dataurl

## ESLint

The codebase makes use of the [eslint](eslint.org) package to ensure that our code adhere to different rules and coding guidelines.
To run `eslint` you will need to have the development packages installed. You can ensure they are installed by running `npm install` in the root of the xyz directory.

To run the lint you can execute `npx eslint .` in the root of the application. This will show any issues there are with the codebase. You can also add the flag `--fix` to the command to allow eslint to fix any issues it may find.

eslint command

npx esbuild .

eslint command with fix

npx esbuild . --fix

There are other extensions you can use in your editor to get on the fly error highlighting where any rules are broken. Please look into what eslint supports in your environment.

## version.js hash

The mapp module object holds a hash of the latest release commit which can be generated by executing the version.js script in the root.
Expand Down
22 changes: 22 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default [
{
ignores: ['public/js/lib/*', 'docs/**/*'],
},
{
files: ['**/*.js', '**/*.mjs'],
rules: {
quotes: ['error', 'single', { 'allowTemplateLiterals': true }],
'prefer-const': ['error', {
'destructuring': 'any',
'ignoreReadBeforeAssign': true
}],
'max-depth': ['error',
{
'max': 4
}
],
// 'complexity': ['error', { 'max': 15 }],
'no-nested-ternary': 'error'
}
}
];
4 changes: 1 addition & 3 deletions express.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ app.get(`${process.env.DIR || ''}/api/provider/:provider?`, api)

app.post(`${process.env.DIR || ''}/api/provider/:provider?`, express.json({ limit: '5mb' }), api)

app.get(`${process.env.DIR || ''}/api/sign/:provider?`, api)

app.post(`${process.env.DIR || ''}/api/sign/:provider?`, express.json({ limit: '5mb' }), api)
app.get(`${process.env.DIR || ''}/api/sign/:signer?`, api)


app.get(`${process.env.DIR || ''}/api/query/:template?`, api)
Expand Down
2 changes: 1 addition & 1 deletion lib/layer/decorate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ async function zoomToExtent(params) {
// Zooms to a specific extent.

// XMLHttpRequest to layer extent endpoint
let response = await mapp.utils.xhr(`${this.mapview.host}/api/query/layer_extent?` +
const response = await mapp.utils.xhr(`${this.mapview.host}/api/query/layer_extent?` +
mapp.utils.paramString({ // build query string for the url
locale: this.mapview.locale.key,
layer: this.key,
Expand Down
6 changes: 3 additions & 3 deletions lib/layer/featureFields.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ The jenks distribution method requires the stats.jenks utility method to calcula
@param {layer} layer A decorated mapp layer object.
*/
function jenks(layer) {
let theme = layer.style.theme;
const theme = layer.style.theme;

let n = Math.min(layer.featureFields[theme.field].values.length, theme.categories.length);
const n = Math.min(layer.featureFields[theme.field].values.length, theme.categories.length);

// Parse array values as float.
layer.featureFields[theme.field].values = layer.featureFields[theme.field].values.map(parseFloat);
Expand All @@ -113,7 +113,7 @@ The count distribution method counts values in the `featureFields.values[]` arra
@param {layer} layer A decorated mapp layer object.
*/
function count(layer) {
let theme = layer.style.theme;
const theme = layer.style.theme;

layer.featureFields[theme.field].values.forEach(val => {

Expand Down
2 changes: 1 addition & 1 deletion lib/layer/featureStyle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default function featureStyle(layer) {

if (!layer.style.cluster) return;

let clusterScale = parseFloat(layer.style.cluster.clusterScale)
const clusterScale = parseFloat(layer.style.cluster.clusterScale)

// Spread cluster style into feature.style.
feature.style = {
Expand Down
2 changes: 1 addition & 1 deletion lib/layer/themes/distributed.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function(theme, feature) {
theme.index = 0
}

let field = theme.field || 'id'
const field = theme.field || 'id'

// Get feature identifier for theme.
const val = feature.properties[field]
Expand Down
6 changes: 3 additions & 3 deletions lib/layer/themes/graduated.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function (theme, feature) {
// The graduated theme requires feature.properties.
if (!feature.properties) return;

let catValue = Array.isArray(feature.properties.features) ?
const catValue = Array.isArray(feature.properties.features) ?

// Reduce array of features to sum catValue
feature.properties.features.reduce((total, F) => total + Number(F.getProperties()[theme.field]), 0) :
Expand All @@ -35,9 +35,9 @@ export default function (theme, feature) {
'greater_than': val => cat => val >= cat.value
}

let index = theme.categories.findIndex(graduated_breaks[theme.graduated_breaks](catValue))
const index = theme.categories.findIndex(graduated_breaks[theme.graduated_breaks](catValue))

let cat = theme.categories.at(index)
const cat = theme.categories.at(index)

// Spread cat style to retain scale property
feature.style = {
Expand Down
2 changes: 1 addition & 1 deletion lib/location/create.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default async function createLocation(feature, interaction, layer) {
setTimeout(checkFeature, 1000);

function checkFeature() {
let found = layer.features?.find(F => F.properties?.id === location.id);
const found = layer.features?.find(F => F.properties?.id === location.id);
if (found) {
layer.source.un('tileloadend', concatFeatures);
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/mapp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ if (window.ol === undefined) {

} else {

let olVersion = parseFloat(ol?.util.VERSION)
const olVersion = parseFloat(ol?.util.VERSION)

console.log(`OpenLayers version ${olVersion}`)

Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/login.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export function login(plugin, mapview) {
btnColumn.appendChild(mapp.utils.html.node`
<a
title=${mapp.user ? mapp.dictionary.toolbar_logout : mapp.dictionary.toolbar_login}
href=${mapp.user ? "?logout=true" : "?login=true"}>
href=${mapp.user ? '?logout=true' : '?login=true'}>
<div class=${iconClass}>`);
}
2 changes: 1 addition & 1 deletion lib/ui/Gazetteer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default gazetteer => {
if (!e.target.value.length) return;

// Get possible coordinates from input.
let ll = e.target.value.split(',').map(parseFloat)
const ll = e.target.value.split(',').map(parseFloat)

// Check whether coordinates are valid float values.
if (ll.length === 2 && ll.every(n => typeof n === 'number' && !isNaN(n) && isFinite(n))) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/elements/legendIcon.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function createIconFromArray(style) {
});
};

let legendScale = style.icon[0].legendScale || 1;
const legendScale = style.icon[0].legendScale || 1;

style.icon.forEach((icon) => {

Expand Down
2 changes: 1 addition & 1 deletion lib/ui/layers/filters.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ async function filter_in(layer, filter) {

const pattern = e.target.value;

let filtered = filter[filter.type].filter(val =>
const filtered = filter[filter.type].filter(val =>

// val may not be string.
val.toString().toLowerCase().startsWith(pattern.toLowerCase()))
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/layers/legends/categorized.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function categorizedTheme(layer) {
const cat_label = cat.label + (cat.count? ` [${cat.count}]`:'')

// Cat label with filter function.
let label = mapp.utils.html`<div
const label = mapp.utils.html`<div
class=${classList}
style="grid-column: 2;"
onclick=${e => catToggle(e, layer, cat)}>${cat_label}`
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/layers/listview.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default function (params) {
group.meta = mapp.utils.html.node`<div class="meta">`

group.drawer = mapp.ui.elements.drawer({
data_id: `layer-drawer`,
data_id: layer.group,
class: `layer-group ${layer.groupClassList || ''}`,
header: mapp.utils.html`
<h2>${layer.group}</h2>
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/layers/view.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default function layerView(layer) {
const drawerClass = `layer-view raised ${layer.classList || ''} ${content.length ? '' : 'empty'}`

layer.drawer = mapp.ui.elements.drawer({
data_id: `layer-drawer`,
data_id: layer.key,
class: drawerClass,
header,
content
Expand Down Expand Up @@ -242,7 +242,7 @@ function changeEnd(layer) {
layer.zoomBtn.style.display = 'block'

// Collapse drawer and disable layer.view.
layer.view.querySelector('[data-id=layer-drawer]').classList.remove('expanded')
layer.view.querySelector('.layer-view.drawer').classList.remove('expanded')

// Disable layer display toggle.
layer.displayToggle.classList.add('disabled')
Expand Down
Loading

0 comments on commit dfc8923

Please sign in to comment.