* authorization added
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
import HttpClient from '../api/HttpClient'
|
||||
import router from '../router'
|
||||
import store from '../store/index'
|
||||
|
||||
//Request in order to retrieve all contracts and print in table
|
||||
//Backend: extra roles check. Allow admin, verwaltung, employee.
|
||||
//REST: GET /contracts
|
||||
//Auth: provide auth token in request
|
||||
//OnError: redirect to page /error?message=somemessage&code=404
|
||||
export async function getContracts() {
|
||||
return HttpClient.get('contracts') //TODO: provide here auth header
|
||||
export async function getContracts(authToken) {
|
||||
return HttpClient.get('contracts', {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
}) //TODO: provide here auth header
|
||||
.then(resp => {
|
||||
return resp.data
|
||||
})
|
||||
@@ -20,7 +25,11 @@ export async function getContracts() {
|
||||
//Auth: provide auth token in request
|
||||
//OnError: redirect to page /error?message=somemessage&code=404
|
||||
export async function getOpenContracts() {
|
||||
return HttpClient.get('contracts/open') //TODO: provide here auth header
|
||||
return HttpClient.get('contracts/open', {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
}) //TODO: provide here auth header
|
||||
.then(resp => {
|
||||
return resp.data.openContracts
|
||||
})
|
||||
@@ -34,8 +43,13 @@ export async function getOpenContracts() {
|
||||
//REST: GET /contract?id=someId
|
||||
//Auth: provide auth token in request
|
||||
//OnError: redirect to page /error?message=somemessage&code=404
|
||||
export async function getContractById(identifier) {
|
||||
return HttpClient.get('/contract', { params: { id: identifier } })
|
||||
export async function getContractById(identifier, authToken) {
|
||||
return HttpClient.get('/contract', {
|
||||
params: { id: identifier },
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
})
|
||||
.then(resp => {
|
||||
//TODO: send also auth token with request
|
||||
return resp.data
|
||||
@@ -47,10 +61,18 @@ export async function getContractById(identifier) {
|
||||
}
|
||||
|
||||
export async function applyContract(contractID, prefRole) {
|
||||
return HttpClient.post('/contract/apply', {
|
||||
id: contractID,
|
||||
role: prefRole
|
||||
})
|
||||
return HttpClient.post(
|
||||
'/contract/apply',
|
||||
{
|
||||
id: contractID,
|
||||
role: prefRole
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
}
|
||||
)
|
||||
.then(resp => {
|
||||
//TODO: send also auth token with request
|
||||
return resp.data
|
||||
@@ -62,9 +84,17 @@ export async function applyContract(contractID, prefRole) {
|
||||
}
|
||||
|
||||
export async function misapply(contractID) {
|
||||
return HttpClient.post('/contract/misapply', {
|
||||
id: contractID
|
||||
})
|
||||
return HttpClient.post(
|
||||
'/contract/misapply',
|
||||
{
|
||||
id: contractID
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
}
|
||||
)
|
||||
.then(resp => {
|
||||
//TODO: send also auth token with request
|
||||
return resp.data
|
||||
@@ -76,16 +106,28 @@ export async function misapply(contractID) {
|
||||
}
|
||||
|
||||
export async function createContract(contractId, contractName, contractClient, contractPassword) {
|
||||
return HttpClient.post('/contract/create', {
|
||||
id: contractId,
|
||||
name: contractName,
|
||||
client: contractClient,
|
||||
password: contractPassword
|
||||
})
|
||||
return HttpClient.post(
|
||||
'/contract/create',
|
||||
{
|
||||
id: contractId,
|
||||
name: contractName,
|
||||
client: contractClient,
|
||||
password: contractPassword
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export async function deleteContract(contractId) {
|
||||
return HttpClient.delete('/contract/delete?id=' + contractId)
|
||||
return HttpClient.delete('/contract/delete?id=' + contractId, {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
})
|
||||
.then(resp => {
|
||||
//TODO: send also auth token with request
|
||||
return resp.data
|
||||
@@ -97,20 +139,34 @@ export async function deleteContract(contractId) {
|
||||
}
|
||||
|
||||
export async function saveComment(comment, contractId) {
|
||||
return HttpClient.post('/contract/' + contractId + '/comments', comment)
|
||||
}
|
||||
|
||||
export async function moveToNextStep(contractId) {
|
||||
return HttpClient.post('/contract/nextstep', {
|
||||
id: contractId
|
||||
return HttpClient.post('/contract/' + contractId + '/comments', comment, {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function moveToNextStep(contractId) {
|
||||
return HttpClient.post(
|
||||
'/contract/nextstep?id=' + contractId,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export async function getStatuses(contractId) {
|
||||
return HttpClient.get('/statuses')
|
||||
return HttpClient.get('/statuses', {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
})
|
||||
.then(resp => {
|
||||
//TODO: send also auth token with request
|
||||
return resp.data.statuses
|
||||
return resp.data
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
@@ -118,10 +174,34 @@ export async function getStatuses(contractId) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function changeStatus(contractId, newStatus) {
|
||||
export async function postChangeStatus(contractId, newStatus) {
|
||||
//TODO: send also auth token with request
|
||||
return HttpClient.post('/contract/status', {
|
||||
id: contractId,
|
||||
status: newStatus
|
||||
})
|
||||
return HttpClient.post(
|
||||
'/contract/status',
|
||||
{
|
||||
id: contractId,
|
||||
status: newStatus
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export async function getAmountOfStatuses(token) {
|
||||
return HttpClient.get('/statuses/amount', {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + store.state.keycloak.keycloak.token
|
||||
}
|
||||
})
|
||||
.then(resp => {
|
||||
//TODO: send also auth token with request
|
||||
return resp.data
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
router.push('/error?message=' + error.message + '&code=' + error.code)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user