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.7KB

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