]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
add NodeInfoRepoStatus
authorFabian Ebner <f.ebner@proxmox.com>
Thu, 22 Jul 2021 13:27:34 +0000 (15:27 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 27 Jul 2021 14:34:12 +0000 (16:34 +0200)
adapted from PMG, because it has an additional fix to avoid setting
undefined in the view model, which still affects PBS (see pmg-gui
commit 774418f08b10c651357d11ccb161ac075e1ae905).

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
src/Makefile
src/panel/NodeInfoRepoStatus.js [new file with mode: 0644]

index 36f316c66d4dc67a10519aa37ee8c3cc99bfafc3..a490ccd7ef47510910f160daea58dc94c410a9d5 100644 (file)
@@ -51,6 +51,7 @@ JSSRC=                                        \
        panel/InputPanel.js             \
        panel/InfoWidget.js             \
        panel/LogView.js                \
+       panel/NodeInfoRepoStatus.js     \
        panel/JournalView.js            \
        panel/PermissionView.js         \
        panel/PruneKeepPanel.js         \
diff --git a/src/panel/NodeInfoRepoStatus.js b/src/panel/NodeInfoRepoStatus.js
new file mode 100644 (file)
index 0000000..df1ca9f
--- /dev/null
@@ -0,0 +1,102 @@
+Ext.define('Proxmox.widget.NodeInfoRepoStatus', {
+    extend: 'Proxmox.widget.Info',
+    alias: 'widget.pmxNodeInfoRepoStatus',
+
+    title: gettext('Repository Status'),
+
+    colspan: 2,
+
+    printBar: false,
+
+    product: undefined,
+    repoLink: undefined,
+
+    viewModel: {
+       data: {
+           subscriptionActive: '',
+           noSubscriptionRepo: '',
+           enterpriseRepo: '',
+           testRepo: '',
+       },
+
+       formulas: {
+           repoStatus: function(get) {
+               if (get('subscriptionActive') === '' || get('enterpriseRepo') === '') {
+                   return '';
+               }
+
+               if (get('noSubscriptionRepo') || get('testRepo')) {
+                   return 'non-production';
+               } else if (get('subscriptionActive') && get('enterpriseRepo')) {
+                   return 'ok';
+               } else if (!get('subscriptionActive') && get('enterpriseRepo')) {
+                   return 'no-sub';
+               } else if (!get('enterpriseRepo') || !get('noSubscriptionRepo') || !get('testRepo')) {
+                   return 'no-repo';
+               }
+               return 'unknown';
+           },
+
+           repoStatusMessage: function(get) {
+               let me = this;
+               let view = me.getView();
+
+               const status = get('repoStatus');
+
+               let repoLink = ` <a data-qtip="${gettext("Open Repositories Panel")}"
+                   href="${view.repoLink}">
+                   <i class="fa black fa-chevron-right txt-shadow-hover"></i>
+                   </a>`;
+
+               return Proxmox.Utils.formatNodeRepoStatus(status, view.product) + repoLink;
+           },
+       },
+    },
+
+    setValue: function(value) { // for binding below
+       this.updateValue(value);
+    },
+
+    bind: {
+       value: '{repoStatusMessage}',
+    },
+
+    setRepositoryInfo: function(standardRepos) {
+       let me = this;
+       let vm = me.getViewModel();
+
+       for (const standardRepo of standardRepos) {
+           const handle = standardRepo.handle;
+           const status = standardRepo.status || 0;
+
+           if (handle === "enterprise") {
+               vm.set('enterpriseRepo', status);
+           } else if (handle === "no-subscription") {
+               vm.set('noSubscriptionRepo', status);
+           } else if (handle === "test") {
+               vm.set('testRepo', status);
+           }
+       }
+    },
+
+    setSubscriptionStatus: function(status) {
+       let me = this;
+       let vm = me.getViewModel();
+
+       vm.set('subscriptionActive', status);
+    },
+
+    initComponent: function() {
+       let me = this;
+
+       if (me.product === undefined) {
+           throw "no product name provided";
+       }
+
+       if (me.repoLink === undefined) {
+           throw "no repo link href provided";
+       }
+
+       me.callParent();
+    },
+});