Skip to content

Commit 13ba959

Browse files
authored
Cleanup unused code, lazy load jspdf & sentry, optimize lodash imports to enable tree shaking, use dynamic routes, configure vite optimizeDeps, remove duplicate project name (#4432)
1 parent 6d745a9 commit 13ba959

21 files changed

Lines changed: 79 additions & 88 deletions

packages/playground/src/calculator/pricing_calculator.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@
235235
<script lang="ts">
236236
import { QueryClient } from "@threefold/tfchain_client";
237237
import { computed, ref, watch } from "vue";
238-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
238+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Used in template
239239
import type { VForm } from "vuetify/components/VForm";
240240
241241
import { manual } from "@/utils/manual";

packages/playground/src/components/filter.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878

7979
<script lang="ts" setup>
8080
import type { NodeStatus } from "@threefold/gridproxy_client";
81-
import { cloneDeep, isEmpty } from "lodash";
81+
import cloneDeep from "lodash/cloneDeep.js";
82+
import isEmpty from "lodash/isEmpty.js";
8283
import equals from "lodash/fp/equals.js";
8384
import { computed, defineComponent, nextTick, onMounted, type PropType, ref, watch } from "vue";
8485
import { type LocationQueryRaw, useRoute } from "vue-router";

packages/playground/src/components/networks.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
</template>
6363

6464
<script lang="ts">
65-
import { noop } from "lodash";
65+
import noop from "lodash/fp/noop.js";
6666
import { computed, getCurrentInstance, onMounted, onUnmounted, ref, watch } from "vue";
6767
6868
import { useForm, ValidatorStatus } from "@/hooks/form_validator";

packages/playground/src/components/node_selector/TfDomainName.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104

105105
<script lang="ts">
106106
import { type FarmInfo, Features, type FilterOptions, type NodeInfo } from "@threefold/grid_client";
107-
import { noop } from "lodash";
107+
import noop from "lodash/fp/noop.js";
108108
import { computed, getCurrentInstance, nextTick, onMounted, onUnmounted, type PropType, ref, watch } from "vue";
109109
110110
import { type InputValidatorService, useInputRef } from "@/hooks/input_validator";
@@ -114,7 +114,7 @@ import { useForm, useFormRef, ValidatorStatus } from "../../hooks/form_validator
114114
import { useWatchDeep } from "../../hooks/useWatchDeep";
115115
import { useGrid } from "../../stores";
116116
import type { DomainInfo, NetworkFeatures, SelectionDetailsFilters } from "../../types/nodeSelector";
117-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
117+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Used in template
118118
import type { INode } from "../../utils/filter_nodes";
119119
import { getNodePageCount, loadNodes } from "../../utils/nodeSelector";
120120

packages/playground/src/components/node_selector/TfSelectGpu.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
<script lang="ts">
4040
import type { GPUCardInfo, NodeInfo } from "@threefold/grid_client";
41-
import { noop } from "lodash";
41+
import noop from "lodash/fp/noop.js";
4242
import { getCurrentInstance, onMounted, onUnmounted, type PropType, ref } from "vue";
4343
4444
import type { InputValidatorService } from "@/hooks/input_validator";

packages/playground/src/components/simulator.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@
139139
<v-row v-if="!isAdvanced" class="mt-1 px-4">
140140
<div class="d-flex align-center">
141141
<label class="label mr-2 mb-0">Net Profit</label>
142-
<!-- <v-switch hide-details color="primary" v-model="isProfit" inset disabled /> -->
143142
<span class="slider" />
144-
<!-- <label class="label ml-2">Return On Investment</label> -->
145143
</div>
146144
</v-row>
147145
<v-row v-show="!isAdvanced">
@@ -167,7 +165,6 @@
167165
/>
168166
</input-validator>
169167

170-
<!-- <v-text-field disabled label="Return On Investment" v-model.number="ROI" /> -->
171168
<v-text-field v-model.number="netProfit" disabled label="Net Profit" type="number" />
172169
<v-text-field v-model.number="grossProfit" disabled label="Gross Profit" type="number" />
173170
<v-text-field v-model.number="totalCosts" disabled label="Total Costs" type="number" />

packages/playground/src/components/ssh_keys/ManageSshDeployemnt.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
<v-alert v-if="selectedKeys.length === 0" type="warning" class="mt-2">
1111
Attention: It appears that no SSH keys have been selected. In order to access your deployment, you must send
1212
at least one SSH key. You can manage your SSH keys from the
13-
<router-link :to="DashboardRoutes.Deploy.SSHKey">
14-
SSH keys management page
15-
</router-link>
13+
<router-link :to="DashboardRoutes.Deploy.SSHKey"> SSH keys management page </router-link>
1614
and add more as needed.
1715
</v-alert>
1816
<v-alert type="info" class="mt-3">
@@ -52,7 +50,7 @@
5250
</template>
5351

5452
<script lang="ts">
55-
import { noop } from "lodash";
53+
import noop from "lodash/fp/noop.js";
5654
import { capitalize, defineComponent, getCurrentInstance, onMounted, onUnmounted, ref, watch } from "vue";
5755
import { useTheme } from "vuetify";
5856
@@ -92,11 +90,10 @@ export default defineComponent({
9290
9391
function chipClass(key: SSHKeyData) {
9492
if (isKeySelected(key)) return ["bg-primary", "v-chip--selected"];
95-
93+
9694
const keys = document.querySelectorAll(".keys .v-chip");
9795
keys.forEach(key => key.classList.remove("v-chip--selected"));
9896
return "anchor";
99-
10097
}
10198
10299
function selectKey(key: SSHKeyData) {

packages/playground/src/components/ssh_keys/SshTable.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@
9393
</v-data-table>
9494
</v-card-text>
9595

96-
<!-- <v-divider /> -->
97-
9896
<v-card-actions class="justify-end my-1 mr-2">
9997
<v-tooltip location="bottom" text="Export all selected keys.">
10098
<template #activator="{ props }">

packages/playground/src/dashboard/components/NodeMintingDetails.vue

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@
5959
</v-row>
6060
<v-row class="row-style">
6161
<v-col class="py-1" cols="1" sm="2" style="min-width: fit-content">
62-
<v-list-item style="text-transform: uppercase">
63-
CU :
64-
</v-list-item>
62+
<v-list-item style="text-transform: uppercase"> CU : </v-list-item>
6563
</v-col>
6664
<v-col class="py-1">
6765
<v-list-item>
@@ -79,9 +77,7 @@
7977
</v-row>
8078
<v-row class="row-style">
8179
<v-col class="py-1" cols="1" sm="2" style="min-width: fit-content">
82-
<v-list-item style="text-transform: uppercase">
83-
SU :
84-
</v-list-item>
80+
<v-list-item style="text-transform: uppercase"> SU : </v-list-item>
8581
</v-col>
8682
<v-col class="py-1">
8783
<v-list-item>
@@ -99,9 +95,7 @@
9995
</v-row>
10096
<v-row class="row-style">
10197
<v-col class="py-1" cols="1" sm="2" style="min-width: fit-content">
102-
<v-list-item style="text-transform: uppercase">
103-
NU :
104-
</v-list-item>
98+
<v-list-item style="text-transform: uppercase"> NU : </v-list-item>
10599
</v-col>
106100
<v-col class="py-1">
107101
<v-list-item>
@@ -126,22 +120,17 @@
126120
</v-row>
127121
</div>
128122
<div v-else>
129-
<v-card-text class="font-weight-bold">
130-
No receipts found for this month
131-
</v-card-text>
123+
<v-card-text class="font-weight-bold"> No receipts found for this month </v-card-text>
132124
</div>
133125
<v-card-actions>
134126
<v-spacer />
135-
<v-btn color="secondary" :disabled="!node.receipts" @click="downloadNodeReceipt">
136-
Download Node Receipt
137-
</v-btn>
127+
<v-btn color="secondary" :disabled="!node.receipts" @click="downloadNodeReceipt"> Download Node Receipt </v-btn>
138128
</v-card-actions>
139129
</v-card>
140130
</v-container>
141131
</template>
142132

143133
<script lang="ts">
144-
import { jsPDF } from "jspdf";
145134
import moment from "moment";
146135
import { computed, type PropType, ref } from "vue";
147136
@@ -174,6 +163,9 @@ export default {
174163
const selectedData = computed(() => [selectedMonth.value, selectedYear.value].filter(Boolean).join(", "));
175164
176165
async function downloadNodeReceipt() {
166+
// Lazy load jspdf and jspdf-autotable only when PDF download is requested
167+
await import("jspdf-autotable");
168+
const { jsPDF } = await import("jspdf");
177169
let doc = new jsPDF();
178170
doc = await generateReceipt(doc, props.node);
179171
doc.save(`node_${props.node.nodeId}_receipts.pdf`);

packages/playground/src/dashboard/components/public_config.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@
160160
import type { PublicConfig } from "@threefold/grid_client";
161161
import { ValidationError } from "@threefold/types";
162162
import CidrTools from "cidr-tools";
163-
import { isEqual } from "lodash";
163+
import isEqual from "lodash/isEqual.js";
164164
import { default as PrivateIp } from "private-ip";
165165
import { onMounted, ref, watch } from "vue";
166166
167-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
167+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Used in template
168168
import type { RuleReturn } from "@/components/input_validator.vue";
169169
import { useFormRef } from "@/hooks/form_validator";
170170
import { useGrid } from "@/stores";

0 commit comments

Comments
 (0)