Skip to content

Commit

Permalink
Alpha -> Dev (30.05.2024) (#97)
Browse files Browse the repository at this point in the history
Updated Dev dependencies from Alpha
  • Loading branch information
NeonKirill authored May 30, 2024
1 parent 2351bf7 commit fefbb8a
Show file tree
Hide file tree
Showing 113 changed files with 1,038 additions and 560 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/propose_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
pr_assignee: ${{ github.actor }}
pr_draft: false
pr_title: ${{ needs.update_version.outputs.version }}
pr_body: ${{ needs.update_version.outputs.changelog }}
pr_body: ${{ needs.update_version.outputs.changelog }}
4 changes: 2 additions & 2 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'
- name: Install Build Tools
run: |
python -m pip install build wheel
5 changes: 4 additions & 1 deletion .github/workflows/publish_version_change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'
- name: Install Setuptools
run: |
python -m pip install -U pip setuptools
- name: Install Build Tools
run: |
python -m pip install build wheel
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ on:

jobs:
unit_tests:
strategy:
matrix:
python-version: [ '3.10' ]
max-parallel: 1
runs-on: ubuntu-latest
env:
PYKLATCHAT_TESTING_CREDENTIALS: ${{ secrets.PYKLATCHAT_TESTING_CREDENTIALS_V2 }}
Expand All @@ -27,9 +23,9 @@ jobs:
- name: echo Testing Creds
run: echo $PYKLATCHAT_TESTING_CREDENTIALS
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -63,7 +59,10 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'
- name: Install Setuptools
run: |
python -m pip install -U pip setuptools
- name: Install Build Tools
run: |
python -m pip install build wheel
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: pretty-format-json
args:
- "--autofix"
- id: requirements-txt-fixer
- id: sort-simple-yaml
- repo: https://github.com/psf/black
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,3 @@ Example of configuration can be found in "chat_client/example_client_config.json
### Launching

Chat Client can be launched as python module from root directory: ```python -m chat_client```

2 changes: 1 addition & 1 deletion base/.gitkeep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DO NOT REMOVE ME: I AM USED AS A PLACE-KEEPER FOR BASE DOCKER IMAGE
DO NOT REMOVE ME: I AM USED AS A PLACE-KEEPER FOR BASE DOCKER IMAGE
18 changes: 6 additions & 12 deletions chat_client/blueprints/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@


@router.get("/profile")
async def get_profile_modal(request: Request, nickname: str = "", edit: str = "0"):
async def get_profile_modal(request: Request, user_id: str = "", edit: str = "0"):
"""Callbacks template with matching modal populated with user's data"""
auth_header = "Authorization"
headers = {auth_header: request.headers.get(auth_header, "")}
Expand All @@ -51,25 +51,19 @@ async def get_profile_modal(request: Request, nickname: str = "", edit: str = "0
)
if resp.ok:
user = resp.json()["data"]
# if user.get('is_tmp'):
# raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED,
# detail='Cannot render edit modal for tmp user')
else:
return respond("Server was not able to process the request", 422)
template_name = "edit_profile_modal"
else:
if not nickname:
return respond("No nickname provided", 422)
if not user_id:
return respond("No user_id provided", 422)
resp = requests.get(
f'{client_config["SERVER_URL"]}/users_api/get_users?nicknames={nickname}',
f'{client_config["SERVER_URL"]}/users_api?user_id={user_id}',
headers=headers,
)
if resp.ok:
user_data = resp.json().get("users", [])
if not user_data:
return respond(f"User with nickname={nickname} not found", 404)
else:
user = user_data[0]
if not (user := resp.json().get("data")):
return respond(f"User with {user_id=} not found", 404)
else:
return respond("Server was not able to process the request", 422)
template_name = "profile_modal"
Expand Down
2 changes: 1 addition & 1 deletion chat_client/example_client_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"SERVER_URL": "HTTP address for chat server"
}
}
}
}
2 changes: 1 addition & 1 deletion chat_client/static/copyright.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion chat_client/static/css/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,4 @@ body{

.modal, .modal-backdrop {
position: absolute !important;
}
}
2 changes: 1 addition & 1 deletion chat_client/static/css/klatchatNano.css
Original file line number Diff line number Diff line change
Expand Up @@ -436,4 +436,4 @@ background-color: darkblue;

