Browse Source

Update APIService

pull/341/head
Hironsan 5 years ago
parent
commit
b22cc80267
10 changed files with 32 additions and 30 deletions
  1. 2
      frontend/components/containers/members/MemberAdditionButton.vue
  2. 8
      frontend/components/organisms/auth/LoginForm.vue
  3. 4
      frontend/services/api.service.js
  4. 8
      frontend/store/auth.js
  5. 14
      frontend/store/documents.js
  6. 6
      frontend/store/labels.js
  7. 6
      frontend/store/members.js
  8. 10
      frontend/store/projects.js
  9. 2
      frontend/store/roles.js
  10. 2
      frontend/store/statistics.js

2
frontend/components/containers/members/MemberAdditionButton.vue

@ -48,7 +48,7 @@ export default {
searchUser(username) {
UserService.getUserList(username)
.then((response) => {
this.items = response
this.items = response.data
})
.catch((error) => {
alert(error)

8
frontend/components/organisms/auth/LoginForm.vue

@ -62,13 +62,15 @@ export default {
validate() {
return this.$refs.form.validate()
},
async tryLogin() {
tryLogin() {
if (this.validate()) {
await this.login({
this.login({
username: this.username,
password: this.password
})
this.$router.push('/projects')
.then((result) => {
this.$router.push('/projects')
})
}
}
}

4
frontend/services/api.service.js

@ -23,8 +23,8 @@ class ApiService {
data,
...config
})
.then(response => response.data)
.catch(error => error)
// .then(response => response.data)
// .catch(error => error)
}
get(url, config = {}) {

8
frontend/store/auth.js

@ -25,10 +25,10 @@ export const actions = {
authenticateUser({ commit }, authData) {
return AuthService.postCredential(authData)
.then((result) => {
commit('setToken', result.token)
localStorage.setItem('token', result.token)
Cookie.set('jwt', result.token)
ApiService.setHeader(result.token)
commit('setToken', result.data.token)
localStorage.setItem('token', result.data.token)
Cookie.set('jwt', result.data.token)
ApiService.setHeader(result.data.token)
})
.catch(e => alert(e))
},

14
frontend/store/documents.js

@ -91,8 +91,8 @@ export const actions = {
payload = Object.assign(payload, state.searchOptions)
return DocumentService.getDocumentList(payload)
.then((response) => {
commit('setDocumentList', response.results)
commit('setTotalItems', response.count)
commit('setDocumentList', response.data.results)
commit('setTotalItems', response.data.count)
})
.catch((error) => {
alert(error)
@ -126,7 +126,7 @@ export const actions = {
commit('setLoading', true)
DocumentService.exportFile(data.projectId, data.format)
.then((response) => {
const url = window.URL.createObjectURL(new Blob([response]))
const url = window.URL.createObjectURL(new Blob([response.data]))
const link = document.createElement('a')
link.href = url
link.setAttribute('download', 'file.' + data.format)
@ -143,7 +143,7 @@ export const actions = {
updateDocument({ commit }, data) {
DocumentService.updateDocument(data.projectId, data.id, data)
.then((response) => {
commit('updateDocument', response)
commit('updateDocument', response.data)
})
.catch((error) => {
alert(error)
@ -165,7 +165,7 @@ export const actions = {
const documentId = state.items[state.current].id
AnnotationService.addAnnotation(payload.projectId, documentId, payload)
.then((response) => {
commit('addAnnotation', response)
commit('addAnnotation', response.data)
})
.catch((error) => {
alert(error)
@ -175,7 +175,7 @@ export const actions = {
const documentId = state.items[state.current].id
AnnotationService.updateAnnotation(payload.projectId, documentId, payload.annotationId, payload)
.then((response) => {
commit('updateAnnotation', response)
commit('updateAnnotation', response.data)
})
.catch((error) => {
alert(error)
@ -198,7 +198,7 @@ export const actions = {
}
DocumentService.approveDocument(payload.projectId, documentId, data)
.then((response) => {
commit('updateDocument', response)
commit('updateDocument', response.data)
})
.catch((error) => {
alert(error)

6
frontend/store/labels.js

@ -42,7 +42,7 @@ export const actions = {
commit('setLoading', true)
return LabelService.getLabelList(payload.projectId)
.then((response) => {
commit('setLabelList', response)
commit('setLabelList', response.data)
})
.catch((error) => {
alert(error)
@ -54,7 +54,7 @@ export const actions = {
createLabel({ commit }, data) {
LabelService.addLabel(data.projectId, data)
.then((response) => {
commit('addLabel', response)
commit('addLabel', response.data)
})
.catch((error) => {
alert(error)
@ -63,7 +63,7 @@ export const actions = {
updateLabel({ commit }, data) {
LabelService.updateLabel(data.projectId, data.id, data)
.then((response) => {
commit('updateLabel', response)
commit('updateLabel', response.data)
})
.catch((error) => {
alert(error)

6
frontend/store/members.js

@ -42,7 +42,7 @@ export const actions = {
commit('setLoading', true)
return MemberService.getMemberList(payload.projectId)
.then((response) => {
commit('setMemberList', response)
commit('setMemberList', response.data)
})
.catch((error) => {
alert(error)
@ -54,7 +54,7 @@ export const actions = {
addMember({ commit }, data) {
MemberService.addMember(data.projectId, data.userId, data.role)
.then((response) => {
commit('addMember', response)
commit('addMember', response.data)
})
.catch((error) => {
alert(error)
@ -63,7 +63,7 @@ export const actions = {
updateMemberRole({ commit }, member) {
MemberService.updateMemberRole(member.projectId, member.id, member.role)
.then((response) => {
commit('updateMember', response)
commit('updateMember', response.data)
})
.catch((error) => {
alert(error)

10
frontend/store/projects.js

@ -226,7 +226,7 @@ export const actions = {
commit('setLoading', true)
ProjectService.getProjectList()
.then((response) => {
commit('setProjectList', response)
commit('setProjectList', response.data)
})
.catch((error) => {
alert(error)
@ -238,7 +238,7 @@ export const actions = {
createProject({ commit }, project) {
ProjectService.createProject(project)
.then((response) => {
commit('createProject', response)
commit('createProject', response.data)
})
.catch((error) => {
alert(error)
@ -247,7 +247,7 @@ export const actions = {
updateProject({ commit }, data) {
ProjectService.updateProject(data.projectId, data)
.then((response) => {
commit('updateProject', response)
commit('updateProject', response.data)
})
.catch((error) => {
alert(error)
@ -268,7 +268,7 @@ export const actions = {
setCurrentProject({ commit }, projectId) {
return ProjectService.fetchProjectById(projectId)
.then((response) => {
commit('setCurrent', response)
commit('setCurrent', response.data)
})
.catch((error) => {
alert(error)
@ -277,7 +277,7 @@ export const actions = {
updateCurrentProject({ commit }, data) {
ProjectService.updateProject(data.projectId, data)
.then((response) => {
commit('setCurrent', response)
commit('setCurrent', response.data)
})
.catch((error) => {
alert(error)

2
frontend/store/roles.js

@ -25,7 +25,7 @@ export const actions = {
commit('setLoading', true)
return RoleService.getRoleList()
.then((response) => {
commit('setRoleList', response)
commit('setRoleList', response.data)
})
.catch((error) => {
alert(error)

2
frontend/store/statistics.js

@ -56,7 +56,7 @@ export const actions = {
commit('setLoading', true)
StatisticsService.getStatistics(payload)
.then((response) => {
commit('setStatistics', response)
commit('setStatistics', response.data)
})
.catch((error) => {
alert(error)

Loading…
Cancel
Save