Browse Source
* Set up UI setting component in profile page * Add UI setting page to the route, remove UI setting section from the profile * Add log auto refresh timer store * Add logTimer to pinia store and cookies * Read logTimer from pinia store, and delay getLogs by passing the logTimer to setInterval in refreshLogs function * Add log timer to getLogs * Fine tune view log, add auto refresh based on time interval set in UI setting * Add useI18n to ui setting * Set up UI setting component in profile page * Add UI setting page to the route, remove UI setting section from the profile * Add log auto refresh timer store * Add logTimer to pinia store and cookies * Read logTimer from pinia store, and delay getLogs by passing the logTimer to setInterval in refreshLogs function * Add log timer to getLogs * Fine tune view log, add auto refresh based on time interval set in UI setting * Add useI18n to ui setting * [Feat][UI] Add UI setting page in the project. * [Feat][UI] Add UI setting page in the project. * Remove logTimer in cookies * Clear timer id, set VITE_APP_DEV_WEB_URL back to default * Clear time id in dag * [Feat][UI] Add license header. * [Feat][UI] Remove console. * [Fix][UI] Fix log timer types. Co-authored-by: songjianet <1778651752@qq.com>3.2.0-release
lynn-illumio
2 years ago
committed by
GitHub
19 changed files with 332 additions and 28 deletions
@ -0,0 +1,23 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
export default { |
||||||
|
log: { |
||||||
|
refresh_time: 'Log Auto Refresh Time', |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,23 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
export default { |
||||||
|
log: { |
||||||
|
refresh_time: '自动刷新时间', |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,43 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
import type { Component } from 'vue' |
||||||
|
import utils from '@/utils' |
||||||
|
|
||||||
|
// All TSX files under the views folder automatically generate mapping relationship
|
||||||
|
const modules = import.meta.glob('/src/views/**/**.tsx') |
||||||
|
const components: { [key: string]: Component } = utils.mapping(modules) |
||||||
|
|
||||||
|
export default { |
||||||
|
path: '/ui-setting', |
||||||
|
name: 'ui-setting', |
||||||
|
meta: { title: '设置' }, |
||||||
|
component: () => import('@/layouts/content'), |
||||||
|
children: [ |
||||||
|
{ |
||||||
|
path: '', |
||||||
|
name: 'ui-setting', |
||||||
|
component: components['ui-setting'], |
||||||
|
meta: { |
||||||
|
title: '设置', |
||||||
|
activeMenu: 'ui-setting', |
||||||
|
showSide: false, |
||||||
|
auth: [] |
||||||
|
} |
||||||
|
} |
||||||
|
] |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
import { defineStore } from 'pinia' |
||||||
|
import { LogTimerStore } from './types' |
||||||
|
|
||||||
|
export const useLogTimerStore = defineStore({ |
||||||
|
id: 'logTimer', |
||||||
|
state: (): LogTimerStore => ({ |
||||||
|
logTimer: 0, |
||||||
|
}), |
||||||
|
persist: true, |
||||||
|
getters: { |
||||||
|
getLogTimer(): number { |
||||||
|
return this.logTimer |
||||||
|
} |
||||||
|
}, |
||||||
|
actions: { |
||||||
|
setLogTimer(timer: number): void { |
||||||
|
this.logTimer = timer |
||||||
|
} |
||||||
|
} |
||||||
|
}) |
||||||
|
|
@ -0,0 +1,21 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
interface LogTimerStore { |
||||||
|
logTimer: number |
||||||
|
} |
||||||
|
|
||||||
|
export { LogTimerStore } |
@ -0,0 +1,91 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
import { useI18n } from 'vue-i18n' |
||||||
|
import { NForm, NFormItem, NSelect } from "naive-ui"; |
||||||
|
import { defineComponent } from "vue"; |
||||||
|
import { useLogTimerStore } from '@/store/logTimer/logTimer' |
||||||
|
|
||||||
|
// Update LogTimer store when select value is updated
|
||||||
|
const handleUpdateValue = (logTimer: number) => { |
||||||
|
const logTimerStore = useLogTimerStore() |
||||||
|
logTimerStore.setLogTimer(logTimer) |
||||||
|
} |
||||||
|
|
||||||
|
const setting = defineComponent({ |
||||||
|
name: 'ui-setting', |
||||||
|
setup() { |
||||||
|
const logTimerStore = useLogTimerStore() |
||||||
|
const defaultLogTimer = logTimerStore.getLogTimer; |
||||||
|
|
||||||
|
const logTimerMap = { |
||||||
|
0: "Off", |
||||||
|
10: '10 Seconds', |
||||||
|
30: '30 Seconds', |
||||||
|
60: '1 Minute', |
||||||
|
300: '5 Minutes', |
||||||
|
1800: '30 Minutes' |
||||||
|
} as any |
||||||
|
|
||||||
|
const logTimerOptions = [ |
||||||
|
{ |
||||||
|
label: "Off", |
||||||
|
value: 0, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: "10 Seconds", |
||||||
|
value: 10, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: "30 Seconds", |
||||||
|
value: 30, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: "1 Minute", |
||||||
|
value: 60, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: "5 Minutes", |
||||||
|
value: 300, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: "30 Minutes", |
||||||
|
value: 1800, |
||||||
|
}, |
||||||
|
] |
||||||
|
return {defaultLogTimer, logTimerMap, logTimerOptions} |
||||||
|
}, |
||||||
|
render() { |
||||||
|
const { t } = useI18n() |
||||||
|
|
||||||
|
return (
|
||||||
|
<> |
||||||
|
<NForm> |
||||||
|
<NFormItem label={t('ui_setting.log.refresh_time')}> |
||||||
|
<NSelect |
||||||
|
default-value={this.logTimerMap[this.defaultLogTimer]} |
||||||
|
options={this.logTimerOptions}
|
||||||
|
onUpdateValue={handleUpdateValue} |
||||||
|
/> |
||||||
|
</NFormItem> |
||||||
|
</NForm> |
||||||
|
</> |
||||||
|
) |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
export default setting |
Loading…
Reference in new issue