Skip to content

Commit

Permalink
refactor(db): use boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
steveiliop56 committed Apr 1, 2024
1 parent 4bfe86b commit c0fb1cd
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion migrations/0001_running_status.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ALTER TABLE shells ADD `running` text;
ALTER TABLE shells ADD `running` text 1;
2 changes: 1 addition & 1 deletion src/app/actions/create-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function create(name: string, distro: string, extraArgs: string) {
port: port,
password: createRandomPassowrd(),
extraArgs: extraArgs,
running: "true",
running: true,
};

const { success, error } = await new containerHelpers(data).createContainer();
Expand Down
2 changes: 1 addition & 1 deletion src/app/actions/start-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { containerHelpers } from "@/utils/container-helpers";
import { revalidatePath } from "next/cache";

export const start = async (shell: containerData) => {
shell.running = "true";
shell.running = true;
const { success, error } = await new containerHelpers(shell).startContainer();

if (success) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/actions/stop-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { containerHelpers } from "@/utils/container-helpers";
import { revalidatePath } from "next/cache";

export const stop = async (shell: containerData) => {
shell.running = "false";
shell.running = false;
const { success, error } = await new containerHelpers(shell).stopContainer();

if (success) {
Expand Down
5 changes: 3 additions & 2 deletions src/app/components/render-shell/render-shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { stop } from "../../actions/stop-action";
import { start } from "../../actions/start-action";

export const renderShell = (shell: containerData) => {
console.log(shell);
const handleStopStart = async () => {
if (shell.running == "true") {
if (shell.running) {
toast.info(`Stopping ${shell.name}...`);
const { success } = await stop(shell);
if (success) {
Expand All @@ -36,7 +37,7 @@ export const renderShell = (shell: containerData) => {
</Flex>
<Flex className="flex-row gap-1 items-center">
<SettingsDialog shell={shell} />
{shell.running == "true" ? (
{shell.running ? (
<Button onClick={() => handleStopStart()} color="red">
Stop
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/server/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export const shells = sqliteTable("shells", {
port: integer("port").notNull(),
password: text("password").notNull(),
extraArgs: text("extraArgs"),
running: text("running"),
running: integer("running", { mode: "boolean" }),
});
2 changes: 1 addition & 1 deletion src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export interface containerData {
port: number;
password: string;
extraArgs: string | null;
running: string | null;
running: boolean | null;
}

0 comments on commit c0fb1cd

Please sign in to comment.