-
Notifications
You must be signed in to change notification settings - Fork 0
/
apply_ui_vue.html
224 lines (202 loc) · 8.16 KB
/
apply_ui_vue.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!doctype html>
<html lang="en">
<head>
<title>Title</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link href='https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css'
rel='stylesheet'>
<!-- Vue 3 -->
<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.global.js'></script>
<!-- Vue 3: production version, optimized for size and speed -->
<!-- <script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.global.prod.js'></script> -->
</head>
<body>
<!-- <p>test</p> -->
<div id="app" class="container my-3">
<h1>BOSS Finder</h1>
<div v-if="!isValidStudent">
<div class="row w-50 my-5 mx-auto border border-secondary-subtle p-3">
<p class="fw-bold text-center">Wrong Page. <br>
</p>
<a href="./main_ui_vue.html" class="mx-auto w-50">
<button type="button" class="btn btn-sm btn-primary w-100">
Return
</button>
</a>
</div>
</div>
<div v-else>
<div class="row">
<div class="row" v-if="!hasproceed">
<div class="row">
<h2>Let's check your skills sets</h2>
</div>
<table class="mx-2">
<tr>
<th>You are missing some skills. The skills are:</th>
</tr>
<tr v-for="skill of lack_skills">
<td>
{{ skill }}
</td>
</tr>
<tr>
<th>Here are some courses you can take</th>
</tr>
<tr v-for="course in courses">
<td>
<a :href="course['course_link']" target="_blank">{{ course['course_name'] }}</a>
</td>
</tr>
<tr v-for="no in test">
<td>{{ no }} {{ test }}</td>
</tr>
</table>
<p class="my-3"></p>
<p class="fw-bold border border-secondary p-3 w-75 mx-auto text-center">
Would you still like to proceed with the application? <br><br>
<button type="button" class="btn btn-success w-50" @click="proceed()">Yes</button>
</p>
</div>
<div v-else class="w-75 mx-auto pb-5">
<div class="row">
<h2>You are ready to apply</h2>
</div>
<div class="row">
Student ID: <input v-model="student_id" placeholder="Insert StudentID"/>
</div>
<div class="row my-3">
<input type="file" id="resume" name="resume"/>
</div>
<div class="row" v-if="!submitted">
<button type="submit" class="btn btn-success" @click="postResume()">Submit</button>
</div>
<div class="row text-center" v-else>
Submitted
</div>
<!-- <p v-if="uploadText !== ''">
{{ uploadText }}
</p> -->
</div>
</div>
<a href="./main_ui_vue.html" class="mx-auto w-50">
<button type="button" class="btn btn-sm btn-primary w-100">
Return
</button>
</a>
</div>
</div>
<form action="" method="post">
<input type="hidden" name="student_id" :value="student_id">
</form>
<script>
const match_job_URL = "http://localhost:5005";
const job_URL = "http://localhost:5002";
const apply_job_URL = "http://localhost:5006"
student_id = sessionStorage.getItem("apply_studentID")
job_id = sessionStorage.getItem("apply_jobID")
courses = sessionStorage.getItem("apply_courses") !== 'undefined' ? JSON.parse(sessionStorage.getItem("apply_courses")) : []
modules = sessionStorage.getItem("apply_modules") !== 'undefined' ? JSON.parse(sessionStorage.getItem("apply_modules")) : []
lack_skills = sessionStorage.getItem("apply_lack_skills") !== null ? sessionStorage.getItem("apply_lack_skills").split(',') : []
isValidStudent = sessionStorage.getItem("isValidStudent")
console.log(student_id, job_id)
console.log(courses)
console.log(lack_skills)
console.log(modules)
console.log(isValidStudent)
const app = Vue.createApp({
data() {
return {
student_id: student_id,
job_id: job_id,
courses: courses,
modules: modules,
lack_skills: lack_skills,
hasError: false,
hasproceed: false,
uploadText: '',
isValidStudent: isValidStudent,
submitted: false,
message: "There is a problem retrieving data, please try again later.",
};
},
methods: {
checkProceed() {
console.log(this.courses.length)
console.log(this.modules.length)
if (this.courses == 0 && this.modules == 0) {
this.hasproceed = true
} else {
this.hasproceed = false
}
console.log('proceed: ' + this.hasproceed)
},
proceed() {
this.hasproceed = true
},
postResume() {
const file = document.getElementById('resume').files[0];
const url = "https://content.dropboxapi.com/2/files/upload";
const path = `/${this.student_id}_${this.job_id}.pdf`;
const headers = {
'Authorization': 'Access token here',
'Dropbox-API-Arg': JSON.stringify({
"autorename": false,
"mode": "add",
"mute": false,
"path": `${path}`,
"strict_conflict": false
}),
'Content-Type': 'application/octet-stream'
};
const config = {
method: 'POST',
headers: headers,
body: new Blob([file])
};
const response =
fetch(url, config)
.then(response => {
console.log(response.json());
this.submitted = true;
})
.catch(error => console.log(error));
},
checkStudent() {
const response =
fetch(`${match_job_URL}/${this.student_id}`)
.then(response => response.json())
.then(data => {
console.log(data);
if (data.code !== 200) {
this.message = data.message;
this.isValidStudent = false
this.hasError = true
} else {
this.matched_jobs = data.data;
this.hasError = false
this.isValidStudent = true
}
})
.catch(error => {
// Errors when calling the service; such as network error,
// service offline, etc
console.log(this.message + error);
this.hasError = true
})
},
},
created() {
// on Vue instance created, load the job list
this.checkProceed();
},
});
const vm = app.mount('#app');
</script>
<!-- Bootstrap Javascript -->
<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js'></script>
</body>
</html>