21
21
{{ sortOrder === 1 ? "▲" : "▼" }}
22
22
</span >
23
23
</th >
24
- <th >Tags</th >
25
- <th >Info</th >
24
+ <th @click =" setSort('tags')" style =" cursor : pointer " >
25
+ Tags
26
+ <span v-if =" sortKey === 'tags'" >
27
+ {{ sortOrder === 1 ? "▲" : "▼" }}
28
+ </span >
29
+ </th >
30
+ <th @click =" setSort('info')" style =" cursor : pointer " >
31
+ Info
32
+ <span v-if =" sortKey === 'info'" >
33
+ {{ sortOrder === 1 ? "▲" : "▼" }}
34
+ </span >
35
+ </th >
26
36
<th @click =" setSort('address')" style =" cursor : pointer " >
27
37
Device Address
28
38
<span v-if =" sortKey === 'address'" >
116
126
117
127
<script >
118
128
import {
119
- // Importing application-wide functions and reactive variables for stream management.
120
129
searchStreams ,
121
130
streams ,
122
131
streamCount ,
@@ -133,52 +142,48 @@ import { ref, computed } from "vue";
133
142
export default {
134
143
name: " StreamsPage" ,
135
144
setup () {
136
- // Reactive variables for sorting streams.
137
- const sortKey = ref (" name" ); // Default sort by "name"
138
- const sortOrder = ref (1 ); // 1 for ascending order, -1 for descending order
145
+ const sortKey = ref (" name" );
146
+ const sortOrder = ref (1 );
139
147
140
- // Function to toggle or set the sorting key and order.
141
148
function setSort (key ) {
142
149
if (sortKey .value === key) {
143
- // If the same key is clicked again, reverse the sorting order.
144
150
sortOrder .value = - sortOrder .value ;
145
151
} else {
146
- // If a different key is clicked, change sort key and reset order to ascending.
147
152
sortKey .value = key;
148
153
sortOrder .value = 1 ;
149
154
}
150
155
}
151
156
152
- // Helper function to retrieve the value for sorting based on the key.
153
157
function getSortValue (stream , key ) {
154
158
switch (key) {
155
159
case " name" :
156
- // Returns the stream name for sorting.
157
160
return stream .name ;
158
161
case " mcast" :
159
- // Returns the multicast address for sorting.
160
162
return stream .mcast ;
161
163
case " address" :
162
- // Returns the device address from the stream's origin.
163
164
return stream .origin .address ;
164
165
case " format" :
165
- // Returns a formatted string only if the stream is supported.
166
166
return stream .isSupported
167
167
? ` ${ stream .codec } ${ stream .samplerate } Hz ${ stream .channels } `
168
168
: " " ;
169
+ case " info" :
170
+ return stream .media [0 ].description ? stream .media [0 ].description : " " ;
171
+ case " tags" :
172
+ var tags = " " ;
173
+ if (stream .dante ) tags += " Dante " ;
174
+ if (stream .manual ) tags += " Manual " ;
175
+ if (stream .announce ) tags += " SAP " ;
176
+ return tags .trim ();
169
177
default :
170
- // Returns generic property based on the key.
171
178
return stream[key];
172
179
}
173
180
}
174
181
175
- // Computed property that returns a sorted list of streams based on the selected sort key and order.
176
182
const sortedStreams = computed (() => {
177
183
const streamsList = searchStreams ();
178
184
return streamsList .slice ().sort ((a , b ) => {
179
185
let propA = getSortValue (a, sortKey .value );
180
186
let propB = getSortValue (b, sortKey .value );
181
- // For string values, perform case-insensitive comparison.
182
187
if (typeof propA === " string" ) propA = propA .toLowerCase ();
183
188
if (typeof propB === " string" ) propB = propB .toLowerCase ();
184
189
if (propA < propB) return - 1 * sortOrder .value ;
@@ -187,7 +192,6 @@ export default {
187
192
});
188
193
});
189
194
190
- // Expose methods and reactive variables to the template.
191
195
return {
192
196
sortedStreams,
193
197
setSort,
@@ -206,7 +210,6 @@ export default {
206
210
};
207
211
},
208
212
methods: {
209
- // Method to delete a manual stream by sending a message through the electronAPI.
210
213
deleteStream (id ) {
211
214
window .electronAPI .sendMessage ({ type: " delete" , data: id });
212
215
},
0 commit comments