Commit c8025339 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

Adapted to new back end api

parent f7bf4473
......@@ -3,28 +3,28 @@
<label for="data-window" :tooltip="tooltip">{{ header }}</label>
<div id="data-window">
<div class="data-entry-container"
:data-state="item.state"
:data-state="item.etl_state"
v-for="item in items">
<div class="data-entry-header"
:data-state="item.state">
<span class="cross" v-if="item.state === 'FAILURE'">&#xd7;</span>
:data-state="item.etl_state">
<span class="cross" v-if="item.etl_state === 'FAILURE'">&#xd7;</span>
<input type="checkbox"
:id="'data-check-' + item.data_id"
:value="item.data_id"
:id="'data-check-' + item.task_id"
:value="item.task_id"
v-model="selectedIDs"
v-if="item.state === 'SUCCESS'"/>
<label :for="'data-check-' + item.data_id">
v-if="item.etl_state === 'SUCCESS'"/>
<label :for="'data-check-' + item.task_id">
{{ item.label }}
</label>
<span class="options" @click="toggleDataEntryBody(item.data_id)">&#9776;</span>
<span class="options" @click="toggleDataEntryBody(item.task_id)">&#9776;</span>
</div>
<div class="data-entry-body" :data-state="item.state" :data-id="item.data_id">
<div class="data-entry-body" :data-state="item.etl_state" :data-id="item.task_id">
<div class="action-btns">
<button class="reload-btn" @click="reloadData(item.data_id)">&#8635;</button>
<button class="delete-btn" @click="deleteData(item.data_id)">&#215;</button><br/>
<button class="reload-btn" @click="reloadData(item.task_id)">&#8635;</button>
<button class="delete-btn" @click="deleteData(item.task_id)">&#215;</button><br/>
</div>
{{ item.message }}
{{ item.etl_message }}
</div>
</div>
</div>
......@@ -68,15 +68,15 @@
}
},
methods: {
toggleDataEntryBody (dataID) {
const $body = $(`.data-entry-body[data-id="${dataID}"]`)
toggleDataEntryBody (taskID) {
const $body = $(`.data-entry-body[data-id="${taskID}"]`)
$body.slideToggle(500)
},
reloadData (dataID) {
store.getters.requestManager.reloadData({dataID})
reloadData (taskID) {
store.getters.requestManager.reloadData({taskID})
},
deleteData (dataID) {
store.getters.requestManager.deleteData({dataID})
deleteData (taskID) {
store.getters.requestManager.deleteData({taskID})
}
}
}
......
......@@ -432,7 +432,7 @@
args.ids = []
}
// function made available via requestHandling mixin
this.runAnalysis({job_name: 'compute-correlation', args: args})
this.runAnalysis({task_name: 'compute-correlation', args: args})
.then(response => {
const results = JSON.parse(response)
results.data = JSON.parse(results.data)
......
'use strict'
import store from '../../store/store'
export default {
methods: {
async runAnalysis ({job_name, args}) {
async runAnalysis ({task_name, args}) {
function timeout (ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
const rv1 = await store.getters.requestManager.createAnalysis({job_name, args})
const jobID = rv1.data.job_id
const rv1 = await store.getters.requestManager.createAnalysis({task_name, args})
const taskID = rv1.data.task_id
let counter = 0
while (counter < 1000) {
await timeout(++counter * 200)
const rv2 = await store.getters.requestManager.getAnalysisStatus({jobID})
const jobInfo = rv2.data
if (jobInfo.state === 'SUCCESS') {
return jobInfo.result
} else if (jobInfo.state === 'FAILURE') {
throw new Error(jobInfo.result)
} else if (jobInfo.state === 'PENDING') {
const rv2 = await store.getters.requestManager.getAnalysisStatus({taskID})
const taskInfo = rv2.data
if (taskInfo.state === 'SUCCESS') {
return taskInfo.result
} else if (taskInfo.state === 'FAILURE') {
throw new Error(taskInfo.result)
} else if (taskInfo.state === 'PENDING') {
} else {
throw new Error(`Analysis Job has unknown state: ${jobInfo.state}`)
throw new Error(`Analysis Task has unknown state: ${taskInfo.state}`)
}
}
}
......
'use strict'
import * as d3 from 'd3'
import d3Tip from 'd3-tip'; d3.tip = d3Tip
......
'use strict'
import Vue from 'vue'
import CorrelationAnalysis from '../components/charts/CorrelationAnalysis.vue'
......
......@@ -15,7 +15,7 @@ export default class {
}
createData ({descriptors}) {
return this._axios.post('/data', {
this._axios.post('/data', {
descriptors,
auth: this._getAuth(),
handler: this._handler,
......@@ -23,42 +23,34 @@ export default class {
})
}
reloadData ({dataID}) {
const dataItem = store.getters.data.find(d => d.data_id === dataID)
reloadData ({taskID}) {
const dataItem = store.getters.data.find(d => d.task_id === taskID)
const descriptors = [dataItem.descriptor]
this.deleteData({taskID})
this.createData({descriptors})
}
getDataStatusByParams ({descriptor}) {
const params = JSON.stringify({server: this._thisBaseURL, descriptor})
return this._axios.get(`/data/${params}`)
}
getDataStatusByID ({dataID}) {
return this._axios.get(`/data/${dataID}`)
}
getAllDataStatus () {
getAllDataStates () {
return this._axios.get('/data')
}
deleteData ({dataID}) {
return this._axios.delete(`/data/${dataID}`)
deleteData ({taskID}) {
return this._axios.delete(`/data/${taskID}`)
}
deleteAllData () {
return this._axios.delete('/data')
}
createAnalysis ({job_name, args}) {
return this._axios.post('/analytics', {job_name, args})
createAnalysis ({task_name, args}) {
return this._axios.post('/analytics', {task_name, args})
}
getAnalysisStatus ({jobID}) {
return this._axios.get(`/analytics/${jobID}`)
getAnalysisStatus ({taskID}) {
return this._axios.get(`/analytics/${taskID}`)
}
cancelAnalysis ({jobID}) {
return this._axios.delete(`/analytics/${jobID}`)
cancelAnalysis ({taskID}) {
return this._axios.delete(`/analytics/${taskID}`)
}
}
......@@ -8,7 +8,7 @@ export default {
context.commit(types.SET_SUBSETS, subsets)
},
updateData: context => {
context.getters.requestManager.getAllDataStatus().then(response => {
context.getters.requestManager.getAllDataStates().then(response => {
context.commit(types.SET_DATA, response.data.data_states)
}).catch(error => {
console.error(error) // TODO: Notify user about this
......
......@@ -14,12 +14,13 @@
<script>
const fjs = fractal.init({
handler: 'ada',
thisBaseURL: 'http://10.79.2.192:8080',
thisBaseURL: 'https://ada.parkinson.lu',
fractalisBaseURL: 'http://127.0.0.1:5000',
getAuth () {
return credentials1
}
})
fjs.clearCache()
fjs.loadData([
{
data_type: 'Enum',
......
......@@ -36,8 +36,8 @@ describe('DataBox', () => {
it('checkboxes are linked to data', () => {
store.state.data = [
{data_type: 'numeric', label: '', data_id: 'A'},
{data_type: 'numeric', label: '', data_id: ''}
{data_type: 'numeric', label: '', task_id: 'A'},
{data_type: 'numeric', label: '', task_id: ''}
]
const Component = Vue.extend(DataBox)
const propsData = {dataType: 'numeric', header: ''}
......
'use strict'
import requestHandling from '../src/components/mixins/request-handling'
import RequestManager from '../src/services/request-manager'
import store from '../src/store/store'
......@@ -18,9 +16,9 @@ describe('runAnalysis method', () => {
expect(rv instanceof Promise).toBe(true)
})
it('fails if unknown job state', done => {
it('fails if unknown task state', done => {
spyOn(store.getters.requestManager, 'createAnalysis')
.and.returnValue(Promise.resolve({data: {job_id: 123}}))
.and.returnValue(Promise.resolve({data: {task_id: 123}}))
spyOn(store.getters.requestManager, 'getAnalysisStatus')
.and.returnValue(Promise.resolve({data: {state: 'FOO', result: ''}}))
runAnalysis({name: '', args: {}})
......@@ -28,9 +26,9 @@ describe('runAnalysis method', () => {
.catch(done)
})
it('resolves if job state is successful', done => {
it('resolves if task state is successful', done => {
spyOn(store.getters.requestManager, 'createAnalysis')
.and.returnValue(Promise.resolve({data: {job_id: 123}}))
.and.returnValue(Promise.resolve({data: {task_id: 123}}))
spyOn(store.getters.requestManager, 'getAnalysisStatus')
.and.returnValue(Promise.resolve({data: {state: 'SUCCESS', result: 123}}))
runAnalysis({name: '', args: {}})
......@@ -41,9 +39,9 @@ describe('runAnalysis method', () => {
.catch(done.fail)
})
it('rejects if job state is unsuccessful', done => {
it('rejects if task state is unsuccessful', done => {
spyOn(store.getters.requestManager, 'createAnalysis')
.and.returnValue(Promise.resolve({data: {job_id: 123}}))
.and.returnValue(Promise.resolve({data: {task_id: 123}}))
spyOn(store.getters.requestManager, 'getAnalysisStatus')
.and.returnValue(Promise.resolve({data: {state: 'FAILURE', result: ''}}))
runAnalysis({name: '', args: {}})
......@@ -51,9 +49,9 @@ describe('runAnalysis method', () => {
.catch(done)
})
it('does wait for job state to switch from PENDING to final state', done => {
it('does wait for task state to switch from PENDING to final state', done => {
spyOn(store.getters.requestManager, 'createAnalysis')
.and.returnValue(Promise.resolve({data: {job_id: 123}}))
.and.returnValue(Promise.resolve({data: {task_id: 123}}))
spyOn(store.getters.requestManager, 'getAnalysisStatus')
.and.returnValues(
Promise.resolve({data: {state: 'PENDING', result: ''}}),
......
'use strict'
import store from '../src/store/store'
import RequestManager from '../src/services/request-manager'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment