diff --git a/src/app/pages/server-compare/server-compare.component.html b/src/app/pages/server-compare/server-compare.component.html index ca80f4d0..d332eabe 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)}} -
-
+ + + +
+ + {{numberWithCommas(value)}} -
- + +
View Server 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; +} diff --git a/src/app/pages/server-compare/server-compare.component.ts b/src/app/pages/server-compare/server-compare.component.ts index 741c455e..7479b983 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,42 @@ 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; }); - }) - } + } + }); }); - */ + 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 ? (Math.floor(score.score * 100) / 100) : '-' + ); + }); + }); + }); this.isLoading = false; }).catch((err) => { @@ -286,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'); } @@ -327,7 +365,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,19 +377,18 @@ export class ServerCompareComponent implements OnInit { } serializeConfig(config: any) { - let result = ''; + let result = ''; + return result; } + public numberWithCommas(x: number) { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); + } + } 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);