Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
56c6cfea
Unverified
Commit
56c6cfea
authored
Oct 19, 2022
by
Lijiaoa
Committed by
GitHub
Oct 19, 2022
Browse files
improve localStorage for better user experience (#5145)
parent
b22f192c
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
205 additions
and
147 deletions
+205
-147
ts/webui/src/App.tsx
ts/webui/src/App.tsx
+2
-0
ts/webui/src/components/experiment/trialdetail/ChangeColumnComponent.tsx
...mponents/experiment/trialdetail/ChangeColumnComponent.tsx
+14
-2
ts/webui/src/components/experiment/trialdetail/chart/Para.tsx
...ebui/src/components/experiment/trialdetail/chart/Para.tsx
+4
-2
ts/webui/src/components/experiment/trialdetail/table/TableList.tsx
...src/components/experiment/trialdetail/table/TableList.tsx
+4
-2
ts/webui/src/static/model/localStorage.ts
ts/webui/src/static/model/localStorage.ts
+41
-0
ts/webui/yarn.lock
ts/webui/yarn.lock
+140
-141
No files found.
ts/webui/src/App.tsx
View file @
56c6cfea
...
@@ -82,6 +82,8 @@ class App extends React.Component<{}, AppState> {
...
@@ -82,6 +82,8 @@ class App extends React.Component<{}, AppState> {
}
}
async
componentDidMount
():
Promise
<
void
>
{
async
componentDidMount
():
Promise
<
void
>
{
localStorage
.
removeItem
(
'
columns
'
);
localStorage
.
removeItem
(
'
paraColumns
'
);
await
Promise
.
all
([
EXPERIMENT
.
init
(),
TRIALS
.
init
()]);
await
Promise
.
all
([
EXPERIMENT
.
init
(),
TRIALS
.
init
()]);
this
.
setState
(
state
=>
({
this
.
setState
(
state
=>
({
experimentUpdateBroadcast
:
state
.
experimentUpdateBroadcast
+
1
,
experimentUpdateBroadcast
:
state
.
experimentUpdateBroadcast
+
1
,
...
...
ts/webui/src/components/experiment/trialdetail/ChangeColumnComponent.tsx
View file @
56c6cfea
import
*
as
React
from
'
react
'
;
import
*
as
React
from
'
react
'
;
import
{
Dialog
,
DialogType
,
DialogFooter
,
Checkbox
,
PrimaryButton
,
DefaultButton
}
from
'
@fluentui/react
'
;
import
{
Dialog
,
DialogType
,
DialogFooter
,
Checkbox
,
PrimaryButton
,
DefaultButton
}
from
'
@fluentui/react
'
;
import
{
EXPERIMENT
}
from
'
@static/datamodel
'
;
import
{
Storage
}
from
'
@model/localStorage
'
;
/**
/**
* changeColumnComponent file is for [customized table column, customized hyper-parameter graph yAxis]
* changeColumnComponent file is for [customized table column, customized hyper-parameter graph yAxis]
...
@@ -67,9 +69,19 @@ class ChangeColumnComponent extends React.Component<ChangeColumnProps, ChangeCol
...
@@ -67,9 +69,19 @@ class ChangeColumnComponent extends React.Component<ChangeColumnProps, ChangeCol
const
selectedColumns
=
allColumns
.
map
(
column
=>
column
.
key
).
filter
(
key
=>
currentSelected
.
includes
(
key
));
const
selectedColumns
=
allColumns
.
map
(
column
=>
column
.
key
).
filter
(
key
=>
currentSelected
.
includes
(
key
));
onSelectedChange
(
selectedColumns
);
onSelectedChange
(
selectedColumns
);
if
(
whichComponent
===
'
table
'
)
{
if
(
whichComponent
===
'
table
'
)
{
localStorage
.
setItem
(
'
columns
'
,
JSON
.
stringify
(
selectedColumns
));
const
storage
=
new
Storage
(
`
${
EXPERIMENT
.
profile
.
id
}
_columns`
,
JSON
.
stringify
(
selectedColumns
),
30
*
24
*
60
*
60
*
1000
);
storage
.
setValue
();
}
else
{
}
else
{
localStorage
.
setItem
(
'
paraColumns
'
,
JSON
.
stringify
(
selectedColumns
));
const
storage
=
new
Storage
(
`
${
EXPERIMENT
.
profile
.
id
}
_paraColumns`
,
JSON
.
stringify
(
selectedColumns
),
30
*
24
*
60
*
60
*
1000
);
storage
.
setValue
();
}
}
this
.
hideDialog
();
this
.
hideDialog
();
};
};
...
...
ts/webui/src/components/experiment/trialdetail/chart/Para.tsx
View file @
56c6cfea
...
@@ -8,6 +8,7 @@ import { SingleAxis, MultipleAxes } from '@static/interface';
...
@@ -8,6 +8,7 @@ import { SingleAxis, MultipleAxes } from '@static/interface';
import
{
Trial
}
from
'
@model/trial
'
;
import
{
Trial
}
from
'
@model/trial
'
;
import
ChangeColumnComponent
from
'
../ChangeColumnComponent
'
;
import
ChangeColumnComponent
from
'
../ChangeColumnComponent
'
;
import
{
optimizeModeValue
}
from
'
./optimizeMode
'
;
import
{
optimizeModeValue
}
from
'
./optimizeMode
'
;
import
{
getValue
}
from
'
@model/localStorage
'
;
import
'
parcoord-es/dist/parcoords.css
'
;
import
'
parcoord-es/dist/parcoords.css
'
;
import
'
@style/button.scss
'
;
import
'
@style/button.scss
'
;
...
@@ -56,9 +57,10 @@ class Para extends React.Component<ParaProps, ParaState> {
...
@@ -56,9 +57,10 @@ class Para extends React.Component<ParaProps, ParaState> {
customizeColumnsDialogVisible
:
false
,
customizeColumnsDialogVisible
:
false
,
availableDimensions
:
[],
availableDimensions
:
[],
chosenDimensions
:
chosenDimensions
:
localStorage
.
getItem
(
'
paraColumns
'
)
!==
null
localStorage
.
getItem
(
`
${
EXPERIMENT
.
profile
.
id
}
_paraColumns`
)
!==
null
&&
getValue
(
`
${
EXPERIMENT
.
profile
.
id
}
_paraColumns`
)
!==
null
?
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
?
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
JSON
.
parse
(
localStorage
.
getItem
(
'
paraColumns
'
)
!
)
JSON
.
parse
(
getValue
(
`
${
EXPERIMENT
.
profile
.
id
}
_
paraColumns
`
)
!
)
:
[]
:
[]
};
};
}
}
...
...
ts/webui/src/components/experiment/trialdetail/table/TableList.tsx
View file @
56c6cfea
...
@@ -16,6 +16,7 @@ import { getTrialsBySearchFilters } from './tableFunction/search/searchFunction'
...
@@ -16,6 +16,7 @@ import { getTrialsBySearchFilters } from './tableFunction/search/searchFunction'
import
PaginationTable
from
'
@components/common/PaginationTable
'
;
import
PaginationTable
from
'
@components/common/PaginationTable
'
;
import
CopyButton
from
'
@components/common/CopyButton
'
;
import
CopyButton
from
'
@components/common/CopyButton
'
;
import
TooltipHostIndex
from
'
@components/common/TooltipHostIndex
'
;
import
TooltipHostIndex
from
'
@components/common/TooltipHostIndex
'
;
import
{
getValue
}
from
'
@model/localStorage
'
;
require
(
'
echarts/lib/chart/line
'
);
require
(
'
echarts/lib/chart/line
'
);
require
(
'
echarts/lib/component/tooltip
'
);
require
(
'
echarts/lib/component/tooltip
'
);
...
@@ -54,9 +55,10 @@ class TableList extends React.Component<TableListProps, TableListState> {
...
@@ -54,9 +55,10 @@ class TableList extends React.Component<TableListProps, TableListState> {
this
.
state
=
{
this
.
state
=
{
displayedItems
:
[],
displayedItems
:
[],
displayedColumns
:
displayedColumns
:
localStorage
.
getItem
(
'
columns
'
)
!==
null
localStorage
.
getItem
(
`
${
EXPERIMENT
.
profile
.
id
}
_columns`
)
!==
null
&&
getValue
(
`
${
EXPERIMENT
.
profile
.
id
}
_columns`
)
!==
null
?
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
?
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
JSON
.
parse
(
localStorage
.
getItem
(
'
columns
'
)
!
)
JSON
.
parse
(
getValue
(
`
${
EXPERIMENT
.
profile
.
id
}
_
columns
`
)
!
)
:
defaultDisplayedColumns
,
:
defaultDisplayedColumns
,
columns
:
[],
columns
:
[],
searchType
:
'
id
'
,
searchType
:
'
id
'
,
...
...
ts/webui/src/static/model/localStorage.ts
0 → 100644
View file @
56c6cfea
export
interface
StorageFormat
{
expire
:
number
;
time
:
number
;
value
:
string
;
}
export
const
getValue
=
(
key
):
null
|
string
=>
{
const
val
=
localStorage
.
getItem
(
key
);
if
(
!
val
)
{
return
null
;
}
const
data
=
JSON
.
parse
(
val
)
as
StorageFormat
;
if
(
Date
.
now
()
-
data
.
time
>
data
.
expire
)
{
localStorage
.
removeItem
(
key
);
return
null
;
}
return
data
.
value
;
};
class
Storage
{
key
:
string
=
''
;
value
:
string
=
''
;
expire
:
number
=
0
;
constructor
(
key
:
string
,
value
:
string
,
expire
:
number
)
{
this
.
key
=
key
;
this
.
value
=
value
;
this
.
expire
=
expire
;
}
public
setValue
():
void
{
const
obj
:
StorageFormat
=
{
value
:
this
.
value
,
time
:
Date
.
now
(),
expire
:
this
.
expire
};
localStorage
.
setItem
(
this
.
key
,
JSON
.
stringify
(
obj
));
}
}
export
{
Storage
};
ts/webui/yarn.lock
View file @
56c6cfea
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment