Merge pull request #228 from ttt246/feature/update_extension_191
Browse files- Extension/package-lock.json +12 -1
- Extension/package.json +2 -1
- Extension/src/assets/img/icon-128.png +0 -0
- Extension/src/assets/img/icon-34.png +0 -0
- Extension/src/assets/img/logo.png +0 -0
- Extension/src/assets/img/logo_panel.png +0 -0
- Extension/src/manifest.json +4 -2
- Extension/src/pages/Panel/Message/index.css +2 -4
- Extension/src/pages/Panel/Panel.css +21 -2
- Extension/src/pages/Panel/Panel.jsx +45 -6
- Extension/webpack.config.js +19 -1
Extension/package-lock.json
CHANGED
|
@@ -14,7 +14,8 @@
|
|
| 14 |
"axios": "^1.4.0",
|
| 15 |
"firebase": "^9.23.0",
|
| 16 |
"react": "^18.2.0",
|
| 17 |
-
"react-dom": "^18.2.0"
|
|
|
|
| 18 |
},
|
| 19 |
"devDependencies": {
|
| 20 |
"@babel/core": "^7.20.12",
|
|
@@ -11539,6 +11540,11 @@
|
|
| 11539 |
"minimalistic-assert": "^1.0.0"
|
| 11540 |
}
|
| 11541 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11542 |
"node_modules/webidl-conversions": {
|
| 11543 |
"version": "3.0.1",
|
| 11544 |
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
|
@@ -20619,6 +20625,11 @@
|
|
| 20619 |
"minimalistic-assert": "^1.0.0"
|
| 20620 |
}
|
| 20621 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20622 |
"webidl-conversions": {
|
| 20623 |
"version": "3.0.1",
|
| 20624 |
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
|
|
|
| 14 |
"axios": "^1.4.0",
|
| 15 |
"firebase": "^9.23.0",
|
| 16 |
"react": "^18.2.0",
|
| 17 |
+
"react-dom": "^18.2.0",
|
| 18 |
+
"webextension-polyfill": "^0.10.0"
|
| 19 |
},
|
| 20 |
"devDependencies": {
|
| 21 |
"@babel/core": "^7.20.12",
|
|
|
|
| 11540 |
"minimalistic-assert": "^1.0.0"
|
| 11541 |
}
|
| 11542 |
},
|
| 11543 |
+
"node_modules/webextension-polyfill": {
|
| 11544 |
+
"version": "0.10.0",
|
| 11545 |
+
"resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz",
|
| 11546 |
+
"integrity": "sha512-c5s35LgVa5tFaHhrZDnr3FpQpjj1BB+RXhLTYUxGqBVN460HkbM8TBtEqdXWbpTKfzwCcjAZVF7zXCYSKtcp9g=="
|
| 11547 |
+
},
|
| 11548 |
"node_modules/webidl-conversions": {
|
| 11549 |
"version": "3.0.1",
|
| 11550 |
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
|
|
|
| 20625 |
"minimalistic-assert": "^1.0.0"
|
| 20626 |
}
|
| 20627 |
},
|
| 20628 |
+
"webextension-polyfill": {
|
| 20629 |
+
"version": "0.10.0",
|
| 20630 |
+
"resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz",
|
| 20631 |
+
"integrity": "sha512-c5s35LgVa5tFaHhrZDnr3FpQpjj1BB+RXhLTYUxGqBVN460HkbM8TBtEqdXWbpTKfzwCcjAZVF7zXCYSKtcp9g=="
|
| 20632 |
+
},
|
| 20633 |
"webidl-conversions": {
|
| 20634 |
"version": "3.0.1",
|
| 20635 |
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
Extension/package.json
CHANGED
|
@@ -14,7 +14,8 @@
|
|
| 14 |
"axios": "^1.4.0",
|
| 15 |
"firebase": "^9.23.0",
|
| 16 |
"react": "^18.2.0",
|
| 17 |
-
"react-dom": "^18.2.0"
|
|
|
|
| 18 |
},
|
| 19 |
"devDependencies": {
|
| 20 |
"@babel/core": "^7.20.12",
|
|
|
|
| 14 |
"axios": "^1.4.0",
|
| 15 |
"firebase": "^9.23.0",
|
| 16 |
"react": "^18.2.0",
|
| 17 |
+
"react-dom": "^18.2.0",
|
| 18 |
+
"webextension-polyfill": "^0.10.0"
|
| 19 |
},
|
| 20 |
"devDependencies": {
|
| 21 |
"@babel/core": "^7.20.12",
|
Extension/src/assets/img/icon-128.png
CHANGED
|
|
|
|
Extension/src/assets/img/icon-34.png
CHANGED
|
|
|
|
Extension/src/assets/img/logo.png
ADDED
|
Extension/src/assets/img/logo_panel.png
ADDED
|
Extension/src/manifest.json
CHANGED
|
@@ -38,9 +38,11 @@
|
|
| 38 |
"resources": [
|
| 39 |
"content.styles.css",
|
| 40 |
"icon-128.png",
|
| 41 |
-
"icon-34.png"
|
|
|
|
|
|
|
| 42 |
],
|
| 43 |
-
"matches": []
|
| 44 |
}
|
| 45 |
]
|
| 46 |
}
|
|
|
|
| 38 |
"resources": [
|
| 39 |
"content.styles.css",
|
| 40 |
"icon-128.png",
|
| 41 |
+
"icon-34.png",
|
| 42 |
+
"logo_panel.png",
|
| 43 |
+
"logo.png"
|
| 44 |
],
|
| 45 |
+
"matches": ["<all_urls>"]
|
| 46 |
}
|
| 47 |
]
|
| 48 |
}
|
Extension/src/pages/Panel/Message/index.css
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
[data-theme='light'] {
|
| 2 |
-
--send-theme-color: #
|
| 3 |
--receive-theme-color: #0d0c0d;
|
| 4 |
}
|
| 5 |
|
| 6 |
[data-theme='dark'] {
|
| 7 |
-
--send-theme-color: #
|
| 8 |
--receive-theme-color: #333333;
|
| 9 |
}
|
| 10 |
|
|
@@ -25,8 +25,6 @@
|
|
| 25 |
.message_received {
|
| 26 |
width: fit-content;
|
| 27 |
padding: 5px;
|
| 28 |
-
border-radius: 5px;
|
| 29 |
-
background-color: var(--receive-theme-color);
|
| 30 |
}
|
| 31 |
|
| 32 |
|
|
|
|
| 1 |
[data-theme='light'] {
|
| 2 |
+
--send-theme-color: #8753e9;
|
| 3 |
--receive-theme-color: #0d0c0d;
|
| 4 |
}
|
| 5 |
|
| 6 |
[data-theme='dark'] {
|
| 7 |
+
--send-theme-color: #8753e9;
|
| 8 |
--receive-theme-color: #333333;
|
| 9 |
}
|
| 10 |
|
|
|
|
| 25 |
.message_received {
|
| 26 |
width: fit-content;
|
| 27 |
padding: 5px;
|
|
|
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
|
Extension/src/pages/Panel/Panel.css
CHANGED
|
@@ -23,14 +23,18 @@
|
|
| 23 |
}
|
| 24 |
|
| 25 |
.header {
|
| 26 |
-
|
| 27 |
text-align: left;
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
.footer {
|
| 31 |
padding: 10px;
|
| 32 |
-
justify-self: end;
|
| 33 |
background-color: var(--theme-color);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
|
| 36 |
.content {
|
|
@@ -57,4 +61,19 @@
|
|
| 57 |
.divider {
|
| 58 |
margin: 0;
|
| 59 |
background-color: grey;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
}
|
|
|
|
| 23 |
}
|
| 24 |
|
| 25 |
.header {
|
| 26 |
+
height: 55px;
|
| 27 |
text-align: left;
|
| 28 |
+
padding-top: 5px;
|
| 29 |
}
|
| 30 |
|
| 31 |
.footer {
|
| 32 |
padding: 10px;
|
|
|
|
| 33 |
background-color: var(--theme-color);
|
| 34 |
+
display: flex;
|
| 35 |
+
gap: 3px;
|
| 36 |
+
align-items: center;
|
| 37 |
+
color: grey;
|
| 38 |
}
|
| 39 |
|
| 40 |
.content {
|
|
|
|
| 61 |
.divider {
|
| 62 |
margin: 0;
|
| 63 |
background-color: grey;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.footer-btn {
|
| 67 |
+
padding: 5px;
|
| 68 |
+
background-color: inherit;
|
| 69 |
+
border: 0;
|
| 70 |
+
color: grey;
|
| 71 |
+
height: 25px;
|
| 72 |
+
cursor: pointer;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.footer-btn:hover {
|
| 76 |
+
background-color: #8753e9;
|
| 77 |
+
border: 1px solid inherit;
|
| 78 |
+
border-radius: 10px;
|
| 79 |
}
|
Extension/src/pages/Panel/Panel.jsx
CHANGED
|
@@ -1,11 +1,23 @@
|
|
| 1 |
import React, {useEffect, useRef, useState} from 'react';
|
| 2 |
-
import {
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
import { getDatabase, onValue, ref } from "firebase/database";
|
| 5 |
|
| 6 |
import Message from './Message'
|
| 7 |
import './Panel.css';
|
| 8 |
import app from './FirebaseApp/firebase-app'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
const {Footer, Content} = Layout;
|
| 11 |
const URL_BASE = 'https://ttt246-brain.hf.space/'
|
|
@@ -26,12 +38,14 @@ const confs = {
|
|
| 26 |
"temperature": 0.6
|
| 27 |
}
|
| 28 |
}
|
|
|
|
|
|
|
| 29 |
const Panel = () => {
|
| 30 |
const [question, setQuestion] = useState("");
|
| 31 |
const [messages, setMessages] = useState([]);
|
| 32 |
const [isLoading, setLoadingStatus] = useState(false);
|
| 33 |
const chat_box = useRef(null);
|
| 34 |
-
|
| 35 |
const handleQuestionUpdated = (event) => {
|
| 36 |
if (event.key === "Enter" && !isLoading) {
|
| 37 |
addMessage(question, true);
|
|
@@ -315,7 +329,7 @@ const Panel = () => {
|
|
| 315 |
return (
|
| 316 |
<Layout className="main-layout" data-theme={isDarkMode ? 'dark': 'light'}>
|
| 317 |
<div className="header">
|
| 318 |
-
<
|
| 319 |
</div>
|
| 320 |
<Divider className="divider"/>
|
| 321 |
<Content className="content" ref={chat_box}>
|
|
@@ -328,11 +342,36 @@ const Panel = () => {
|
|
| 328 |
</Content>
|
| 329 |
<Divider className="divider"/>
|
| 330 |
<Footer className="footer">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
<Input
|
| 332 |
-
addonAfter={<SendOutlined/>}
|
| 333 |
value={question}
|
| 334 |
onChange={handleQuestionChange}
|
| 335 |
-
onKeyDown={handleQuestionUpdated}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
</Footer>
|
| 337 |
</Layout>
|
| 338 |
);
|
|
|
|
| 1 |
import React, {useEffect, useRef, useState} from 'react';
|
| 2 |
+
import {
|
| 3 |
+
Divider,
|
| 4 |
+
Input,
|
| 5 |
+
Layout,
|
| 6 |
+
Tooltip
|
| 7 |
+
} from 'antd';
|
| 8 |
import { getDatabase, onValue, ref } from "firebase/database";
|
| 9 |
|
| 10 |
import Message from './Message'
|
| 11 |
import './Panel.css';
|
| 12 |
import app from './FirebaseApp/firebase-app'
|
| 13 |
+
import Browser from 'webextension-polyfill'
|
| 14 |
+
import {
|
| 15 |
+
SettingOutlined,
|
| 16 |
+
SyncOutlined,
|
| 17 |
+
SoundOutlined,
|
| 18 |
+
CopyOutlined,
|
| 19 |
+
MessageOutlined
|
| 20 |
+
} from '@ant-design/icons'
|
| 21 |
|
| 22 |
const {Footer, Content} = Layout;
|
| 23 |
const URL_BASE = 'https://ttt246-brain.hf.space/'
|
|
|
|
| 38 |
"temperature": 0.6
|
| 39 |
}
|
| 40 |
}
|
| 41 |
+
const logoUrl = Browser.runtime.getURL('logo_panel.png')
|
| 42 |
+
|
| 43 |
const Panel = () => {
|
| 44 |
const [question, setQuestion] = useState("");
|
| 45 |
const [messages, setMessages] = useState([]);
|
| 46 |
const [isLoading, setLoadingStatus] = useState(false);
|
| 47 |
const chat_box = useRef(null);
|
| 48 |
+
|
| 49 |
const handleQuestionUpdated = (event) => {
|
| 50 |
if (event.key === "Enter" && !isLoading) {
|
| 51 |
addMessage(question, true);
|
|
|
|
| 329 |
return (
|
| 330 |
<Layout className="main-layout" data-theme={isDarkMode ? 'dark': 'light'}>
|
| 331 |
<div className="header">
|
| 332 |
+
<img src={logoUrl} height="50px" alt="no image" />
|
| 333 |
</div>
|
| 334 |
<Divider className="divider"/>
|
| 335 |
<Content className="content" ref={chat_box}>
|
|
|
|
| 342 |
</Content>
|
| 343 |
<Divider className="divider"/>
|
| 344 |
<Footer className="footer">
|
| 345 |
+
<Tooltip title="Settings" arrow="show" placement="bottom">
|
| 346 |
+
<div className="footer-btn">
|
| 347 |
+
<SettingOutlined />
|
| 348 |
+
</div>
|
| 349 |
+
</Tooltip>
|
| 350 |
<Input
|
|
|
|
| 351 |
value={question}
|
| 352 |
onChange={handleQuestionChange}
|
| 353 |
+
onKeyDown={handleQuestionUpdated}
|
| 354 |
+
/>
|
| 355 |
+
<Tooltip title="re-send" arrow="show" placement="bottom">
|
| 356 |
+
<div className="footer-btn">
|
| 357 |
+
<SyncOutlined />
|
| 358 |
+
</div>
|
| 359 |
+
</Tooltip>
|
| 360 |
+
<Tooltip title="voice recognition" arrow="show" placement="bottom">
|
| 361 |
+
<div className="footer-btn">
|
| 362 |
+
<SoundOutlined />
|
| 363 |
+
</div>
|
| 364 |
+
</Tooltip>
|
| 365 |
+
<Tooltip title="copy" arrow="show" placement="bottom">
|
| 366 |
+
<div className="footer-btn">
|
| 367 |
+
<CopyOutlined />
|
| 368 |
+
</div>
|
| 369 |
+
</Tooltip>
|
| 370 |
+
<Tooltip title="message" arrow="show" placement="bottom">
|
| 371 |
+
<div className="footer-btn">
|
| 372 |
+
<MessageOutlined />
|
| 373 |
+
</div>
|
| 374 |
+
</Tooltip>
|
| 375 |
</Footer>
|
| 376 |
</Layout>
|
| 377 |
);
|
Extension/webpack.config.js
CHANGED
|
@@ -144,7 +144,7 @@ var options = {
|
|
| 144 |
from: 'src/manifest.json',
|
| 145 |
to: path.join(__dirname, 'build'),
|
| 146 |
force: true,
|
| 147 |
-
transform: function (content
|
| 148 |
// generates the manifest file using the package.json informations
|
| 149 |
return Buffer.from(
|
| 150 |
JSON.stringify({
|
|
@@ -184,6 +184,24 @@ var options = {
|
|
| 184 |
},
|
| 185 |
],
|
| 186 |
}),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
new HtmlWebpackPlugin({
|
| 188 |
template: path.join(__dirname, 'src', 'pages', 'Newtab', 'index.html'),
|
| 189 |
filename: 'newtab.html',
|
|
|
|
| 144 |
from: 'src/manifest.json',
|
| 145 |
to: path.join(__dirname, 'build'),
|
| 146 |
force: true,
|
| 147 |
+
transform: function (content) {
|
| 148 |
// generates the manifest file using the package.json informations
|
| 149 |
return Buffer.from(
|
| 150 |
JSON.stringify({
|
|
|
|
| 184 |
},
|
| 185 |
],
|
| 186 |
}),
|
| 187 |
+
new CopyWebpackPlugin({
|
| 188 |
+
patterns: [
|
| 189 |
+
{
|
| 190 |
+
from: 'src/assets/img/logo_panel.png',
|
| 191 |
+
to: path.join(__dirname, 'build'),
|
| 192 |
+
force: true,
|
| 193 |
+
},
|
| 194 |
+
],
|
| 195 |
+
}),
|
| 196 |
+
new CopyWebpackPlugin({
|
| 197 |
+
patterns: [
|
| 198 |
+
{
|
| 199 |
+
from: 'src/assets/img/logo.png',
|
| 200 |
+
to: path.join(__dirname, 'build'),
|
| 201 |
+
force: true,
|
| 202 |
+
},
|
| 203 |
+
],
|
| 204 |
+
}),
|
| 205 |
new HtmlWebpackPlugin({
|
| 206 |
template: path.join(__dirname, 'src', 'pages', 'Newtab', 'index.html'),
|
| 207 |
filename: 'newtab.html',
|