From 73c4003bc6adb0c213f9fa853e96b434014f58da Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Fri, 15 May 2020 23:14:35 +0200
Subject: [PATCH] app: load vendors from vendormodels

This loads the vendor list for the dropdown menu from the vendormodels
structure. This way, only vendors for enabled device categories are
displayed.
---
 app.js | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/app.js b/app.js
index 7c4f3c1..07282ec 100644
--- a/app.js
+++ b/app.js
@@ -725,6 +725,20 @@ var firmwarewizard = function() {
     }
   }
 
+  function getVendors() {
+    var vendorlist = [];
+    for (var device_category_idx in enabled_device_categories) {
+      var device_category = enabled_device_categories[device_category_idx];
+      var category_vendors = Object.keys(config.vendormodels[device_category]);
+      category_vendors.forEach(function (val, idx) {
+        if (!vendorlist.includes(val)) {
+          vendorlist.push(val);
+        }
+      });
+    }
+    return vendorlist;
+  }
+
   // update all elements of the page according to the wizard object.
   function updateHTML(wizard) {
     // parse searchstring to retrieve current vendor and model
@@ -747,7 +761,7 @@ var firmwarewizard = function() {
         createOption('', '-- Bitte Hersteller wählen --')
       );
 
-      var vendors = Object.keys(images).sort(sortCaseInsensitive);
+      var vendors = getVendors().sort(sortCaseInsensitive);
       for (var i in vendors) {
         select.appendChild(
           createOption(atomic(vendors[i]), vendors[i], atomic(currentVendor))
-- 
GitLab