@smartnet360/svelte-components 0.0.112 → 0.0.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,6 +10,33 @@
|
|
|
10
10
|
let groupBy: CellTableGroupField = $state('none');
|
|
11
11
|
let columnPreset: ColumnPreset = $state('default');
|
|
12
12
|
let searchTerm = $state('');
|
|
13
|
+
|
|
14
|
+
// Loading states
|
|
15
|
+
let isCreating = $state(false);
|
|
16
|
+
let isReloading = $state(false);
|
|
17
|
+
let isLoading = $derived(isCreating || isReloading);
|
|
18
|
+
|
|
19
|
+
// Check if 5G-3500 already exists for the searched site
|
|
20
|
+
let has5G3500 = $derived.by(() => {
|
|
21
|
+
const siteId = searchTerm.trim();
|
|
22
|
+
if (!siteId) return false;
|
|
23
|
+
return demoCells.some(cell =>
|
|
24
|
+
cell.siteId.toLowerCase() === siteId.toLowerCase() &&
|
|
25
|
+
cell.fband === '5G-3500'
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Create button disabled state
|
|
30
|
+
let createDisabled = $derived(!searchTerm.trim() || isLoading || has5G3500);
|
|
31
|
+
|
|
32
|
+
// Tooltip for create button
|
|
33
|
+
let createTooltip = $derived.by(() => {
|
|
34
|
+
if (!searchTerm.trim()) return 'Enter a site ID first';
|
|
35
|
+
if (has5G3500) return '5G-3500 already exists for this site';
|
|
36
|
+
if (isCreating) return 'Creating...';
|
|
37
|
+
if (isReloading) return 'Reloading...';
|
|
38
|
+
return 'Create 5G-3500 cell for this site';
|
|
39
|
+
});
|
|
13
40
|
|
|
14
41
|
function handleSelectionChange(event: RowSelectionEvent) {
|
|
15
42
|
console.log('Selection changed:', event.ids);
|
|
@@ -40,6 +67,64 @@
|
|
|
40
67
|
handleSearch();
|
|
41
68
|
}
|
|
42
69
|
}
|
|
70
|
+
|
|
71
|
+
// ============================================
|
|
72
|
+
// PLACEHOLDER FUNCTIONS - Replace with your API calls
|
|
73
|
+
// ============================================
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Create a new 5G-3500 cell for the given site
|
|
77
|
+
* TODO: Replace with your actual API call
|
|
78
|
+
*/
|
|
79
|
+
async function createCellForSite(siteId: string): Promise<void> {
|
|
80
|
+
// Simulate API call - replace with your implementation
|
|
81
|
+
console.log(`Creating 5G-3500 cell for site: ${siteId}`);
|
|
82
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
83
|
+
console.log(`Cell created for site: ${siteId}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Reload site data after creation
|
|
88
|
+
* TODO: Replace with your actual API call
|
|
89
|
+
*/
|
|
90
|
+
async function reloadSiteData(siteId: string): Promise<typeof demoCells> {
|
|
91
|
+
// Simulate API call - replace with your implementation
|
|
92
|
+
console.log(`Reloading data for site: ${siteId}`);
|
|
93
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
94
|
+
// For demo, just return filtered data
|
|
95
|
+
const allCells = generateCellsFromPreset(datasetSize);
|
|
96
|
+
return allCells.filter(cell =>
|
|
97
|
+
cell.siteId.toLowerCase().includes(siteId.toLowerCase())
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ============================================
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Handle create cell button click
|
|
105
|
+
*/
|
|
106
|
+
async function handleCreateCell() {
|
|
107
|
+
const siteId = searchTerm.trim();
|
|
108
|
+
if (!siteId || isLoading || has5G3500) return;
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
// Step 1: Create the cell
|
|
112
|
+
isCreating = true;
|
|
113
|
+
await createCellForSite(siteId);
|
|
114
|
+
isCreating = false;
|
|
115
|
+
|
|
116
|
+
// Step 2: Reload the data
|
|
117
|
+
isReloading = true;
|
|
118
|
+
demoCells = await reloadSiteData(siteId);
|
|
119
|
+
isReloading = false;
|
|
120
|
+
|
|
121
|
+
console.log('Cell created and data reloaded successfully');
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error('Error creating cell:', error);
|
|
124
|
+
isCreating = false;
|
|
125
|
+
isReloading = false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
43
128
|
</script>
|
|
44
129
|
|
|
45
130
|
<div class="cell-table-page vh-100 d-flex flex-column">
|
|
@@ -79,22 +164,48 @@
|
|
|
79
164
|
onselectionchange={handleSelectionChange}
|
|
80
165
|
>
|
|
81
166
|
{#snippet headerSearch()}
|
|
82
|
-
<div class="
|
|
83
|
-
<input
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
167
|
+
<div class="d-flex align-items-center gap-2">
|
|
168
|
+
<div class="input-group input-group-sm" style="width: 180px;">
|
|
169
|
+
<input
|
|
170
|
+
type="text"
|
|
171
|
+
class="form-control"
|
|
172
|
+
placeholder="Search site or cell..."
|
|
173
|
+
bind:value={searchTerm}
|
|
174
|
+
onkeydown={handleSearchKeydown}
|
|
175
|
+
disabled={isLoading}
|
|
176
|
+
/>
|
|
177
|
+
<button
|
|
178
|
+
class="btn btn-outline-primary"
|
|
179
|
+
type="button"
|
|
180
|
+
onclick={handleSearch}
|
|
181
|
+
title="Search"
|
|
182
|
+
aria-label="Search"
|
|
183
|
+
disabled={isLoading}
|
|
184
|
+
>
|
|
185
|
+
{#if isReloading}
|
|
186
|
+
<span class="spinner-border spinner-border-sm" role="status"></span>
|
|
187
|
+
{:else}
|
|
188
|
+
<i class="bi bi-search"></i>
|
|
189
|
+
{/if}
|
|
190
|
+
</button>
|
|
191
|
+
</div>
|
|
90
192
|
<button
|
|
91
|
-
class="btn btn-
|
|
193
|
+
class="btn btn-sm"
|
|
194
|
+
class:btn-outline-success={!has5G3500}
|
|
195
|
+
class:btn-success={has5G3500}
|
|
92
196
|
type="button"
|
|
93
|
-
onclick={
|
|
94
|
-
title=
|
|
95
|
-
aria-label="
|
|
197
|
+
onclick={handleCreateCell}
|
|
198
|
+
title={createTooltip}
|
|
199
|
+
aria-label="Create 5G-3500 cell"
|
|
200
|
+
disabled={createDisabled}
|
|
96
201
|
>
|
|
97
|
-
|
|
202
|
+
{#if isCreating}
|
|
203
|
+
<span class="spinner-border spinner-border-sm" role="status"></span>
|
|
204
|
+
{:else if has5G3500}
|
|
205
|
+
<i class="bi bi-check-lg"></i>
|
|
206
|
+
{:else}
|
|
207
|
+
<i class="bi bi-plus-lg"></i>
|
|
208
|
+
{/if}
|
|
98
209
|
</button>
|
|
99
210
|
</div>
|
|
100
211
|
{/snippet}
|