From c08cf06191ea85d33e69b348d7539966ed1aedd9 Mon Sep 17 00:00:00 2001 From: Palabola Date: Tue, 11 Jun 2024 11:17:07 +0200 Subject: [PATCH 1/5] crash fix --- .../pages/server-details/server-details.component.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/pages/server-details/server-details.component.ts b/src/app/pages/server-details/server-details.component.ts index 8d41b194..76040a3f 100644 --- a/src/app/pages/server-details/server-details.component.ts +++ b/src/app/pages/server-details/server-details.component.ts @@ -225,16 +225,20 @@ export class ServerDetailsComponent implements OnInit { question: `What is ${this.serverDetails.display_name}?`, answer: this.description }, - { - question: `How much does the ${this.serverDetails.display_name} server cost?`, - answer: `The pricing for ${this.serverDetails.display_name} servers starts at $${this.serverDetails.prices[0].price} per hour, but the actual price depends on the selected region, zone and server allocation method (e.g. on-demand versus spot pricing options). Currently, the maximum price stands at $${this.serverDetails.prices.slice(-1)[0].price}.` - }, { question: `What are the specs of the ${this.serverDetails.display_name} server?`, answer: `The ${this.serverDetails.display_name} server is equipped with ${this.serverDetails.vcpus || this.serverDetails.cpu_cores} vCPU(s), ${this.getMemory()} of memory, ${this.getStorage()} of storage, and ${this.serverDetails.gpu_count} GPU(s). Additional block storage can be attached as needed.` } ]; + if(this.serverDetails.prices[0]) { + this.faqs.push( + { + question: `How much does the ${this.serverDetails.display_name} server cost?`, + answer: `The pricing for ${this.serverDetails.display_name} servers starts at $${this.serverDetails.prices[0].price} per hour, but the actual price depends on the selected region, zone and server allocation method (e.g. on-demand versus spot pricing options). Currently, the maximum price stands at $${this.serverDetails.prices.slice(-1)[0].price}.` + }); + } + const keywords = this.title + ', ' + this.serverDetails.server_id + ', ' + this.serverDetails.vendor.vendor_id; this.SEOHandler.updateTitleAndMetaTags(this.title, this.description, keywords); From 55e180ffb70b76f4ab8c46ceb9af6ff2059c7b4f Mon Sep 17 00:00:00 2001 From: Palabola Date: Tue, 11 Jun 2024 11:25:00 +0200 Subject: [PATCH 2/5] benchmark scores on compare --- .../server-compare.component.html | 17 +++--- .../server-compare.component.ts | 58 ++++++++++++------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/app/pages/server-compare/server-compare.component.html b/src/app/pages/server-compare/server-compare.component.html index ca80f4d0..9db871a3 100644 --- a/src/app/pages/server-compare/server-compare.component.html +++ b/src/app/pages/server-compare/server-compare.component.html @@ -135,18 +135,15 @@

Server Comparison

