mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 01:45:44 +03:00
* Hook and latch on the initial index * Serialization and restart of controller and table * de-log * allocBlocks reimplemented at job model level * totalAllocs doesnt mean on jobmodel what it did in steady.js * Hamburgers to sausages * Hacky way to bring new jobs back around and parent job handling in list view * Getting closer to hook/latch * Latch from update on hook from initialize, but fickle * Note on multiple-watch problem * Sensible monday morning comment removal * use of abortController to handle transition and reset events * Next token will now update when there's an on-page shift * Very rough anti-jostle technique * Demoable, now to move things out of route and into controller * Into the controller, generally * Smarter cancellations * Reset abortController on index models run, and system/sysbatch jobs now have an improved groupCountSum computed property * Prev Page reverse querying * n+1th jobs existing will trigger nextToken/pagination display * Start of a GET/POST statuses return * Namespace fix * Unblock tests * Realizing to my small horror that this skipURLModification flag may be too heavy handed * Lintfix * Default liveupdates localStorage setting to true * Pagination and index rethink * Big uncoupling of watchable and url-append stuff * Testfixes for region, search, and keyboard * Job row class for test purposes * Allocations in test now contain events * Starting on the jobs list tests in earnest * Forbidden state de-bubbling cleanup * Job list page size fixes * Facet/Search/Filter jobs list tests skipped * Maybe it's the automatic mirage logging * Unbreak task unit test * Pre-sort sort * styling for jobs list pagination and general PR cleanup * moving from Job.ActiveDeploymentID to Job.LatestDeployment.ID * modifyIndex-based pagination (#20350) * modifyIndex-based pagination * modifyIndex gets its own column and pagination compacted with icons * A generic withPagination handler for mirage * Some live-PR changes * Pagination and button disabled tests * Job update handling tests for jobs index * assertion timeout in case of long setTimeouts * assert.timeouts down to 500ms * de-to-do * Clarifying comment and test descriptions * Bugfix: resizing your browser on the new jobs index page would make the viz grow forever (#20458) * [ui] Searching and filtering options (#20459) * Beginnings of a search box for filter expressions * jobSearchBox integration test * jobs list updateFilter initial test * Basic jobs list filtering tests * First attempt at side-by-side facets and search with a computed filter * Weirdly close to an iterative approach but checked isnt tracked properly * Big rework to make filter composition and decomposition work nicely with the url * Namespace facet dropdown added * NodePool facet dropdown added * hdsFacet for future testing and basic namespace filtering test * Namespace filter existence test * Status filtering * Node pool/dynamic facet test * Test patchups * Attempt at optimize test fix * Allocation re-load on optimize page explainer * The Big Un-Skip * Post-PR-review cleanup * todo-squashing * [ui] Handle parent/child jobs with the paginated Jobs Index route (#20493) * First pass at a non-watchQuery version * Parameterized jobs get child fetching and jobs index status style for parent jobs * Completed allocs vs Running allocs in a child-job context, and fix an issue where moving from parent to parent would not reset index * Testfix and better handling empty-child-statuses-list * Parent/child test case * Dont show empty allocation-status bars for parent jobs with no children * Splits Settings into 2 sections, sign-in/profile and user settings (#20535) * Changelog
181 lines
4.6 KiB
JavaScript
181 lines
4.6 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Service, { inject as service } from '@ember/service';
|
|
import { computed } from '@ember/object';
|
|
import { alias } from '@ember/object/computed';
|
|
import PromiseObject from '../utils/classes/promise-object';
|
|
import PromiseArray from '../utils/classes/promise-array';
|
|
import { namespace } from '../adapters/application';
|
|
import jsonWithDefault from '../utils/json-with-default';
|
|
import classic from 'ember-classic-decorator';
|
|
import { task } from 'ember-concurrency';
|
|
|
|
@classic
|
|
export default class SystemService extends Service {
|
|
@service token;
|
|
@service store;
|
|
|
|
@computed('activeRegion')
|
|
get leader() {
|
|
const token = this.token;
|
|
|
|
return PromiseObject.create({
|
|
promise: token
|
|
.authorizedRequest(`/${namespace}/status/leader`)
|
|
.then((res) => res.json())
|
|
.then((rpcAddr) => ({ rpcAddr }))
|
|
.then((leader) => {
|
|
// Dirty self so leader can be used as a dependent key
|
|
this.notifyPropertyChange('leader.rpcAddr');
|
|
return leader;
|
|
}),
|
|
});
|
|
}
|
|
|
|
@computed
|
|
get agent() {
|
|
const token = this.token;
|
|
return PromiseObject.create({
|
|
promise: token
|
|
.authorizedRawRequest(`/${namespace}/agent/self`)
|
|
.then(jsonWithDefault({}))
|
|
.then((agent) => {
|
|
if (agent?.config?.Version) {
|
|
const { Version, VersionPrerelease, VersionMetadata } =
|
|
agent.config.Version;
|
|
agent.version = Version;
|
|
if (VersionPrerelease)
|
|
agent.version = `${agent.version}-${VersionPrerelease}`;
|
|
if (VersionMetadata)
|
|
agent.version = `${agent.version}+${VersionMetadata}`;
|
|
}
|
|
return agent;
|
|
}),
|
|
});
|
|
}
|
|
|
|
@computed
|
|
get defaultRegion() {
|
|
const token = this.token;
|
|
return PromiseObject.create({
|
|
promise: token
|
|
.authorizedRawRequest(`/${namespace}/agent/members`)
|
|
.then(jsonWithDefault({}))
|
|
.then((json) => {
|
|
return { region: json.ServerRegion };
|
|
}),
|
|
});
|
|
}
|
|
|
|
@computed
|
|
get regions() {
|
|
const token = this.token;
|
|
|
|
return PromiseArray.create({
|
|
promise: token
|
|
.authorizedRawRequest(`/${namespace}/regions`)
|
|
.then(jsonWithDefault([])),
|
|
});
|
|
}
|
|
|
|
@computed('regions.[]')
|
|
get activeRegion() {
|
|
const regions = this.regions;
|
|
const region = window.localStorage.nomadActiveRegion;
|
|
|
|
if (regions.includes(region)) {
|
|
return region;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
set activeRegion(value) {
|
|
if (value == null) {
|
|
window.localStorage.removeItem('nomadActiveRegion');
|
|
return;
|
|
} else {
|
|
// All localStorage values are strings. Stringify first so
|
|
// the return value is consistent with what is persisted.
|
|
const strValue = value + '';
|
|
window.localStorage.nomadActiveRegion = strValue;
|
|
}
|
|
}
|
|
|
|
@computed('regions.[]')
|
|
get shouldShowRegions() {
|
|
return this.get('regions.length') > 1;
|
|
}
|
|
|
|
@computed('activeRegion', 'defaultRegion.region', 'shouldShowRegions')
|
|
get shouldIncludeRegion() {
|
|
return (
|
|
this.shouldShowRegions &&
|
|
this.activeRegion !== this.get('defaultRegion.region')
|
|
);
|
|
}
|
|
|
|
@computed('activeRegion')
|
|
get namespaces() {
|
|
return PromiseArray.create({
|
|
promise: this.store
|
|
.findAll('namespace')
|
|
.then((namespaces) => namespaces.compact()),
|
|
});
|
|
}
|
|
|
|
@computed('namespaces.[]')
|
|
get shouldShowNamespaces() {
|
|
const namespaces = this.namespaces.toArray();
|
|
return (
|
|
namespaces.length &&
|
|
namespaces.some((namespace) => namespace.get('id') !== 'default')
|
|
);
|
|
}
|
|
|
|
get shouldShowNodepools() {
|
|
return true; // TODO: make this dependent on there being at least one non-default node pool
|
|
}
|
|
|
|
@task(function* () {
|
|
const emptyLicense = { License: { Features: [] } };
|
|
|
|
try {
|
|
return yield this.token
|
|
.authorizedRawRequest(`/${namespace}/operator/license`)
|
|
.then(jsonWithDefault(emptyLicense));
|
|
} catch (e) {
|
|
return emptyLicense;
|
|
}
|
|
})
|
|
fetchLicense;
|
|
|
|
@task(function* () {
|
|
try {
|
|
const request = yield this.token.authorizedRequest('/v1/search/fuzzy', {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
Text: 'feature-detection-query',
|
|
Context: 'namespaces',
|
|
}),
|
|
});
|
|
|
|
return request.ok;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
})
|
|
checkFuzzySearchPresence;
|
|
|
|
@alias('fetchLicense.lastSuccessful.value') license;
|
|
@alias('checkFuzzySearchPresence.last.value') fuzzySearchEnabled;
|
|
|
|
@computed('license.License.Features.[]')
|
|
get features() {
|
|
return this.get('license.License.Features') || [];
|
|
}
|
|
}
|