Skip to content

Commit

Permalink
Merge pull request #176 from mikepsinn/develop
Browse files Browse the repository at this point in the history
Flows
  • Loading branch information
mikepsinn authored Apr 11, 2024
2 parents 2fa4a81 + cc3e99c commit 68ad5a5
Show file tree
Hide file tree
Showing 8 changed files with 9,292 additions and 15 deletions.
117 changes: 117 additions & 0 deletions apps/chat-widget/flowise.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<!DOCTYPE html>
<html>
<head>
<title>Chat Window Iframe Example</title>
<style>
/* Styles for the chat window */
#chat-window {
position: fixed;
right: 20px;
bottom: 20px;
width: 300px;
height: 400px;
border: 1px solid #ccc;
z-index: 1000;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
display: none; /* Initially hidden */
}
</style>
</head>
<body>

<div id="chat-window"></div> <!-- Placeholder for the chat window -->

<script type="module">
import Chatbot from "https://cdn.jsdelivr.net/npm/flowise-embed/dist/web.js"
Chatbot.init({
chatflowid: "3a2b0429-3878-490a-aff2-729cfa0007ef",
apiHost: "https://fw.fdai.earth",
chatflowConfig: {
// topK: 2
},
theme: {
button: {
backgroundColor: "#3B81F6",
right: 20,
bottom: 20,
size: "medium",
iconColor: "white",
customIconSrc: "https://raw.githubusercontent.com/FDA-AI/FDAi/develop/apps/dfda-1/public/app/public/img/robots/robot-head.svg",
},
chatWindow: {
welcomeMessage: "Hi! I'm your personal FDAi! How can I help you?",
backgroundColor: "#ffffff",
height: 700,
width: 400,
fontSize: 16,
poweredByTextColor: "#ffffff",
botMessage: {
backgroundColor: "#f7f8ff",
textColor: "#303235",
showAvatar: true,
avatarSrc: "https://raw.githubusercontent.com/FDA-AI/FDAi/develop/apps/dfda-1/public/app/public/img/robots/robot-head.svg",
},
userMessage: {
backgroundColor: "#3B81F6",
textColor: "#ffffff",
showAvatar: true,
avatarSrc: "https://raw.githubusercontent.com/zahidkhawaja/langchain-chat-nextjs/main/public/usericon.png",
},
textInput: {
placeholder: "Type your question",
backgroundColor: "#ffffff",
textColor: "#303235",
sendButtonColor: "#3B81F6",
}
}
}
})
</script><script type="module">
import Chatbot from "https://cdn.jsdelivr.net/npm/flowise-embed/dist/web.js"
Chatbot.init({
chatflowid: "3a2b0429-3878-490a-aff2-729cfa0007ef",
apiHost: "https://fw.fdai.earth",
chatflowConfig: {
// topK: 2
},
theme: {
button: {
backgroundColor: "#3B81F6",
right: 20,
bottom: 20,
size: "medium",
iconColor: "white",
customIconSrc: "https://raw.githubusercontent.com/FDA-AI/FDAi/develop/apps/dfda-1/public/app/public/img/robots/robot-head.svg",
},
chatWindow: {
welcomeMessage: "Hi! I'm your personal FDAi! How can I help you?",
backgroundColor: "#ffffff",
height: 700,
width: 400,
fontSize: 16,
poweredByTextColor: "#ffffff",
botMessage: {
backgroundColor: "#f7f8ff",
textColor: "#303235",
showAvatar: true,
avatarSrc: "https://raw.githubusercontent.com/FDA-AI/FDAi/develop/apps/dfda-1/public/app/public/img/robots/robot-head.svg",
},
userMessage: {
backgroundColor: "#3B81F6",
textColor: "#ffffff",
showAvatar: true,
avatarSrc: "https://raw.githubusercontent.com/zahidkhawaja/langchain-chat-nextjs/main/public/usericon.png",
},
textInput: {
placeholder: "Type your question",
backgroundColor: "#ffffff",
textColor: "#303235",
sendButtonColor: "#3B81F6",
}
}
}
})
</script>

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import { useRouter } from "next/navigation"
import { Button, ButtonProps } from "@/components/ui/button"
import { toast } from "@/components/ui/use-toast"
import { Icons } from "@/components/icons"
interface UserVariable {
unitAbbreviatedName: string;
combinationOperation: string;
variableCategoryName: string;
id: string;
lastValue: number;
unitName: string;
}
import { UserVariable } from "@/types/models/UserVariable";

interface QuickMeasurementButtonProps extends ButtonProps {
userVariable: UserVariable;
userVariable: Pick<
UserVariable,
"id" | "name" | "description" | "createdAt" | "imageUrl" |
"combinationOperation" | "unitAbbreviatedName" | "variableCategoryName" |
"lastValue" | "unitName"
>
}

