Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(provider): settings feature #476

Merged
merged 74 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
ebe6471
added server-access and server-form files
jigar-arc10 Aug 22, 2024
6342ed9
added wallet import page - wip, fixed issue with file upload in serve…
jigar-arc10 Aug 23, 2024
7f89ed8
added become-provider steps ui
jigar-arc10 Aug 29, 2024
58055d7
server access step added with state support
jigar-arc10 Sep 18, 2024
192d116
added provider config and provider attribute screen
jigar-arc10 Sep 19, 2024
da07743
added provider process with hoc to prevent access to pages
jigar-arc10 Oct 7, 2024
329e06c
added progress for becoming prvider for final stage
jigar-arc10 Oct 8, 2024
51e5ef0
Code clean up and added navigation logic to homecontainer
jigar-arc10 Oct 10, 2024
c977e2e
package lock updated
jigar-arc10 Oct 10, 2024
66d0f11
fixed package-lock.json merge issue
jigar-arc10 Oct 10, 2024
25ed729
more cleanup and remove general warnings
jigar-arc10 Oct 10, 2024
897066e
removed unused npm package
jigar-arc10 Oct 10, 2024
aefe70b
fix minor error on api
jigar-arc10 Oct 11, 2024
8e5eb6a
Added dashboard and actions page
jigar-arc10 Oct 11, 2024
ea30723
change status api endpoint
jigar-arc10 Oct 11, 2024
d024c0d
Merge branch 'feature/provider-console/become-provider-process' into …
jigar-arc10 Oct 11, 2024
ead4eac
added stat line and pie charts
jigar-arc10 Oct 11, 2024
f5c243f
Added console apis to get dashboard data and show appropriate details
jigar-arc10 Oct 11, 2024
4472dbd
fixed actions and changed home component
jigar-arc10 Oct 12, 2024
8df762a
token varification and refresh token fix
jigar-arc10 Oct 15, 2024
d4288b3
changed wallet connect from wallet status to wallet provider
jigar-arc10 Oct 15, 2024
6e8b289
fixed issue in loading provider status
jigar-arc10 Oct 16, 2024
44934ae
fixed home loading issue
jigar-arc10 Oct 16, 2024
d91d340
fixed refresh token, added disabled menu items
jigar-arc10 Oct 16, 2024
fd62ae2
fixed build process
jigar-arc10 Oct 16, 2024
3276a95
feat(provider): added sentry and docker
jigar-arc10 Oct 17, 2024
8f123e1
fix(provider): fixed wallet switching and getting status
jigar-arc10 Oct 18, 2024
5fa9f63
feat(provider): reduced number of events in dashboard
jigar-arc10 Oct 18, 2024
2b0d5e0
feat(provider): added docker compose changes for provider-console
jigar-arc10 Oct 18, 2024
781a99c
feat(provider): added deployments and deployment detail page
jigar-arc10 Oct 18, 2024
ee5d564
fix(provider): change hours to seconds for calculation purpose)
jigar-arc10 Oct 18, 2024
7057434
feat(provider): added auth for deployments and deployment details page
jigar-arc10 Oct 18, 2024
8648e13
feat(provider): added env and removed settingsprovider
jigar-arc10 Oct 29, 2024
f1637fd
fix(provider): fix lint errors and removed console.logs
jigar-arc10 Oct 29, 2024
614c4ba
fix(provider): become-provider looped, fixed it
jigar-arc10 Oct 30, 2024
5d08b82
fix(provider): router and reset process fixed
jigar-arc10 Oct 30, 2024
1110b35
fix(provider): removed Get Started button for now
jigar-arc10 Oct 30, 2024
f2696bf
fix(provider): removed unused import in nav
jigar-arc10 Oct 30, 2024
7344be9
fix(provider): change functions to react fc component
jigar-arc10 Oct 30, 2024
7f9da2b
fix(provider): fix lint issues
jigar-arc10 Oct 30, 2024
c9df37a
fix(provider): change functions to react fc component
jigar-arc10 Oct 31, 2024
1f2d277
fix(provider): rebased main
jigar-arc10 Oct 31, 2024
a97c913
fix(provider): added docker build and fix build related issues
jigar-arc10 Nov 5, 2024
91e8bcd
feat(provider): control machine edit, add from sidebar
jigar-arc10 Nov 5, 2024
c2bb251
feat(provider): added attributes screen
jigar-arc10 Nov 5, 2024
f4629af
fix(provider): control machine auto connect on page load
jigar-arc10 Nov 5, 2024
aa5009a
Merge branch 'feature/provider/control-machine' into feature/provider…
jigar-arc10 Nov 5, 2024
3811d55
fix(provider): fix loading not showing while connecting provider cont…
jigar-arc10 Nov 6, 2024
2df1f61
Merge branch 'feature/provider/control-machine' into feature/provider…
jigar-arc10 Nov 6, 2024
226e744
fix(provider): close drawer on successfull connection
jigar-arc10 Nov 6, 2024
4927267
feat(provider): change favicon to akash favicon
jigar-arc10 Nov 6, 2024
799001a
Merge branch 'feature/provider/control-machine' into feature/provider…
jigar-arc10 Nov 6, 2024
38ec68e
feat(provider): provider add, edit and remove and show acitons list page
jigar-arc10 Nov 6, 2024
e587c32
fix(provider): fix url when provider process finish
jigar-arc10 Nov 6, 2024
a1505e0
feat(provider): provider pricing feature added
jigar-arc10 Nov 6, 2024
d0a552d
feat(provider): added pricing update and extracted provider context
jigar-arc10 Nov 7, 2024
55e1e7f
fix(provider): auto import and lint issues fixed
jigar-arc10 Nov 7, 2024
22a0dc9
feat(provider): added restart provider feature and settings page with…
jigar-arc10 Nov 7, 2024
7e5d747
fix(provider): fix lint issues
jigar-arc10 Nov 7, 2024
81aa543
fix(provider): pricing loading screen fix
jigar-arc10 Nov 7, 2024
ff748cd
Merge branch 'feature/provider/pricing' into feature/provider/settings
jigar-arc10 Nov 7, 2024
13c537b
Merge branch 'main' into feature/provider/control-machine
jigar-arc10 Nov 14, 2024
eeb82b8
fix(provider): merge issues with main
jigar-arc10 Nov 14, 2024
1303c66
Merge branch 'feature/provider/control-machine' into feature/provider…
jigar-arc10 Nov 14, 2024
f519f09
Merge branch 'feature/provider/attributes-actions' into feature/provi…
jigar-arc10 Nov 14, 2024
ad06e23
Merge branch 'feature/provider/pricing' into feature/provider/settings
jigar-arc10 Nov 14, 2024
b26c45d
fix(provider): pricing update fix
jigar-arc10 Dec 2, 2024
da08635
Merge branch 'feature/provider/pricing' into feature/provider/settings
jigar-arc10 Dec 2, 2024
6f06164
Merge branch 'main' into feature/provider/pricing
jigar-arc10 Dec 2, 2024
8dec5aa
chore: package-lock modified
jigar-arc10 Dec 2, 2024
499722c
Merge branch 'main' into feature/provider/pricing
jigar-arc10 Dec 4, 2024
7c81903
Merge branch 'feature/provider/pricing' into feature/provider/settings
jigar-arc10 Dec 4, 2024
11c3906
chore: merged main into settings
jigar-arc10 Dec 10, 2024
b2f9482
fix(provider): issue related to string coming empty
jigar-arc10 Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/provider-console/src/components/layout/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export const Sidebar: React.FC<Props> = ({ isMobileOpen, handleDrawerToggle, isN
{
title: "Settings",
icon: props => <Settings {...props} />,
url: "#",
activeRoutes: ["#"],
disabled: true
url: UrlService.settings(),
activeRoutes: [UrlService.settings()],
disabled: false
}
]
},
Expand Down
112 changes: 112 additions & 0 deletions apps/provider-console/src/pages/settings/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { useState } from "react";
import { Alert, Button, Input } from "@akashnetwork/ui/components";
import { cn } from "@akashnetwork/ui/utils";
import { z } from "zod";

