Housekeeping...

This commit is contained in:
Pieter Vander Vennet 2022-10-27 01:50:01 +02:00
parent 707b25529b
commit 6d822b42ca
158 changed files with 7939 additions and 11272 deletions

View file

@ -148,7 +148,13 @@ export default abstract class BaseUIElement {
} catch (e) {
const domExc = e as DOMException
if (domExc) {
console.error("An exception occured", domExc.code, domExc.message, domExc.name, domExc)
console.error(
"An exception occured",
domExc.code,
domExc.message,
domExc.name,
domExc
)
}
console.error(e)
}

View file

@ -70,7 +70,7 @@ export default class ExportPDF {
console.error(e)
self.cleanup()
}
}, 500)
}, 500),
})
minimap.SetStyle(

View file

@ -13,7 +13,7 @@ export default class LanguagePicker extends Toggle {
console.log("Constructing a language pîcker for languages", languages)
if (languages === undefined || languages.length <= 1) {
super(undefined, undefined, undefined)
}else {
} else {
const normalPicker = LanguagePicker.dropdownFor(languages, label)
const fullPicker = new Lazy(() => LanguagePicker.dropdownFor(allLanguages, label))
super(fullPicker, normalPicker, Locale.showLinkToWeblate)

View file

@ -544,7 +544,7 @@ export default class SpecialVisualizations {
const features: { freshness: Date; feature: any }[] = []
for (const key of keys) {
const value = properties[key]
if(value === undefined || value === null){
if (value === undefined || value === null) {
continue
}
@ -556,7 +556,7 @@ export default class SpecialVisualizations {
for (const id of idList) {
const feature = featureStore.get(id)
if(feature === undefined){
if (feature === undefined) {
console.warn("No feature found for id ", id)
continue
}

View file

@ -1,27 +1,26 @@
/**
* The statistics-gui shows statistics from previous MapComplete-edits
*/
import {UIEventSource} from "../Logic/UIEventSource"
import {VariableUiElement} from "./Base/VariableUIElement"
import { UIEventSource } from "../Logic/UIEventSource"
import { VariableUiElement } from "./Base/VariableUIElement"
import Loading from "./Base/Loading"
import {Utils} from "../Utils"
import { Utils } from "../Utils"
import Combine from "./Base/Combine"
import {StackedRenderingChart} from "./BigComponents/TagRenderingChart"
import {LayerFilterPanel} from "./BigComponents/FilterView"
import {AllKnownLayouts} from "../Customizations/AllKnownLayouts"
import { StackedRenderingChart } from "./BigComponents/TagRenderingChart"
import { LayerFilterPanel } from "./BigComponents/FilterView"
import { AllKnownLayouts } from "../Customizations/AllKnownLayouts"
import MapState from "../Logic/State/MapState"
import BaseUIElement from "./BaseUIElement"
import Title from "./Base/Title"
import { FixedUiElement } from "./Base/FixedUiElement"
import List from "./Base/List";
import List from "./Base/List"
class StatisticsForOverviewFile extends Combine {
constructor(homeUrl: string, paths: string[]) {
paths = paths.filter(p => !p.endsWith("file-overview.json"))
paths = paths.filter((p) => !p.endsWith("file-overview.json"))
const layer = AllKnownLayouts.allKnownLayouts.get("mapcomplete-changes").layers[0]
const filteredLayer = MapState.InitializeFilteredLayers(
{id: "statistics-view", layers: [layer]},
{ id: "statistics-view", layers: [layer] },
undefined
)[0]
const filterPanel = new LayerFilterPanel(undefined, filteredLayer)
@ -30,7 +29,7 @@ class StatisticsForOverviewFile extends Combine {
const downloaded = new UIEventSource<{ features: ChangeSetData[] }[]>([])
for (const filepath of paths) {
if(filepath.endsWith("file-overview.json")){
if (filepath.endsWith("file-overview.json")) {
continue
}
Utils.downloadJson(homeUrl + filepath).then((data) => {
@ -41,7 +40,7 @@ class StatisticsForOverviewFile extends Combine {
data.features = data
}
data?.features?.forEach((item) => {
item.properties = {...item.properties, ...item.properties.metadata}
item.properties = { ...item.properties, ...item.properties.metadata }
delete item.properties.metadata
})
downloaded.data.push(data)
@ -55,7 +54,6 @@ class StatisticsForOverviewFile extends Combine {
)
)
super([
filterPanel,
new VariableUiElement(
@ -117,27 +115,32 @@ class StatisticsForOverviewFile extends Combine {
"import",
"conflation",
"link-image",
"soft-delete"]
"soft-delete",
]
const allThemes = Utils.Dedup(overview._meta.map(f => f.properties.theme))
const allThemes = Utils.Dedup(overview._meta.map((f) => f.properties.theme))
const excludedThemes = new Set<string>()
if(allThemes.length > 1){
excludedThemes.add("grb")
excludedThemes.add("etymology")
if (allThemes.length > 1) {
excludedThemes.add("grb")
excludedThemes.add("etymology")
}
const summedValues = valuesToSum
.map(key => [key, overview.sum(key, excludedThemes)])
.filter(kv => kv[1] != 0)
.map(kv => kv.join(": "))
.map((key) => [key, overview.sum(key, excludedThemes)])
.filter((kv) => kv[1] != 0)
.map((kv) => kv.join(": "))
const elements: BaseUIElement[] = [
new Title(allThemes .length === 1 ? "General statistics for "+allThemes[0] :"General statistics (excluding etymology- and GRB-theme changes)"),
new Title(
allThemes.length === 1
? "General statistics for " + allThemes[0]
: "General statistics (excluding etymology- and GRB-theme changes)"
),
new Combine([
overview._meta.length + " changesets match the filters",
new List(summedValues)
new List(summedValues),
]).SetClass("flex flex-col border rounded-xl"),
new Title("Breakdown")
new Title("Breakdown"),
]
for (const tr of trs) {
let total = undefined
@ -244,7 +247,7 @@ class ChangesetsOverview {
public sum(key: string, excludeThemes: Set<string>): number {
let s = 0
for (const feature of this._meta) {
if(excludeThemes.has(feature.properties.theme)){
if (excludeThemes.has(feature.properties.theme)) {
continue
}
const parsed = Number(feature.properties[key])
@ -280,8 +283,7 @@ class ChangesetsOverview {
}
try {
cs.properties.host = new URL(cs.properties.host).host
} catch (e) {
}
} catch (e) {}
return cs
}
}