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.

149 lines
4.9 KiB

8 years ago
8 years ago
8 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. <p>Enter a Micropub endpoint and token below and any trips that are written to this database will be sent to the endpoint as well.</p>
  72. <div class="panel">
  73. <form action="/settings/{{ $database->name }}" method="post" class="ui form">
  74. <div class="field">
  75. <label for="micropub_endpoint">Micropub Endpoint</label>
  76. <input name="micropub_endpoint" type="url" placeholder="http://example.com/micropub" class="pure-input-1" value="{{ $database->micropub_endpoint }}">
  77. </div>
  78. <div class="field">
  79. <label for="micropub_token">Access Token</label>
  80. <input name="micropub_token" type="text" placeholder="" class="pure-input-1" value="{{ $database->micropub_token }}">
  81. </div>
  82. <button type="submit" class="ui button primary">Save</button>
  83. </form>
  84. </div>
  85. <br>
  86. <h2>Ping on New Location</h2>
  87. <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>
  88. <div class="panel">
  89. <form action="/settings/{{ $database->name }}" method="post" class="ui form">
  90. <div class="field">
  91. <label for="ping_urls">Ping URLs</label>
  92. <textarea name="ping_urls" class="pure-input-1">{{ $database->ping_urls }}</textarea>
  93. </div>
  94. <button type="submit" class="ui button primary">Save</button>
  95. </form>
  96. </div>
  97. <br>
  98. </div>
  99. <script>
  100. jQuery(function($){
  101. $(".users .user").hover(function(){
  102. $(this).children(".remove-user").removeClass("hidden");
  103. }, function(){
  104. $(this).children(".remove-user").addClass("hidden");
  105. });
  106. $(".remove-user").click(function(){
  107. $.post("/settings/{{ $database->name }}", {
  108. database: "{{ $database->name }}",
  109. remove_user: $(this).data('user')
  110. }, function(data){
  111. window.location = window.location;
  112. });
  113. return false;
  114. });
  115. $(".show-api-endpoint").click(function(){
  116. $(".api-endpoint").removeClass("hidden");
  117. $(".show-api-endpoint").addClass("hidden");
  118. });
  119. });
  120. </script>
  121. @endsection