ソースを参照

Get applications from backend

Ecconia 7 年 前
コミット
270f10d72d
2 ファイル変更11 行追加80 行削除
  1. 3 45
      src/views/Application.vue
  2. 8 35
      src/views/Applications.vue

+ 3 - 45
src/views/Application.vue

@@ -24,51 +24,9 @@
 			'id'
 		],
 		created () {
-			if(!/^\+?(0|[1-9]\d*)$/.test(this.id)) {
-				this.error = 'Application ID has to be a positive integer.'
-				return
-			}
-
-			let apps = {
-				1: {
-					username: 'Joke',
-					fields: {
-						'Age?': '69',
-						'U like de pancake?': 'Ye I love them so much',
-						'Will Dutch survive?': 'No he lives underwater.',
-						'Op?': 'Yes please, cause I am from P L A N E T M I N E C R A F T',
-					}
-				},
-				2: {
-					username: 'Josh (KingTempest07)',
-					fields: {
-						'Age:': '11',
-						'Why are you insterested in joining this server?': 'I love redstone, and I am not the best, at all, but I am trying to learn, so I thought maybe a server with some good redstone engineers could help! Also, I have no online friends, really, just real life, so I have been looking for servers on many different games, like: Terraria, Minecraft, etc.',
-						'Current redstone knowledge:': 'Let\'s just say, I\'m terrible. I watch tons of Mumbo Jumbo, which is both entertaining and helpful, but I am still better at building than redstone. I know how to do things like: minecart systems, pulse extenders, double piston extenders, monostable circuits, some piston doors, do slab/redstone torch elevators, etc., but I can\'t really find was to compact or combine them easily!',
-						'Past redstone experience:': 'I have made 2x2 piston doors with pressure plates on both sides, and only used around a 8x3 block area with redstone torch elevators, and I can also make some simple things, like item transport systems with water and ice, hoppers, and I\'m not that good with storage systems, but I\'m getting there!',
-						'About how often do you play Minecraft?': '1-5 hours per day',
-						'What kind of creations would you like to build on this server?': 'Maybe some mob farms, storage systems, and minigames, but not so soon for minigames, but I might get there!',
-						'State:': 'Approved',
-					}
-				},
-				3: {
-					username: 'Jack',
-				},
-				4: {
-					username: 'John',
-				},
-				5: {
-					username: 'Jeff',
-				},
-			}
-
-			if(!apps.hasOwnProperty(this.id))
-			{
-				this.error = 'Application does not exist.'
-				return
-			}
-
-			this.appdata = apps[this.id]
+			this.core.get('/application/' + this.id).then((response) => {
+				this.appdata = response.data;
+			})
 		},
 		methods: {
 		},

+ 8 - 35
src/views/Applications.vue

@@ -10,9 +10,9 @@
 
 		<div class="app-container">
 			<router-link class="app-entry" :to="{ name: 'application', params: { id: app.id }}" v-for="app in apps" :key="app.id">
-				<p>Name: {{ app.playername }} </p>
+				<p>Name: {{ app.username }} </p>
 				<p>State: {{ passedChar(app) }}</p>
-				<p>Posted: {{ readableTime(app.date) }}</p>
+				<p>Posted: {{ readableTime(app.time) }}</p>
 			</router-link>
 		</div>
 	</div>
@@ -22,40 +22,13 @@
 	export default {
 		data () {
 			return {
-				apps: [
-					{
-						id: 5,
-						playername: 'Jeff',
-						date: 1539202084,
-					},
-					{
-						id: 4,
-						playername: 'John',
-						date: 1539102084,
-						passed: false,
-					},
-					{
-						id: 3,
-						playername: 'Jack',
-						date: 1529202084,
-						passed: true,
-					},
-					{
-						id: 2,
-						playername: 'Josh',
-						date: 1528202084,
-						passed: true,
-					},
-					{
-						id: 1,
-						playername: 'Joke',
-						date: 1439202084,
-						passed: false,
-					},
-				],
+				apps: [],
 			}
 		},
 		created () {
+			this.core.get('/applications').then((response) => {
+				this.apps = response.data;
+			})
 		},
 		computed: {
 			getUser() {
@@ -75,10 +48,10 @@
 				}
 			},
 			passedChar(app) {
-				if(typeof app.passed === "undefined") {
+				if(typeof app.state === "undefined") {
 					return '...'
 				} else {
-					return app.passed ? '👍' : '👎'
+					return app.state ? '👍' : '👎'
 				}
 			}
 		},