You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.5 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. import { Controller } from '@hotwired/stimulus';
  2. export default class extends Controller {
  3. static values = {
  4. imagery: String,
  5. importurl: String,
  6. layername: String,
  7. sendosm: Boolean,
  8. bottom: Number,
  9. top: Number,
  10. left: Number,
  11. right: Number,
  12. comment: String,
  13. source: String,
  14. hashtags: String,
  15. }
  16. remoteControl() {
  17. // cf <https://josm.openstreetmap.de/wiki/Help/RemoteControlCommands>
  18. const baseurl = 'http://localhost:8111';
  19. const _this = this;
  20. var url = baseurl + '/version';
  21. fetch(url)
  22. .then(function (response) {
  23. return response.json();
  24. })
  25. .then(function (json) {
  26. console.log('JOSM v' + json.version);
  27. url = baseurl + '/imagery?' + (new URLSearchParams({
  28. 'id': _this.imageryValue,
  29. }));
  30. fetch(url)
  31. .then(function (response) {
  32. return response.text();
  33. })
  34. .then(function (text) {
  35. console.log('JOSM imagery ' + text);
  36. });
  37. if (_this.sendosmValue) {
  38. url = baseurl + '/import?' + (new URLSearchParams({
  39. 'new_layer': true,
  40. 'layer_name': _this.layernameValue,
  41. 'url': _this.importurlValue,
  42. }));
  43. fetch(url)
  44. .then(function (response) {
  45. return response.text();
  46. })
  47. .then(function (text) {
  48. console.log('JOSM import ' + text);
  49. });
  50. }
  51. url = baseurl + '/zoom?' + (new URLSearchParams({
  52. 'bottom': _this.bottomValue,
  53. 'top': _this.topValue,
  54. 'left': _this.leftValue,
  55. 'right': _this.rightValue,
  56. 'changeset_comment': _this.commentValue,
  57. 'changeset_source': _this.sourceValue,
  58. 'changeset_hashtags': _this.hashtagsValue,
  59. }));
  60. fetch(url)
  61. .then(function (response) {
  62. return response.text();
  63. })
  64. .then(function (text) {
  65. console.log('JOSM zoom ' + text);
  66. });
  67. });
  68. }
  69. }