1
0

Migration Improvements (#47)

Make "migration" "import everywhere"

Add checking for migration status before trying to migrate

Add get status from migrations

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/47
This commit is contained in:
konrad
2020-01-20 21:22:32 +00:00
parent 9b232c7d4f
commit d61a7511da
4 changed files with 50 additions and 9 deletions

View File

@ -282,9 +282,21 @@ export default class AbstractService {
return Promise.reject({message: 'This model is not able to get data.'})
}
return this.getM(this.paths.get, model, params)
}
/**
* This is a more abstract implementation which only does a get request.
* Services which need more flexibility can use this.
* @param url
* @param model
* @param params
* @returns {Q.Promise<unknown>}
*/
getM(url, model = {}, params = {}) {
const cancel = this.setLoading()
model = this.beforeGet(model)
return this.http.get(this.getReplacedRoute(this.paths.get, model), {params: params})
return this.http.get(this.getReplacedRoute(url, model), {params: params})
.catch(error => {
return this.errorHandler(error)
})

View File

@ -3,15 +3,21 @@ import AbstractService from '../abstractService'
// This service builds on top of the abstract service and basically just hides away method names.
// It enables migration services to be created with minimal overhead and even better method names.
export default class AbstractMigrationService extends AbstractService {
serviceUrlKey = ''
constructor(serviceUrlKey) {
super({
update: '/migration/'+serviceUrlKey+'/migrate',
get: '/migration/'+serviceUrlKey+'/auth',
})
this.serviceUrlKey = serviceUrlKey
}
getAuthUrl() {
return this.get({})
return this.getM('/migration/'+this.serviceUrlKey+'/auth')
}
getStatus() {
return this.getM('/migration/'+this.serviceUrlKey+'/status')
}
migrate(data) {