Huge update: Front-end for client fixed.

This commit is contained in:
2017-12-20 16:39:11 +07:00
parent 8418a77e8c
commit 573f678c69
156 changed files with 33035 additions and 0 deletions

20
assets/js/models/Answer.js vendored Normal file
View File

@@ -0,0 +1,20 @@
import m from "mithril"
const Answer = {
list: [],
current: {},
loading: false,
fetch: function(answerId) {
Answer.loading = true
m.request({
url: "http://api.questionnaire.dev/v1/answers/" + answerId,
method: "GET"
})
.then(function(res) {
Answer.loading = false
console.log("response: ", res);
})
}
}
export default Answer

22
assets/js/models/Question.js vendored Normal file
View File

@@ -0,0 +1,22 @@
import m from "mithril"
const Question = {
current: {},
list: [],
loading: false,
fetchCurrent: function(sectionId, url) {
Question.loading = true
if (_.isNil(url)) url = "http://api.questionnaire.dev/v1/sections/" + sectionId + "/questions"
m.request({
url,
method: "GET",
})
.then(function(res) {
res.data = res.data[0]
Question.current = res
Question.loading = false
})
}
}
export default Question

32
assets/js/models/QuestionAnswer.js vendored Normal file
View File

@@ -0,0 +1,32 @@
import m from "mithril"
const QuestionAnswer = {
list: [],
current: {},
loading: false,
fetch: function(questionId) {
QuestionAnswer.loading = true
m.request({
url: "http://api.questionnaire.dev/v1/questions/" + questionId + "/answers",
method: "GET"
})
.then(function(res) {
QuestionAnswer.loading = false
console.log("response: ", res);
})
},
upload: function(questionId) {
QuestionAnswer.loading = true
m.request({
url: "http://api.questionnaire.dev/v1/questions/" + questionId + "/answers",
method: "POST",
data: QuestionAnswer.current
})
.then(function(res) {
QuestionAnswer.loading = false
console.log("response: ", res);
})
}
}
export default QuestionAnswer

31
assets/js/models/Questionnaire.js vendored Normal file
View File

@@ -0,0 +1,31 @@
import m from "mithril"
const Questionnaire = {
current: {},
list: [],
loading: false,
fetch: function(id) {
Questionnaire.loading = true
m.request({
url: "http://api.questionnaire.dev/v1/questionnaires/" + id,
method: "GET"
})
.then(function(res) {
Questionnaire.current = res
Questionnaire.loading = false
})
},
loadList: function() {
Questionnaire.loading = true
m.request({
url: "http://api.questionnaire.dev/v1/questionnaires",
method: "GET"
})
.then(function(res) {
Questionnaire.list = res.data
Questionnaire.loading = false
})
}
}
export default Questionnaire

View File

@@ -0,0 +1,20 @@
import m from "mithril"
const QuestionnaireSection = {
current: {},
list: [],
loading: false,
fetch: function(questionnaireId) {
QuestionnaireSection.loading = true
m.request({
url: "http://api.questionnaire.dev/v1/questionnaires/" + questionnaireId + "/sections",
method: "GET"
})
.then(function(res) {
QuestionnaireSection.current = res
QuestionnaireSection.loading = false
})
}
}
export default QuestionnaireSection

20
assets/js/models/Respondent.js vendored Normal file
View File

@@ -0,0 +1,20 @@
import m from "mithril"
const Respondent = {
list: [],
current: {},
loading: false,
fetch: function(id) {
Respondent.loading = true
m.request({
url: "http://api.questionnaire.dev/v1/respondents/" + id,
method: "GET"
})
.then(function(res) {
Respondent.current = res
Respondent.loading = false
})
}
}
export default Respondent

20
assets/js/models/Section.js vendored Normal file
View File

@@ -0,0 +1,20 @@
import m from "mithril"
const Section = {
current: {},
list: [],
loading: false,
fetch: function(id) {
Section.loading = true
m.request({
url: "http://api.questionnaire.dev/v1/sections/" + id,
method: "GET"
})
.then(function(res) {
Section.current = res
Section.loading = false
})
}
}
export default Section

33
assets/js/models/SectionQuestion.js vendored Normal file
View File

@@ -0,0 +1,33 @@
import m from "mithril"
const SectionQuestion = {
current: {},
list: [],
loading: false,
fetch: function(sectionId) {
SectionQuestion.loading = true
m.request({
url: "http://api.questionnaire.dev/v1/sections/" + sectionId + "/questions",
method: "GET"
})
.then(function(res) {
res.data = res.data[0]
SectionQuestion.current = res
SectionQuestion.loading = false
})
},
nextOrPrev: function(url) {
SectionQuestion.loading = true
m.request({
url,
method: "GET"
})
.then(function(res) {
res.data = res.data[0]
SectionQuestion.current = res
SectionQuestion.loading = false
})
}
}
export default SectionQuestion

