From 34fcc7894b44172c95470fd9f8a6c01a39adfd31 Mon Sep 17 00:00:00 2001 From: maayarosama <66883096+maayarosama@users.noreply.github.com> Date: Tue, 17 Oct 2023 09:49:42 +0300 Subject: [PATCH] Adding simulator to playground (#1131) * Adding simulator to playground * adding graphs and remaining fields * fixing charts bug * undoing changes * Remove unrelated files from pr * Remove unrelated files from pr #2 * using vue-chartjs instead of chartjs * Converting FarmingProfile class into a vue component * fixing line chart * Removing props from charts' divs --------- Co-authored-by: MohamedElmdary --- packages/playground/package.json | 3 + .../playground/src/components/line_chart.vue | 78 ++++ .../playground/src/components/pie_chart.vue | 49 +++ .../playground/src/components/simulator.vue | 406 ++++++++++++++++++ packages/playground/src/plugins/vuetify.ts | 1 + .../playground/src/portal/simulator_view.vue | 69 +++ packages/playground/src/router/index.ts | 6 + packages/playground/src/types/index.ts | 28 ++ 8 files changed, 640 insertions(+) create mode 100644 packages/playground/src/components/line_chart.vue create mode 100644 packages/playground/src/components/pie_chart.vue create mode 100644 packages/playground/src/components/simulator.vue create mode 100644 packages/playground/src/portal/simulator_view.vue diff --git a/packages/playground/package.json b/packages/playground/package.json index adb32dd828..5a1d4be524 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -31,6 +31,8 @@ "vue-router": "^4.1.6", "vuetify": "^3.1.15", "web-ssh-keygen": "^0.1.2", + "chart.js": "^4.4.0", + "vue-chartjs": "^5.2.0", "moment": "^2.29.4" }, "devDependencies": { @@ -39,6 +41,7 @@ "@types/marked": "^5.0.0", "@types/node": "^18.14.2", "@types/qrcode": "^1.5.0", + "@types/chart.js": "^2.9.38", "@vitejs/plugin-vue": "^4.0.0", "@vue/eslint-config-prettier": "^7.1.0", "@vue/eslint-config-typescript": "^11.0.2", diff --git a/packages/playground/src/components/line_chart.vue b/packages/playground/src/components/line_chart.vue new file mode 100644 index 0000000000..564f8652f9 --- /dev/null +++ b/packages/playground/src/components/line_chart.vue @@ -0,0 +1,78 @@ + + + + diff --git a/packages/playground/src/components/pie_chart.vue b/packages/playground/src/components/pie_chart.vue new file mode 100644 index 0000000000..eab8852fc8 --- /dev/null +++ b/packages/playground/src/components/pie_chart.vue @@ -0,0 +1,49 @@ + + + + diff --git a/packages/playground/src/components/simulator.vue b/packages/playground/src/components/simulator.vue new file mode 100644 index 0000000000..a9ff76f1b2 --- /dev/null +++ b/packages/playground/src/components/simulator.vue @@ -0,0 +1,406 @@ + + + + + diff --git a/packages/playground/src/plugins/vuetify.ts b/packages/playground/src/plugins/vuetify.ts index aefe3b1a8a..38bee4b0d7 100644 --- a/packages/playground/src/plugins/vuetify.ts +++ b/packages/playground/src/plugins/vuetify.ts @@ -21,6 +21,7 @@ const vuetify = createVuetify({ primary: "#1aa18f", secondary: "#74DDC3", title: "#1AA18F", + disclaimer: "#4D776D", info: "#7de3c8", warning: "#FFCC00", link: "#5695ff", diff --git a/packages/playground/src/portal/simulator_view.vue b/packages/playground/src/portal/simulator_view.vue new file mode 100644 index 0000000000..2c86ab505e --- /dev/null +++ b/packages/playground/src/portal/simulator_view.vue @@ -0,0 +1,69 @@ + + + diff --git a/packages/playground/src/router/index.ts b/packages/playground/src/router/index.ts index 5d30113037..116158eda7 100644 --- a/packages/playground/src/router/index.ts +++ b/packages/playground/src/router/index.ts @@ -53,6 +53,12 @@ const router = createRouter({ component: () => import("../calculator/resource_pricing.vue"), meta: { title: "Resource Pricing" }, }, + + { + path: "simulator", + component: () => import("../portal/simulator_view.vue"), + meta: { title: "Twin" }, + }, ], }, { diff --git a/packages/playground/src/types/index.ts b/packages/playground/src/types/index.ts index b14c3c9da7..88d8a1dcae 100644 --- a/packages/playground/src/types/index.ts +++ b/packages/playground/src/types/index.ts @@ -4,6 +4,34 @@ import type { INode } from "@/utils/filter_nodes"; import type * as validators from "../utils/validators"; +export enum ProfileTypes { + DIY, + TITAN, +} + +export enum Certification { + NONE = 0, + CERTIFIED = 1, + GOLD_CERTIFIED = 2, +} + +export interface FarmingProfileOptions { + type: ProfileTypes; + name: string; + memory: number; + cpu: number; + hdd: number; + ssd: number; + price: number; + priceAfter5Years: number; + maximumTokenPrice: number; + powerUtilization: number; + powerCost: number; + certified: Certification; + publicIp: boolean; + investmentCostHW: number; + nuRequiredPerCu: number; +} export interface K8SWorker { name: string; cpu: number;