export function QuickMeasurementButton({ userVariable, ...props }: QuickMeasurementButtonProps) {
Expand Down
8 changes: 4 additions & 4 deletions apps/nextjs/components/userVariable/user-variable-item.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"use client"

import Link from "next/link"
import { UserVariable } from "@prisma/client"

import { formatDate } from "@/lib/utils"
import { Skeleton } from "@/components/ui/skeleton"
import { UserVariableOperations } from "@/components/userVariable/user-variable-operations"
import { QuickMeasurementButton } from '@/components/userVariable/measurements/quick-measurement-button';
import { UserVariable } from "@/types/models/UserVariable";

interface UserVariableItemProps {
userVariable: Pick<
UserVariable,
"id" | "name" | "description" | "createdAt"
"id" | "name" | "description" | "createdAt" | "imageUrl" |
"combinationOperation" | "unitAbbreviatedName" | "variableCategoryName" |
"lastValue" | "unitName"
>
}

export function UserVariableItem({ userVariable }: UserVariableItemProps) {
return (
<div className="flex items-center justify-between gap-2 p-4">
Expand Down
10 changes: 8 additions & 2 deletions apps/nextjs/components/userVariable/user-variable-operations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import { toast } from "@/components/ui/use-toast"
import { Icons } from "@/components/icons"

import { MeasurementsAddForm } from "./measurements/measurements-add-form"
import { UserVariable } from "@/types/models/UserVariable"

async function deleteUserVariable(userVariableId: string) {
async function deleteUserVariable(userVariableId: number) {
const response = await fetch(`/api/userVariables/${userVariableId}`, {
method: "DELETE",
})
Expand All @@ -47,7 +48,12 @@ async function deleteUserVariable(userVariableId: string) {
}

interface UserVariableOperationsProps {
userVariable: Pick<UserVariable, "id">
userVariable: Pick<
UserVariable,
"id" | "name" | "description" | "createdAt" | "imageUrl" |
"combinationOperation" | "unitAbbreviatedName" | "variableCategoryName" |
"lastValue" | "unitName"
>
children?: React.ReactNode
}

Expand Down
132 changes: 132 additions & 0 deletions apps/nextjs/prisma/migrations/20240408205952_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
-- CreateTable
CREATE TABLE "accounts" (
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"type" TEXT NOT NULL,
"provider" TEXT NOT NULL,
"provider_account_id" TEXT NOT NULL,
"refresh_token" TEXT,
"access_token" TEXT,
"expires_at" INTEGER,
"token_type" TEXT,
"scope" TEXT,
"id_token" TEXT,
"session_state" TEXT,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,

CONSTRAINT "accounts_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "sessions" (
"id" TEXT NOT NULL,
"session_token" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"expires" TIMESTAMP(3) NOT NULL,

CONSTRAINT "sessions_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "users" (
"id" TEXT NOT NULL,
"fdai_user_id" INTEGER,
"fdai_access_token" TEXT,
"fdai_refresh_token" TEXT,
"fdai_expires_in" INTEGER,
"fdai_scope" TEXT,
"fdai_access_token_expires_at" TIMESTAMP(3),
"address" TEXT,
"banned" BOOLEAN,
"birthday" TIMESTAMP(3),
"city" TEXT,
"country_code" TEXT,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted_at" TIMESTAMP(3),
"email" TEXT,
"email_verified" TIMESTAMP(3),
"email_validated" BOOLEAN NOT NULL DEFAULT false,
"first_name" TEXT,
"gdpr_consent" BOOLEAN NOT NULL DEFAULT false,
"gender" TEXT,
"image" TEXT,
"ip_address" VARCHAR(45),
"language" TEXT,
"last_name" TEXT,
"last_sign_in_at" BIGINT,
"name" TEXT,
"newsletter_subscribed" BOOLEAN NOT NULL DEFAULT false,
"phone_number" TEXT,
"postal_code" TEXT,
"referrer_user_id" TEXT,
"state_province" TEXT,
"updated_at" TIMESTAMP(3) NOT NULL,
"username" TEXT NOT NULL,
"web3_wallet" TEXT,
"unsafe_metadata" JSONB,
"public_metadata" JSONB,
"private_metadata" JSONB,

CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "verification_tokens" (
"identifier" TEXT NOT NULL,
"token" TEXT NOT NULL,
"expires" TIMESTAMP(3) NOT NULL
);

-- CreateTable
CREATE TABLE "activities" (
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
"color_code" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,

CONSTRAINT "activities_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "activity_log" (
"id" TEXT NOT NULL,
"activity_id" TEXT NOT NULL,
"date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"count" INTEGER NOT NULL DEFAULT 1,

CONSTRAINT "activity_log_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "accounts_provider_provider_account_id_key" ON "accounts"("provider", "provider_account_id");

-- CreateIndex
CREATE UNIQUE INDEX "sessions_session_token_key" ON "sessions"("session_token");

-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");

-- CreateIndex
CREATE UNIQUE INDEX "users_username_key" ON "users"("username");

-- CreateIndex
CREATE UNIQUE INDEX "verification_tokens_token_key" ON "verification_tokens"("token");

-- CreateIndex
CREATE UNIQUE INDEX "verification_tokens_identifier_token_key" ON "verification_tokens"("identifier", "token");

-- AddForeignKey
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "activities" ADD CONSTRAINT "activities_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "activity_log" ADD CONSTRAINT "activity_log_activity_id_fkey" FOREIGN KEY ("activity_id") REFERENCES "activities"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
3 changes: 3 additions & 0 deletions apps/nextjs/prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
Loading

0 comments on commit 68ad5a5

Please sign in to comment.