diff --git a/AllTranslationAssets.ts b/AllTranslationAssets.ts index 3ef54ca..bd826a6 100644 --- a/AllTranslationAssets.ts +++ b/AllTranslationAssets.ts @@ -123,5 +123,8 @@ export default class AllTranslationAssets { favourite: { panelIntro: new Translation( {"en":"

Your personal theme

Activate your favourite layers from all the official themes","ca":"

La teva interfície personal

Activa les teves capes favorites de totes les interfícies oficials","es":"

Tu interficie personal

Activa tus capas favoritas de todas las interficies oficiales","gl":"

O teu tema personalizado

Activa as túas capas favoritas de todos os temas oficiais","de":"

Ihr persönliches Thema

Aktivieren Sie Ihre Lieblingsebenen aus allen offiziellen Themen"} ), loginNeeded: new Translation( {"en":"

Log in

A personal layout is only available for OpenStreetMap users","es":"

Entrar

El diseño personalizado sólo está disponible para los usuarios de OpenstreetMap","ca":"

Entrar

El disseny personalizat només està disponible pels usuaris d' OpenstreetMap","gl":"

Iniciar a sesión

O deseño personalizado só está dispoñíbel para os usuarios do OpenstreetMap","de":"

Anmelden

Ein persönliches Layout ist nur für OpenStreetMap-Benutzer verfügbar"} ), reload: new Translation( {"en":"Reload the data","es":"Recargar datos","ca":"Recarregar dades","gl":"Recargar os datos","de":"Daten neu laden"} ), +}, + reviews: { title: new Translation( {"en":"Reviews","nl":"Beoordelingen"} ), + attribution: new Translation( {"en":"Reviews are powered by Mangrove Reviews and are available under CC-BY 4.0"} ), }, }} \ No newline at end of file diff --git a/Customizations/JSON/TagRenderingConfig.ts b/Customizations/JSON/TagRenderingConfig.ts index 24fdd0b..d6e9a92 100644 --- a/Customizations/JSON/TagRenderingConfig.ts +++ b/Customizations/JSON/TagRenderingConfig.ts @@ -26,7 +26,7 @@ export default class TagRenderingConfig { mappings?: { if: TagsFilter, then: Translation - hideInAnswer: boolean + hideInAnswer: boolean | TagsFilter }[] constructor(json: string | TagRenderingConfigJson, context?: string) { @@ -62,10 +62,16 @@ export default class TagRenderingConfig { if (mapping.then === undefined) { throw "Invalid mapping: if without body" } + let hideInAnswer : boolean | TagsFilter = false; + if(typeof mapping.hideInAnswer === "boolean"){ + hideInAnswer = mapping.hideInAnswer; + }else{ + hideInAnswer = FromJSON.Tag(mapping.hideInAnswer); + } return { if: FromJSON.Tag(mapping.if, `${context}.mapping[${i}]`), then: Translations.T(mapping.then), - hideInAnswer: mapping.hideInAnswer ?? false + hideInAnswer: hideInAnswer }; }); } diff --git a/Logic/Web/MangroveReviews.ts b/Logic/Web/MangroveReviews.ts new file mode 100644 index 0000000..1d8f45b --- /dev/null +++ b/Logic/Web/MangroveReviews.ts @@ -0,0 +1,50 @@ +import * as mangrove from 'mangrove-reviews' +import {UIEventSource} from "../UIEventSource"; + +export default class MangroveReviews { + + constructor() { + } + + /** + * Gives a UIEVentsource with all reviews. + * Note: rating is between 1 and 100 + */ + public static GetReviewsFor(lon: number, lat: number, name: string): UIEventSource<{ + comment?: string, + author: string, + date: Date, + rating: number + }[]> { + + let uri = `geo:${lat},${lon}?u=50`; + if (name !== undefined && name !== null) { + uri += "&q=" + name; + } + const reviewsSource : UIEventSource< { + comment?: string, + author: string, + date: Date, + rating: number + }[]> = new UIEventSource([]); + + mangrove.getReviews({sub: uri}).then( + (data) => { + const reviews = []; + for (const review of data.reviews) { + const r = review.payload; + reviews.push({ + date: new Date(r.iat * 1000), + comment: r.opinion, + author: r.metadata.nickname, + rating: r.rating // percentage points + }) + } + reviewsSource.setData(reviews) + } + ); + return reviewsSource; + } + + +} \ No newline at end of file diff --git a/Svg.ts b/Svg.ts index e49ccaa..5b6bafd 100644 --- a/Svg.ts +++ b/Svg.ts @@ -239,6 +239,11 @@ export default class Svg { public static star_svg() { return new FixedUiElement(Svg.star);} public static star_ui() { return new FixedUiElement(Svg.star_img);} + public static star_half = " Created by potrace 1.15, written by Peter Selinger 2001-2017 image/svg+xml " + public static star_half_img = Img.AsImageElement(Svg.star_half) + public static star_half_svg() { return new FixedUiElement(Svg.star_half);} + public static star_half_ui() { return new FixedUiElement(Svg.star_half_img);} + public static statistics = " Svg Vector Icons : http://www.onlinewebfonts.com/icon " public static statistics_img = Img.AsImageElement(Svg.statistics) public static statistics_svg() { return new FixedUiElement(Svg.statistics);} @@ -264,4 +269,4 @@ export default class Svg { public static wikipedia_svg() { return new FixedUiElement(Svg.wikipedia);} public static wikipedia_ui() { return new FixedUiElement(Svg.wikipedia_img);} -public static All = {"add.svg": Svg.add,"addSmall.svg": Svg.addSmall,"ampersand.svg": Svg.ampersand,"arrow-left-smooth.svg": Svg.arrow_left_smooth,"arrow-right-smooth.svg": Svg.arrow_right_smooth,"bug.svg": Svg.bug,"camera-plus.svg": Svg.camera_plus,"checkmark.svg": Svg.checkmark,"circle.svg": Svg.circle,"clock.svg": Svg.clock,"close.svg": Svg.close,"compass.svg": Svg.compass,"cross_bottom_right.svg": Svg.cross_bottom_right,"crosshair-blue-center.svg": Svg.crosshair_blue_center,"crosshair-blue.svg": Svg.crosshair_blue,"crosshair.svg": Svg.crosshair,"delete_icon.svg": Svg.delete_icon,"direction.svg": Svg.direction,"direction_gradient.svg": Svg.direction_gradient,"down.svg": Svg.down,"envelope.svg": Svg.envelope,"floppy.svg": Svg.floppy,"gear.svg": Svg.gear,"help.svg": Svg.help,"home.svg": Svg.home,"home_white_bg.svg": Svg.home_white_bg,"josm_logo.svg": Svg.josm_logo,"layers.svg": Svg.layers,"layersAdd.svg": Svg.layersAdd,"logo.svg": Svg.logo,"logout.svg": Svg.logout,"mapillary.svg": Svg.mapillary,"no_checkmark.svg": Svg.no_checkmark,"or.svg": Svg.or,"osm-logo-us.svg": Svg.osm_logo_us,"osm-logo.svg": Svg.osm_logo,"pencil.svg": Svg.pencil,"phone.svg": Svg.phone,"pin.svg": Svg.pin,"pop-out.svg": Svg.pop_out,"reload.svg": Svg.reload,"ring.svg": Svg.ring,"search.svg": Svg.search,"send_email.svg": Svg.send_email,"share.svg": Svg.share,"square.svg": Svg.square,"star.svg": Svg.star,"statistics.svg": Svg.statistics,"up.svg": Svg.up,"wikidata.svg": Svg.wikidata,"wikimedia-commons-white.svg": Svg.wikimedia_commons_white,"wikipedia.svg": Svg.wikipedia};} +public static All = {"add.svg": Svg.add,"addSmall.svg": Svg.addSmall,"ampersand.svg": Svg.ampersand,"arrow-left-smooth.svg": Svg.arrow_left_smooth,"arrow-right-smooth.svg": Svg.arrow_right_smooth,"bug.svg": Svg.bug,"camera-plus.svg": Svg.camera_plus,"checkmark.svg": Svg.checkmark,"circle.svg": Svg.circle,"clock.svg": Svg.clock,"close.svg": Svg.close,"compass.svg": Svg.compass,"cross_bottom_right.svg": Svg.cross_bottom_right,"crosshair-blue-center.svg": Svg.crosshair_blue_center,"crosshair-blue.svg": Svg.crosshair_blue,"crosshair.svg": Svg.crosshair,"delete_icon.svg": Svg.delete_icon,"direction.svg": Svg.direction,"direction_gradient.svg": Svg.direction_gradient,"down.svg": Svg.down,"envelope.svg": Svg.envelope,"floppy.svg": Svg.floppy,"gear.svg": Svg.gear,"help.svg": Svg.help,"home.svg": Svg.home,"home_white_bg.svg": Svg.home_white_bg,"josm_logo.svg": Svg.josm_logo,"layers.svg": Svg.layers,"layersAdd.svg": Svg.layersAdd,"logo.svg": Svg.logo,"logout.svg": Svg.logout,"mapillary.svg": Svg.mapillary,"no_checkmark.svg": Svg.no_checkmark,"or.svg": Svg.or,"osm-logo-us.svg": Svg.osm_logo_us,"osm-logo.svg": Svg.osm_logo,"pencil.svg": Svg.pencil,"phone.svg": Svg.phone,"pin.svg": Svg.pin,"pop-out.svg": Svg.pop_out,"reload.svg": Svg.reload,"ring.svg": Svg.ring,"search.svg": Svg.search,"send_email.svg": Svg.send_email,"share.svg": Svg.share,"square.svg": Svg.square,"star.svg": Svg.star,"star_half.svg": Svg.star_half,"statistics.svg": Svg.statistics,"up.svg": Svg.up,"wikidata.svg": Svg.wikidata,"wikimedia-commons-white.svg": Svg.wikimedia_commons_white,"wikipedia.svg": Svg.wikipedia};} diff --git a/UI/Popup/TagRenderingQuestion.ts b/UI/Popup/TagRenderingQuestion.ts index 2bf52d7..1cdd805 100644 --- a/UI/Popup/TagRenderingQuestion.ts +++ b/UI/Popup/TagRenderingQuestion.ts @@ -198,9 +198,12 @@ export default class TagRenderingQuestion extends UIElement { private GenerateMappingElement(mapping: { if: TagsFilter, then: Translation, - hideInAnswer: boolean + hideInAnswer: boolean | TagsFilter }): InputElement { - if (mapping.hideInAnswer) { + if (mapping.hideInAnswer === true) { + return undefined; + } + if(typeof(mapping.hideInAnswer) !== "boolean" && mapping.hideInAnswer.matches(this._tags.data)){ return undefined; } return new FixedInputElement( diff --git a/UI/ReviewElement.ts b/UI/ReviewElement.ts new file mode 100644 index 0000000..858c239 --- /dev/null +++ b/UI/ReviewElement.ts @@ -0,0 +1,65 @@ +import {UIElement} from "./UIElement"; +import {UIEventSource} from "../Logic/UIEventSource"; +import Translations from "./i18n/Translations"; +import Combine from "./Base/Combine"; +import {FixedUiElement} from "./Base/FixedUiElement"; +import {Utils} from "../Utils"; + +/** + * Shows the reviews and scoring base on mangrove.reviesw + */ +export default class ReviewElement extends UIElement { + private _reviews: UIEventSource<{ comment?: string; author: string; date: Date; rating: number }[]>; + + constructor(reviews: UIEventSource<{ + comment?: string, + author: string, + date: Date, + rating: number + }[]>) { + super(reviews); + this._reviews = reviews; + } + + InnerRender(): string { + + const elements = []; + + elements.push(Translations.t.reviews.title.SetClass("review-title")); + + elements.push(...this._reviews.data.map(review => { + const stars = Math.round(review.rating / 10) + const fullStars = Math.floor(stars / 2); + const d = review.date; + + return new Combine( + [ + new Combine([ + + new Combine([ + "".repeat(fullStars), + stars % 2 == 1 ? "" : "" + ]).SetClass("review-rating"), + new FixedUiElement(`${d.getFullYear()}-${Utils.TwoDigits(d.getMonth() + 1)}-${Utils.TwoDigits(d.getDate())} ${Utils.TwoDigits(d.getHours())}:${Utils.TwoDigits(d.getMinutes())}`) + .SetClass("review-date"), + ]).SetClass("review-stars-date"), + + new FixedUiElement(review.comment).SetClass("review-comment"), + "
", + new FixedUiElement(review.author).SetClass("review-author"), + + ] + ).SetClass("review-element") + })); + elements.push( + new Combine([ + Translations.t.reviews.attribution, + "" + ]) + + .SetClass("review-attribution")) + + return new Combine(elements).SetClass("review").Render(); + } + +} \ No newline at end of file diff --git a/assets/mangrove_logo.png b/assets/mangrove_logo.png new file mode 100644 index 0000000..38f39f8 Binary files /dev/null and b/assets/mangrove_logo.png differ diff --git a/assets/svg/star_half.svg b/assets/svg/star_half.svg new file mode 100644 index 0000000..db57d41 --- /dev/null +++ b/assets/svg/star_half.svg @@ -0,0 +1,63 @@ + + + + + +Created by potrace 1.15, written by Peter Selinger 2001-2017 + + + image/svg+xml + + + + + + + + diff --git a/assets/translations.json b/assets/translations.json index d5ce8bf..ae6b47d 100644 --- a/assets/translations.json +++ b/assets/translations.json @@ -907,5 +907,19 @@ "gl": "Recargar os datos", "de": "Daten neu laden" } + }, + "reviews": { + "title": { + "en": "Reviews", + "nl": "Beoordelingen" + }, + "no_reviews_yet": { + "en": "There are no reviews yet. Be the first to write one and help open data and the business!", + "nl": "Er zijn nog geen beoordelingen. Wees de eerste om een beoordeling te schrijven en help open data en het bedrijf" + }, + "attribution": { + "en": "Reviews are powered by Mangrove Reviews and are available under CC-BY 4.0", + "nl": "De beoordelingen worden voorzien door Mangrove Reviews en zijn beschikbaar onder deCC-BY 4.0-licentie " + } } } \ No newline at end of file diff --git a/css/ReviewElement.css b/css/ReviewElement.css new file mode 100644 index 0000000..9389fc5 --- /dev/null +++ b/css/ReviewElement.css @@ -0,0 +1,56 @@ +.review-rating img { + max-width: 1em; + height: 1em; +} + +.review-rating { + display: flex; + flex-direction: row; +} + +.review-date { + color: var(--subtle-detail-color-light-contrast); +} + +.review-stars-date { + display: flex; + justify-content: space-between; + margin-bottom: 0.5em; +} + +.review-author { + font-weight: bold; + display: flex; + justify-content: flex-end; +} + +.review-element { + padding: 1em; + margin: 0.5em; + display: block; + border-radius: 1em; + background-color: var(--subtle-detail-color); + color: var(--subtle-detail-color-contrast); +} + +.review-attribution { + display: flex; + color: var(--subtle-detail-color-light-contrast); + justify-content: flex-end; + margin-right: 1em; +} + +.review-attribution span { + width: calc(65% - 3em); + text-align: right; + max-width: 20em; +} + +.review-attribution img { + height: 3em; + margin-left: 0.5em; +} + +.review-title { + font-size: x-large; +} \ No newline at end of file diff --git a/customGenerator.html b/customGenerator.html index a87a8d4..ed8dec7 100644 --- a/customGenerator.html +++ b/customGenerator.html @@ -91,7 +91,8 @@
- 'maindiv' not attached + Loading the MapComplete custom theme builder...
+ If this message persists, make sure javascript is enabled and no script blocker is blocking this.
diff --git a/index.css b/index.css index ac3de5e..8f1cdc0 100644 --- a/index.css +++ b/index.css @@ -1,6 +1,8 @@ :root { --subtle-detail-color: #e5f5ff; --subtle-detail-color-contrast: black; + --subtle-detail-color-light-contrast: lightgrey; + --catch-detail-color: #3a3aeb; --catch-detail-color-contrast: white; --alert-color: #fee4d1; diff --git a/index.html b/index.html index 9692608..c2bae3a 100644 --- a/index.html +++ b/index.html @@ -15,6 +15,7 @@ + diff --git a/package-lock.json b/package-lock.json index b82b3c9..59b5059 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3907,6 +3907,14 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.0.tgz", "integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==" }, + "axios": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", + "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", + "requires": { + "follow-redirects": "1.5.10" + } + }, "babel-plugin-dynamic-import-node": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz", @@ -4242,6 +4250,11 @@ "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-0.0.1.tgz", "integrity": "sha1-kbx0sR6kBbyRa8aqkI+q+ltKrEs=" }, + "buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" + }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", @@ -5441,6 +5454,14 @@ "safer-buffer": "^2.1.0" } }, + "ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "requires": { + "safe-buffer": "^5.0.1" + } + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -5825,6 +5846,29 @@ "locate-path": "^2.0.0" } }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -6761,6 +6805,11 @@ } } }, + "jose": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jose/-/jose-3.3.1.tgz", + "integrity": "sha512-dMVfVKnyJyl2d9OBkwu/nvheGh9fbS1khhkJdvbGnINNe8IUfSJ/U+BXJOQvk65BCIJ58lp7xQKJTGQQ5dxrZA==" + }, "jquery": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz", @@ -6895,6 +6944,23 @@ "minimist": "^1.2.0" } }, + "jsonwebtoken": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz", + "integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==", + "requires": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^5.6.0" + } + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -6911,6 +6977,53 @@ "resolved": "https://registry.npmjs.org/jsts/-/jsts-1.1.2.tgz", "integrity": "sha1-0gXSzIOTCB2eSErjYoIRBpXtwjA=" }, + "jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "requires": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "jwk-to-pem": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/jwk-to-pem/-/jwk-to-pem-2.0.4.tgz", + "integrity": "sha512-4CCK9UBHNWjWtfSHdyu3I6rA8vlN5cWqnVuwY0cOMyXtw6M1tP+yrM8GZpwk+P932Dc3cLag4d35B6CqyIf89A==", + "requires": { + "asn1.js": "^5.3.0", + "elliptic": "^6.5.3", + "safe-buffer": "^5.0.1" + }, + "dependencies": { + "asn1.js": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", + "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", + "requires": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "safer-buffer": "^2.1.0" + } + }, + "bn.js": { + "version": "4.11.9", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", + "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==" + } + } + }, + "jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "requires": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, "kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -7126,11 +7239,46 @@ "resolved": "https://registry.npmjs.org/lodash.clone/-/lodash.clone-4.5.0.tgz", "integrity": "sha1-GVhwRQ9aExkkeN9Lw9I9LeoZB7Y=" }, + "lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8=" + }, + "lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY=" + }, + "lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha1-YZwK89A/iwTDH1iChAt3sRzWg0M=" + }, + "lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w=" + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" + }, + "lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=" + }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", "integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=" }, + "lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" + }, "lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", @@ -7191,6 +7339,16 @@ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", "dev": true }, + "mangrove-reviews": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/mangrove-reviews/-/mangrove-reviews-0.1.3.tgz", + "integrity": "sha512-uaUMaRI3ZWwBIqudOzoDd3/d2YVp0A1ZbhC8MQ0VNJDjl0yyQ/T/Aq3TQyz+dO7tvIqR+Lq8UGWFnsiGVVKNGw==", + "requires": { + "axios": "^0.19.2", + "jsonwebtoken": "^8.5.1", + "jwk-to-pem": "^2.0.3" + } + }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -8099,16 +8257,6 @@ } } }, - "parcel-plugin-static-files-copy": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/parcel-plugin-static-files-copy/-/parcel-plugin-static-files-copy-2.4.3.tgz", - "integrity": "sha512-tUZn54XsZIZ9hhhNQkyaWaHLvjOj2wra8pp4yPjp1b5p1frQ+YEwG6eaNtaQVyA+UvORsZg+Wni7n9gIOBE8eA==", - "dev": true, - "requires": { - "minimatch": "3.0.4", - "path": "0.12.7" - } - }, "parse-asn1": { "version": "5.1.5", "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", @@ -8146,33 +8294,6 @@ "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=" }, - "path": { - "version": "0.12.7", - "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", - "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", - "dev": true, - "requires": { - "process": "^0.11.1", - "util": "^0.10.3" - }, - "dependencies": { - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "util": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", - "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", - "dev": true, - "requires": { - "inherits": "2.0.3" - } - } - } - }, "path-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", diff --git a/package.json b/package.json index ca47743..1bed8df 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "leaflet-providers": "^1.10.2", "libphonenumber": "0.0.10", "libphonenumber-js": "^1.7.55", + "mangrove-reviews": "^0.1.3", "moment": "^2.29.0", "opening_hours": "^3.5.0", "osm-auth": "^1.0.2", diff --git a/test.html b/test.html index 521de22..cd57114 100644 --- a/test.html +++ b/test.html @@ -7,28 +7,12 @@ + - -
'maindiv' not attached
-
'extradiv' not attached
diff --git a/test.ts b/test.ts index d04a40d..31382ee 100644 --- a/test.ts +++ b/test.ts @@ -1,4 +1,49 @@ +//* +import MangroveReviews from "./Logic/Web/MangroveReviews"; +import ReviewElement from "./UI/ReviewElement"; + +const review = MangroveReviews.GetReviewsFor(3.22000, 51.21576, "Pietervdvn Software Consultancy") +new ReviewElement(review).AttachTo("maindiv"); /* +mangrove.getReviews({sub: 'geo:,?q=&u=15'}).then( + (data) => { + for (const review of data.reviews) { + console.log(review.payload); + // .signature + // .kid + // .jwt + } + } +);*/ + +/* +mangrove.generateKeypair().then( + keypair => { + mangrove.keypairToJwk(keypair).then(jwk => { + console.log(jwk) + // const restoredKeypair = await mangrove.jwkToKeypair(jwk). +// Sign and submit a review (reviews of this example subject are removed from the database). + mangrove.signAndSubmitReview(keypair, { + // Lat,lon! + sub: "geo:51.21576,3.22000?q=Pietervdvn Software Consultancy&u=15", + rating: 100, + opinion: "Excellent knowledge about OSM", + metadata: { + nickname: "Pietervdvn", + } + }) + }) + } +) +*/ + +/* +// Given by a particular user since certain time. +const userReviews = await getReviews({ + kid: '-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEDo6mN4kY6YFhpvF0u3hfVWD1RnDElPweX3U3KiUAx0dVeFLPAmeKdQY3J5agY3VspnHo1p/wH9hbZ63qPbCr6g==-----END PUBLIC KEY-----', + gt_iat: 1580860800 +})*/ + /*/