1
1
<template >
2
2
<el-container >
3
- <el-menu
4
- ref =" menu"
5
- style =" -webkit-user-select :none ; overflow : auto ;"
6
- mode =" vertical"
7
- id =" side-menu"
8
- background-color =" #545c64"
9
- text-color =" #fff"
10
- active-text-color =" #ffd04b"
11
- router >
3
+ <el-menu ref =" menu" style =" -webkit-user-select :none ; overflow : auto ;" mode =" vertical" id =" side-menu"
4
+ background-color =" #545c64" text-color =" #fff" active-text-color =" #ffd04b" router >
12
5
<el-menu-item-group :index =" group" v-for =" (group_modules, group) in matching_modules_grouped" v-bind:key =" group" >
13
- <span class =" menu-title" slot =" title" >{{group}}</span >
14
- <el-menu-item :index =" m.path" v-for =" m in group_modules" v-bind:key =" m.path" :route =" {name: m.path}" >
6
+ <span class =" menu-title" slot =" title" >{{ group }}</span >
7
+ <el-menu-item :index =" m.path" v-for =" m in group_modules" v-bind:key =" m.path" :route =" { name: m.path }" >
15
8
<i v-bind:class =" m.icon" ></i >
16
- <span >{{m.label}}</span >
9
+ <span >{{ m.label }}</span >
17
10
</el-menu-item >
18
11
</el-menu-item-group >
19
12
</el-menu >
20
13
<nav id =" top-bar" class =" navbar navbar-expand-lg navbar-light bg-light" >
21
- <a class =" navbar-brand" href =" #" >{{connection.label}}</a >
22
- <el-form
23
- :disabled =" dids.length === 0" >
24
- <el-select
25
- v-model =" active_did"
26
- no-data-text =" No DIDs found"
27
- filterable placeholder =" Activate DID" >
28
- <el-option
29
- v-for =" did in dids"
30
- :key =" did.did"
31
- :label =" did.did"
32
- :value =" did" >
14
+ <a class =" navbar-brand" href =" #" >{{ connection.label }}</a >
15
+ <el-form :disabled =" dids.length === 0" >
16
+ <el-select v-model =" active_did" no-data-text =" No DIDs found" filterable placeholder =" Activate DID" >
17
+ <el-option v-for =" did in dids" :key =" did.did"
18
+ :label =" did.metadata?.label ? `${did.metadata.label} (${did.did})` : did.did" :value =" did" >
33
19
</el-option >
34
20
</el-select >
35
21
<!--
@@ -65,16 +51,16 @@ import Vue from 'vue';
65
51
import { mapState , mapActions , mapGetters } from " vuex" ;
66
52
import { from_store } from ' ../connection_detail.js' ;
67
53
import message_bus from ' @/message_bus.js' ;
68
- import share , {share_source } from ' @/share.js' ;
69
- import components , {shared } from ' ./components.js' ;
54
+ import share , { share_source } from ' @/share.js' ;
55
+ import components , { shared } from ' ./components.js' ;
70
56
import Taa from ' ./TAA.vue' ;
71
57
72
58
73
59
// handle crashes and kill events
74
- process .on (' uncaughtException' , function (err ) {
60
+ process .on (' uncaughtException' , function (err ) {
75
61
// log the message and stack trace
76
62
let datestring = new Date ().toISOString ();
77
- fs .writeFileSync (' crash.log' , datestring + " \n " + err + " \n " + err .stack + " \n " , {flag: ' a+' });
63
+ fs .writeFileSync (' crash.log' , datestring + " \n " + err + " \n " + err .stack + " \n " , { flag: ' a+' });
78
64
79
65
// do any cleanup like shutting down servers, etc
80
66
@@ -98,50 +84,52 @@ let module_list = Object.entries(components).map(([modulename, module]) => ({
98
84
}));
99
85
100
86
// sort modules by priority, then label
101
- module_list .sort ((a ,b ) => a .priority - b .priority ||
102
- a .label .localeCompare (b .label ));
87
+ module_list .sort ((a , b ) => a .priority - b .priority ||
88
+ a .label .localeCompare (b .label ));
103
89
104
90
export default {
105
91
name: ' agent-base' ,
106
92
mixins: [
107
- message_bus ({ events: {
108
- ' redirect ' : (vm , route ) => {
109
- vm .redirect (route);
110
- },
111
- ' send-message ' : (v , msg , return_route ) => {
112
- v .send_connection_message (msg, return_route);
113
- },
114
- ' toolbox-mediator-change ' : (vm ) => {
115
- let mediator_agent = vm .agent_list .find (a => a .active_as_mediator === true );
116
- if (mediator_agent != null && mediator_agent .active_as_mediator ){
117
- vm .connection .disable_return_route ();
118
- } else {
119
- vm .connection .enable_return_route ();
93
+ message_bus ({
94
+ events: {
95
+ ' redirect ' : (vm , route ) => {
96
+ vm .redirect (route);
97
+ },
98
+ ' send-message ' : (v , msg , return_route ) => {
99
+ v .send_connection_message (msg, return_route);
100
+ },
101
+ ' toolbox-mediator-change ' : (vm ) => {
102
+ let mediator_agent = vm .agent_list .find (a => a .active_as_mediator === true );
103
+ if (mediator_agent != null && mediator_agent .active_as_mediator ) {
104
+ vm .connection .disable_return_route ();
105
+ } else {
106
+ vm .connection .enable_return_route ();
107
+ }
108
+ console .log (" mediator change!" , mediator_agent);
109
+ },
110
+ ' did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/notification/1.0/problem-report' :
111
+ (vm , msg ) => {
112
+ vm .$notify .error ({
113
+ title: ' Small problem...' ,
114
+ message: (text => {
115
+ if (text .length > 30 ) {
116
+ return text .slice (0 , 30 ).trim () + ' ...' ;
117
+ }
118
+ return text;
119
+ })(msg[" explain-ltxt" ] || msg[' description' ][' en' ]),
120
+ onClick : () => vm .redirect (' message-history' ),
121
+ duration: 4000 ,
122
+ customClass: ' problem-report-notification'
123
+ })
124
+ },
125
+ ' did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/coordinate-mediation/1.0/mediate-grant ' : (vm , msg ) => {
126
+ vm .enable_as_mediator (msg);
127
+ },
128
+ ' https://didcomm.org/coordinate-mediation/1.0/mediate-grant ' : (vm , msg ) => {
129
+ vm .enable_as_mediator (msg);
120
130
}
121
- console .log (" mediator change!" , mediator_agent);
122
- },
123
- ' did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/notification/1.0/problem-report' :
124
- (vm , msg ) => {
125
- vm .$notify .error ({
126
- title: ' Small problem...' ,
127
- message: (text => {
128
- if (text .length > 30 ) {
129
- return text .slice (0 , 30 ).trim () + ' ...' ;
130
- }
131
- return text;
132
- })(msg[" explain-ltxt" ] || msg[' description' ][' en' ]),
133
- onClick : () => vm .redirect (' message-history' ),
134
- duration: 4000 ,
135
- customClass: ' problem-report-notification'
136
- })
137
- },
138
- ' did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/coordinate-mediation/1.0/mediate-grant ' : (vm , msg ) => {
139
- vm .enable_as_mediator (msg);
140
- },
141
- ' https://didcomm.org/coordinate-mediation/1.0/mediate-grant ' : (vm , msg ) => {
142
- vm .enable_as_mediator (msg);
143
131
}
144
- }} ),
132
+ }),
145
133
share_source (shared),
146
134
share ({
147
135
use: [' dids' , ' public_did' , ' protocols' ],
@@ -155,35 +143,36 @@ export default {
155
143
})
156
144
],
157
145
props: [' agentid' ],
158
- components: {Taa},
159
- data : function () {
146
+ components: { Taa },
147
+ data : function () {
160
148
return {
161
- ' connection' : {' label' : ' loading...' },
149
+ ' connection' : { ' label' : ' loading...' },
162
150
' modules' : module_list,
163
151
' return_route_poll_timer' : ' ' ,
164
152
}
165
153
},
166
154
computed: {
167
155
... mapState (" Agents" , [" agent_list" ]),
168
156
active_did: {
169
- get () {
170
- return this .public_did || " " ;
157
+ get () {
158
+ const aDid = this .dids .filter (did => did .did === this .public_did )[0 ]
159
+ return (! aDid) ? ' ' : (aDid .metadata ? .label ? ` ${ aDid .metadata .label } (${ aDid .did } )` : this .public_did )
171
160
},
172
- set (did) {
161
+ set (did ) {
173
162
return this .activate_did (did)
174
163
}
175
164
},
176
- matching_modules_grouped : function () {
165
+ matching_modules_grouped: function () {
177
166
// This computed attribute updates when the supported protocol list is updated.
178
167
let pid_list = this .protocols .map (p => p .pid );
179
- let filtered_list = module_list .filter (function (m ){
168
+ let filtered_list = module_list .filter (function (m ) {
180
169
return m .required_protocols .every (req_protocol => pid_list .includes (req_protocol));
181
170
});
182
171
// group modules
183
172
let module_groups = filtered_list .reduce (function (r , m ) {
184
- r[m .group ] = r[m .group ] || [];
185
- r[m .group ].push (m);
186
- return r;
173
+ r[m .group ] = r[m .group ] || [];
174
+ r[m .group ].push (m);
175
+ return r;
187
176
}, Object .create (null ));
188
177
return module_groups;
189
178
}
@@ -192,26 +181,26 @@ export default {
192
181
methods: {
193
182
... mapGetters (" Agents" , [" get_agent" ]),
194
183
... mapActions (" Agents" , [" update_agent" ]),
195
- async send_connection_message (msg ){
184
+ async send_connection_message (msg ) {
196
185
await this .connection_loaded ;
197
186
let sent_message = await this .connection .send_message (msg);
198
187
this .$message_bus .$emit (' sent-message' , sent_message)
199
188
},
200
- get_connection (){
189
+ get_connection () {
201
190
return this .connection ;
202
191
},
203
- async processInbound (msg ){
192
+ async processInbound (msg ) {
204
193
// RFC 0348 Step 1: modify prefix (if present) to old standard
205
194
let OLD = " did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/" ;
206
195
let NEW = " https://didcomm.org/" ;
207
- if (msg[' @type' ].startsWith (NEW )){
196
+ if (msg[' @type' ].startsWith (NEW )) {
208
197
msg[' @type' ] = msg[' @type' ].replace (NEW , OLD );
209
198
}
210
199
// END RFC 0348 Step 1
211
200
this .$message_bus .$emit (' message-received' , msg);
212
201
this .$message_bus .$emit (msg[' @type' ], msg);
213
202
},
214
- return_route_poll (){
203
+ return_route_poll () {
215
204
// This brute forces picking up return route messages
216
205
let msg = {
217
206
" @type" : " did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/trust_ping/1.0/ping" ,
@@ -222,11 +211,11 @@ export default {
222
211
};
223
212
this .send_message (msg);
224
213
},
225
- redirect : function (route ) {
226
- this .$router .push ({name: route});
214
+ redirect : function (route ) {
215
+ this .$router .push ({ name: route });
227
216
this .$refs .menu .updateActiveIndex (route);
228
217
},
229
- enable_as_mediator : function (grant_msg ) {
218
+ enable_as_mediator : function (grant_msg ) {
230
219
let conn = this .get_connection ();
231
220
conn .active_as_mediator = true ;
232
221
conn .mediator_info = {
@@ -242,7 +231,7 @@ export default {
242
231
get_connection: this .get_connection
243
232
}
244
233
},
245
- created : async function () {
234
+ created : async function () {
246
235
let vm = this ; // hold reference
247
236
this .connection_loaded = (async () => {
248
237
let agent_info = await vm .get_agent (vm .agentid )(vm .agentid );
@@ -252,7 +241,7 @@ export default {
252
241
// don't use return route in the agent window if any connection is configured as a mediator connection.
253
242
254
243
let mediator_agent = this .agent_list .find (a => a .active_as_mediator === true );
255
- if (mediator_agent != null && mediator_agent .active_as_mediator ){
244
+ if (mediator_agent != null && mediator_agent .active_as_mediator ) {
256
245
this .connection .disable_return_route ();
257
246
}
258
247
this .fetch_protocols ();
@@ -261,11 +250,11 @@ export default {
261
250
this .fetch_connections ();
262
251
this .$message_bus .$emit (' agent-created' );
263
252
// start poll timer
264
- if (this .connection .needs_return_route_poll ()){
253
+ if (this .connection .needs_return_route_poll ()) {
265
254
this .return_route_poll_timer = setInterval (this .return_route_poll , 10000 );
266
255
}
267
256
},
268
- mounted () {
257
+ mounted () {
269
258
this .$electron .ipcRenderer .on (' inbound_message' , async (event , data ) => {
270
259
console .log (" inbound mediated message" , data);
271
260
this .connection .process_inbound (await this .connection .unpackMessage (data .msg ));
@@ -313,54 +302,55 @@ export default {
313
302
}
314
303
});
315
304
},
316
- beforeDestroy : function () {
317
- if (this .connection .needs_return_route_poll ()) {
305
+ beforeDestroy : function () {
306
+ if (this .connection .needs_return_route_poll ()) {
318
307
clearInterval (this .return_route_poll_timer )
319
308
}
320
309
}
321
310
}
322
311
< / script>
323
312
324
313
< style>
325
- #top-bar {
326
- position :absolute ;
327
- right : 0px ;
328
- left :200px ;
329
- height : 60px ;
330
- }
314
+ #top- bar {
315
+ position: absolute;
316
+ right: 0px ;
317
+ left: 200px ;
318
+ height: 60px ;
319
+ }
331
320
332
- #main-display {
333
- position : absolute ;
334
- right :0px ;
335
- bottom : 0px ;
336
- top : 60px ;
337
- left : 200px ;
338
- }
321
+ #main- display {
322
+ position: absolute;
323
+ right: 0px ;
324
+ bottom: 0px ;
325
+ top: 60px ;
326
+ left: 200px ;
327
+ }
339
328
340
- #side-menu {
341
- height : 100% ;
342
- width : 200px ;
343
- position : absolute ;
329
+ #side- menu {
330
+ height: 100 % ;
331
+ width: 200px ;
332
+ position: absolute;
344
333
345
- }
346
- #side-menu .menu-title {
347
- color : #fff
348
- }
349
- #side-menu i {
350
- color : #409EFF ;
351
- }
334
+ }
352
335
353
- .el- menu-item-group__title {
354
- font-size : 18 px ;
355
- }
336
+ #side - menu . menu - title {
337
+ color : #fff
338
+ }
356
339
357
- .el-menu-item {
358
- height : 36px ;
359
- line-height : 36px ;
360
- }
340
+ #side- menu i {
341
+ color: #409EFF ;
342
+ }
361
343
362
- .problem-report-notification {
363
- cursor : pointer ;
364
- }
344
+ . el - menu - item - group__title {
345
+ font - size : 18px ;
346
+ }
365
347
348
+ .el - menu- item {
349
+ height: 36px ;
350
+ line- height: 36px ;
351
+ }
352
+
353
+ .problem - report- notification {
354
+ cursor: pointer;
355
+ }
366
356
< / style>
0 commit comments