From ae9032dce3c20f2a62f007e9b83b1eda45523192 Mon Sep 17 00:00:00 2001 From: Sebastian Held Date: Sun, 9 Aug 2020 15:30:46 +0200 Subject: [PATCH 01/10] use Octopart v4 API --- app/config/parameters.php.dist | 9 +- .../js/Components/OctoPart/DataApplicator.js | 206 +++++++++--------- .../js/Components/OctoPart/SearchPanel.js | 10 +- .../Controller/DefaultController.php | 20 +- .../Services/OctoPartService.php | 178 +++++++++++++-- 5 files changed, 286 insertions(+), 137 deletions(-) diff --git a/app/config/parameters.php.dist b/app/config/parameters.php.dist index 163f35dd9..90cdc8820 100644 --- a/app/config/parameters.php.dist +++ b/app/config/parameters.php.dist @@ -259,11 +259,16 @@ $container->setParameter('partkeepr.filesystem.data_directory', '%kernel.root_di $container->setParameter('partkeepr.cronjob.check', true); /** - * Specifies which API key PartKeepr should use to talk to OctoPart. You can get an API key by registering at - * https://octopart.com/api/home and then registering an application. + * Specifies which v4 API key PartKeepr should use to talk to OctoPart. You can get an API key by registering at + * https://octopart.com/api and then registering an application. */ $container->setParameter('partkeepr.octopart.apikey', ''); +/** + * The number of returned parts from API calls is limited. Try to keep this value low + */ +$container->setParameter('partkeepr.octopart.limit', '3'); + /** * Specifies which URL contains the patreon status. If you do not wish to display the patreon status, * set this parameter to false. Please note that we rely on your Patreon pledges to ensure further diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js index fbb01f43e..e74f50cbc 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js @@ -8,6 +8,7 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { { this.setImport("parameters", true); this.setImport("distributors", true); + this.setImport("bestDatasheet", true); this.setImport("datasheets", true); this.setImport("cadModels", true); this.setImport("complianceDocuments", true); @@ -74,18 +75,20 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { if (this.import.parameters) { - for (i in this.data.specs) + for (i in this.data["specs"]) { - if (this.data.specs[i].metadata.unit !== null) + var q_value, q_unit; + [q_value,q_unit] = this.parseQuantity( this.data.specs[i].display_value ); + if (q_unit) { unit = PartKeepr.getApplication().getUnitStore().findRecord("symbol", - this.data.specs[i].metadata.unit.symbol, 0, false, true, true); + q_unit, 0, false, true, true); if (unit === null) { - this.displayWaitWindow(i18n("Creating Unit…"), this.data.specs[i].metadata.unit.name); + this.displayWaitWindow(i18n("Creating Unit…"), q_unit); unit = Ext.create("PartKeepr.UnitBundle.Entity.Unit"); - unit.set("name", this.data.specs[i].metadata.unit.name); - unit.set("symbol", this.data.specs[i].metadata.unit.symbol); + unit.set("name", q_unit); // v4 API does not have that anymore + unit.set("symbol", q_unit); unit.save({ success: function () { @@ -105,17 +108,17 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { if (this.import.distributors) { - for (i in this.data.offers) + for (i in this.data['sellers']) { distributor = PartKeepr.getApplication().getDistributorStore().findRecord("name", - this.data.offers[i].seller.name, 0, false, true, true); + this.data.sellers[i].company.name, 0, false, true, true); if (distributor === null) { - this.displayWaitWindow(i18n("Creating Distributor…"), this.data.offers[i].seller.name); + this.displayWaitWindow(i18n("Creating Distributor…"), this.data.sellers[i].company.name); distributor = Ext.create("PartKeepr.DistributorBundle.Entity.Distributor"); - distributor.set("name", this.data.offers[i].seller.name); - distributor.set("website", this.data.offers[i].seller.homepage_url); + distributor.set("name", this.data.sellers[i].company.name); + distributor.set("url", this.data.sellers[i].company.homepage_url); distributor.save({ success: function () { @@ -132,11 +135,12 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { } } - if (this.import.datasheets) + if (this.import.bestDatasheet) { - if (this.data.datasheets.length > 0) + if (this.data['best_datasheet']) { - file = this.data.datasheets.shift(); + file = this.data.best_datasheet; + delete this.data.best_datasheet; this.displayWaitWindow(i18n("Uploading datasheet…"), file.url); if (!this.checkIfAttachmentFilenameExists(file.url)) @@ -152,15 +156,36 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { } } - if (this.import.cadModels) +/* if (this.import.datasheets) { - if (this.data.cad_models.length > 0) + if (this.data.document_collections.length > 0) { - file = this.data.cad_models.shift(); - this.displayWaitWindow(i18n("Uploading CAD Model…"), file.url); + file = this.data.datasheets.shift(); + this.displayWaitWindow(i18n("Uploading datasheet…"), file.url); + if (!this.checkIfAttachmentFilenameExists(file.url)) { - PartKeepr.getApplication().uploadFileFromURL(file.url, i18n("CAD Model"), this.onFileUploaded, + PartKeepr.getApplication().uploadFileFromURL(file.url, i18n("Datasheet"), this.onFileUploaded, + this); + } else + { + this.applyData(); + } + + return false; + } + }*/ + + if (this.import.cadModels) + { + if (this.data['cad']) + { + file = this.data.cad; + delete this.data.cad; + this.displayWaitWindow(i18n("Uploading CAD Model…"), file.add_to_library_url); + if (!this.checkIfAttachmentFilenameExists(file.add_to_library_url)) + { + PartKeepr.getApplication().uploadFileFromURL(file.add_to_library_url, i18n("CAD Model"), this.onFileUploaded, this); } else { @@ -170,7 +195,7 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { } } - if (this.import.complianceDocuments) +/* if (this.import.complianceDocuments) { if (this.data.compliance_documents.length > 0) { @@ -187,7 +212,7 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { } return false; } - } + }*/ if (this.import.referenceDesigns) { @@ -210,42 +235,19 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { if (this.import.images) { - if (this.data.imagesets.length > 0) + if (this.data['best_image']) { - file = this.data.imagesets.shift(); - image = null; - - if (file.swatch_image !== null) - { - image = file.swatch_image; - } - - if (file.small_image !== null) - { - image = file.small_image; - } - - if (file.medium_image !== null) - { - image = file.medium_image; - } + image = this.data.best_image; + delete this.data.best_image; - if (file.large_image !== null) + this.displayWaitWindow(i18n("Uploading Image…"), image.url); + if (!this.checkIfAttachmentFilenameExists(image.url)) { - image = file.large_image; - } - - if (image !== null) + PartKeepr.getApplication().uploadFileFromURL(image.url, i18n("Image"), this.onFileUploaded, + this); + } else { - this.displayWaitWindow(i18n("Uploading Image…"), image.url); - if (!this.checkIfAttachmentFilenameExists(image.url)) - { - PartKeepr.getApplication().uploadFileFromURL(image.url, i18n("Image"), this.onFileUploaded, - this); - } else - { - this.applyData(); - } + this.applyData(); } return false; @@ -346,26 +348,26 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { if (this.import.distributors) { - for (i = 0; i < this.data.offers.length; i++) + for (i in this.data['sellers']) { distributor = PartKeepr.getApplication().getDistributorStore().findRecord("name", - this.data.offers[i].seller.name, 0, false, true, true); + this.data.sellers[i].company.name, 0, false, true, true); if (distributor === null) { // @todo put out error message continue; } - for (currency in this.data.offers[i].prices) + for (o in this.data.sellers[i]['offers']) { - for (j = 0; j < this.data.offers[i].prices[currency].length; j++) + for (p in this.data.sellers[i].offers[o].prices) { partDistributor = Ext.create("PartKeepr.PartBundle.Entity.PartDistributor"); partDistributor.setDistributor(distributor); - partDistributor.set("sku", this.data.offers[i].sku); - partDistributor.set("packagingUnit", this.data.offers[i].prices[currency][j][0]); - partDistributor.set("currency", currency); - partDistributor.set("price", this.data.offers[i].prices[currency][j][1]); + partDistributor.set("sku", this.data.sellers[i].offers[o].sku); + partDistributor.set("packagingUnit", this.data.sellers[i].offers[o].prices[p].quantity); + partDistributor.set("currency", this.data.sellers[i].offers[o].prices[p].currency); + partDistributor.set("price", this.data.sellers[i].offers[o].prices[p].price); found = null; @@ -382,7 +384,7 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { if (found !== null) { - found.set("price", this.data.offers[i].prices[currency][j][1]); + found.set("price", this.data.sellers[i].offers[o].prices[p].price); } else { this.part.distributors().add(partDistributor); @@ -394,54 +396,33 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { if (this.import.parameters) { - for (i in this.data.specs) + for (i in this.data["specs"]) { spec = Ext.create("PartKeepr.PartBundle.Entity.PartParameter"); - spec.set("name", this.data.specs[i].metadata.name); + spec.set("name", this.data.specs[i].attribute.name); + + var q_value, q_unit; + [q_value,q_unit] = this.parseQuantity( this.data.specs[i].display_value ); - if (this.data.specs[i].metadata.unit !== null) + if (q_value != null && q_unit != null) { unit = PartKeepr.getApplication().getUnitStore().findRecord("symbol", - this.data.specs[i].metadata.unit.symbol, 0, false, true, true); + q_unit, 0, false, true, true); spec.setUnit(unit); + spec.set("valueType", "numeric"); + siPrefix = this.findSiPrefixForValueAndUnit(q_value, unit); + spec.set("value", this.applySiPrefix(q_value, siPrefix)); + spec.setSiPrefix(siPrefix); } - - switch (this.data.specs[i].metadata.datatype) + else if (q_value != null) { + spec.set("valueType", "numeric"); + spec.set("value", q_value); + } + else { - case "string": - spec.set("valueType", "string"); - spec.set("stringValue", this.data.specs[i].value[0]); - break; - case "decimal": - case "integer": - spec.set("valueType", "numeric"); - - if (this.data.specs[i].min_value !== null) - { - value = parseFloat(this.data.specs[i].min_value); - siPrefix = this.findSiPrefixForValueAndUnit(value, unit); - spec.set("minValue", this.applySiPrefix(value, siPrefix)); - spec.setMinSiPrefix(siPrefix); - } - - if (this.data.specs[i].max_value !== null) - { - value = parseFloat(this.data.specs[i].max_value); - siPrefix = this.findSiPrefixForValueAndUnit(value, unit); - spec.set("maxValue", this.applySiPrefix(value, siPrefix)); - spec.setMaxSiPrefix(siPrefix); - } - - if (this.data.specs[i].value.length === 1) - { - value = parseFloat(this.data.specs[i].value[0]); - siPrefix = this.findSiPrefixForValueAndUnit(value, unit); - spec.set("value", this.applySiPrefix(value, siPrefix)); - spec.setSiPrefix(siPrefix); - } - - break; + spec.set("valueType", "string"); + spec.set("stringValue", this.data.specs[i].display_value); } found = null; @@ -495,5 +476,28 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { } return siPrefix; + }, + parseQuantity: function( quantity ) + { + try { + quantity = quantity.trim(); + const regex = /[^\d+-.]/g; + var idx = quantity.search(regex); + if (idx == -1) { + // no unit, but maybe value only + var value = parseFloat(quantity); + if (!isNaN(value)) { + return [value,null]; + } + } else { + var value = parseFloat(quantity.slice(0,idx)); + if (isNaN(value)) + return [null,null]; + var unit = quantity.slice(idx).trim(); + return [value,unit]; + } + } + finally {} + return [null,null]; } }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js index 89f847609..a99379fc3 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js @@ -95,10 +95,15 @@ Ext.define("PartKeepr.Components.OctoPart.SearchPanel", { itemId: "importParameters", checked: PartKeepr.getApplication().getUserPreference("partkeepr.octopart.importParameters", true), boxLabel: i18n("Parameters") + }, { + xtype: 'checkbox', + itemId: "importBestDatasheet", + checked: PartKeepr.getApplication().getUserPreference("partkeepr.octopart.importBestDatasheet", true), + boxLabel: i18n("Best Datasheet") }, { xtype: 'checkbox', itemId: "importDatasheets", - checked: PartKeepr.getApplication().getUserPreference("partkeepr.octopart.importDatasheets", true), + checked: PartKeepr.getApplication().getUserPreference("partkeepr.octopart.importDatasheets", false), boxLabel: i18n("Datasheets") }, { xtype: 'checkbox', @@ -108,7 +113,7 @@ Ext.define("PartKeepr.Components.OctoPart.SearchPanel", { }, { xtype: 'checkbox', itemId: "importComplianceDocuments", - checked: PartKeepr.getApplication().getUserPreference("partkeepr.octopart.importComplianceDocuments", true), + checked: PartKeepr.getApplication().getUserPreference("partkeepr.octopart.importComplianceDocuments", false), boxLabel: i18n("Compliance Documents") }, { xtype: 'checkbox', @@ -186,6 +191,7 @@ Ext.define("PartKeepr.Components.OctoPart.SearchPanel", { j.setImport("distributors", this.down("#importDistributors").getValue()); j.setImport("parameters", this.down("#importParameters").getValue()); + j.setImport("bestDatasheet", this.down("#importBestDatasheet").getValue()); j.setImport("datasheets", this.down("#importDatasheets").getValue()); j.setImport("cadModels", this.down("#importCADModels").getValue()); j.setImport("complianceDocuments", this.down("#importComplianceDocuments").getValue()); diff --git a/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php b/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php index dd7757fb0..f9e80ddc5 100644 --- a/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php +++ b/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php @@ -50,19 +50,23 @@ public function getPartsByQueryAction(Request $request) $data = $this->get("partkeepr.octopart_service")->getPartyByQuery($query, $start); + $errors = $data["errors"]; + $data = $data["data"]["search"]; + $responseData["hits"] = $data["hits"]; $responseData["results"] = []; foreach ($data["results"] as $result) { + $part = $result["part"]; $responseItem = []; - $responseItem["mpn"] = $result["item"]["mpn"]; - $responseItem["title"] = $result["snippet"]; - $responseItem["manufacturer"] = $result["item"]["manufacturer"]["name"]; - $responseItem["numOffers"] = count($result["item"]["offers"]); - $responseItem["numSpecs"] = count($result["item"]["specs"]); - $responseItem["numDatasheets"] = count($result["item"]["datasheets"]); - $responseItem["url"] = $result["item"]["octopart_url"]; - $responseItem["uid"] = $result["item"]["uid"]; + $responseItem["mpn"] = $part["mpn"]; + $responseItem["title"] = $part["short_description"]; + $responseItem["manufacturer"] = $part["manufacturer"]["name"]; + $responseItem["numOffers"] = count($part["sellers"]); + $responseItem["numSpecs"] = count($part["specs"]); + $responseItem["numDatasheets"] = count($part["document_collections"]); + $responseItem["url"] = "https://octopart.com" . $part["slug"]; + $responseItem["uid"] = $part["id"]; $responseData["results"][] = $responseItem; } diff --git a/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php b/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php index a8ae5a75a..2d274344f 100644 --- a/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php +++ b/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php @@ -3,12 +3,108 @@ namespace PartKeepr\OctoPartBundle\Services; use Guzzle\Http\Client; +use Predis\Client as PredisClient; class OctoPartService { - const OCTOPART_ENDPOINT = "http://octopart.com/api/v3/"; + const OCTOPART_ENDPOINT = "https://octopart.com/api/v4/endpoint"; + + const OCTOPART_FIELDS = <<<'EOD' + hits + + manufacturer_agg { + company { + id + name + } + count + } + + results { + part { + id + mpn + slug + short_description + counts + manufacturer { + name + } + best_datasheet { + name + url + credit_string + credit_url + page_count + mime_type + } + best_image { + url + } + specs { + attribute { + name + group + } + display_value + } + document_collections { + name + documents { + name + url + credit_string + credit_url + } + } + descriptions { + credit_string + text + } + cad { + add_to_library_url + } + reference_designs { + name + url + } + sellers { + company { + homepage_url + is_verified + name + slug + } + is_authorized + is_broker + is_rfq + offers { + click_url + inventory_level + moq + packaging + prices { + conversion_rate + converted_currency + converted_price + currency + price + quantity + } + sku + updated + } + } + } + } +EOD; + + const OCTOPART_PARTQUERY = 'query MyPartSearch($id: String!, $country: String = "DE", $currency: String = "EUR") { parts(ids: [$id]) {' . self::OCTOPART_FIELDS . '}}'; + + const OCTOPART_QUERY = 'query MyPartSearch($q: String!, $filters: Map, $limit: Int!, $start: Int, $country: String = "DE", $currency: String = "EUR") { search(q: $q, filters: $filters, limit: $limit, start: $start, country: $country, currency: $currency) {' . self::OCTOPART_FIELDS . '}}'; private $apiKey; + private $limit = "3"; public function __construct($apiKey) { @@ -17,39 +113,73 @@ public function __construct($apiKey) public function getPartByUID($uid) { - $client = new Client(); - $request = $client->createRequest('GET', self::OCTOPART_ENDPOINT."parts/".$uid); - - $request->getQuery()->add("apikey", $this->apiKey); - $request->getQuery()->add("include", [ - "short_description", - "datasheets", - "compliance_documents", - "descriptions", - "imagesets", - "specs", - "reference_designs", - "cad_models", - ]); + try { + $redisclient = new PredisClient(); + $part = $redisclient->get($uid); + if ($part) { + return json_decode( $part, true ); + } + } + finally {} + + $request = $client->createRequest('POST', self::OCTOPART_ENDPOINT); + $request->setHeader('Content-Type', 'application/json'); + $request->getQuery()->add("token", $this->apiKey); + + $graphql = array( + "query" => self::OCTOPART_PARTQUERY, + "operationName" => "MyPartSearch", + "variables" => [ + "id" => $uid + ] + ); + $request->setBody(json_encode($graphql)); $request->send(); - return json_decode($request->getResponse()->getBody(), true); + $body = $request->getResponse()->getBody(); + + $data = json_decode($body, true); + + return $data["data"]["parts"]; } - public function getPartyByQuery($query, $start = 0) + public function getPartyByQuery($q, $start = 1) { $client = new Client(); - $request = $client->createRequest('GET', self::OCTOPART_ENDPOINT."parts/search"); - $request->getQuery()->add("apikey", $this->apiKey); - $request->getQuery()->add("q", $query); - $request->getQuery()->add("start", ($start - 1) * 20); - $request->getQuery()->add("include", ["short_description", "specs", "datasheets"]); - $request->getQuery()->add("limit", 20); + $request = $client->createRequest('POST', self::OCTOPART_ENDPOINT); + $request->setHeader('Content-Type', 'application/json'); + $request->getQuery()->add("token", $this->apiKey); + + $graphql = array( + "query" => self::OCTOPART_QUERY, + "operationName" => "MyPartSearch", + "variables" => [ + "q" => $q, + "limit" => $this->limit, + "start" => ($start - 1) * 3 + ] + ); + $request->setBody(json_encode($graphql)); $request->send(); - return json_decode($request->getResponse()->getBody(), true); + $body = $request->getResponse()->getBody(); + + $parts = json_decode($body, true); + + // work around the low number of allowed accesses to octopart's api + try { + $redisclient = new PredisClient(); + $results = $parts["data"]["search"]["results"]; + foreach ($results as $result) { + $id = $result["part"]["id"]; + $redisclient->set($id, json_encode($result["part"])); + } + } + finally {} + + return $parts; } } From 7efd47ae3dbe6ba99922dd2ced7a8866a50001b7 Mon Sep 17 00:00:00 2001 From: Sebastian Held Date: Sun, 9 Aug 2020 17:23:47 +0200 Subject: [PATCH 02/10] fix "without redis" usecase --- .../Services/OctoPartService.php | 112 +++++++++++++++--- 1 file changed, 95 insertions(+), 17 deletions(-) diff --git a/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php b/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php index 2d274344f..f957cade4 100644 --- a/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php +++ b/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php @@ -9,17 +9,11 @@ class OctoPartService { const OCTOPART_ENDPOINT = "https://octopart.com/api/v4/endpoint"; - const OCTOPART_FIELDS = <<<'EOD' + const OCTOPART_QUERY = <<<'EOD' + query MyPartSearch($q: String!, $filters: Map, $limit: Int!, $start: Int, $country: String = "DE", $currency: String = "EUR") { + search(q: $q, filters: $filters, limit: $limit, start: $start, country: $country, currency: $currency) { hits - manufacturer_agg { - company { - id - name - } - count - } - results { part { id @@ -97,11 +91,88 @@ class OctoPartService } } } + } + } EOD; - const OCTOPART_PARTQUERY = 'query MyPartSearch($id: String!, $country: String = "DE", $currency: String = "EUR") { parts(ids: [$id]) {' . self::OCTOPART_FIELDS . '}}'; - - const OCTOPART_QUERY = 'query MyPartSearch($q: String!, $filters: Map, $limit: Int!, $start: Int, $country: String = "DE", $currency: String = "EUR") { search(q: $q, filters: $filters, limit: $limit, start: $start, country: $country, currency: $currency) {' . self::OCTOPART_FIELDS . '}}'; + const OCTOPART_PARTQUERY = <<<'EOD' + query MyPartSearch($id: String!, $country: String = "DE", $currency: String = "EUR") { + parts(ids: [$id], country: $country, currency: $currency) { + id + mpn + slug + short_description + counts + manufacturer { + name + } + best_datasheet { + name + url + credit_string + credit_url + page_count + mime_type + } + best_image { + url + } + specs { + attribute { + name + group + } + display_value + } + document_collections { + name + documents { + name + url + credit_string + credit_url + } + } + descriptions { + credit_string + text + } + cad { + add_to_library_url + } + reference_designs { + name + url + } + sellers { + company { + homepage_url + is_verified + name + slug + } + is_authorized + is_broker + is_rfq + offers { + click_url + inventory_level + moq + packaging + prices { + conversion_rate + converted_currency + converted_price + currency + price + quantity + } + sku + updated + } + } + }} +EOD; private $apiKey; private $limit = "3"; @@ -115,13 +186,17 @@ public function getPartByUID($uid) { try { $redisclient = new PredisClient(); + $redisclient->connect(); $part = $redisclient->get($uid); if ($part) { return json_decode( $part, true ); } + $redisclient->disconnect(); + } + catch (\Exception $e) { } - finally {} + $client = new Client(); $request = $client->createRequest('POST', self::OCTOPART_ENDPOINT); $request->setHeader('Content-Type', 'application/json'); $request->getQuery()->add("token", $this->apiKey); @@ -141,10 +216,10 @@ public function getPartByUID($uid) $data = json_decode($body, true); - return $data["data"]["parts"]; + return $data["data"]["parts"][0]; } - public function getPartyByQuery($q, $start = 1) + public function getPartyByQuery($q, $startpage = 1) { $client = new Client(); @@ -158,7 +233,7 @@ public function getPartyByQuery($q, $start = 1) "variables" => [ "q" => $q, "limit" => $this->limit, - "start" => ($start - 1) * 3 + "start" => ($startpage - 1) * $this->limit // "start" is 0-based ] ); @@ -172,13 +247,16 @@ public function getPartyByQuery($q, $start = 1) // work around the low number of allowed accesses to octopart's api try { $redisclient = new PredisClient(); + $redisclient->connect(); $results = $parts["data"]["search"]["results"]; foreach ($results as $result) { $id = $result["part"]["id"]; $redisclient->set($id, json_encode($result["part"])); } + $redisclient->disconnect(); + } + catch (\Exception $e) { } - finally {} return $parts; } From 03b6ae3736caf4e5a93523cdeac3c0774e4a0d72 Mon Sep 17 00:00:00 2001 From: Sebastian Held Date: Sun, 9 Aug 2020 17:37:11 +0200 Subject: [PATCH 03/10] use limit config option --- src/PartKeepr/OctoPartBundle/Resources/config/services.xml | 1 + src/PartKeepr/OctoPartBundle/Services/OctoPartService.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PartKeepr/OctoPartBundle/Resources/config/services.xml b/src/PartKeepr/OctoPartBundle/Resources/config/services.xml index 6eb6dc1b3..05e4fda48 100644 --- a/src/PartKeepr/OctoPartBundle/Resources/config/services.xml +++ b/src/PartKeepr/OctoPartBundle/Resources/config/services.xml @@ -7,6 +7,7 @@ %partkeepr.octopart.apikey% + %partkeepr.octopart.limit% diff --git a/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php b/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php index f957cade4..17b4790ac 100644 --- a/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php +++ b/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php @@ -177,9 +177,10 @@ class OctoPartService private $apiKey; private $limit = "3"; - public function __construct($apiKey) + public function __construct($apiKey, $limit) { $this->apiKey = $apiKey; + $this->limit = $limit; } public function getPartByUID($uid) From 5c67082d18fc320e689f4bc775a9f0256da718c3 Mon Sep 17 00:00:00 2001 From: Sebastian Held Date: Wed, 12 Aug 2020 11:37:03 +0200 Subject: [PATCH 04/10] style --- .../Controller/DefaultController.php | 2 +- .../Services/OctoPartService.php | 38 +++++++++---------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php b/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php index f9e80ddc5..460cd9cf0 100644 --- a/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php +++ b/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php @@ -65,7 +65,7 @@ public function getPartsByQueryAction(Request $request) $responseItem["numOffers"] = count($part["sellers"]); $responseItem["numSpecs"] = count($part["specs"]); $responseItem["numDatasheets"] = count($part["document_collections"]); - $responseItem["url"] = "https://octopart.com" . $part["slug"]; + $responseItem["url"] = "https://octopart.com".$part["slug"]; $responseItem["uid"] = $part["id"]; $responseData["results"][] = $responseItem; } diff --git a/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php b/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php index 17b4790ac..81cb1ff94 100644 --- a/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php +++ b/src/PartKeepr/OctoPartBundle/Services/OctoPartService.php @@ -190,25 +190,24 @@ public function getPartByUID($uid) $redisclient->connect(); $part = $redisclient->get($uid); if ($part) { - return json_decode( $part, true ); + return json_decode($part, true); } $redisclient->disconnect(); - } - catch (\Exception $e) { + } catch (\Exception $e) { } $client = new Client(); $request = $client->createRequest('POST', self::OCTOPART_ENDPOINT); $request->setHeader('Content-Type', 'application/json'); $request->getQuery()->add("token", $this->apiKey); - - $graphql = array( - "query" => self::OCTOPART_PARTQUERY, + + $graphql = [ + "query" => self::OCTOPART_PARTQUERY, "operationName" => "MyPartSearch", - "variables" => [ - "id" => $uid - ] - ); + "variables" => [ + "id" => $uid, + ], + ]; $request->setBody(json_encode($graphql)); $request->send(); @@ -227,16 +226,16 @@ public function getPartyByQuery($q, $startpage = 1) $request = $client->createRequest('POST', self::OCTOPART_ENDPOINT); $request->setHeader('Content-Type', 'application/json'); $request->getQuery()->add("token", $this->apiKey); - - $graphql = array( - "query" => self::OCTOPART_QUERY, + + $graphql = [ + "query" => self::OCTOPART_QUERY, "operationName" => "MyPartSearch", - "variables" => [ - "q" => $q, + "variables" => [ + "q" => $q, "limit" => $this->limit, - "start" => ($startpage - 1) * $this->limit // "start" is 0-based - ] - ); + "start" => ($startpage - 1) * $this->limit, // "start" is 0-based + ], + ]; $request->setBody(json_encode($graphql)); $request->send(); @@ -255,8 +254,7 @@ public function getPartyByQuery($q, $startpage = 1) $redisclient->set($id, json_encode($result["part"])); } $redisclient->disconnect(); - } - catch (\Exception $e) { + } catch (\Exception $e) { } return $parts; From fd22bb7260bd92a0cb991c4f796cd53fa3a774d3 Mon Sep 17 00:00:00 2001 From: Sebastian Held Date: Wed, 12 Aug 2020 16:25:02 +0200 Subject: [PATCH 05/10] add error dialog --- .../js/Components/OctoPart/SearchPanel.js | 19 +++++++++++- .../Controller/DefaultController.php | 29 ++++++++++--------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js index a99379fc3..d82be3429 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js @@ -25,7 +25,8 @@ Ext.define("PartKeepr.Components.OctoPart.SearchPanel", { reader: { type: 'json', totalProperty: 'hits', - rootProperty: 'results' + rootProperty: 'results', + transform: this.checkForErrors } }, autoLoad: false @@ -163,6 +164,8 @@ Ext.define("PartKeepr.Components.OctoPart.SearchPanel", { this.onSelectChange, this); + this.store.on("load", this.checkForApiError, this); + this.callParent(arguments); }, @@ -212,5 +215,19 @@ Ext.define("PartKeepr.Components.OctoPart.SearchPanel", { ); this.store.load(); this.searchBar.setValue(query); + }, + checkForErrors: function (data) + { + if (data.results.length == 0 && data.errors.length > 0) { + Ext.Msg.alert(i18n("OctoPart Error"), data.errors.map(e => e.message).join()); + } + + return data; + }, + checkForApiError: function (store, records, successful, eOpts ) + { + if (!successful) { + Ext.Msg.alert(i18n("OctoPart Error"), "PartKeepr cannot access the OctoPart API"); + } } }); diff --git a/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php b/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php index 460cd9cf0..cbad140c5 100644 --- a/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php +++ b/src/PartKeepr/OctoPartBundle/Controller/DefaultController.php @@ -38,7 +38,7 @@ public function indexAction($id) */ public function getPartsByQueryAction(Request $request) { - $start = 0; + $start = 1; $responseData = []; @@ -55,19 +55,22 @@ public function getPartsByQueryAction(Request $request) $responseData["hits"] = $data["hits"]; $responseData["results"] = []; + $responseData["errors"] = $errors; - foreach ($data["results"] as $result) { - $part = $result["part"]; - $responseItem = []; - $responseItem["mpn"] = $part["mpn"]; - $responseItem["title"] = $part["short_description"]; - $responseItem["manufacturer"] = $part["manufacturer"]["name"]; - $responseItem["numOffers"] = count($part["sellers"]); - $responseItem["numSpecs"] = count($part["specs"]); - $responseItem["numDatasheets"] = count($part["document_collections"]); - $responseItem["url"] = "https://octopart.com".$part["slug"]; - $responseItem["uid"] = $part["id"]; - $responseData["results"][] = $responseItem; + if ($data) { + foreach ($data["results"] as $result) { + $part = $result["part"]; + $responseItem = []; + $responseItem["mpn"] = $part["mpn"]; + $responseItem["title"] = $part["short_description"]; + $responseItem["manufacturer"] = $part["manufacturer"]["name"]; + $responseItem["numOffers"] = count($part["sellers"]); + $responseItem["numSpecs"] = count($part["specs"]); + $responseItem["numDatasheets"] = count($part["document_collections"]); + $responseItem["url"] = "https://octopart.com".$part["slug"]; + $responseItem["uid"] = $part["id"]; + $responseData["results"][] = $responseItem; + } } return $responseData; From cdd9453e8f3bc1c7c04a558113bc87d720aec3ca Mon Sep 17 00:00:00 2001 From: Sebastian Held Date: Wed, 12 Aug 2020 16:36:50 +0200 Subject: [PATCH 06/10] correct spelling of Octopart --- .../public/js/Components/OctoPart/DataApplicator.js | 6 +++--- .../Resources/public/js/Components/OctoPart/SearchPanel.js | 4 ++-- .../Resources/public/js/Components/OctoPart/SearchWindow.js | 2 +- .../public/js/Components/Part/Editor/PartEditorWindow.js | 4 ++-- .../UserPreferences/Preferences/OctoPartConfiguration.js | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js index e74f50cbc..17c644ea5 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js @@ -25,9 +25,9 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { this.part = part; }, /** - * Loads the data via the PartKeepr API from OctoPart. + * Loads the data via the PartKeepr API from Octopart. * - * @param {String} id The OctoPart UID to load + * @param {String} id The Octopart UID to load */ loadData: function (id) { @@ -38,7 +38,7 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { }); }, /** - * Called after the OctoPart Part data has been loaded. + * Called after the Octopart Part data has been loaded. * * @param {Object} response The response data */ diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js index d82be3429..60e48ac8c 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js @@ -219,7 +219,7 @@ Ext.define("PartKeepr.Components.OctoPart.SearchPanel", { checkForErrors: function (data) { if (data.results.length == 0 && data.errors.length > 0) { - Ext.Msg.alert(i18n("OctoPart Error"), data.errors.map(e => e.message).join()); + Ext.Msg.alert(i18n("Octopart Error"), data.errors.map(e => e.message).join()); } return data; @@ -227,7 +227,7 @@ Ext.define("PartKeepr.Components.OctoPart.SearchPanel", { checkForApiError: function (store, records, successful, eOpts ) { if (!successful) { - Ext.Msg.alert(i18n("OctoPart Error"), "PartKeepr cannot access the OctoPart API"); + Ext.Msg.alert(i18n("Octopart Error"), "PartKeepr cannot access the Octopart API"); } } }); diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchWindow.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchWindow.js index dcf12a6eb..1c9644937 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchWindow.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchWindow.js @@ -1,6 +1,6 @@ Ext.define("PartKeepr.Components.OctoPart.SearchWindow", { extend: "Ext.window.Window", - title: i18n("OctoPart Search"), + title: i18n("Octopart Search"), iconCls: "partkeepr-icon octopart", width: 750, height: 300, diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/Editor/PartEditorWindow.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/Editor/PartEditorWindow.js index 8dec451d2..f99befb4d 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/Editor/PartEditorWindow.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/Editor/PartEditorWindow.js @@ -62,7 +62,7 @@ Ext.define('PartKeepr.PartEditorWindow', { this.editor.on("itemSaved", this.onItemSaved, this); this.octoPartButton = Ext.create("Ext.button.Button", { - text: i18n("OctoPart…"), + text: i18n("Octopart…"), iconCls: 'partkeepr-icon octopart', handler: Ext.bind(this.onOctoPartClick, this) }); @@ -143,7 +143,7 @@ Ext.define('PartKeepr.PartEditorWindow', { this.octoPartQueryWindow.startSearch(this.editor.nameField.getValue()); this.octoPartQueryWindow.on("refreshData", this.onRefreshData, this); } else { - Ext.MessageBox.alert(i18n("OctoPart is not configured"), i18n("Your administrator needs to configure the API key for OctoPart in the parameters.php file - see parameters.php.dist for instructions")); + Ext.MessageBox.alert(i18n("Octopart is not configured"), i18n("Your administrator needs to configure the API key for Octopart in the parameters.php file - see parameters.php.dist for instructions")); } }, onRefreshData: function () { diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/UserPreferences/Preferences/OctoPartConfiguration.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/UserPreferences/Preferences/OctoPartConfiguration.js index e09bc8e0e..555f1fa67 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/UserPreferences/Preferences/OctoPartConfiguration.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/UserPreferences/Preferences/OctoPartConfiguration.js @@ -100,7 +100,7 @@ Ext.define('PartKeepr.Components.UserPreferences.Preferences.OctoPartConfigurati }, statics: { iconCls: 'partkeepr-icon octopart', - title: i18n('OctoPart'), + title: i18n('Octopart'), menuPath: [{iconCls: 'fugue-icon ui-scroll-pane-image', text: i18n("User Interface")}] } }); From cf383ed883b1959584b83ef3c21878b17592a061 Mon Sep 17 00:00:00 2001 From: Sebastian Held Date: Tue, 29 Sep 2020 07:45:49 +0200 Subject: [PATCH 07/10] fix units --- .../js/Components/OctoPart/DataApplicator.js | 55 ++++++++++++++++--- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js index 17c644ea5..279f62cda 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js @@ -406,14 +406,20 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { if (q_value != null && q_unit != null) { - unit = PartKeepr.getApplication().getUnitStore().findRecord("symbol", - q_unit, 0, false, true, true); - - spec.setUnit(unit); + [value,unit,siPrefix] = this.SIUnitPrefix(q_value, q_unit); + if (value && unit && siPrefix) { + spec.setUnit(unit); + spec.set("value", value); + spec.setSiPrefix(siPrefix); + } else { + unit = PartKeepr.getApplication().getUnitStore().findRecord("symbol", + q_unit, 0, false, true, true); + spec.setUnit(unit); + siPrefix = this.findSiPrefixForValueAndUnit(q_value, unit); + spec.set("value", this.applySiPrefix(q_value, siPrefix)); + spec.setSiPrefix(siPrefix); + } spec.set("valueType", "numeric"); - siPrefix = this.findSiPrefixForValueAndUnit(q_value, unit); - spec.set("value", this.applySiPrefix(q_value, siPrefix)); - spec.setSiPrefix(siPrefix); } else if (q_value != null) { spec.set("valueType", "numeric"); @@ -499,5 +505,40 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { } finally {} return [null,null]; + }, + SIUnitPrefix: function( q_value, q_unit ) + { + // the new Octopart API returns quantities as display strings: e.g. "12 mm" + // try to recognize SI-unit and SI-prefix + + // check if the unit as a whole is already known + var unit = PartKeepr.getApplication().getUnitStore().findRecord("symbol", q_unit, 0, false, true, true); + if (unit) { + var siPrefix = PartKeepr.getApplication().getSiPrefixStore().findRecord("exponent", 0, 0, false, false, true); + return [q_value, unit, siPrefix]; + } + + // assume the first character is an SI-prefix + if (q_unit.length >= 2) { + unit = PartKeepr.getApplication().getUnitStore().findRecord("symbol", q_unit.substring(1), 0, false, true, true); + if (unit) { + // now check that the first character is a valid SI-prefix + console.log(unit); + var siPrefix; + for (var i=0; i Date: Thu, 1 Oct 2020 21:30:58 +0200 Subject: [PATCH 08/10] fix units with SI prefixes and consider 0402 as a string --- .../js/Components/OctoPart/DataApplicator.js | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js index 279f62cda..1cf7c2643 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js @@ -77,10 +77,12 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { { for (i in this.data["specs"]) { - var q_value, q_unit; + var q_value, q_unit, q_siPrefix; [q_value,q_unit] = this.parseQuantity( this.data.specs[i].display_value ); - if (q_unit) + [q_value,q_unit2,q_siPrefix] = this.SIUnitPrefix(q_value, q_unit); + if (q_unit2 === null && q_unit) { + // there is a unit (q_unit), but we do not know about it or the prefix of the unit is disabled unit = PartKeepr.getApplication().getUnitStore().findRecord("symbol", q_unit, 0, false, true, true); if (unit === null) @@ -404,6 +406,14 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { var q_value, q_unit; [q_value,q_unit] = this.parseQuantity( this.data.specs[i].display_value ); + // some fields need to be treated as strings + if (this.data.specs[i].attribute.name == "Case/Package" || + this.data.specs[i].attribute.name == "Case Code (Imperial)" || + this.data.specs[i].attribute.name == "Case Code (Metric)") { + q_value = null; // force string interpretation + q_unit = null; // force string interpretation + } + if (q_value != null && q_unit != null) { [value,unit,siPrefix] = this.SIUnitPrefix(q_value, q_unit); @@ -519,7 +529,7 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { } // assume the first character is an SI-prefix - if (q_unit.length >= 2) { + if (q_unit && q_unit.length >= 2) { unit = PartKeepr.getApplication().getUnitStore().findRecord("symbol", q_unit.substring(1), 0, false, true, true); if (unit) { // now check that the first character is a valid SI-prefix @@ -527,7 +537,10 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { var siPrefix; for (var i=0; i Date: Sun, 1 Nov 2020 18:37:53 +0100 Subject: [PATCH 09/10] remove dead code --- .../js/Components/OctoPart/DataApplicator.js | 41 ------------------- .../js/Components/OctoPart/SearchPanel.js | 12 ------ 2 files changed, 53 deletions(-) diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js index 1cf7c2643..fb0fda265 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/DataApplicator.js @@ -9,9 +9,7 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { this.setImport("parameters", true); this.setImport("distributors", true); this.setImport("bestDatasheet", true); - this.setImport("datasheets", true); this.setImport("cadModels", true); - this.setImport("complianceDocuments", true); this.setImport("referenceDesigns", true); this.setImport("images", true); @@ -158,26 +156,6 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { } } -/* if (this.import.datasheets) - { - if (this.data.document_collections.length > 0) - { - file = this.data.datasheets.shift(); - this.displayWaitWindow(i18n("Uploading datasheet…"), file.url); - - if (!this.checkIfAttachmentFilenameExists(file.url)) - { - PartKeepr.getApplication().uploadFileFromURL(file.url, i18n("Datasheet"), this.onFileUploaded, - this); - } else - { - this.applyData(); - } - - return false; - } - }*/ - if (this.import.cadModels) { if (this.data['cad']) @@ -197,25 +175,6 @@ Ext.define("PartKeepr.Components.OctoPart.DataApplicator", { } } -/* if (this.import.complianceDocuments) - { - if (this.data.compliance_documents.length > 0) - { - file = this.data.compliance_documents.shift(); - this.displayWaitWindow(i18n("Uploading Compliance Document…"), file.url); - if (!this.checkIfAttachmentFilenameExists(file.url)) - { - PartKeepr.getApplication().uploadFileFromURL(file.url, i18n("Compliance Document"), - this.onFileUploaded, - this); - } else - { - this.applyData(); - } - return false; - } - }*/ - if (this.import.referenceDesigns) { if (this.data.reference_designs.length > 0) diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js index 60e48ac8c..1f146f572 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/OctoPart/SearchPanel.js @@ -101,21 +101,11 @@ Ext.define("PartKeepr.Components.OctoPart.SearchPanel", { itemId: "importBestDatasheet", checked: PartKeepr.getApplication().getUserPreference("partkeepr.octopart.importBestDatasheet", true), boxLabel: i18n("Best Datasheet") - }, { - xtype: 'checkbox', - itemId: "importDatasheets", - checked: PartKeepr.getApplication().getUserPreference("partkeepr.octopart.importDatasheets", false), - boxLabel: i18n("Datasheets") }, { xtype: 'checkbox', itemId: "importCADModels", checked: PartKeepr.getApplication().getUserPreference("partkeepr.octopart.importCADModels", true), boxLabel: i18n("CAD Models") - }, { - xtype: 'checkbox', - itemId: "importComplianceDocuments", - checked: PartKeepr.getApplication().getUserPreference("partkeepr.octopart.importComplianceDocuments", false), - boxLabel: i18n("Compliance Documents") }, { xtype: 'checkbox', itemId: "importReferenceDesigns", @@ -195,9 +185,7 @@ Ext.define("PartKeepr.Components.OctoPart.SearchPanel", { j.setImport("distributors", this.down("#importDistributors").getValue()); j.setImport("parameters", this.down("#importParameters").getValue()); j.setImport("bestDatasheet", this.down("#importBestDatasheet").getValue()); - j.setImport("datasheets", this.down("#importDatasheets").getValue()); j.setImport("cadModels", this.down("#importCADModels").getValue()); - j.setImport("complianceDocuments", this.down("#importComplianceDocuments").getValue()); j.setImport("referenceDesigns", this.down("#importReferenceDesigns").getValue()); j.setImport("images", this.down("#importImages").getValue()); From 4edae1a72ccb7135e1e3d670b38a3e636d743c55 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Sat, 7 Nov 2020 11:36:40 +0100 Subject: [PATCH 10/10] Added entry to Changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a604eb72c..27b4e894d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +Bugfixes and other features: + * Updated to the most recent Octopart API version 4 [#1150](https://github.com/partkeepr/PartKeepr/pull/1150) + ## PartKeepr 1.4.0 New Features: