Applications.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div>
  3. <h1>Applications:</h1>
  4. <p>This area is basically the first big GOAL of the final product. Creating and Judging apps. The path to get here is quite long though, many other issues have to be solved first.</p>
  5. <div v-if="getUser && getUser.rank === undefined">
  6. <router-link to="/myapp" v-if="getUser.appstate === 0">Create application.</router-link>
  7. <router-link to="/myapp" v-else-if="getUser.appstate === 1">Edit application.</router-link>
  8. </div>
  9. <div class="app-container">
  10. <router-link class="app-entry" :to="{ name: 'application', params: { id: app.id }}" v-for="app in apps" :key="app.id">
  11. <p>Name: {{ app.playername }} </p>
  12. <p>State: {{ passedChar(app) }}</p>
  13. <p>Posted: {{ readableTime(app.date) }}</p>
  14. </router-link>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. export default {
  20. data () {
  21. return {
  22. apps: [
  23. {
  24. id: 5,
  25. playername: 'Jeff',
  26. date: 1539202084,
  27. },
  28. {
  29. id: 4,
  30. playername: 'John',
  31. date: 1539102084,
  32. passed: false,
  33. },
  34. {
  35. id: 3,
  36. playername: 'Jack',
  37. date: 1529202084,
  38. passed: true,
  39. },
  40. {
  41. id: 2,
  42. playername: 'Josh',
  43. date: 1528202084,
  44. passed: true,
  45. },
  46. {
  47. id: 1,
  48. playername: 'Joke',
  49. date: 1439202084,
  50. passed: false,
  51. },
  52. ],
  53. }
  54. },
  55. created () {
  56. },
  57. computed: {
  58. getUser() {
  59. return this.$store.state.user
  60. },
  61. },
  62. methods: {
  63. readableTime(timestamp) {
  64. let date = new Date(timestamp * 1000)
  65. return date.getFullYear() + '.' + (date.getMonth()+1) + '.' + date.getDate() + ' ' + date.getHours() + ':' + this.pad(date.getMinutes())
  66. },
  67. pad(input) {
  68. if(input < 10) {
  69. return '0' + input
  70. } else {
  71. return input
  72. }
  73. },
  74. passedChar(app) {
  75. if(typeof app.passed === "undefined") {
  76. return '...'
  77. } else {
  78. return app.passed ? '👍' : '👎'
  79. }
  80. }
  81. },
  82. }
  83. </script>
  84. <style scoped>
  85. .app-container {
  86. display: block;
  87. }
  88. .app-entry {
  89. display: inline-block;
  90. border: 1px solid;
  91. margin: 0.5em;
  92. padding: 0.5em;
  93. color: #aaa;
  94. text-decoration: none;
  95. }
  96. .app-entry:visited {
  97. color: #aaa;
  98. }
  99. .app-entry:hover {
  100. color: #ddd;
  101. }
  102. .app-entry p {
  103. margin: 0;
  104. }
  105. </style>