125
125
v-on =" on"
126
126
icon
127
127
>
128
- <v-icon >mdi-bell-cog -outline</v-icon >
128
+ <v-icon >mdi-message-badge -outline</v-icon >
129
129
</v-btn >
130
130
</template >
131
- <span >Enable notifications </span >
131
+ <span >Notifications and logging </span >
132
132
</v-tooltip >
133
133
</div >
134
134
<div v-if =" selectedId !== -1" center-vertical class =" ms-2" >
470
470
471
471
<v-dialog v-model =" notifySettings" max-width =" 70ch" persistent scrollable >
472
472
<v-card >
473
- <v-card-title >Notifications</v-card-title >
473
+ <v-card-title >Notifications and logging </v-card-title >
474
474
<v-card-text class =" d-flex flex-column" >
475
475
<div class =" d-flex align-center" >
476
476
<v-text-field
540
540
</div >
541
541
<div class =" mt-2" >
542
542
<div class =" d-flex justify-space-between align-center" >
543
- <span >Notification conditions:</span >
543
+ <span >Trigger conditions:</span >
544
544
<v-btn-toggle v-model =" notifyJoinType" >
545
545
<v-btn
546
546
v-bind:value =" joinModes.OR"
618
618
</div >
619
619
</v-list >
620
620
</div >
621
+ <div class =" mt-2 d-flex align-center justify-space-between" >
622
+ <v-switch
623
+ v-model =" notifySwitch"
624
+ label =" Enable notifications"
625
+ inset
626
+ />
627
+ <v-switch
628
+ v-model =" fileLoggingSwitch"
629
+ label =" Enable file logging"
630
+ inset
631
+ />
632
+ </div >
633
+ <v-slide-y-transition >
634
+ <div v-if =" fileLoggingSwitch" >
635
+ <v-text-field
636
+ v-model =" messageLogger.logsFolder"
637
+ v-bind:outlined =" outline"
638
+ label =" Logs folder location"
639
+ readonly
640
+ />
641
+ </div >
642
+ </v-slide-y-transition >
621
643
</v-card-text >
622
644
<v-card-actions >
623
- <v-btn v-on:click =" notifyEntries = [] " color =" error" text >
645
+ <v-btn v-on:click =" resetNotifyAndLogging " color =" error" text >
624
646
Reset
625
647
</v-btn >
626
648
<v-spacer />
@@ -769,6 +791,7 @@ import Connection from "../utils/Connection";
769
791
import ConnectionProperties from " ../models/ConnectionProperties" ;
770
792
import SearchEngine from " ../utils/SearchEngine" ;
771
793
import TreeNode from " ../models/TreeNode" ;
794
+ import MessageLogger from " ../utils/MessageLogger" ;
772
795
import { ipcRenderer } from " electron" ;
773
796
774
797
export default {
@@ -794,6 +817,8 @@ export default {
794
817
searchModes: SearchEngine .modes ,
795
818
searchQuery: SearchEngine .QUERY ,
796
819
notifySettings: false ,
820
+ notifySwitch: false ,
821
+ fileLoggingSwitch: false ,
797
822
notifyFilterType: undefined ,
798
823
notifyEntry: undefined ,
799
824
notifyEntries: [],
@@ -802,6 +827,7 @@ export default {
802
827
OR : " or" ,
803
828
AND : " and" ,
804
829
},
830
+ messageLogger: undefined ,
805
831
}),
806
832
807
833
computed: {
@@ -839,6 +865,15 @@ export default {
839
865
},
840
866
},
841
867
868
+ watch: {
869
+ fileLoggingSwitch (newValue , oldValue ) {
870
+ if (oldValue === newValue) return ;
871
+
872
+ if (newValue) this .messageLogger ? .startLogging ();
873
+ else this .messageLogger ? .stopLogging ();
874
+ },
875
+ },
876
+
842
877
beforeMount () {
843
878
this .connectionProperties .init (
844
879
this .$store .getters .getConnectionByIndex (this .$route .params .index )
@@ -850,6 +885,8 @@ export default {
850
885
() => this .treeData .length
851
886
);
852
887
888
+ this .messageLogger = new MessageLogger (this .connectionProperties .name );
889
+
853
890
ipcRenderer .send (" enterViewerPage" );
854
891
ipcRenderer .on (" searchPressed" , this .toggleSearchField );
855
892
},
@@ -863,6 +900,7 @@ export default {
863
900
},
864
901
865
902
beforeDestroy () {
903
+ this .messageLogger ? .stopLogging ();
866
904
ipcRenderer .removeListener (" searchPressed" , this .toggleSearchField );
867
905
},
868
906
@@ -965,7 +1003,7 @@ export default {
965
1003
}
966
1004
967
1005
if (! toDelete) {
968
- this .notify (node);
1006
+ this .notifyAndWrite (node);
969
1007
}
970
1008
971
1009
return toDelete;
@@ -999,10 +1037,15 @@ export default {
999
1037
return " mdi-equal" ;
1000
1038
}
1001
1039
},
1040
+ resetNotifyAndLogging () {
1041
+ this .notifySwitch = false ;
1042
+ this .fileLoggingSwitch = false ;
1043
+ this .notifyEntries = [];
1044
+ },
1002
1045
deleteNotifyEntry (entry ) {
1003
1046
this .notifyEntries = this .notifyEntries .filter ((item ) => item !== entry);
1004
1047
},
1005
- notify (node ) {
1048
+ notifyAndWrite (node ) {
1006
1049
let foundNodes = this .notifyEntries .flatMap ((entry ) => {
1007
1050
return node .deepSearch (entry .notifyEntry , entry .filterType );
1008
1051
});
@@ -1022,15 +1065,24 @@ export default {
1022
1065
1023
1066
foundNodes .forEach ((foundNode ) => {
1024
1067
if (! foundNode? .value ) return ;
1025
- this .sendNotification (
1026
- foundNode .value .topic ,
1027
- foundNode .value .payload ,
1028
- () => {
1029
- // Open the app if closed/minimized and select the topic
1030
- this .getProperties (foundNode);
1031
- ipcRenderer .send (" focusWindow" );
1032
- }
1033
- );
1068
+
1069
+ if (this .fileLoggingSwitch ) {
1070
+ // Write entry to file
1071
+ this .messageLogger .enqueue (foundNode .value );
1072
+ }
1073
+
1074
+ if (this .notifySwitch ) {
1075
+ // Send a system notification
1076
+ this .sendNotification (
1077
+ foundNode .value .topic ,
1078
+ foundNode .value .payload ,
1079
+ () => {
1080
+ // Open the app if closed/minimized and select the topic
1081
+ this .getProperties (foundNode);
1082
+ ipcRenderer .send (" focusWindow" );
1083
+ }
1084
+ );
1085
+ }
1034
1086
});
1035
1087
},
1036
1088
publishItem () {
0 commit comments