74
assets/js/models/User.bak.js vendored Normal file
View File

@@ -0,0 +1,74 @@
import m from "mithril"
export const User = {
list: [],
current: {},
message: "",
error: "",
fetchList: function() {
m.request({
method: "GET",
url: ""
})
.then(function(res) {
User.list = res
})
.catch(function(e) {
User.error = e.message
})
},
fetchCurrent: function() {
m.request({
method: "GET",
url: ""
})
.then(function(res) {
User.current = res
})
.catch(function(e) {
User.error = e.message
})
},
regist: function() {
m.request({
method: "POST",
url: "",
data: User.current,
withCredentials: true
})
.then(function(res) {
User.message = res
})
.catch(function(e) {
User.error = e.message
})
},
login: function() {
m.request({
method: "GET",
url: "",
data: User.current,
withCredentials: true
})
.then(function(res) {
/* Must set header here*/
User.message = res
})
.catch(function(e) {
User.error = e.message
})
},
logout: function() {
m.request({
method: "GET",
url: "",
withCredentials: true
})
.then(function(res) {
User.message = res
})
.catch(function(e) {
User.error = e.message
})
}
}

32
assets/js/models/User.js vendored Normal file
View File

@@ -0,0 +1,32 @@
import m from "mithril"
const User = {
list: [],
current: {},
loading: false,
fetchList: function() {
User.list = require("../../json/users/example").data
},
fetchCurrent: function(userId) {
User.loading = true
m.request({
url: "http://api.questionnaire.dev/v1/users/" + userId,
method: "GET"
})
.then(function(res) {
User.current = res
User.loading = false
})
},
regist: function() {
},
login: function() {
m.route.set("/user/questionnaires")
},
logout: function() {
}
}
export default User

24
assets/js/models/beta/Dept.js vendored Normal file
View File

@@ -0,0 +1,24 @@
const Dept = {
list: [
{id: 1, name: "BPH Yayasan"},
{id: 2, name: "Sekretariat Yayasan"},
{id: 3, name: "HRD"},
{id: 4, name: "Keuangan"},
{id: 5, name: "Pimpinan Perguruan Tinggi"},
{id: 6, name: "LC & LPU"},
{id: 7, name: "Pelaksana Kerjasama"},
{id: 8, name: "Esbed"},
{id: 9, name: "Kemahasiswaan"},
{id: 10, name: "Kreatif"},
{id: 11, name: "Web & IT"},
{id: 12, name: "Humas"},
{id: 12, name: "TU SMK"},
{id: 13, name: "Marketing, Receptionist, and Student Adminision"},
{id: 14, name: "P3S dan Umum"},
{id: 15, name: "Lab. Komputer"},
{id: 16, name: "Satpam"}
],
current: {}
}
export default Dept

69
assets/js/models/beta/User.js vendored Normal file
View File

@@ -0,0 +1,69 @@
const User = {
list: [
{
id: 1,
name: "Dhimas",
dept: 11,
super: 1,
address: "Perum Paku Jaya Permai A2/8 007/05 Paku Jaya Tangerang",
birth: "Madiun, 2 Agustus 1990",
phone: "083895518773",
mail: "dhimas@lepisi.ac.id",
workEntry: "1 Maret 2012",
workPeriod: "4 tahun",
education: "S2 Sistem Informasi"
},
{
id: 2,
name: "Barsan",
dept: 11,
address: "Persada Raya J6/16 005/008 Gembor Tangerang",
birth: "Tangerang, 13 April 1996",
phone: "085892313773",
mail: "barsan@lepisi.ac.id",
workEntry: "4 Oktober 2017",
workPeriod: "2 bulan",
education: "S1 Teknik Informatika"
},
{
id: 3,
name: "Gregorio",
dept: 11,
address: "Jalan Cempaka III HQ/22 Bumi Indah Kab. Tangerang",
birth: "Tangerang, 23 Mei 1999",
phone: "085819967701",
mail: "gregorio@lepisi.ac.id",
workEntry: "1 Agustus 2017",
workPeriod: "4 bulan",
education: "S1 Teknik Informatika"
},
{
id: 4,
name: "Donny",
dept: 10,
address: "Jl. Pepaya Raya E/22 No. 15 05/17 Bumi Asri, Tangerang",
birth: "Tangerang, 14 Januari 1997",
phone: "083813154407",
mail: "donny@lepisi.ac.id",
workEntry: "25 Juni 2014",
workPeriod: "2 tahun",
education: "TK III STT"
},
{
id: 5,
name: "Widi",
dept: 10,
super: 1,
address: "Dasana Indah UD 4/26 No. 26 Tangerang",
birth: "Tangerang, 30 September 1995",
phone: "081298877765",
mail: "widi@lepisi.ac.id",
workEntry: "25 Juni 2014",
workPeriod: "2 tahun",
education: "TK III STT"
}
],
current: {}
}
export default User