File tree Expand file tree Collapse file tree 7 files changed +54
-13
lines changed Expand file tree Collapse file tree 7 files changed +54
-13
lines changed Original file line number Diff line number Diff line change @@ -313,6 +313,7 @@ const internalCertificate = {
313
313
. where ( 'is_deleted' , 0 )
314
314
. andWhere ( 'id' , data . id )
315
315
. allowGraph ( '[owner]' )
316
+ . allowGraph ( '[proxy_hosts]' )
316
317
. first ( ) ;
317
318
318
319
if ( access_data . permission_visibility !== 'all' ) {
@@ -464,6 +465,7 @@ const internalCertificate = {
464
465
. where ( 'is_deleted' , 0 )
465
466
. groupBy ( 'id' )
466
467
. allowGraph ( '[owner]' )
468
+ . allowGraph ( '[proxy_hosts]' )
467
469
. orderBy ( 'nice_name' , 'ASC' ) ;
468
470
469
471
if ( access_data . permission_visibility !== 'all' ) {
Original file line number Diff line number Diff line change 4
4
const db = require ( '../db' ) ;
5
5
const helpers = require ( '../lib/helpers' ) ;
6
6
const Model = require ( 'objection' ) . Model ;
7
- const User = require ( './user' ) ;
8
7
const now = require ( './now_helper' ) ;
9
8
10
9
Model . knex ( db ) ;
@@ -68,6 +67,8 @@ class Certificate extends Model {
68
67
}
69
68
70
69
static get relationMappings ( ) {
70
+ const ProxyHost = require ( './proxy_host' ) ;
71
+ const User = require ( './user' ) ;
71
72
return {
72
73
owner : {
73
74
relation : Model . HasOneRelation ,
@@ -79,6 +80,17 @@ class Certificate extends Model {
79
80
modify : function ( qb ) {
80
81
qb . where ( 'user.is_deleted' , 0 ) ;
81
82
}
83
+ } ,
84
+ proxy_hosts : {
85
+ relation : Model . HasManyRelation ,
86
+ modelClass : ProxyHost ,
87
+ join : {
88
+ from : 'certificate.id' ,
89
+ to : 'proxy_host.certificate_id'
90
+ } ,
91
+ modify : function ( qb ) {
92
+ qb . where ( 'proxy_host.is_deleted' , 0 ) ;
93
+ }
82
94
}
83
95
} ;
84
96
}
Original file line number Diff line number Diff line change 33
33
<td class =" <%- isExpired() ? 'text-danger' : '' %>" >
34
34
<% - formatDbDate (expires_on, ' Do MMMM YYYY, h:mm a' ) %>
35
35
</td >
36
+ <td >
37
+ <% if (proxy_hosts .length > 0 ) { % >
38
+ < span class = " status-icon bg-success" >< / span> < %- i18n (' certificates' , ' in-use' ) % >
39
+ < % } else { % >
40
+ < span class = " status-icon bg-danger" >< / span> < %- i18n (' certificates' , ' inactive' ) % >
41
+ < % } %>
42
+ </td >
36
43
<% if (canManage) { % >
37
44
< td class = " text-right" >
38
45
< div class = " item-action dropdown" >
48
55
< div class = " dropdown-divider" >< / div>
49
56
< % } % >
50
57
< a href= " #" class = " delete dropdown-item" >< i class = " dropdown-icon fe fe-trash-2" >< / i> < %- i18n (' str' , ' delete' ) % >< / a>
58
+ < % if (proxy_hosts .length > 0 ) { % >
59
+ < div class = " dropdown-divider" >< / div>
60
+ < span class = " dropdown-header" >< %- i18n (' certificates' , ' active-domain_names' ) % >< / span>
61
+ < % proxy_hosts .forEach (function (host ) { % >
62
+ < a href= " https://<%- host %>" class = " dropdown-item" target= " _blank" >< %- host % >< / a>
63
+ < % }); % >
64
+ < % } % >
51
65
< / div>
52
66
< / div>
53
67
< / td>
Original file line number Diff line number Diff line change @@ -44,12 +44,23 @@ module.exports = Mn.View.extend({
44
44
} ,
45
45
} ,
46
46
47
- templateContext : {
48
- canManage : App . Cache . User . canManage ( 'certificates' ) ,
49
- isExpired : function ( ) {
50
- return moment ( this . expires_on ) . isBefore ( moment ( ) ) ;
51
- } ,
52
- dns_providers : dns_providers
47
+ templateContext : function ( ) {
48
+ return {
49
+ canManage : App . Cache . User . canManage ( 'certificates' ) ,
50
+ isExpired : function ( ) {
51
+ return moment ( this . expires_on ) . isBefore ( moment ( ) ) ;
52
+ } ,
53
+ dns_providers : dns_providers ,
54
+ proxy_hosts : this . getProxyHosts ( )
55
+ } ;
56
+ } ,
57
+
58
+ getProxyHosts : function ( ) {
59
+ const hosts = this . model . attributes . proxy_hosts || [ ] ;
60
+ return hosts . reduce ( ( acc , host ) => {
61
+ acc . push ( ...( host . domain_names || [ ] ) ) ;
62
+ return acc ;
63
+ } , [ ] ) ;
53
64
} ,
54
65
55
66
initialize : function ( ) {
Original file line number Diff line number Diff line change 2
2
<th width =" 30" >  ; </th >
3
3
<th ><% - i18n (' str' , ' name' ) %> </th >
4
4
<th ><% - i18n (' all-hosts' , ' cert-provider' ) %> </th >
5
- <th ><% - i18n (' str' , ' active-hosts' ) %> </th >
6
5
<th ><% - i18n (' str' , ' expires' ) %> </th >
6
+ <th ><% - i18n (' str' , ' status' ) %> </th >
7
7
<% if (canManage) { % >
8
8
< th> & nbsp;< / th>
9
9
< % } %>
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ module.exports = Mn.View.extend({
74
74
e . preventDefault ( ) ;
75
75
let query = this . ui . query . val ( ) ;
76
76
77
- this . fetch ( [ 'owner' ] , query )
77
+ this . fetch ( [ 'owner' , 'proxy_hosts' ] , query )
78
78
. then ( response => this . showData ( response ) )
79
79
. catch ( err => {
80
80
this . showError ( err ) ;
@@ -89,7 +89,7 @@ module.exports = Mn.View.extend({
89
89
onRender : function ( ) {
90
90
let view = this ;
91
91
92
- view . fetch ( [ 'owner' ] )
92
+ view . fetch ( [ 'owner' , 'proxy_hosts' ] )
93
93
. then ( response => {
94
94
if ( ! view . isDestroyed ( ) ) {
95
95
if ( response && response . length ) {
Original file line number Diff line number Diff line change 35
35
"value" : " Value" ,
36
36
"please-wait" : " Please wait..." ,
37
37
"all" : " All" ,
38
- "any" : " Any" ,
39
- "active-hosts" : " Active Hosts"
38
+ "any" : " Any"
40
39
},
41
40
"login" : {
42
41
"title" : " Login to your account"
207
206
"reachability-other" : " There is a server found at this domain but it returned an unexpected status code {code}. Is it the NPM server? Please make sure your domain points to the IP where your NPM instance is running." ,
208
207
"download" : " Download" ,
209
208
"renew-title" : " Renew Let's Encrypt Certificate" ,
210
- "search" : " Search Certificate…"
209
+ "search" : " Search Certificate…" ,
210
+ "in-use" : " In use" ,
211
+ "inactive" : " Inactive" ,
212
+ "active-domain_names" : " Active domain names"
211
213
},
212
214
"access-lists" : {
213
215
"title" : " Access Lists" ,
You can’t perform that action at this time.
0 commit comments