Skip to content

Commit

Permalink
Merge pull request #247 from stakwork/update/group-endpoint
Browse files Browse the repository at this point in the history
Update/group endpoint
  • Loading branch information
tobi-bams authored Jul 10, 2024
2 parents 9b50018 + 074220e commit cf1a2ca
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
17 changes: 12 additions & 5 deletions app/src/components/Endpoint.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@
async function handleUpdatePaidEndpoint(status) {
disabled = true;
const result = await update_paid_endpoint(id, status);
const parsedResult = JSON.parse(result);
success = parsedResult.success;
disabled = false;
sendDataToParent(success);
for (let i = 0; i < id.length; i++) {
try {
const result = await update_paid_endpoint(id[i], status);
const parsedResult = JSON.parse(result);
success = parsedResult.success;
} catch (error) {
console.error(`Error Updating endpoint status: ${error}`);
}
disabled = false;
sendDataToParent(success);
}
}
</script>

Expand Down
24 changes: 22 additions & 2 deletions app/src/components/EnpointPermission.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,28 @@
async function getAllPaidEndpoint() {
const endpoints = await list_all_paid_endpoint();
const parsedEndpoints = JSON.parse(endpoints);
const endpointsObj = {};
const tempAllEndpoints = [];
if (parsedEndpoints.success) {
allEndpoints = [...parsedEndpoints.endpoints];
for (let i = 0; i < parsedEndpoints.endpoints.length; i++) {
const parsedEndpoint = parsedEndpoints.endpoints[i];
const routeDescription = parsedEndpoint.route_description;
if (endpointsObj[routeDescription]) {
endpointsObj[routeDescription].id.push(parsedEndpoint.id);
} else {
endpointsObj[routeDescription] = {
id: [parsedEndpoint.id],
route_description: routeDescription,
price: parsedEndpoint.price,
endpoint: parsedEndpoint.endpoint,
status: parsedEndpoint.status,
};
}
}
for (let key in endpointsObj) {
tempAllEndpoints.push(endpointsObj[key]);
}
allEndpoints = [...tempAllEndpoints];
}
}
Expand All @@ -37,7 +57,7 @@
</div>
{/if}
</div>
{#each allEndpoints as endpoint, index (endpoint.id)}
{#each allEndpoints as endpoint, index (endpoint.route_description)}
<Endpoint
on:customEvent={handleCustomEvent}
description={endpoint.route_description}
Expand Down
17 changes: 17 additions & 0 deletions app/src/components/SecondBrain/general.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
settings: {
value: true,
},
chatInterface: {
value: true,
},
};
$: about = {};
$: isSuccess = false;
Expand All @@ -43,6 +46,7 @@
addItem: { value: true, isChange: false },
addContent: { value: true, isChange: false },
settings: { value: true, isChange: false },
chatInterface: { value: true, isChange: false },
};
const featureFlags = [
Expand All @@ -66,6 +70,11 @@
label: "Settings",
description: "Toggle Settings on the Graph",
},
{
key: "chatInterface",
label: "AI Summary",
description: "Toggle AI Summary Feature flag",
},
];
function handleCheckBoxChange(e, value) {
Expand Down Expand Up @@ -248,6 +257,9 @@
settings: {
value: parsedFeatureFlag.data.settings.user,
},
chatInterface: {
value: parsedFeatureFlag.data.chatInterface.user,
},
};
//update changedState
Expand All @@ -267,6 +279,10 @@
value: parsedFeatureFlag.data.settings.user,
isChange: false,
},
chatInterface: {
value: parsedFeatureFlag.data.chatInterface.user,
isChange: false,
},
};
});
</script>
Expand Down Expand Up @@ -508,6 +524,7 @@
flex-direction: column;
margin-top: 1.38rem;
gap: 1.38rem;
margin-bottom: 1.5rem;
}
.checkbox-container {
Expand Down

0 comments on commit cf1a2ca

Please sign in to comment.