- - - + + -
-
- {{scoreItem.score}} {{serializeConfig(scoreItem.config)}} -
-
+
+ + {{value}} -
- + +
View Server diff --git a/src/app/pages/server-compare/server-compare.component.ts b/src/app/pages/server-compare/server-compare.component.ts index 741c455e..80513314 100644 --- a/src/app/pages/server-compare/server-compare.component.ts +++ b/src/app/pages/server-compare/server-compare.component.ts @@ -107,8 +107,6 @@ export class ServerCompareComponent implements OnInit { } }); - - /* this.benchmarkMeta = data[1].body ?.filter((benchmark: any) => { let found = false; @@ -123,18 +121,40 @@ export class ServerCompareComponent implements OnInit { return { ...b, collapsed: true, - scores: this.servers.map((s: any) => { - return s.benchmark_scores?.filter((score: any) => score.benchmark_id === b.benchmark_id).sort((a: any, b: any) => { - if(a.config && b.config) { - return JSON.stringify(a).localeCompare(JSON.stringify(b)); + configs: [] + } + }); + + this.benchmarkMeta.forEach((benchmark: any) => { + this.servers.forEach((server: any) => { + const scores = server.benchmark_scores?.filter((s: any) => s.benchmark_id === benchmark.benchmark_id); + if(scores) { + scores.forEach((score: any) => { + const config = benchmark.configs.find((c: any) => { + return JSON.stringify(c.config) === JSON.stringify(score.config); + }); + if(!config) { + benchmark.configs.push({ + config: score.config, + values: [] + }); } - return 0; }); - }) - } + } + }); }); - */ + this.benchmarkMeta.forEach((benchmark: any) => { + benchmark.configs.forEach((config: any) => { + this.servers.forEach((server: any) => { + const score = server.benchmark_scores + ?.find((s: any) => s.benchmark_id === benchmark.benchmark_id && JSON.stringify(s.config) === JSON.stringify(config.config)); + config.values.push( + score ? score.score : '-' + ); + }); + }); + }); this.isLoading = false; }).catch((err) => { @@ -327,7 +347,8 @@ export class ServerCompareComponent implements OnInit { getBestPrice(server: ServerPKsWithPrices, allocation: Allocation = Allocation.Ondemand) { if(server.prices?.find((p) => p.allocation === allocation)){ - return `${server.prices.filter(x => x.allocation === allocation).sort((a,b) => a.price - b.price)[0].price}$`; + let best = server.prices.filter(x => x.allocation === allocation).sort((a,b) => a.price - b.price)[0]; + return `${best.price} ${best.currency}`; } else { return '-'; } @@ -338,18 +359,13 @@ export class ServerCompareComponent implements OnInit { } serializeConfig(config: any) { - let result = ''; + let result = ''; + return result; } From 0de0457d43b04bfe06229819aff3a08d066341c4 Mon Sep 17 00:00:00 2001 From: Palabola Date: Tue, 11 Jun 2024 11:41:59 +0200 Subject: [PATCH 3/5] formatting values --- .../server-compare.component.html | 8 +++---- .../server-compare.component.ts | 24 ++++++++++++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/app/pages/server-compare/server-compare.component.html b/src/app/pages/server-compare/server-compare.component.html index 9db871a3..d332eabe 100644 --- a/src/app/pages/server-compare/server-compare.component.html +++ b/src/app/pages/server-compare/server-compare.component.html @@ -137,10 +137,10 @@

Server Comparison

- -
- - {{value}} + +
+ + {{numberWithCommas(value)}}
diff --git a/src/app/pages/server-compare/server-compare.component.ts b/src/app/pages/server-compare/server-compare.component.ts index 80513314..7479b983 100644 --- a/src/app/pages/server-compare/server-compare.component.ts +++ b/src/app/pages/server-compare/server-compare.component.ts @@ -144,13 +144,15 @@ export class ServerCompareComponent implements OnInit { }); }); + console.log(this.benchmarkMeta); + this.benchmarkMeta.forEach((benchmark: any) => { benchmark.configs.forEach((config: any) => { this.servers.forEach((server: any) => { const score = server.benchmark_scores ?.find((s: any) => s.benchmark_id === benchmark.benchmark_id && JSON.stringify(s.config) === JSON.stringify(config.config)); config.values.push( - score ? score.score : '-' + score ? (Math.floor(score.score * 100) / 100) : '-' ); }); }); @@ -306,6 +308,22 @@ export class ServerCompareComponent implements OnInit { return isBest ? this.bestCellStyle : ''; } + isBestStyle(value: any, values: any[], benchmark: any) { + if(value === '-' || value === 0) return ''; + let isBest = true; + values.forEach((v) => { + if(!isNaN(v)) { + if(benchmark.higher_is_better === false && v < value) { + isBest = false; + } else if(v > value) { + isBest = false; + } + } + }); + + return isBest ? this.bestCellStyle : ''; + } + viewServer(server: ServerPKsWithPrices) { window.open(`/server/${server.vendor_id}/${server.api_reference}`, '_blank'); } @@ -369,4 +387,8 @@ export class ServerCompareComponent implements OnInit { return result; } + public numberWithCommas(x: number) { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); + } + } From 9a4a8c0b3d3a92634a830946da097839d63689e9 Mon Sep 17 00:00:00 2001 From: Palabola Date: Tue, 11 Jun 2024 11:54:03 +0200 Subject: [PATCH 4/5] right align --- src/app/pages/server-compare/server-compare.component.html | 2 +- src/app/pages/server-compare/server-compare.component.scss | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/pages/server-compare/server-compare.component.html b/src/app/pages/server-compare/server-compare.component.html index d332eabe..3d99b58e 100644 --- a/src/app/pages/server-compare/server-compare.component.html +++ b/src/app/pages/server-compare/server-compare.component.html @@ -139,7 +139,7 @@

Server Comparison

- + {{numberWithCommas(value)}} diff --git a/src/app/pages/server-compare/server-compare.component.scss b/src/app/pages/server-compare/server-compare.component.scss index f4213dd1..f5f15837 100644 --- a/src/app/pages/server-compare/server-compare.component.scss +++ b/src/app/pages/server-compare/server-compare.component.scss @@ -45,3 +45,7 @@ } } } + +.number_line { + text-align: right !important; +} From d254cbbcf9b357c0a52a52ab411c87ffc0737aef Mon Sep 17 00:00:00 2001 From: Palabola Date: Tue, 11 Jun 2024 13:45:28 +0200 Subject: [PATCH 5/5] revert number align --- src/app/pages/server-compare/server-compare.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/pages/server-compare/server-compare.component.html b/src/app/pages/server-compare/server-compare.component.html index 3d99b58e..d332eabe 100644 --- a/src/app/pages/server-compare/server-compare.component.html +++ b/src/app/pages/server-compare/server-compare.component.html @@ -139,7 +139,7 @@

Server Comparison

- + {{numberWithCommas(value)}}