fix setting load

This commit is contained in:
undefined committed 2020-07-16 16:52:51 +08:00
1 parent 2d5eef8d08
commit 0f23611853
4 files changed
+15 -4

No files matched your search

+3 -1
View File
@@ -87,6 +87,8 @@ export async function setting(pending: string[], fail: string[], modelSetting: t
};
for (const i of pending) {
let p = path.resolve(i, 'setting.yaml');
const t = i.split(path.sep);
const name = t[t.length - 1];
if (!fs.existsSync(p)) p = path.resolve(i, 'settings.yaml');
if (fs.existsSync(p) && !fail.includes(i)) {
try {
@@ -94,7 +96,7 @@ export async function setting(pending: string[], fail: string[], modelSetting: t
for (const key in cfg) {
map[cfg[key].category || 'system'](
modelSetting.Setting(
i, `${i}.${key}`, cfg[key].range, cfg[key].default,
name, `${name}.${key}`, cfg[key].range, cfg[key].default,
cfg[key].type || 'text', cfg[key].name || key, cfg[key].desc || '',
),
);
@@ -78,7 +78,7 @@ export default class ScratchpadRecordsRowContainer extends React.PureComponent {
{shouldShowDetail(data) ? `${Math.ceil(data.memory / 1000)} MB` : '-'}
</td>
<td className="col--time">
{shouldShowDetail(data) ? `${(data.time_ms / 1000).toFixed(1)}s` : '-'}
{shouldShowDetail(data) ? `${(data.time / 1000).toFixed(1)}s` : '-'}
</td>
<td className="col--at">
<time data-tooltip={moment(submitAt).format('YYYY-MM-DD HH:mm:ss')}>
@@ -16,7 +16,6 @@ export default function reducer(state = {
return {
...state,
output: (rdoc.stdout || '') + (rdoc.stderr || ''),
rid: null,
};
}
}
+11 -1
View File
@@ -15,9 +15,19 @@ export default function reducer(state = {
}
case 'SCRATCHPAD_RECORDS_PUSH': {
const { rdoc } = action.payload;
const rows = [...state.rows];
if (!rows.includes(rdoc._id)) {
return {
...state,
rows: [rdoc._id, ...state.rows],
items: {
...state.items,
[rdoc._id]: rdoc,
},
};
}
return {
...state,
rows: [rdoc._id, ...state.rows],
items: {
...state.items,
[rdoc._id]: rdoc,