-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI: Client and Server Monitor #8177
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2eceffa
Create new monitor route for clients
DingoEatingFuzz cc8aed8
Monitor component and query param interaction
DingoEatingFuzz 9e59488
Implement the log streaming portion of the AgentMonitor component
DingoEatingFuzz f02beee
Reimplement synchronizeScrollPosition in a way that actually works
DingoEatingFuzz 0a4cde3
Refactor AgentMonitor levels handling to be simpler
DingoEatingFuzz 47969c4
Inline-block the buttons to remove weird text-flow spacing
DingoEatingFuzz 88e7e7e
Preserve the log when switching log levels on monitor
DingoEatingFuzz 2c85e69
Temporary helpers for ember-power-select
DingoEatingFuzz f896a62
Test coverage for the AgentMonitor component
DingoEatingFuzz d0a0ffd
Test coverage for the client monitor page
DingoEatingFuzz a4a8c9e
Ability for agent:read
DingoEatingFuzz c3b4999
New component version of the forbidden-message partial
DingoEatingFuzz a0fce03
Show a helpful forbidden message when monitor access is not authorized
DingoEatingFuzz 9e5cd53
Refactor the servers/server pages to match the subnav style of nested…
DingoEatingFuzz 9294a7a
Add nested monitor route to servers/server
DingoEatingFuzz 7185757
Redesign the server detail page to be inline with everything else
DingoEatingFuzz 53027ba
Test coverage for new features of the server detail page
DingoEatingFuzz a0c6cc2
Server monitor page
DingoEatingFuzz 5bb3c43
Select all shortcut support for the streaming file component
DingoEatingFuzz 619aea8
Guard the request animation frame with the existing requestFrame flag
DingoEatingFuzz 34e8e1f
Code review feedback
DingoEatingFuzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import AbstractAbility from './abstract'; | ||
import { computed, get } from '@ember/object'; | ||
import { or } from '@ember/object/computed'; | ||
|
||
export default class Client extends AbstractAbility { | ||
@or('bypassAuthorization', 'selfTokenIsManagement', 'policiesIncludeAgentReadOrWrite') | ||
canRead; | ||
|
||
@computed('token.selfTokenPolicies.[]') | ||
get policiesIncludeAgentReadOrWrite() { | ||
const policies = (get(this, 'token.selfTokenPolicies') || []) | ||
.toArray() | ||
.map(policy => get(policy, 'rulesJSON.Agent.Policy')) | ||
.compact(); | ||
|
||
return policies.some(policy => policy === 'read' || policy === 'write'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
import { assert } from '@ember/debug'; | ||
import { tagName } from '@ember-decorators/component'; | ||
import classic from 'ember-classic-decorator'; | ||
import Log from 'nomad-ui/utils/classes/log'; | ||
|
||
const LEVELS = ['error', 'warn', 'info', 'debug', 'trace']; | ||
|
||
@classic | ||
@tagName('') | ||
export default class AgentMonitor extends Component { | ||
@service token; | ||
|
||
client = null; | ||
server = null; | ||
level = LEVELS[2]; | ||
onLevelChange() {} | ||
|
||
levels = LEVELS; | ||
monitorUrl = '/v1/agent/monitor'; | ||
isStreaming = true; | ||
logger = null; | ||
|
||
@computed('level', 'client.id', 'server.id') | ||
get monitorParams() { | ||
assert( | ||
'Provide a client OR a server to AgentMonitor, not both.', | ||
this.server != null || this.client != null | ||
); | ||
|
||
const type = this.server ? 'server_id' : 'client_id'; | ||
const id = this.server ? this.server.id : this.client && this.client.id; | ||
|
||
return { | ||
log_level: this.level, | ||
[type]: id, | ||
}; | ||
} | ||
|
||
didInsertElement() { | ||
this.updateLogger(); | ||
} | ||
|
||
updateLogger() { | ||
let currentTail = this.logger ? this.logger.tail : ''; | ||
if (currentTail) { | ||
currentTail += `\n...changing log level to ${this.level}...\n\n`; | ||
} | ||
this.set( | ||
'logger', | ||
Log.create({ | ||
logFetch: url => this.token.authorizedRequest(url), | ||
params: this.monitorParams, | ||
url: this.monitorUrl, | ||
tail: currentTail, | ||
}) | ||
); | ||
} | ||
|
||
setLevel(level) { | ||
this.logger.stop(); | ||
this.set('level', level); | ||
this.onLevelChange(level); | ||
this.updateLogger(); | ||
} | ||
|
||
toggleStream() { | ||
this.set('streamMode', 'streaming'); | ||
this.toggleProperty('isStreaming'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Component from '@ember/component'; | ||
import { tagName } from '@ember-decorators/component'; | ||
|
||
@tagName('') | ||
export default class ClientSubnav extends Component {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Component from '@ember/component'; | ||
import { tagName } from '@ember-decorators/component'; | ||
|
||
@tagName('') | ||
export default class ForbiddenMessage extends Component {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Component from '@ember/component'; | ||
import { tagName } from '@ember-decorators/component'; | ||
|
||
@tagName('') | ||
export default class ServerSubnav extends Component {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Controller from '@ember/controller'; | ||
|
||
export default class ClientMonitorController extends Controller { | ||
queryParams = ['level']; | ||
level = 'info'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,5 @@ | ||
import { alias } from '@ember/object/computed'; | ||
import Controller from '@ember/controller'; | ||
import Sortable from 'nomad-ui/mixins/sortable'; | ||
|
||
export default class ServersController extends Controller.extend(Sortable) { | ||
@alias('model.nodes') nodes; | ||
@alias('model.agents') agents; | ||
|
||
queryParams = [ | ||
{ | ||
currentPage: 'page', | ||
}, | ||
{ | ||
sortProperty: 'sort', | ||
}, | ||
{ | ||
sortDescending: 'desc', | ||
}, | ||
]; | ||
|
||
currentPage = 1; | ||
pageSize = 8; | ||
|
||
sortProperty = 'isLeader'; | ||
sortDescending = true; | ||
|
||
export default class ServersController extends Controller { | ||
isForbidden = false; | ||
|
||
@alias('agents') listToSort; | ||
@alias('listSorted') sortedAgents; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
import { alias } from '@ember/object/computed'; | ||
import Controller, { inject as controller } from '@ember/controller'; | ||
import Sortable from 'nomad-ui/mixins/sortable'; | ||
|
||
export default class IndexController extends Controller { | ||
export default class IndexController extends Controller.extend(Sortable) { | ||
@controller('servers') serversController; | ||
@alias('serversController.isForbidden') isForbidden; | ||
|
||
@alias('model.nodes') nodes; | ||
@alias('model.agents') agents; | ||
|
||
queryParams = [ | ||
{ | ||
currentPage: 'page', | ||
}, | ||
{ | ||
sortProperty: 'sort', | ||
}, | ||
{ | ||
sortDescending: 'desc', | ||
}, | ||
]; | ||
|
||
currentPage = 1; | ||
pageSize = 8; | ||
|
||
sortProperty = 'isLeader'; | ||
sortDescending = true; | ||
|
||
@alias('agents') listToSort; | ||
@alias('listSorted') sortedAgents; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Controller from '@ember/controller'; | ||
|
||
export default class ServerMonitorController extends Controller { | ||
queryParams = ['level']; | ||
level = 'info'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that using
this.set
means this needs to be@classic
. I see now that I failed to follow the part of the instructions that would cause this to be a linting error, so I’m sorry about that, I’ll open a PR 😳