.modal, .modal-backdrop {
position: absolute !important;
}
}
2 changes: 1 addition & 1 deletion chat_client/static/css/sidebar.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chat_client/static/example_runtime_config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"SOCKET_IO_SERVER_URL": "IP address Socket IO server"
}
}
4 changes: 2 additions & 2 deletions chat_client/static/js/attachments.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function downloadAttachment(attachmentItem, cid, messageID){
await fetchServer(getFileURL).then(async response => {
response.ok ?
download(await response.blob(), fileName, mime)
:console.error(`No file data received for path,
:console.error(`No file data received for path,
cid=${cid};\n
message_id=${messageID};\n
file_name=${fileName}`)
Expand Down Expand Up @@ -147,4 +147,4 @@ function resolveMessageAttachments(cid, messageID,attachments = []){
}
}
}
}
}
2 changes: 1 addition & 1 deletion chat_client/static/js/builder_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ async function buildPromptHTML(prompt) {
let submindsHTML = "";
const promptData = prompt['data'];
if (prompt['is_completed'] === '0'){
promptData['winner'] = `Prompt in progress
promptData['winner'] = `Prompt in progress
<div class="spinner-border spinner-border-sm text-dark" role="status">
<span class="sr-only">Loading...</span>
</div>`
Expand Down
1 change: 0 additions & 1 deletion chat_client/static/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ document.addEventListener('DOMContentLoaded', async (e)=>{
document.dispatchEvent(configFullLoadedEvent);
}
});

2 changes: 1 addition & 1 deletion chat_client/static/js/date_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ function strFmtDate(year, month, day, hours, minutes, seconds){
}
}
return finalDate;
}
}
14 changes: 9 additions & 5 deletions chat_client/static/js/http_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,21 @@ const setSessionToken = (val) => {
}
}

