]>
Commit | Line | Data |
---|---|---|
14247821 FE |
1 | Ext.define('Proxmox.widget.NodeInfoRepoStatus', { |
2 | extend: 'Proxmox.widget.Info', | |
3 | alias: 'widget.pmxNodeInfoRepoStatus', | |
4 | ||
5 | title: gettext('Repository Status'), | |
6 | ||
7 | colspan: 2, | |
8 | ||
9 | printBar: false, | |
10 | ||
11 | product: undefined, | |
12 | repoLink: undefined, | |
13 | ||
14 | viewModel: { | |
15 | data: { | |
16 | subscriptionActive: '', | |
17 | noSubscriptionRepo: '', | |
18 | enterpriseRepo: '', | |
19 | testRepo: '', | |
20 | }, | |
21 | ||
22 | formulas: { | |
23 | repoStatus: function(get) { | |
24 | if (get('subscriptionActive') === '' || get('enterpriseRepo') === '') { | |
25 | return ''; | |
26 | } | |
27 | ||
28 | if (get('noSubscriptionRepo') || get('testRepo')) { | |
29 | return 'non-production'; | |
30 | } else if (get('subscriptionActive') && get('enterpriseRepo')) { | |
31 | return 'ok'; | |
32 | } else if (!get('subscriptionActive') && get('enterpriseRepo')) { | |
33 | return 'no-sub'; | |
34 | } else if (!get('enterpriseRepo') || !get('noSubscriptionRepo') || !get('testRepo')) { | |
35 | return 'no-repo'; | |
36 | } | |
37 | return 'unknown'; | |
38 | }, | |
39 | ||
40 | repoStatusMessage: function(get) { | |
41 | let me = this; | |
42 | let view = me.getView(); | |
43 | ||
44 | const status = get('repoStatus'); | |
45 | ||
46 | let repoLink = ` <a data-qtip="${gettext("Open Repositories Panel")}" | |
47 | href="${view.repoLink}"> | |
48 | <i class="fa black fa-chevron-right txt-shadow-hover"></i> | |
49 | </a>`; | |
50 | ||
51 | return Proxmox.Utils.formatNodeRepoStatus(status, view.product) + repoLink; | |
52 | }, | |
53 | }, | |
54 | }, | |
55 | ||
56 | setValue: function(value) { // for binding below | |
57 | this.updateValue(value); | |
58 | }, | |
59 | ||
60 | bind: { | |
61 | value: '{repoStatusMessage}', | |
62 | }, | |
63 | ||
64 | setRepositoryInfo: function(standardRepos) { | |
65 | let me = this; | |
66 | let vm = me.getViewModel(); | |
67 | ||
68 | for (const standardRepo of standardRepos) { | |
69 | const handle = standardRepo.handle; | |
70 | const status = standardRepo.status || 0; | |
71 | ||
72 | if (handle === "enterprise") { | |
73 | vm.set('enterpriseRepo', status); | |
74 | } else if (handle === "no-subscription") { | |
75 | vm.set('noSubscriptionRepo', status); | |
76 | } else if (handle === "test") { | |
77 | vm.set('testRepo', status); | |
78 | } | |
79 | } | |
80 | }, | |
81 | ||
82 | setSubscriptionStatus: function(status) { | |
83 | let me = this; | |
84 | let vm = me.getViewModel(); | |
85 | ||
86 | vm.set('subscriptionActive', status); | |
87 | }, | |
88 | ||
89 | initComponent: function() { | |
90 | let me = this; | |
91 | ||
92 | if (me.product === undefined) { | |
93 | throw "no product name provided"; | |
94 | } | |
95 | ||
96 | if (me.repoLink === undefined) { | |
97 | throw "no repo link href provided"; | |
98 | } | |
99 | ||
100 | me.callParent(); | |
101 | }, | |
102 | }); |