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.

AuthTokenList.vue 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <!--
  2. - @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
  3. -
  4. - @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
  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. <template>
  22. <table id="app-tokens-table">
  23. <thead v-if="tokens.length">
  24. <tr>
  25. <th />
  26. <th>{{ t('settings', 'Device') }}</th>
  27. <th>{{ t('settings', 'Last activity') }}</th>
  28. <th />
  29. </tr>
  30. </thead>
  31. <tbody class="token-list">
  32. <AuthToken v-for="token in sortedTokens"
  33. :key="token.id"
  34. :token="token"
  35. @toggleScope="toggleScope"
  36. @rename="rename"
  37. @delete="onDelete"
  38. @wipe="onWipe" />
  39. </tbody>
  40. </table>
  41. </template>
  42. <script>
  43. import AuthToken from './AuthToken'
  44. export default {
  45. name: 'AuthTokenList',
  46. components: {
  47. AuthToken
  48. },
  49. props: {
  50. tokens: {
  51. type: Array,
  52. required: true
  53. }
  54. },
  55. computed: {
  56. sortedTokens() {
  57. return this.tokens.slice().sort((t1, t2) => {
  58. var ts1 = parseInt(t1.lastActivity, 10)
  59. var ts2 = parseInt(t2.lastActivity, 10)
  60. return ts2 - ts1
  61. })
  62. }
  63. },
  64. methods: {
  65. toggleScope(token, scope, value) {
  66. // Just pass it on
  67. this.$emit('toggleScope', token, scope, value)
  68. },
  69. rename(token, newName) {
  70. // Just pass it on
  71. this.$emit('rename', token, newName)
  72. },
  73. onDelete(token) {
  74. // Just pass it on
  75. this.$emit('delete', token)
  76. },
  77. onWipe(token) {
  78. // Just pass it on
  79. this.$emit('wipe', token)
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. table {
  86. width: 100%;
  87. min-height: 50px;
  88. padding-top: 5px;
  89. max-width: 580px;
  90. th {
  91. opacity: .5;
  92. padding: 10px 10px 10px 0;
  93. }
  94. }
  95. .token-list {
  96. td > a.icon-more {
  97. transition: opacity var(--animation-quick);
  98. }
  99. a.icon-more {
  100. padding: 14px;
  101. display: block;
  102. width: 44px;
  103. height: 44px;
  104. opacity: .5;
  105. }
  106. tr {
  107. &:hover td > a.icon,
  108. td > a.icon:focus,
  109. &.active td > a.icon {
  110. opacity: 1;
  111. }
  112. }
  113. }
  114. </style>
  115. <!-- some styles are not scoped to make them work on subcomponents -->
  116. <style lang="scss">
  117. #app-tokens-table {
  118. tr > *:nth-child(2) {
  119. padding-left: 6px;
  120. }
  121. tr > *:nth-child(3) {
  122. text-align: right;
  123. }
  124. }
  125. </style>