const fetchServer = async (urlSuffix, method=REQUEST_METHODS.GET, body=null, noCors=false) => {
const fetchServer = async (urlSuffix, method=REQUEST_METHODS.GET, body=null, json=false) => {
const options = {
method: method,
headers: new Headers({'Authorization': getSessionToken()})
}
if (noCors){
options['mode'] = 'no-cors';
}
if (body){
options['body'] = body;
}
// TODO: there is an issue validating FormData on backend, so JSON property should eventually become true
if (json){
options['headers'].append('Content-Type', 'application/json');
if (options['body']) {
options['body'] &&= JSON.stringify(options['body'])
}
}
return fetch(`${configData["CHAT_SERVER_URL_BASE"]}/${urlSuffix}`, options).then(async response => {
if (response.status === 401){
const responseJson = await response.json();
Expand All @@ -39,4 +43,4 @@ const fetchServer = async (urlSuffix, method=REQUEST_METHODS.GET, body=null, noC
}
return response;
});
}
}
2 changes: 1 addition & 1 deletion chat_client/static/js/klatchatNano.js
Original file line number Diff line number Diff line change
Expand Up @@ -3617,4 +3617,4 @@ const initKlatChat = (options) => {
document.addEventListener('DOMContentLoaded', (e) => {
return new NanoBuilder(options);
})
};
};
2 changes: 1 addition & 1 deletion chat_client/static/js/language_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,4 @@ document.addEventListener('DOMContentLoaded', (_)=>{
document.addEventListener('configLoaded',async (_)=>{
await fetchSupportedLanguages().then(_ => document.dispatchEvent(supportedLanguagesLoadedEvent));
});
});
});
2 changes: 1 addition & 1 deletion chat_client/static/js/message_type_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ function addCommunicationChannelTransformCallback(conversationData) {
addMessageTransformCallback(conversationData['_id'], message['message_id'], message?.is_audio);
});
}
}
}
25 changes: 13 additions & 12 deletions chat_client/static/js/message_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function addNewMessage(cid, userID=null, messageID=null, messageText, time
messageList.insertAdjacentHTML('beforeend', messageHTML);
resolveMessageAttachments(cid, messageID, attachments);
resolveUserReply(messageID, repliedMessageID);
addProfileDisplay(cid, messageID, 'plain');
addProfileDisplay(userID, cid, messageID, 'plain');
addConversationParticipant(cid, userData['nickname'], true);
scrollOnNewMessage(messageList);
return messageID;
Expand Down Expand Up @@ -261,31 +261,32 @@ function initLoadOldMessages(conversationData, skin) {

/**
* Attaches event listener to display element's target user profile
* @param elem: target DOM element
* @param userID target user id
* @param elem target DOM element
*/
function attachTargetProfileDisplay(elem){
function attachTargetProfileDisplay(userID, elem){
if (elem) {
elem.addEventListener( 'click', async (_) => {
const userNickname = elem.getAttribute( 'data-target' );
if (userNickname) await showProfileModal( userNickname )
if (userID) await showProfileModal( userID )
} );
}
}

/**
* Adds callback for showing profile information on profile avatar click
* @param cid: target conversation id
* @param messageId: target message id
* @param messageType: type of message to display
* @param userID target user id
* @param cid target conversation id
* @param messageId target message id
* @param messageType type of message to display
*/
function addProfileDisplay(cid, messageId, messageType='plain'){
function addProfileDisplay(userID, cid, messageId, messageType='plain'){
if (messageType === 'plain') {
attachTargetProfileDisplay(document.getElementById( `${messageId}_avatar` ))
attachTargetProfileDisplay(userID, document.getElementById( `${messageId}_avatar` ))
}else if (messageType === 'prompt'){
const promptTBody = document.getElementById(`${messageId}_tbody`);
const rows = promptTBody.getElementsByTagName('tr');
Array.from(rows).forEach(row=>{
attachTargetProfileDisplay(Array.from(row.getElementsByTagName('td'))[0].getElementsByClassName('chat-img')[0]);
attachTargetProfileDisplay(userID, Array.from(row.getElementsByTagName('td'))[0].getElementsByClassName('chat-img')[0]);
})
}
}
Expand All @@ -297,7 +298,7 @@ function addProfileDisplay(cid, messageId, messageType='plain'){
*/
function initProfileDisplay(conversationData){
getUserMessages(conversationData, null).forEach(message => {
addProfileDisplay( conversationData['_id'], getMessageID(message), message['message_type']);
addProfileDisplay( message['user_id'], conversationData['_id'], getMessageID(message), message['message_type']);
});
}

Expand Down
2 changes: 1 addition & 1 deletion chat_client/static/js/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*/
const metaConfig = {
'client': 'main'
}
}
2 changes: 1 addition & 1 deletion chat_client/static/js/nano_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ function displayModalInCID(modalElem, cid){
modalElem.modal('hide');
$('.modal-backdrop').appendTo(`#${cid}`);
modalElem.modal('show');
}
}
10 changes: 5 additions & 5 deletions chat_client/static/js/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ const myAccountLink = document.getElementById('myAccountLink');
*
* @return true if modal shown successfully, false otherwise
*/
async function showProfileModal(nick=null, edit='0'){
async function showProfileModal(userID=null, edit='0'){
let fetchURL = `${configData['currentURLBase']}/components/profile?`
let modalId;
let avatarId;
if(edit === '1'){
modalId = `${currentUser['nickname']}EditModal`;
modalId = `${currentUser['_id']}EditModal`;
// avatarId = `${currentUser['nickname']}EditAvatar`;
fetchURL += `edit=1`;
}else{
modalId = `${nick}Modal`;
modalId = `${userID}Modal`;
// avatarId = `${nick}Avatar`;
fetchURL += `nickname=${nick}`;
fetchURL += `user_id=${userID}`;
}
const profileModalHTML = await fetch(fetchURL, {headers: new Headers({'Authorization': getSessionToken()})}).then(async (response) => {
if (response.ok) {
Expand Down Expand Up @@ -148,4 +148,4 @@ document.addEventListener('DOMContentLoaded', (e) => {
if (configData.client === CLIENTS.MAIN) {
attachEditModalInvoker(myAccountLink);
}
});
});
2 changes: 1 addition & 1 deletion chat_client/static/js/scroller_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ function scrollOnNewMessage(messageList, lastNElements=3){
if(getMessageScrollPosition(messageList, lastNElements, MessageScrollPosition.END) === MessageScrollPosition.END){
messageList.lastChild.scrollIntoView();
}
}
}
6 changes: 4 additions & 2 deletions chat_client/static/js/sio.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ function initSIO(){
}

socket.on('auth_expired', ()=>{
console.log('Authorization Token expired, refreshing...')
location.reload();
if (currentUser && Object.keys(currentUser).length > 0) {
console.log('Authorization Token expired, refreshing...')
location.reload();
}
});

socket.on('connect', () => {
Expand Down
2 changes: 1 addition & 1 deletion chat_client/static/js/speak_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ async function addRecorder(conversationData) {
}
};
}
}
}
2 changes: 1 addition & 1 deletion chat_client/static/js/suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ async function renderSuggestions() {
});
importConversationModalSuggestions.style.setProperty('display', 'inherit', 'important');
});
}
}
Loading

0 comments on commit fefbb8a

Please sign in to comment.