Skip to content

Commit 109c77a

Browse files
fix: Fix issue where saving throws an error after entering a decimal in frequency access limit (#7997)
1 parent fb29917 commit 109c77a

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

frontend/src/directives/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { App, Directive } from 'vue';
2+
import integerInput from './modules/integer';
3+
4+
const directivesList: { [key: string]: Directive } = {
5+
'integer-input': integerInput,
6+
};
7+
8+
const directives = {
9+
install: function (app: App<Element>) {
10+
Object.keys(directivesList).forEach((key) => {
11+
app.directive(key, directivesList[key]);
12+
});
13+
},
14+
};
15+
16+
export default directives;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { Directive, DirectiveBinding } from 'vue';
2+
3+
const integerInput: Directive = {
4+
mounted(el: HTMLElement, binding: DirectiveBinding) {
5+
const { value } = binding;
6+
el.addEventListener('input', (event: Event) => {
7+
const inputElement = event.target as HTMLInputElement;
8+
let inputValue = inputElement.value;
9+
inputValue = inputValue.replace(/\..*/, '');
10+
if (value?.min !== undefined && Number(inputValue) < value.min) {
11+
inputValue = value.min.toString();
12+
}
13+
if (value?.max !== undefined && Number(inputValue) > value.max) {
14+
inputValue = value.max.toString();
15+
}
16+
inputElement.value = inputValue;
17+
const inputEvent = new Event('input', { bubbles: true });
18+
inputElement.dispatchEvent(inputEvent);
19+
});
20+
},
21+
};
22+
23+
export default integerInput;

frontend/src/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import hljsVuePlugin from '@highlightjs/vue-plugin';
2828
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css';
2929
import VirtualScroller from 'vue-virtual-scroller';
3030

31+
import directives from '@/directives/index';
32+
3133
const app = createApp(App);
3234
app.use(hljsVuePlugin);
3335
app.component('SvgIcon', SvgIcon);
@@ -43,4 +45,6 @@ app.use(router);
4345
app.use(i18n);
4446
app.use(pinia);
4547
app.use(Components);
48+
app.use(directives);
49+
4650
app.mount('#app');

frontend/src/views/host/file-management/process/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</div>
2525
<div class="w-full">
2626
<el-progress
27-
v-if="value.total === 0"
27+
v-if="value.total === 0 && value.percent != 100"
2828
:percentage="100"
2929
:indeterminate="true"
3030
:duration="1"

0 commit comments

Comments
 (0)