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.

153 lines
5.1 KiB

9 years ago
9 years ago
9 years ago
  1. @extends('layouts.master')
  2. @section('content')
  3. @include('partials/logged-in')
  4. <div class="dashboard">
  5. <br>
  6. <h2>Database: {{ $database->name }}</h2>
  7. <form class="ui form">
  8. <div class="field">
  9. <label>Read Token</label>
  10. <input readonly="" value="{{ $database->read_token }}">
  11. </div>
  12. @if ($database->created_by == session('user_id'))
  13. <div class="field">
  14. <label>Write Token <a href="#" class="show-api-endpoint">(show API endpoint)</a></label>
  15. <input readonly="" value="{{ $database->write_token }}">
  16. </div>
  17. <div class="api-endpoint field hidden">
  18. <label>API Endpoint</label>
  19. <input type="text" readonly value="{{ env('BASE_URL') }}api/input?token={{ $database->write_token }}">
  20. </div>
  21. @endif
  22. </form>
  23. <div style="margin-top: 20px;">
  24. <h3>Users with Access</h3>
  25. <ul class="users">
  26. @foreach($users as $user)
  27. <li class="user">
  28. @if($user->id != session('user_id'))
  29. <a href="#" data-user="{{ $user->url }}" class="remove-user hidden">&times;</a>
  30. @endif
  31. {{ $user->url }}
  32. </li>
  33. @endforeach
  34. <li>
  35. <a href="javascript:$('.users .create').removeClass('hidden');$('.create-link').addClass('hidden');" class="pure-button create-link {{ session('create-error') ? 'hidden' : '' }}">New User</a>
  36. @if(session('create-error'))
  37. <div class="error">{{ session('create-error') }}</div>
  38. @endif
  39. <span class="create {{ session('create-error') ? '' : 'hidden' }}">
  40. <form action="/settings/{{ $database->name }}" method="post" class="ui form">
  41. <div class="ui action input">
  42. <input type="url" name="add_user" value="{{ session('add-user-url') }}" placeholder="github or indieauth url">
  43. <button type="submit" class="ui button primary">Add User</button>
  44. </div>
  45. </form>
  46. </span>
  47. </li>
  48. </ul>
  49. </div>
  50. <br>
  51. <h2>Settings</h2>
  52. <p>Here you can pick a default timezone and system of measurement to display this database in.</p>
  53. <div class="panel">
  54. <form action="/settings/{{ $database->name }}" method="post" class="ui form">
  55. <div class="field">
  56. <label for="timezone">Timezone</label>
  57. <input name="timezone" type="text" class="pure-input-1" value="{{ $database->timezone }}">
  58. </div>
  59. <div class="field">
  60. <label for="metric">System</label>
  61. <select name="metric" class="pure-input-1">
  62. <option value="0" {{ $database->metric ? '' : 'selected' }}>Imperial (miles)</option>
  63. <option value="1" {{ $database->metric ? 'selected' : '' }}>Metric (kilometer)</option>
  64. </select>
  65. </div>
  66. <button type="submit" class="ui button primary">Save</button>
  67. </form>
  68. </div>
  69. <br>
  70. <h2>Realtime Micropub Export</h2>
  71. <div class="panel">
  72. @if (empty($database->micropub_token))
  73. <p>Authorize Compass with a micropub endpoint and any trips that are written to this database will be sent to that endpoint as well.</p>
  74. <form action="/settings/{{ $database->name }}/auth/start" method="post" class="ui form">
  75. <div class="field">
  76. <label for="micropub_endpoint">web sign-in</label>
  77. <input name="me" type="url" placeholder="http://example.com/" class="pure-input-1" value="">
  78. </div>
  79. <button type="submit" class="ui button primary">Connect</button>
  80. </form>
  81. @else
  82. <form action="/settings/{{ $database->name }}/auth/remove" method="post" class="ui form">
  83. <div class="field">
  84. <p>You are currently posting to <strong>{{$database->micropub_endpoint}}</strong>. Any trips that are written to this database will be sent to that endpoint as well.</p>
  85. </div>
  86. <button type="submit" class="ui button primary">Disconnect</button>
  87. </form>
  88. @endif
  89. </div>
  90. <br>
  91. <h2>Ping on New Location</h2>
  92. <p>Enter one or more URLs to ping when new location data is available. This will send a POST request to the URLs with the URL to fetch the last location from the database, e.g. <code>url=https://compass.p3k.io/api/last?token=xxxx</code>. Enter one or more URLs separated by whitespace.</p>
  93. <div class="panel">
  94. <form action="/settings/{{ $database->name }}" method="post" class="ui form">
  95. <div class="field">
  96. <label for="ping_urls">Ping URLs</label>
  97. <textarea name="ping_urls" class="pure-input-1">{{ $database->ping_urls }}</textarea>
  98. </div>
  99. <button type="submit" class="ui button primary">Save</button>
  100. </form>
  101. </div>
  102. <br>
  103. </div>
  104. <script>
  105. jQuery(function($){
  106. $(".users .user").hover(function(){
  107. $(this).children(".remove-user").removeClass("hidden");
  108. }, function(){
  109. $(this).children(".remove-user").addClass("hidden");
  110. });
  111. $(".remove-user").click(function(){
  112. $.post("/settings/{{ $database->name }}", {
  113. database: "{{ $database->name }}",
  114. remove_user: $(this).data('user')
  115. }, function(data){
  116. window.location = window.location;
  117. });
  118. return false;
  119. });
  120. $(".show-api-endpoint").click(function(){
  121. $(".api-endpoint").removeClass("hidden");
  122. $(".show-api-endpoint").addClass("hidden");
  123. });
  124. });
  125. </script>
  126. @endsection