1bd6a69067
Closes #7197 #7199 Note: Test coverage is limited to adapter and serializer unit tests. All acceptance tests have been stubbed and all features have been manually tested end-to-end. This represents Phase 1 of #6993 which is the core workflow of CSI in the UI. It includes a couple new pages for viewing all external volumes as well as the allocations associated with each. It also updates existing volume related views on job and allocation pages to handle both Host Volumes and CSI Volumes.
100 lines
2.4 KiB
JavaScript
100 lines
2.4 KiB
JavaScript
import Ember from 'ember';
|
|
import { get } from '@ember/object';
|
|
import RSVP from 'rsvp';
|
|
import { task } from 'ember-concurrency';
|
|
import wait from 'nomad-ui/utils/wait';
|
|
import XHRToken from 'nomad-ui/utils/classes/xhr-token';
|
|
import config from 'nomad-ui/config/environment';
|
|
|
|
const isEnabled = config.APP.blockingQueries !== false;
|
|
|
|
export function watchRecord(modelName) {
|
|
return task(function*(id, throttle = 2000) {
|
|
const token = new XHRToken();
|
|
if (typeof id === 'object') {
|
|
id = get(id, 'id');
|
|
}
|
|
while (isEnabled && !Ember.testing) {
|
|
try {
|
|
yield RSVP.all([
|
|
this.store.findRecord(modelName, id, {
|
|
reload: true,
|
|
adapterOptions: { watch: true, abortToken: token },
|
|
}),
|
|
wait(throttle),
|
|
]);
|
|
} catch (e) {
|
|
yield e;
|
|
break;
|
|
} finally {
|
|
token.abort();
|
|
}
|
|
}
|
|
}).drop();
|
|
}
|
|
|
|
export function watchRelationship(relationshipName) {
|
|
return task(function*(model, throttle = 2000) {
|
|
const token = new XHRToken();
|
|
while (isEnabled && !Ember.testing) {
|
|
try {
|
|
yield RSVP.all([
|
|
this.store
|
|
.adapterFor(model.constructor.modelName)
|
|
.reloadRelationship(model, relationshipName, { watch: true, abortToken: token }),
|
|
wait(throttle),
|
|
]);
|
|
} catch (e) {
|
|
yield e;
|
|
break;
|
|
} finally {
|
|
token.abort();
|
|
}
|
|
}
|
|
}).drop();
|
|
}
|
|
|
|
export function watchAll(modelName) {
|
|
return task(function*(throttle = 2000) {
|
|
const token = new XHRToken();
|
|
while (isEnabled && !Ember.testing) {
|
|
try {
|
|
yield RSVP.all([
|
|
this.store.findAll(modelName, {
|
|
reload: true,
|
|
adapterOptions: { watch: true, abortToken: token },
|
|
}),
|
|
wait(throttle),
|
|
]);
|
|
} catch (e) {
|
|
yield e;
|
|
break;
|
|
} finally {
|
|
token.abort();
|
|
}
|
|
}
|
|
}).drop();
|
|
}
|
|
|
|
export function watchQuery(modelName) {
|
|
return task(function*(params, throttle = 10000) {
|
|
const token = new XHRToken();
|
|
while (isEnabled && !Ember.testing) {
|
|
try {
|
|
yield RSVP.all([
|
|
this.store.query(modelName, params, {
|
|
reload: true,
|
|
adapterOptions: { watch: true, abortToken: token },
|
|
}),
|
|
wait(throttle),
|
|
]);
|
|
} catch (e) {
|
|
yield e;
|
|
break;
|
|
} finally {
|
|
token.abort();
|
|
}
|
|
}
|
|
}).drop();
|
|
}
|