import { Layout } from "@src/components/layout/Layout";
import { Title } from "@src/components/shared/Title";
import { withAuth } from "@src/components/shared/withAuth";
import { useControlMachine } from "@src/context/ControlMachineProvider";
import { useProvider } from "@src/context/ProviderContext";
import restClient from "@src/utils/restClient";
import { sanitizeMachineAccess } from "@src/utils/sanityUtils";
import { stripProviderPrefixAndPort } from "@src/utils/urlUtils";

const urlSchema = z.string().url();

const SettingsPage: React.FC = () => {
const [url, setUrl] = useState("");
const [urlError, setUrlError] = useState("");
const [isRestartLoading, setIsRestartLoading] = useState(false);
const [showSuccess, setShowSuccess] = useState(false);

const { providerDetails } = useProvider();
const { activeControlMachine } = useControlMachine();

const handleUrlUpdate = () => {
try {
urlSchema.parse(url);

// TODO: call update provider url api here
setUrlError("");
} catch (error) {
setUrlError("Please enter a valid URL");
}
};

const restartProvider = async () => {
try {
setIsRestartLoading(true);
const request = {
control_machine: sanitizeMachineAccess(activeControlMachine)
};
const response = await restClient.post("/restart-provider", request);
if (response) {
setShowSuccess(true);
setTimeout(() => setShowSuccess(false), 20000);
}
} catch (error) {
console.error(error);
} finally {
setIsRestartLoading(false);
}
};

const upgradeProvider = () => {
// TODO: call upgrade provider api here
};

if (!activeControlMachine) {
return (
<Layout>
<Alert>Please update control machine before accessing provider settings</Alert>
</Layout>
);
}

return (
<Layout>
<div className="flex items-center">
<div className="w-10 flex-1">
<Title>Settings</Title>
</div>
</div>

<div className="mt-8 space-y-8">
<div className="rounded-lg border p-6">
<h2 className="text-xl font-semibold">Restart Provider</h2>
<p className="mt-2 text-gray-600">Restart your provider instance. This may cause temporary service interruption.</p>
<Button onClick={() => restartProvider()} className="mt-4" disabled={isRestartLoading}>
{isRestartLoading ? "Restarting..." : "Restart Provider"}
</Button>
<div className="mt-4">{showSuccess && <div className="text-green-500">Provider restarted successfully</div>}</div>
</div>

<div className="rounded-lg border p-6">
<h2 className="text-xl font-semibold">Upgrade Provider</h2>
<p className="mt-2 text-gray-600">Upgrade your provider to the latest version.</p>
<Button onClick={() => upgradeProvider()} className="mt-4" variant="outline">
Upgrade Provider
</Button>
</div>

<div className="rounded-lg border p-6">
<h2 className="text-xl font-semibold">Provider URL</h2>
<p className="mt-2 text-gray-600">Update the URL for your provider service.</p>
<div className="mt-4 flex gap-4">
<Input
value={url || stripProviderPrefixAndPort(providerDetails?.hostUri || "")}
onChange={e => setUrl(e.target.value)}
placeholder={"Enter new URL"}
error={urlError ? true : undefined}
className={cn("min-w-[400px]")}
/>
<Button onClick={handleUrlUpdate}>Update URL</Button>
</div>
</div>
</div>
</Layout>
);
};

export default withAuth(SettingsPage);
9 changes: 8 additions & 1 deletion apps/provider-console/src/utils/urlUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ export class UrlService {
static home = () => "/";
static deployments = () => "/deployments";
static attributes = () => "/attributes";
static settings = () => "/settings";
static getStarted = () => "/get-started";
static privacyPolicy = () => "/privacy-policy";
static termsOfService = () => "/terms-of-service";
static actions = () => "/actions";
static pricing = () => "/pricing";
}
}

export const stripProviderPrefixAndPort = (url: string) => {
return url
.replace(/^https?:\/\/provider\./, '') // Remove https://provider. or http://provider.
.replace(/:\d+$/, ''); // Remove port number at the end
};
Loading