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.

App.vue 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!--
  2. - @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl>
  3. -
  4. - @author Roeland Jago Douma <roeland@famdouma.nl>
  5. -
  6. - @license GNU AGPL version 3 or any later version
  7. -
  8. - This program is free software: you can redistribute it and/or modify
  9. - it under the terms of the GNU Affero General Public License as
  10. - published by the Free Software Foundation, either version 3 of the
  11. - License, or (at your option) any later version.
  12. -
  13. - This program is distributed in the hope that it will be useful,
  14. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. - GNU Affero General Public License for more details.
  17. -
  18. - You should have received a copy of the GNU Affero General Public License
  19. - along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. -
  21. -->
  22. <template>
  23. <div id="oauth2" class="section">
  24. <h2>{{ t('oauth2', 'OAuth 2.0 clients') }}</h2>
  25. <p class="settings-hint">
  26. {{ t('oauth2', 'OAuth 2.0 allows external services to request access to {instanceName}.', { instanceName: OC.theme.name}) }}
  27. </p>
  28. <table v-if="clients.length > 0" class="grid">
  29. <thead>
  30. <tr>
  31. <th id="headerName" scope="col">
  32. {{ t('oauth2', 'Name') }}
  33. </th>
  34. <th id="headerRedirectUri" scope="col">
  35. {{ t('oauth2', 'Redirection URI') }}
  36. </th>
  37. <th id="headerClientIdentifier" scope="col">
  38. {{ t('oauth2', 'Client Identifier') }}
  39. </th>
  40. <th id="headerSecret" scope="col">
  41. {{ t('oauth2', 'Secret') }}
  42. </th>
  43. <th id="headerRemove">
  44. &nbsp;
  45. </th>
  46. </tr>
  47. </thead>
  48. <tbody>
  49. <OAuthItem v-for="client in clients"
  50. :key="client.id"
  51. :client="client"
  52. @delete="deleteClient" />
  53. </tbody>
  54. </table>
  55. <br>
  56. <h3>{{ t('oauth2', 'Add client') }}</h3>
  57. <span v-if="newClient.error" class="msg error">{{ newClient.errorMsg }}</span>
  58. <form @submit.prevent="addClient">
  59. <input id="name"
  60. v-model="newClient.name"
  61. type="text"
  62. name="name"
  63. :placeholder="t('oauth2', 'Name')">
  64. <input id="redirectUri"
  65. v-model="newClient.redirectUri"
  66. type="url"
  67. name="redirectUri"
  68. :placeholder="t('oauth2', 'Redirection URI')">
  69. <input type="submit" class="button" :value="t('oauth2', 'Add')">
  70. </form>
  71. </div>
  72. </template>
  73. <script>
  74. import axios from 'nextcloud-axios'
  75. import OAuthItem from './components/OAuthItem'
  76. export default {
  77. name: 'App',
  78. components: {
  79. OAuthItem
  80. },
  81. props: {
  82. clients: {
  83. type: Array,
  84. required: true
  85. }
  86. },
  87. data: function() {
  88. return {
  89. newClient: {
  90. name: '',
  91. redirectUri: '',
  92. errorMsg: '',
  93. error: false
  94. }
  95. }
  96. },
  97. methods: {
  98. deleteClient(id) {
  99. axios.delete(OC.generateUrl('apps/oauth2/clients/{id}', { id: id }))
  100. .then((response) => {
  101. this.clients = this.clients.filter(client => client.id !== id)
  102. })
  103. },
  104. addClient() {
  105. this.newClient.error = false
  106. axios.post(
  107. OC.generateUrl('apps/oauth2/clients'),
  108. {
  109. name: this.newClient.name,
  110. redirectUri: this.newClient.redirectUri
  111. }
  112. ).then(response => {
  113. this.clients.push(response.data)
  114. this.newClient.name = ''
  115. this.newClient.redirectUri = ''
  116. }).catch(reason => {
  117. this.newClient.error = true
  118. this.newClient.errorMsg = reason.response.data.message
  119. })
  120. }
  121. }
  122. }
  123. </script>