Skip to content

Commit 6ab8dfa

Browse files
authored
Merge pull request #224 from labmlai/custom-metrics
fix back button issues
2 parents c04dfb2 + 2483ef8 commit 6ab8dfa

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

app/ui/src/components/buttons.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ export class BackButton extends Button {
7272
this.currentPath = window.location.pathname
7373
this.navigatePath = null
7474

75-
if (/\/run\/.+\/.+/.test(this.currentPath)) {
75+
if (/\/run\/.+_\d+/.test(this.currentPath)) {
76+
this.navigatePath = this.currentPath.replace(/(\/run\/.+?)_\d+/, '$1');
77+
this.text = "Run"
78+
} else if (/\/run\/.+\/metrics\/.+/.test(this.currentPath)) {
79+
this.text = 'Run'
80+
this.navigatePath = this.currentPath.replace(/\/run\/(.+)\/metrics\/.+/, '/run/$1');
81+
} else if (/\/run\/.+\/.+/.test(this.currentPath)) {
7682
this.text = 'Run'
7783
this.navigatePath = this.currentPath.replace(/\/run\/(.+)\/.+/, '/run/$1')
7884
} else if (/\/session\/.+\/.+/.test(this.currentPath)) {
@@ -97,7 +103,7 @@ export class BackButton extends Button {
97103
}
98104

99105
onClick = () => {
100-
if (ROUTER.canBack() && this.navigatePath == null) {
106+
if (ROUTER.canBack()) {
101107
ROUTER.back()
102108
return
103109
}

app/ui/src/views/run_view.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class RunView extends ScreenView {
4545
private processContainer: WeyaElement
4646
private customMetrics: CustomMetricList
4747

48-
constructor(uuid: string, rank?: string) {
48+
constructor(uuid: string) {
4949
super()
50-
this.uuid = uuid + (rank ? '_' + rank : '')
51-
this.rank = rank
50+
this.uuid = uuid
51+
this.rank = uuid.split('_')[1]
5252
this.runCache = CACHE.getRun(this.uuid)
5353
this.statusCache = CACHE.getRunStatus(this.uuid)
5454
this.userCache = CACHE.getUser()
@@ -325,7 +325,7 @@ class RunView extends ScreenView {
325325
this.rankElems = $('div', '.hidden.list.runs-list.list-group', $ => {
326326
for (const [rank, run_uuid] of Object.entries(this.run.other_rank_run_uuids)) {
327327
$('a', '.list-item.list-group-item.list-group-item-action',
328-
{href: `/run/${this.uuid}/${rank}`, target: "_blank"},
328+
{href: `/run/${this.uuid}_${rank}`, target: "_blank"},
329329
$ => {
330330
$('div', $ => {
331331
$('h6', `Rank ${+rank + 1}`)
@@ -340,11 +340,6 @@ class RunView extends ScreenView {
340340
export class RunHandler {
341341
constructor() {
342342
ROUTER.route('run/:uuid', [this.handleRun])
343-
ROUTER.route('run/:uuid/:rank', [this.handleDistributedRun])
344-
}
345-
346-
handleDistributedRun = (uuid: string, rank: string) => {
347-
SCREEN.setView(new RunView(uuid, rank))
348343
}
349344

350345
handleRun = (uuid: string) => {

0 commit comments

Comments
 (0)