11<template >
22 <div
3- class =" w-full h-full col-start-1 col-span-full row-start-1 row-span-full bg-[#1b1b1d] rounded-md grid grid-cols-12 grid-rows-12 p-2 space-y-2"
3+ class =" w-full h-full col-start-1 col-span-full row-start-1 row-span-full bg-[#1b1b1d] rounded-md grid grid-cols-12 grid-rows-12 p-2 space-y-2 divide-y divide-gray-500 "
44 >
5- <div class =" col-start-1 col-span-full row-start-1 row-span-2 border-b border-gray-700 p-1 grid grid-cols-12 grid-rows-2" >
5+ <div class =" col-start-1 col-span-full row-start-1 row-span-2 p-1 grid grid-cols-12 grid-rows-2" >
66 <div class =" col-start-1 col-span-full row-start-1 row-span-1 text-xs font-bold uppercase text-[#336666]" >
77 {{ t("serverSetting.nodeServerTtl") }}
88 </div >
2727 </label >
2828 </div >
2929 </div >
30- <div
31- v-if =" isAutoUpdateEnabled"
32- class =" col-start-1 col-span-full row-start-3 row-span-8 border-b border-gray-700 p-1 grid grid-cols-12 grid-rows-7 gap-y-3"
33- >
34- <div class =" col-start-1 col-span-full row-start-1 row-span-1 text-xs font-bold uppercase text-[#336666]" >
30+ <div v-if =" isAutoUpdateEnabled" class =" col-start-1 col-span-full row-start-3 row-span-8 p-1 grid grid-cols-12 grid-rows-7 gap-y-3" >
31+ <div class =" col-start-1 col-span-10 row-start-1 row-span-1 text-xs font-bold uppercase text-[#336666]" >
3532 Set your update time and date
3633 </div >
34+ <div
35+ class =" col-start-12 col-span-1 row-start-1 row-span-1 flex items-center justify-center p-1 w-8 h-full bg-black rounded-md cursor-pointer hover:scale-110 active:scale-95 transition-all duration-300 ease-in-out"
36+ @click =" activeEdit"
37+ >
38+ <img src =" /img/icon/service-setting-icons/edit.png" alt =" Edit" class =" w-6 h-6" />
39+ </div >
3740
3841 <div v-if =" inputMsg" class =" col-start-1 col-span-full row-start-2 row-span-1 text-xs text-red-500 bg-[#2a2a2c] p-2 rounded-md" >
3942 {{ inputMsg }}
4851 min =" 1"
4952 max =" 100"
5053 class =" w-full h-7 bg-[#2a2a2c] text-white border border-gray-700 rounded-md p-2 text-sm focus:border-[#336666] focus:outline-none transition-colors"
54+ :class =" !isEditActive ? 'cursor-not-allowed opacity-50' : ''"
55+ :disabled =" !isEditActive"
5156 placeholder =" 1-100"
5257 />
5358 </div >
6368 max =" 23"
6469 class =" w-full h-7 bg-[#2a2a2c] text-white border border-gray-700 rounded-md p-2 text-sm focus:border-[#336666] focus:outline-none transition-colors"
6570 placeholder =" 0-23"
71+ :class =" !isEditActive ? 'cursor-not-allowed opacity-50' : ''"
72+ :disabled =" !isEditActive"
6673 />
6774 </div >
6875 </div >
7784 max =" 59"
7885 class =" w-full h-7 bg-[#2a2a2c] text-white border border-gray-700 rounded-md p-2 text-sm focus:border-[#336666] focus:outline-none transition-colors"
7986 placeholder =" 0-59"
87+ :class =" !isEditActive ? 'cursor-not-allowed opacity-50' : ''"
88+ :disabled =" !isEditActive"
8089 />
8190 </div >
8291 </div >
8392
8493 <button
8594 @click =" confirmChanges"
8695 class =" col-start-1 col-span-full row-start-7 row-span-1 bg-gradient-to-r from-[#336666] to-[#4a8080] hover:from-[#4a8080] hover:to-[#336666] text-xs uppercase text-white font-medium py-1 px-4 rounded-md transition-all duration-300 ease-in-out transform hover:scale-[1.02] active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed"
87- :disabled =" !areInputsValid"
96+ :class =" !isEditActive ? 'cursor-not-allowed opacity-50 pointer-events-none' : ''"
97+ :disabled =" !areInputsValid || !isEditActive"
8898 >
8999 Confirm
90100 </button >
@@ -108,6 +118,7 @@ const hourInput = ref(3);
108118const minuteInput = ref (0 );
109119const isChangesConfirmed = ref (false );
110120const inputMsg = ref (" " );
121+ const isEditActive = ref (false );
111122
112123const areInputsValid = computed (() => {
113124 if (intervalDayInput .value === null || hourInput .value === null || minuteInput .value === null ) {
@@ -125,6 +136,10 @@ const onOff = computed(() => {
125136 return isAutoUpdateEnabled .value ? " absolute left-3" : " absolute right-3" ;
126137});
127138
139+ const activeEdit = () => {
140+ isEditActive .value = ! isEditActive .value ;
141+ };
142+
128143const turnOnOff = () => {
129144 isAutoUpdateEnabled .value = ! isAutoUpdateEnabled .value ;
130145 if (! isAutoUpdateEnabled .value ) {
@@ -133,7 +148,7 @@ const turnOnOff = () => {
133148 }
134149};
135150
136- const confirmChanges = () => {
151+ const confirmChanges = async () => {
137152 if (! areInputsValid .value ) {
138153 if (intervalDayInput .value < 1 || intervalDayInput .value > 100 ) {
139154 inputMsg .value = " Days must be between 1 and 100" ;
@@ -152,16 +167,18 @@ const confirmChanges = () => {
152167
153168 inputMsg .value = " " ;
154169 isChangesConfirmed .value = true ;
170+ isEditActive .value = false ;
155171 footerStore .cursorLocation = t (" serverSetting.confirmed" );
156172 setTimeout (() => {
157173 footerStore .cursorLocation = " " ;
158174 }, 2000 );
175+ await updateSettings ();
176+ updateConfigFile ();
159177};
160178
161179const updateSettings = async () => {
162180 let settings = await ControlService .getStereumSettings ();
163181 const unattended = settings .stereum .settings .updates .unattended ;
164-
165182 unattended .install = isAutoUpdateEnabled .value ;
166183
167184 if (isAutoUpdateEnabled .value && isChangesConfirmed .value ) {
@@ -179,20 +196,11 @@ const updateConfigFile = async () => {
179196 config .autoUpdate = isAutoUpdateEnabled .value ;
180197 await ControlService .writeConfig (config);
181198 const test = await ControlService .readConfig ();
182- console .log (" test" , test);
183- console .log (" Config file updated successfully" );
184199 } catch (error) {
185200 console .error (" Error updating config file:" , error);
186201 }
187202};
188203
189- watch (isChangesConfirmed, (newVal ) => {
190- if (newVal) {
191- updateSettings ();
192- updateConfigFile ();
193- }
194- });
195-
196204const getSettings = async () => {
197205 let settings = await ControlService .getStereumSettings ();
198206 if (settings .stereum ? .settings .updates .unattended .install ) {
0 commit comments