change header columns elements in airwatch

This commit is contained in:
Tykayn 2025-08-14 12:18:20 +02:00 committed by tykayn
parent 219fa8c4f9
commit fa8a7ca996
215 changed files with 26292 additions and 45 deletions

5
.gitignore vendored
View file

@ -1,2 +1,3 @@
ng-demo #ng-demo
.gitignore #.gitignore
node_modules

3
.gitmodules vendored
View file

@ -1,3 +1,4 @@
[submodule "ng-demo"] [submodule "ng-demo"]
path = ng-demo path = sae-airwatch
url = https://source.cipherbliss.com/tykayn/ng-demo url = https://source.cipherbliss.com/tykayn/ng-demo
branch = dev

8
.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View file

@ -1,21 +1,21 @@
.feedback-button { .feedback-button {
background: #ecf3fa; /*background: #ecf3fa;*/
color: #083b7d; /*color: #083b7d;*/
padding: 8px; /*padding: 8px;*/
border-radius: 8px; /*border-radius: 8px;*/
border-bottom-left-radius: 0; /*border-bottom-left-radius: 0;*/
border-bottom-right-radius: 0; /*border-bottom-right-radius: 0;*/
transform: rotate(270deg); /*transform: rotate(270deg);*/
cursor: pointer; /*cursor: pointer;*/
display: flex; /*display: flex;*/
align-items: center; /*align-items: center;*/
gap: 8px; /*gap: 8px;*/
margin-right: -35px; /*margin-right: -35px;*/
position: fixed; /*position: fixed;*/
right: 0; /*right: 0;*/
top: 240px; /*top: 240px;*/
z-index: 100; /*z-index: 100;*/
&:hover { &:hover {
background: #d9e8f6; background: #d9e8f6;

View file

@ -1,19 +1,19 @@
.feedback-button { .feedback-button {
background: #ecf3fa; //background: #ecf3fa;
color: #083b7d; //color: #083b7d;
padding: 8px; //padding: 15px;
border-radius: 8px 8px 0 0; //border-radius: 8px 8px 0 0;
transform: rotate(270deg); //transform: rotate(270deg);
cursor: pointer; //cursor: pointer;
display: flex; //display: flex;
align-items: center; //align-items: center;
gap: 8px; //gap: 8px;
//
margin-right: -35px; //margin-right: -35px;
position: fixed; //position: fixed;
right: 0; //right: 0;
top: 240px; //top: 240px;
z-index: 100; //z-index: 100;
&:hover { &:hover {
background: #d9e8f6; background: #d9e8f6;

View file

@ -50,8 +50,8 @@
} }
#newChatBar { #newChatBar {
margin-top: 24px; margin: 20px 0;
margin-bottom: 16px;
.is-expanded-left & .column-conversation { .is-expanded-left & .column-conversation {
width: variables.$large-column-panel; width: variables.$large-column-panel;
@ -75,11 +75,24 @@
} }
.new-chat-title { .new-chat-title {
//text-align: left; text-align: left;
font-size: 20px; font-size: 20px;
font-weight: 600; font-weight: 600;
width: 100%; width: 100%;
display: block; display: block;
.chips {
}
.title {
float: left;
}
.action {
float: right;
margin-top: -1.75em;
}
} }
.search-button { .search-button {
@ -253,10 +266,12 @@
.chat-column { .chat-column {
min-width: 1000px; min-width: 1000px;
} }
.chatbot-container-box { .chatbot-container-box {
margin-right: 100px; margin-top: 38px;
margin-right: 84px;
} }
.conversation-title { .conversation-title {
@ -268,7 +283,7 @@
.chat { .chat {
background: variables.$bg-color-chat;
text-align: center; text-align: center;
padding: variables.$spacing-1; padding: variables.$spacing-1;
@ -283,10 +298,17 @@
.panel-more { .panel-more {
background: variables.$bg-color-chat; background: variables.$bg-color-chat;
padding-top: 0 !important;
width: 0; width: 0;
display: none; display: none;
padding-top: 24px;
.export-chat-button {
margin-top: 16px;
margin-bottom: 16px;
float: right;
display: inline-block;
}
.is-expanded-right & { .is-expanded-right & {
width: variables.$large-column-panel !important; width: variables.$large-column-panel !important;
@ -309,8 +331,10 @@
} }
.main-conversation-container { .main-conversation-container {
margin-right: 16px; //margin-right: 16px;
padding-top: 88px; padding-top: 88px;
border-radius: 10px;
background: variables.$bg-color-chat;
} }
.app-theme-light & { .app-theme-light & {
@ -405,9 +429,14 @@
padding-top: 0; padding-top: 0;
&.panel-more { &.panel-more {
width: 0px;
display: none;
margin-top: 16px;
&.expanded { &.expanded {
width: 300px; width: 516px;
flex-basis: 300px; flex-basis: 516px;
display: block;
} }
} }
} }

View file

@ -0,0 +1,17 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
ij_typescript_use_double_quotes = false
[*.md]
max_line_length = off
trim_trailing_whitespace = false

View file

@ -0,0 +1 @@
OPENWEATHER=de58cb9a19aec9c6073e9f1f75da1d26

46
old-sae-airwatch/.gitignore vendored Normal file
View file

@ -0,0 +1,46 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out
# Node
/node_modules
npm-debug.log
yarn-error.log
# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings
# System files
.DS_Store
Thumbs.db
*storybook.log
storybook-static
.idea

View file

@ -0,0 +1,59 @@
import type { StorybookConfig } from '@storybook/angular';
const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-links',
// '@storybook/addon-essentials', // Commented out due to compatibility issues with Storybook v9
// '@storybook/addon-interactions', // Commented out due to compatibility issues with Storybook v9
],
framework: {
name: '@storybook/angular',
options: {},
},
// docs: {
// autodocs: 'tag',
// },
staticDirs: ['../src/stories/assets', '../src/app/styles/typo'], // Pour les assets statiques et les polices
webpackFinal: async (config) => {
// Add support for MDX files
if (config.module?.rules) {
config.module.rules.push({
test: /\.mdx?$/,
use: [
{
loader: require.resolve('@mdx-js/loader'),
},
],
});
// Add support for font files
config.module.rules.push({
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
},
},
],
});
}
// Add alias for tilde (~) notation to resolve to the project root
if (!config.resolve) {
config.resolve = {};
}
if (!config.resolve.alias) {
config.resolve.alias = {};
}
config.resolve.alias['~src'] = require('path').resolve(__dirname, '../src');
return config;
},
};
export default config;

View file

@ -0,0 +1,19 @@
import type { Preview } from '@storybook/angular';
// Import des styles globaux
import '../src/app/styles/styles.scss';
const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};
export default preview;

View file

@ -0,0 +1,10 @@
// This tsconfig is used by Compodoc to generate the documentation for the project.
// If Compodoc is not used, this file can be deleted.
{
"extends": "./tsconfig.json",
// Exclude all files that are not needed for documentation generation.
"exclude": ["../src/test.ts", "../src/**/*.spec.ts", "../src/**/*.stories.ts"],
// Please make sure to include all files from which Compodoc should generate documentation.
"include": ["../src/**/*"],
"files": ["./typings.d.ts"]
}

View file

@ -0,0 +1,11 @@
{
"extends": "../tsconfig.app.json",
"compilerOptions": {
"types": ["node"],
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true
},
"exclude": ["../src/test.ts", "../src/**/*.spec.ts"],
"include": ["../src/**/*.stories.*", "./preview.ts"],
"files": ["./typings.d.ts"]
}

View file

@ -0,0 +1,9 @@
declare module '*.md' {
const content: string;
export default content;
}
declare module '*.mdx' {
const content: any;
export default content;
}

View file

@ -0,0 +1,4 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
}

20
old-sae-airwatch/.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,20 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
]
}

42
old-sae-airwatch/.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,42 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
},
{
"type": "npm",
"script": "test",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
}
]
}

View file

@ -0,0 +1,46 @@
# Changes Made
## Auto-scrolling Fix
The issue was that the conversation container wasn't automatically scrolling to the bottom when new messages were added. This was fixed by:
1. Removing the direct DOM manipulation approach in the store subscription:
```typescript
// Old code
if (prevMessagesLength !== newMessagesLength) {
const container = document.querySelector('.main-conversation-container');
if (container) {
container.scrollTop = container.scrollHeight;
}
}
// New code
if (prevMessagesLength !== newMessagesLength) {
this.shouldScrollToBottom = true;
}
```
2. Using the existing ViewChild and ngAfterViewChecked approach consistently throughout the component.
This ensures that when new messages are added to the conversation, the view will automatically scroll to the bottom to show the latest message.
## Storybook @font-face Issue
The issue was that Storybook couldn't understand the @font-face declarations in the _typo.scss file because they were using tilde (~) notation for paths. This was fixed by:
1. Changing all font paths from tilde notation to relative paths:
```scss
// Old path
src: url('~src/app/styles/typo/Barlow/Barlow-Thin.ttf') format('truetype');
// New path
src: url('../styles/typo/Barlow/Barlow-Thin.ttf') format('truetype');
```
This change allows Storybook to properly process the @font-face declarations and load the fonts correctly.
## Summary
These changes ensure that:
1. The conversation container automatically scrolls to the latest message when new messages are added.
2. Storybook can properly load and display fonts defined with @font-face declarations.

235
old-sae-airwatch/LICENSE.md Normal file
View file

@ -0,0 +1,235 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the Program.
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.

View file

@ -0,0 +1,45 @@
# MyApp
Démo de design system avec Angular
faisant des composants web.
Storybook.
### Usage
### Build Script Features
To build the application and prepare files for implementation:
```bash
./build.sh
```
- Builds the Angular application
- Checks for Node.js version compatibility (requires v20.19+ or v22.12+)
- Renames the output files to match the expected names in the implementation directory:
- CSS file → `design-system.css`
- JS files → `design-system.js` (combines main and polyfills)
- Copies the renamed files to the `implementation/assets` directory
### Requirements
- Node.js v20.19+ or v22.12+
- npm
## Development
- Angular application with web components
- Storybook for component development and testing
# notes
- génération de web components
- maj des imports scss https://sass-lang.com/documentation/breaking-changes/import/
# implémentation
Pour implémenter les composants de l'application Angular:
- charger le service de chatbot
- mettre un composant

View file

@ -0,0 +1,119 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"my-app": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"browser": "src/main.ts",
"polyfills": [
"zone.js",
"@angular/localize/init"
],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/app/styles/styles.scss"
],
"server": "src/main.server.ts"
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kB",
"maximumError": "8kB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular/build:dev-server",
"configurations": {
"production": {
"buildTarget": "my-app:build:production"
},
"development": {
"buildTarget": "my-app:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular/build:extract-i18n"
},
"test": {
"builder": "@angular/build:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing",
"@angular/localize/init"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.scss"
]
}
},
"storybook": {
"builder": "@storybook/angular:start-storybook",
"options": {
"configDir": ".storybook",
"browserTarget": "my-app:build",
"compodoc": false,
"port": 6006
}
},
"build-storybook": {
"builder": "@storybook/angular:build-storybook",
"options": {
"configDir": ".storybook",
"browserTarget": "my-app:build",
"compodoc": false,
"outputDir": "storybook-static"
}
}
}
}
}
}

84
old-sae-airwatch/build.sh Executable file
View file

@ -0,0 +1,84 @@
#!/bin/bash
# Script to build the Angular application and prepare files for implementation
# Created: 2025-07-22
# Exit on error
set -e
echo "=== Angular Build Script ==="
echo "This script builds the Angular application and prepares files for implementation"
# Check Node.js version
NODE_VERSION=$(node -v | cut -d 'v' -f 2)
NODE_MAJOR_VERSION=$(echo $NODE_VERSION | cut -d '.' -f 1)
NODE_MINOR_VERSION=$(echo $NODE_VERSION | cut -d '.' -f 2)
echo "Detected Node.js version: v$NODE_VERSION"
# Check if Node.js version is compatible (v20.19+ or v22.12+)
if [[ ($NODE_MAJOR_VERSION -eq 20 && $NODE_MINOR_VERSION -ge 19) || ($NODE_MAJOR_VERSION -ge 22 && $NODE_MINOR_VERSION -ge 12) || ($NODE_MAJOR_VERSION -gt 22) ]]; then
echo "Node.js version is compatible."
else
echo "Error: Angular CLI requires Node.js version v20.19+ or v22.12+"
echo "Please update your Node.js version or visit https://nodejs.org/ for additional instructions."
exit 1
fi
# Build the Angular application
echo "Building Angular application..."
npm run build
# Check if build was successful
if [ $? -ne 0 ]; then
echo "Error: Angular build failed."
exit 1
fi
# Define paths
DIST_DIR="dist/my-app/browser"
IMPLEMENTATION_ASSETS_DIR="implementation/assets"
# Create implementation assets directory if it doesn't exist
mkdir -p "$IMPLEMENTATION_ASSETS_DIR"
# Find the CSS and JS files
CSS_FILE=$(find "$DIST_DIR" -name "styles-*.css" | head -n 1)
MAIN_JS_FILE=$(find "$DIST_DIR" -name "main-*.js" | head -n 1)
POLYFILLS_JS_FILE=$(find "$DIST_DIR" -name "polyfills-*.js" | head -n 1)
# Check if files exist
if [ -z "$CSS_FILE" ]; then
echo "Error: Could not find styles CSS file in $DIST_DIR"
exit 1
fi
if [ -z "$MAIN_JS_FILE" ]; then
echo "Error: Could not find main JS file in $DIST_DIR"
exit 1
fi
# Copy and rename CSS file
echo "Copying CSS file to implementation assets..."
cp "$CSS_FILE" "$IMPLEMENTATION_ASSETS_DIR/design-system.css"
# Combine JS files if polyfills exist, otherwise just use main JS
if [ -n "$POLYFILLS_JS_FILE" ]; then
echo "Combining main and polyfills JS files..."
cat "$MAIN_JS_FILE" "$POLYFILLS_JS_FILE" > "$IMPLEMENTATION_ASSETS_DIR/design-system.js"
else
echo "Copying main JS file to implementation assets..."
cp "$MAIN_JS_FILE" "$IMPLEMENTATION_ASSETS_DIR/design-system.js"
fi
echo "Build completed successfully!"
echo "Files have been copied to $IMPLEMENTATION_ASSETS_DIR:"
echo "- design-system.css"
echo "- design-system.js"
# Show file sizes
echo "File sizes:"
ls -lh "$IMPLEMENTATION_ASSETS_DIR/design-system.css" | awk '{print "- CSS: " $5}'
ls -lh "$IMPLEMENTATION_ASSETS_DIR/design-system.js" | awk '{print "- JS: " $5}'
echo "=== Done ==="

18755
old-sae-airwatch/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,72 @@
{
"name": "my-app",
"version": "0.0.0",
"scripts": {
"build": "ng build",
"build-storybook": "ng run my-app:build-storybook",
"build:elements": "ng build --configuration production --output-hashing none && cat dist/runtime.js dist/polyfills.js dist/main.js > dist/color-display.js",
"link-sae-lib": "bash ./scripts/link-sae-lib.sh",
"ng": "ng",
"postinstall": "npm run link-sae-lib",
"serve:ssr:my-app": "node dist/my-app/server/server.mjs",
"start": "ng serve",
"storybook": "ng run my-app:storybook",
"test": "ng test",
"watch": "ng build --watch --configuration development"
},
"prettier": {
"overrides": [
{
"files": "*.html",
"options": {
"parser": "angular"
}
}
]
},
"private": true,
"dependencies": {
"@angular/common": "^20.1.0",
"@angular/compiler": "^20.1.0",
"@angular/core": "^20.1.0",
"@angular/forms": "^20.1.0",
"@angular/platform-browser": "^20.1.0",
"@angular/platform-server": "^20.1.0",
"@angular/router": "^20.1.0",
"@angular/ssr": "^20.1.1",
"@ngrx/store": "^20.0.0",
"@ngrx/store-devtools": "^20.0.0",
"@sjmc11/tourguidejs": "^0.0.27",
"angular-shepherd": "^20.0.0",
"express": "^5.1.0",
"remixicon": "^4.6.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^20.1.1",
"@angular/build": "^20.1.1",
"@angular/cli": "^20.1.1",
"@angular/compiler-cli": "^20.1.0",
"@angular/localize": "^20.1.2",
"@mdx-js/loader": "^3.1.0",
"@storybook/addon-docs": "^9.0.17",
"@storybook/addon-links": "^9.0.17",
"@storybook/addon-vitest": "^9.0.17",
"@storybook/angular": "^9.0.17",
"@types/express": "^5.0.1",
"@types/jasmine": "~5.1.0",
"@types/node": "^20.17.19",
"ag-grid-angular": "^34.0.2",
"bulma": "^1.0.4",
"jasmine-core": "~5.8.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"storybook": "^9.0.17",
"typescript": "~5.8.2"
}
}

View file

@ -0,0 +1,22 @@
{
"locale": "en-US",
"translations": {
"welcome": "Welcome to our chatbot application",
"newChat": "New conversation",
"search": "Search",
"sources": "Sources",
"noSources": "No sources available",
"feedback": "Feedback",
"send": "Send",
"loading": "Loading...",
"error": "System error - I couldn't process your request. Please try again in a few moments",
"language": "Language",
"theme": "Theme",
"userMessage": "User message",
"botMessage": "Bot message",
"documentation": "Documentation",
"about": "About",
"contact": "Contact",
"reportIssue": "Report an issue"
}
}

View file

@ -0,0 +1,22 @@
{
"locale": "fr-FR",
"translations": {
"welcome": "Bienvenue dans notre application de chatbot",
"newChat": "Nouvelle conversation",
"search": "Rechercher",
"sources": "Sources",
"noSources": "Aucune source disponible",
"feedback": "Commentaires",
"send": "Envoyer",
"loading": "Chargement...",
"error": "Erreur système - Je n'ai pas pu traiter votre demande. Veuillez réessayer dans quelques instants",
"language": "Langue",
"theme": "Thème",
"userMessage": "Message utilisateur",
"botMessage": "Message du bot",
"documentation": "Documentation",
"about": "À propos",
"contact": "Contact",
"reportIssue": "Signaler un problème"
}
}

View file

@ -0,0 +1,4 @@
{
"locale": "en-US",
"translations": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -0,0 +1,22 @@
{
"locale": "en-US",
"translations": {
"welcome": "Welcome to our chatbot application",
"newChat": "New conversation",
"search": "Search",
"sources": "Sources",
"noSources": "No sources available",
"feedback": "Feedback",
"send": "Send",
"loading": "Loading...",
"error": "System error - I couldn't process your request. Please try again in a few moments",
"language": "Language",
"theme": "Theme",
"userMessage": "User message",
"botMessage": "Bot message",
"documentation": "Documentation",
"about": "About",
"contact": "Contact",
"reportIssue": "Report an issue"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -0,0 +1,22 @@
{
"locale": "fr-FR",
"translations": {
"welcome": "Bienvenue dans notre application de chatbot",
"newChat": "Nouvelle conversation",
"search": "Rechercher",
"sources": "Sources",
"noSources": "Aucune source disponible",
"feedback": "Commentaires",
"send": "Envoyer",
"loading": "Chargement...",
"error": "Erreur système - Je n'ai pas pu traiter votre demande. Veuillez réessayer dans quelques instants",
"language": "Langue",
"theme": "Thème",
"userMessage": "Message utilisateur",
"botMessage": "Message du bot",
"documentation": "Documentation",
"about": "À propos",
"contact": "Contact",
"reportIssue": "Signaler un problème"
}
}

View file

@ -0,0 +1,22 @@
{
"locale": "en-US",
"translations": {
"welcome": "Welcome to our chatbot application",
"newChat": "New conversation",
"search": "Search",
"sources": "Sources",
"noSources": "No sources available",
"feedback": "Feedback",
"send": "Send",
"loading": "Loading...",
"error": "System error - I couldn't process your request. Please try again in a few moments",
"language": "Language",
"theme": "Theme",
"userMessage": "User message",
"botMessage": "Bot message",
"documentation": "Documentation",
"about": "About",
"contact": "Contact",
"reportIssue": "Report an issue"
}
}

View file

@ -0,0 +1,22 @@
{
"locale": "fr-FR",
"translations": {
"welcome": "Bienvenue dans notre application de chatbot",
"newChat": "Nouvelle conversation",
"search": "Rechercher",
"sources": "Sources",
"noSources": "Aucune source disponible",
"feedback": "Commentaires",
"send": "Envoyer",
"loading": "Chargement...",
"error": "Erreur système - Je n'ai pas pu traiter votre demande. Veuillez réessayer dans quelques instants",
"language": "Langue",
"theme": "Thème",
"userMessage": "Message utilisateur",
"botMessage": "Message du bot",
"documentation": "Documentation",
"about": "À propos",
"contact": "Contact",
"reportIssue": "Signaler un problème"
}
}

View file

@ -0,0 +1,4 @@
{
"locale": "en-US",
"translations": {}
}

View file

@ -0,0 +1,4 @@
{
"locale": "en-US",
"translations": {}
}

View file

@ -0,0 +1,134 @@
<svg width="108" height="32" viewBox="0 0 108 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_78_4310)">
<path d="M60.5489 12.736V15.44H66.7657L66.3933 17.2H60.5651V21.072H57.7319V10.96H67.737L67.3647 12.72H60.5489V12.736ZM94.9839 21.088H91.7298L90.7423 19.04H85.2864L84.3474 21.088H82.2914L87.0996 10.976H89.01C89.7385 10.976 90.0137 11.264 90.3861 12.016C90.7423 12.736 94.9839 21.088 94.9839 21.088ZM89.9004 17.28L87.9739 13.248L86.1121 17.28H89.9004ZM56.3073 21.088H53.0532L52.0818 19.04H46.6259L45.687 21.088H43.6309L48.4554 10.976H50.3657C51.0942 10.976 51.3695 11.264 51.7418 12.016C52.0656 12.736 56.3073 21.088 56.3073 21.088ZM51.2238 17.28L49.2972 13.248L47.4354 17.28H51.2238ZM37.657 21.408C41.3158 21.408 42.9995 20.08 42.9995 18.16C42.9995 16.48 41.4615 15.616 38.1103 14.72C36.1028 14.176 34.8562 14.064 34.8562 13.392C34.8562 12.72 36.0218 12.416 37.8189 12.496C40.0692 12.608 41.5101 13.536 41.5101 13.536L42.4005 12.128C42.4005 12.128 40.3768 10.64 37.1389 10.64C33.6258 10.64 31.7802 11.696 31.7802 13.648C31.7802 15.6 33.8848 16.24 36.9446 17.104C38.8388 17.632 39.9235 17.744 39.9235 18.448C39.9235 18.992 39.3569 19.68 36.8475 19.568C34.4353 19.456 32.3468 18.064 32.3468 18.064L31.2783 19.344C31.2783 19.376 33.5772 21.408 37.657 21.408ZM105.879 10.976V17.008C105.879 17.008 99.8893 12.288 99.4036 11.888C98.5132 11.184 98.1085 10.976 97.1209 10.976H96.3924V21.088H98.497V15.152C98.497 15.152 104.439 19.84 104.94 20.224C105.831 20.928 106.284 21.088 107.272 21.088H108V10.976H105.879ZM81.2067 21.088H79.2963C78.163 21.088 77.4669 20.304 77.046 19.776C76.5927 19.184 75.427 17.68 75.427 17.68H72.3186V21.104H69.4855V10.992H75.2328C77.4345 10.992 80.5915 11.216 80.6077 14.336C80.6077 16.144 79.5392 16.976 78.2116 17.36L81.2067 21.088ZM77.5317 14.32C77.5317 13.264 76.8517 12.736 75.3461 12.736H72.351L72.3186 12.72V15.92L72.351 15.904H75.3461C76.8517 15.904 77.5317 15.376 77.5317 14.32Z" fill="white"/>
<mask id="mask0_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="7" y="20" width="20" height="7">
<path d="M25.9191 20.384C23.8144 23.232 20.4147 25.088 16.5777 25.088C12.7408 25.088 9.34105 23.232 7.23642 20.384H7.00977C8.70966 23.92 12.3523 26.352 16.5777 26.352C20.8032 26.352 24.4458 23.904 26.1457 20.384H25.9191Z" fill="white"/>
</mask>
<g mask="url(#mask0_78_4310)">
<path d="M26.1457 20.384H7.00977V26.352H26.1457V20.384Z" fill="url(#paint0_radial_78_4310)"/>
</g>
<mask id="mask1_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="7" y="7" width="19" height="18">
<path d="M9.82723 9.50397C8.56446 10.432 8.06258 11.376 7.8845 12.256C6.99408 16.56 15.6069 18.272 18.9095 19.344C20.7228 19.92 20.9656 20.704 20.9494 21.328C20.917 22.768 18.861 24.064 18.8448 24.064C20.5285 24.032 22.795 23.056 24.1549 21.536C24.673 20.96 25.1263 20.192 25.2396 19.632C25.7415 17.056 23.3131 15.744 20.4475 14.752C18.2134 13.984 16.3678 13.456 14.7974 12.976C12.3042 12.224 11.8833 11.504 11.8995 10.72C11.9157 9.80797 12.9032 8.65597 14.0041 7.98397C13.9879 7.95197 11.9157 7.95197 9.82723 9.50397Z" fill="white"/>
</mask>
<g mask="url(#mask1_78_4310)">
<path d="M0 20.128L21.1758 32L32.7351 11.872L11.5593 0L0 20.128Z" fill="url(#paint1_linear_78_4310)"/>
</g>
<mask id="mask2_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="5" y="2" width="27" height="27">
<path d="M31.9256 2.01599H5.09961V28.672H31.9256V2.01599Z" fill="white"/>
</mask>
<g mask="url(#mask2_78_4310)">
<mask id="mask3_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="11" y="7" width="15" height="16">
<path d="M11.7375 10.576C11.7213 10.672 11.7051 10.752 11.7051 10.848V10.912C11.7213 11.728 12.5146 12.448 14.6192 13.088C16.1896 13.568 18.0352 14.096 20.2693 14.864C23.1348 15.856 25.4985 17.008 24.9804 19.6C24.8347 20.288 24.1224 21.552 22.4225 22.736C22.9406 22.512 23.75 22 24.1872 21.52C24.7052 20.944 25.1585 20.176 25.2719 19.616C25.3204 19.392 25.3366 19.184 25.3366 18.976V18.944C25.3204 16.8 23.0863 15.632 20.4798 14.736C18.2456 13.968 16.4 13.44 14.8296 12.96C12.3365 12.208 11.9155 11.488 11.9317 10.704C11.9479 9.79202 12.9355 8.64002 14.0364 7.96802C12.4174 8.92802 11.867 9.87202 11.7375 10.576Z" fill="white"/>
</mask>
<g mask="url(#mask3_78_4310)">
<path d="M31.9258 11.584L15.0887 2.08002L5.26172 19.104L22.115 28.592L31.9258 11.584Z" fill="url(#paint2_linear_78_4310)"/>
</g>
</g>
<g opacity="0.8">
<mask id="mask4_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="13" y="10" width="16" height="16">
<path d="M28.72 10.128H13.4209V25.056H28.72V10.128Z" fill="white"/>
</mask>
<g mask="url(#mask4_78_4310)">
<mask id="mask5_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="16" y="13" width="10" height="9">
<path d="M17.2739 13.984C17.0148 13.984 16.8691 14.08 16.8691 14.208V14.24C16.8853 14.416 17.1606 14.672 17.7758 14.864C18.4557 15.088 19.3461 15.392 20.0908 15.616C22.5355 16.416 24.7858 17.424 24.3649 19.92C24.2677 20.432 24.203 20.656 23.7982 21.184C23.863 21.104 24.9801 20.624 25.1582 19.392C25.1743 19.264 25.1905 19.136 25.1905 19.008V18.928C25.1582 16.832 22.7783 15.712 20.2527 14.848C19.5728 14.608 18.6662 14.32 17.9053 14.08C17.6786 14.016 17.5005 13.984 17.3386 13.968H17.2739V13.984Z" fill="white"/>
</mask>
<g mask="url(#mask5_78_4310)">
<mask id="mask6_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="13" y="10" width="16" height="16">
<path d="M28.72 10.128H13.4209V25.056H28.72V10.128Z" fill="white"/>
</mask>
<g mask="url(#mask6_78_4310)">
<mask id="mask7_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="13" y="10" width="16" height="16">
<path d="M18.9993 10.1164L13.4277 19.2768L23.1546 25.0551L28.7261 15.8947L18.9993 10.1164Z" fill="white"/>
</mask>
<g mask="url(#mask7_78_4310)">
<path d="M17.4836 3.45599L6.75 21.088L24.6556 31.728L35.3892 14.08L17.4836 3.45599Z" fill="url(#paint3_linear_78_4310)"/>
</g>
</g>
</g>
</g>
</g>
<g opacity="0.5">
<mask id="mask8_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="13" y="12" width="16" height="16">
<path d="M28.931 12.304H13.7129V27.376H28.931V12.304Z" fill="white"/>
</mask>
<g mask="url(#mask8_78_4310)">
<mask id="mask9_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="17" y="15" width="8" height="10">
<path d="M17.8574 18.688C18.3107 18.816 18.7155 18.944 19.0878 19.04C20.9496 19.568 21.5648 20.336 21.3543 21.504C21.1277 22.736 19.0878 23.904 18.845 24.048C20.2697 23.92 22.6819 22.704 23.7828 21.2C24.1875 20.672 24.2523 20.432 24.3494 19.92C24.7541 17.44 22.52 16.416 20.0754 15.616L17.8574 18.688Z" fill="white"/>
</mask>
<g mask="url(#mask9_78_4310)">
<path d="M13.7129 20.784L22.099 27.376L28.9148 18.896L20.5449 12.304L13.7129 20.784Z" fill="url(#paint4_linear_78_4310)"/>
</g>
</g>
</g>
<mask id="mask10_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="7" y="12" width="15" height="13">
<path d="M21.5801 12.368H7.15527V24.048H21.5801V12.368Z" fill="white"/>
</mask>
<g mask="url(#mask10_78_4310)">
<mask id="mask11_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="7" y="12" width="15" height="13">
<path d="M18.9087 19.328C20.7219 19.904 20.9647 20.688 20.9486 21.312C20.9162 22.704 18.9896 23.968 18.8601 24.048C19.1353 23.888 21.1428 22.72 21.3695 21.504C21.5799 20.336 20.9647 19.568 19.103 19.04C18.1316 18.768 16.9336 18.416 15.5089 17.984C14.408 17.664 13.0157 17.168 11.7044 16.608C8.22363 15.088 7.77032 13.232 7.86746 12.368C7.15512 16.592 15.6384 18.288 18.9087 19.328Z" fill="white"/>
</mask>
<g mask="url(#mask11_78_4310)">
<path d="M21.5801 12.368H7.15527V24.032H21.5801V12.368Z" fill="url(#paint5_linear_78_4310)"/>
</g>
</g>
<mask id="mask12_78_4310" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="7" y="5" width="20" height="7">
<path d="M7.00977 11.408H7.23642C9.34105 8.56002 12.7408 6.70402 16.5777 6.70402C20.4147 6.70402 23.8144 8.56002 25.9191 11.408H26.1457C24.4458 7.87202 20.8032 5.44002 16.5777 5.44002C12.3685 5.42402 8.70966 7.87202 7.00977 11.408Z" fill="white"/>
</mask>
<g mask="url(#mask12_78_4310)">
<path d="M6.28125 5.51999L7.30119 13.712L26.8905 11.312L25.8543 3.12L6.28125 5.51999Z" fill="url(#paint6_linear_78_4310)"/>
</g>
</g>
<defs>
<radialGradient id="paint0_radial_78_4310" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(16.5812 23.3647) scale(10.698 10.5728)">
<stop stop-color="#84CFED"/>
<stop offset="0.22" stop-color="#59A7D5"/>
<stop offset="0.45" stop-color="#3284C0"/>
<stop offset="0.67" stop-color="#176BB1"/>
<stop offset="0.86" stop-color="#065BA7"/>
<stop offset="1" stop-color="#0056A4"/>
</radialGradient>
<linearGradient id="paint1_linear_78_4310" x1="10.8516" y1="12.9448" x2="25.3329" y2="21.2553" gradientUnits="userSpaceOnUse">
<stop stop-color="#57BCEC"/>
<stop offset="0.08" stop-color="#4CB1E3"/>
<stop offset="0.34" stop-color="#2B8FC9"/>
<stop offset="0.59" stop-color="#1376B6"/>
<stop offset="0.81" stop-color="#0567AB"/>
<stop offset="1" stop-color="#0062A7"/>
</linearGradient>
<linearGradient id="paint2_linear_78_4310" x1="22.1862" y1="17.3685" x2="13.1713" y2="12.1656" gradientUnits="userSpaceOnUse">
<stop stop-color="#84CFED"/>
<stop offset="0.31" stop-color="#57A6D4"/>
<stop offset="0.78" stop-color="#196DB2"/>
<stop offset="1" stop-color="#0056A4"/>
</linearGradient>
<linearGradient id="paint3_linear_78_4310" x1="22.6372" y1="15.1296" x2="21.6733" y2="16.7523" gradientUnits="userSpaceOnUse">
<stop stop-color="white"/>
<stop offset="0.08" stop-color="white"/>
<stop offset="1" stop-color="white"/>
</linearGradient>
<linearGradient id="paint4_linear_78_4310" x1="18.484" y1="17.6353" x2="23.4572" y2="21.6395" gradientUnits="userSpaceOnUse">
<stop stop-color="white"/>
<stop offset="1" stop-color="#0069B4"/>
</linearGradient>
<linearGradient id="paint5_linear_78_4310" x1="7.71112" y1="18.0613" x2="21.3006" y2="18.0613" gradientUnits="userSpaceOnUse">
<stop stop-color="#84CFED"/>
<stop offset="0.31" stop-color="#57A6D4"/>
<stop offset="0.78" stop-color="#196DB2"/>
<stop offset="1" stop-color="#0056A4"/>
</linearGradient>
<linearGradient id="paint6_linear_78_4310" x1="16.1324" y1="5.2491" x2="18.6841" y2="26.0376" gradientUnits="userSpaceOnUse">
<stop stop-color="#81CDEC"/>
<stop offset="0.08" stop-color="#5FADD8"/>
<stop offset="0.16" stop-color="#4292C8"/>
<stop offset="0.25" stop-color="#2A7CBB"/>
<stop offset="0.35" stop-color="#176BB1"/>
<stop offset="0.47" stop-color="#0A5FA9"/>
<stop offset="0.62" stop-color="#0258A5"/>
<stop offset="0.94" stop-color="#0056A4"/>
<stop offset="1" stop-color="#0056A4"/>
</linearGradient>
<clipPath id="clip0_78_4310">
<rect width="108" height="32" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -0,0 +1,37 @@
#!/bin/bash
# Script pour lier sae-lib comme un module npm local
echo "script de postinstallation pour relier la lib SAE Aero au projet courant"
# Vérifier si npm est installé
if ! [ -x "$(command -v npm)" ]; then
echo 'Erreur: npm n est pas installé.' >&2
exit 1
fi
# Configurer npm pour utiliser un répertoire dans l'espace utilisateur
NPM_PREFIX="$HOME/.npm-global"
mkdir -p "$NPM_PREFIX"
npm config set prefix "$NPM_PREFIX"
# Ajouter temporairement au PATH
export PATH="$NPM_PREFIX/bin:$PATH"
# Aller dans le dossier de la bibliothèque
cd ../my-workspace/projects/sae-lib
# Vérifier si package.json existe
if [ ! -f "package.json" ]; then
echo "Erreur: package.json n\'existe pas dans le dossier sae-lib." >&2
exit 1
fi
echo "Création d'un lien npm pour sae-lib..."
npm link
cd ../../../sae-airwatch
# Utiliser le lien dans l'application
echo "Utilisation du lien dans l'application sae-csc..."
npm link sae-lib
echo "Lien créé avec succès. sae-lib est maintenant disponible comme un module npm."

View file

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ApiService } from './api-service';
describe('ApiService', () => {
let service: ApiService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ApiService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View file

@ -0,0 +1,484 @@
import {Injectable} from '@angular/core';
import {HttpClient, HttpErrorResponse, HttpHeaders} from '@angular/common/http';
import {from, Observable, Subject, throwError} from 'rxjs';
import {catchError, finalize, takeUntil, tap} from 'rxjs/operators';
import {Store} from '@ngrx/store';
import {ActionTypes, StateInterface} from './reducers';
import {ChatbotMessage} from './services/chatbot.message.type';
/**
* Interface for Open-Meteo API response
*/
export interface OpenMeteoResponse {
latitude: number;
longitude: number;
generationtime_ms: number;
utc_offset_seconds: number;
timezone: string;
timezone_abbreviation: string;
elevation: number;
hourly_units: {
time: string;
temperature_2m: string;
};
hourly: {
time: string[];
temperature_2m: number[];
};
}
/**
* gérer la connexion avec le backend
*/
@Injectable({
providedIn: 'root'
})
export class ApiService {
/**
* /api/v1
* /messages
* /{userId}/conversations
* /{conversationId}/feedback
* /conversations/{conversationId}
* /conversations/{conversationId}/last-answer
* /send-documents
* /file // lien pour récupérer un doc via s3
*
*/
private BASE_URL = "";
// Ollama API URL - default to localhost:11434
private OLLAMA_API_URL = "http://localhost:11434";
// Default Ollama model to use
// private OLLAMA_MODEL = "llava";
// private OLLAMA_MODEL = "mistral:7b";
private OLLAMA_MODEL = "tinyllama:latest";
private ENDPOINTS: any = {
"main": {
"v1": {
"messages": "messages",
"user": {
"conversations": "/{userId}/conversations",
"feedback": "/user-feedback"
},
// /{userId}/conversations
// /{conversationId}/feedback
// /conversations/{conversationId}
// /conversations/{conversationId}/last-answer
// /send-documents
// /file
"conversations": {
"id": "/{conversationId}",
"feedback": "/{conversationId}/feedback",
"last-anwser": "/{conversationId}/last-answer",
},
"send-documents": "send-documents",
"file": "file",
}
}
};
private CUSTOM_HEADERS: any = {
"method.response.header.Access-Control-Allow-Headers": "Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token",
"method.response.header.Access-Control-Allow-Methods": "OPTIONS,POST",
"method.response.header.Access-Control-Allow-Origin": "'*'",
}
constructor(private http: HttpClient, private store: Store<StateInterface>) {
}
async fetchEndPoint(kind: string, subKind: string): Promise<Observable<Object>> {
// Record the start time for measuring response time
const startTime = Date.now();
let fetchUrl: string = `${this.BASE_URL}/api/v1`
if (undefined !== this.ENDPOINTS.main.v1[kind]) {
fetchUrl += this.ENDPOINTS.main.v1[kind]
if (undefined !== this.ENDPOINTS.main.v1[kind][subKind]) {
fetchUrl += '/' + this.ENDPOINTS.main.v1[kind][subKind]
}
}
// Get the response and pipe it to measure response time
const resp: Observable<Object> = await this.http.get(fetchUrl,
{headers: this.CUSTOM_HEADERS}
).pipe(
tap(() => {
// Measure and update the response time
this.measureResponseTime(startTime);
})
);
return resp;
}
/**
* Fetches weather forecast data from the Open-Meteo API
*
* @returns Observable with the typed JSON response from Open-Meteo API
*
* Example usage:
* ```
* this.apiService.fetchDemoResponse().subscribe(
* (data) => {
* console.log('Weather data:', data);
* console.log('Temperature at noon:', data.hourly.temperature_2m[12]);
* },
* (error) => console.error('Error fetching weather data:', error)
* );
* ```
*/
fetchDemoResponse(): Observable<OpenMeteoResponse> {
// Coordinates for Corbeil-Essonne
const latitude = "48.57727";
const longitude = "4.42634";
const url = 'https://api.open-meteo.com/v1/forecast';
// Record the start time for measuring response time
const startTime = Date.now();
// Get the current average response time for the delay
return new Observable<OpenMeteoResponse>(observer => {
this.store.select(state => state.app.averageResponseTime).pipe(
tap(averageResponseTime => {
// Use the average response time for the delay
setTimeout(() => {
this.http.get<OpenMeteoResponse>(url, {
params: {
latitude,
longitude,
hourly: 'temperature_2m',
forecast_days: '1'
}
}).pipe(
tap(response => {
console.log('Open-Meteo API Response:', response);
// Measure and update the response time
this.measureResponseTime(startTime);
}),
catchError(this.handleError)
).subscribe({
next: (response) => {
observer.next(response);
observer.complete();
},
error: (error) => {
observer.error(error);
}
});
}, averageResponseTime); // Use the average response time for the delay
})
).subscribe().unsubscribe(); // Unsubscribe after getting the value
});
}
/**
* Send user feedback to the API
* @param feedback The feedback text from the user
* @returns Observable with the API response
*/
async sendUserFeedback(feedback: string): Promise<Observable<Object>> {
// Record the start time for measuring response time
const startTime = Date.now();
const fetchUrl: string = `${this.BASE_URL}/api/v1/user-feedback`;
// Get the response and pipe it to measure response time
const resp: Observable<Object> = await this.http.post(
fetchUrl,
{feedback},
{headers: this.CUSTOM_HEADERS}
).pipe(
tap(() => {
// Measure and update the response time
this.measureResponseTime(startTime);
})
);
return resp;
}
/**
* Check if the Ollama backend is available
* @returns Observable that emits true if Ollama is available, false otherwise
*/
checkOllamaAvailability(): Observable<boolean> {
return new Observable<boolean>(observer => {
// Make a simple request to the Ollama API to check if it's available
this.http.get(`${this.OLLAMA_API_URL}/api/tags`, {
headers: new HttpHeaders({
'Content-Type': 'application/json'
}),
observe: 'response'
}).pipe(
catchError(error => {
console.error('Error checking Ollama availability:', error);
// Update the Redux store to indicate Ollama is not available
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
ollamaAvailable: false
}
});
// Return false to indicate Ollama is not available
return from([false]);
})
).subscribe({
next: (response) => {
// If we get a response, Ollama is available
// Check if response is an HttpResponse (has status property)
const isAvailable = typeof response === 'object' && response !== null && 'status' in response && response.status === 200;
// Update the Redux store with the result
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
ollamaAvailable: isAvailable
}
});
// Emit the result and complete the observable
observer.next(isAvailable);
observer.complete();
},
error: () => {
// If there's an error, Ollama is not available
observer.next(false);
observer.complete();
}
});
});
}
/**
* Query the Ollama backend with a prompt and handle streaming responses
* @param prompt The text prompt to send to Ollama
* @returns Observable that completes when the full response is received
*/
queryOllama(prompt: string): Observable<void> {
// Create a subject to notify when to complete the stream
const complete$ = new Subject<void>();
// Record the start time for measuring response time
const startTime = Date.now();
// Set loading state to true
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
loading: true
}
});
// Create an empty response to accumulate the streamed content
let accumulatedResponse = '';
// Create the request payload
const payload = {
model: this.OLLAMA_MODEL,
prompt: 'réponds en Français en étant un assistant amical et respectueux. Ta réponse doit être consiste steuplai. Et fais des retours à la ligne dans tes réponses. Voici ma question : ' + prompt,
stream: false,
// raw: true,
};
// Set up headers for the request
const headers = new HttpHeaders({
'Content-Type': 'application/json'
});
// Create a subject that will emit the final response
const result = new Subject<void>();
// Make the request to Ollama API
this.http.post(`${this.OLLAMA_API_URL}/api/generate`, payload, {
headers,
responseType: 'json',
observe: 'response'
})
.pipe(
takeUntil(complete$),
finalize(() => {
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
loading: false
}
});
this.measureResponseTime(startTime);
// If we have accumulated a response, create a message and add it to the conversation
if (accumulatedResponse) {
accumulatedResponse = accumulatedResponse.replace(/\. /g, ". <br/><br/>");
const responseMessage = new ChatbotMessage({
kind: 'llm',
user: {},
content: accumulatedResponse,
name: 'Ollama'
});
// Dispatch the message to the active conversation
this.store.dispatch({
type: ActionTypes.POST_MESSAGE_TO_ACTIVE_CONVERSATION,
payload: {
message: responseMessage
}
});
// Get the current active conversation from the store
this.store.select(state => state.activeConversation).subscribe(activeConv => {
if (activeConv && Object.keys(activeConv).length > 0) {
// Update the conversation in the conversations list
this.store.dispatch({
type: ActionTypes.UPDATE_SINGLE_CONVERSATION,
payload: {
conversation: activeConv
}
});
}
}).unsubscribe(); // Unsubscribe immediately after getting the value
}
// Complete the result subject
result.complete();
})
)
.subscribe({
next: (response) => {
console.log('Ollama response:', response);
if (response.body) {
// Process the non-streaming response
// Ollama returns a single JSON object with a 'response' field
try {
const responseData = response.body as any;
if (responseData.response) {
// Set the accumulated response text
accumulatedResponse = responseData.response;
console.log('Ollama response:', accumulatedResponse);
// Complete the stream
complete$.next();
complete$.complete();
} else {
console.error('No response field found in Ollama response:', responseData);
}
} catch (e) {
console.error('Error processing Ollama response:', e);
}
}
},
error: (error) => {
console.error('Error querying Ollama:', error);
// Set loading state to false
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
loading: false,
displayErrorResponse: true
}
});
// Send error message to chat
const errorMessage = new ChatbotMessage({
kind: 'llm',
user: {},
content: "Error connecting to Ollama backend. Please check if the service is running.",
name: 'System'
});
this.store.dispatch({
type: ActionTypes.POST_MESSAGE_TO_ACTIVE_CONVERSATION,
payload: {
message: errorMessage
}
});
// Get the current active conversation from the store
this.store.select(state => state.activeConversation).subscribe(activeConv => {
if (activeConv && Object.keys(activeConv).length > 0) {
// Update the conversation in the conversations list
this.store.dispatch({
type: ActionTypes.UPDATE_SINGLE_CONVERSATION,
payload: {
conversation: activeConv
}
});
}
}).unsubscribe(); // Unsubscribe immediately after getting the value
// Reset error state after 3 seconds
setTimeout(() => {
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
displayErrorResponse: false
}
});
}, 3000);
// Complete the subjects
complete$.next();
complete$.complete();
result.error(error);
}
});
return result.asObservable();
}
/**
* Updates the average response time in the store
* @param responseTime The actual response time in milliseconds
*/
private updateAverageResponseTime(responseTime: number): void {
// Get the current average response time from the store
this.store.select(state => state.app.averageResponseTime).subscribe(currentAverage => {
// Calculate the new average (average of current average and new response time)
const newAverage = Math.round((currentAverage + responseTime) / 2);
// Update the store with the new average
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
averageResponseTime: newAverage
}
});
}).unsubscribe(); // Unsubscribe immediately after getting the value
}
/**
* Measures the response time of an API call and updates the average
* @param startTime The timestamp when the API call started
*/
private measureResponseTime(startTime: number): void {
const endTime = Date.now();
const responseTime = endTime - startTime;
this.updateAverageResponseTime(responseTime);
}
/**
* Error handler for HTTP requests
* @param error The HTTP error response
* @returns An observable that errors with a user-friendly message
*/
private handleError(error: HttpErrorResponse): Observable<never> {
let errorMessage = 'An unknown error occurred';
if (error.error instanceof ErrorEvent) {
// Client-side error
errorMessage = `Error: ${error.error.message}`;
} else {
// Server-side error
errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}`;
}
console.error(errorMessage);
return throwError(() => new Error(errorMessage));
}
}

View file

@ -0,0 +1,12 @@
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
import { provideServerRendering, withRoutes } from '@angular/ssr';
import { appConfig } from './app.config';
import { serverRoutes } from './app.routes.server';
const serverConfig: ApplicationConfig = {
providers: [
provideServerRendering(withRoutes(serverRoutes))
]
};
export const config = mergeApplicationConfig(appConfig, serverConfig);

View file

@ -0,0 +1,20 @@
import {ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection, isDevMode} from '@angular/core';
import {provideRouter} from '@angular/router';
import {routes} from './app.routes';
import {provideHttpClient, withFetch} from '@angular/common/http';
import { provideStore } from '@ngrx/store';
import { reducers, metaReducers } from './reducers';
import { provideStoreDevtools } from '@ngrx/store-devtools';
export const appConfig: ApplicationConfig = {
providers: [
provideBrowserGlobalErrorListeners(),
provideHttpClient(withFetch()),
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideStore(reducers, { metaReducers }),
provideStoreDevtools({ maxAge: 25, logOnly: !isDevMode() })
]
};

View file

@ -0,0 +1,32 @@
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * The content below * * * * * * * * * * * -->
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * -->
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * Delete the template below * * * * * * * * * -->
<!-- * * * * * * * to get started with your project! * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<style>
</style>
<main class="main">
<div class="content">
<h1>Hello, {{ title() }}</h1>
<p>Congratulations! Your app is running. 🎉</p>
</div>
<div aria-label="Divider" class="divider" role="separator"></div>
</main>
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * The content above * * * * * * * * * * * * -->
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * * -->
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * End of Placeholder * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<router-outlet/>

View file

@ -0,0 +1,8 @@
import { RenderMode, ServerRoute } from '@angular/ssr';
export const serverRoutes: ServerRoute[] = [
{
path: '**',
renderMode: RenderMode.Prerender
}
];

View file

@ -0,0 +1,41 @@
import {Routes} from '@angular/router';
import {ColorsPage} from './pages/colors-page/colors-page';
import {AirwatchDemo} from './pages/airwatch-demo/airwatch-demo';
import {Csc} from './pages/csc/csc';
import {LayoutDemo} from './pages/layout-demo/layout-demo';
export const routes: Routes = [
{
path: '',
component: LayoutDemo,
title: 'Démo Layout'
},
{
path: 'home',
component: LayoutDemo,
title: 'Démo Layout'
},
{
path: 'grid',
loadComponent: () => import('./pages/grid-demo/grid-demo').then(m => m.GridDemo),
title: 'Démo AG Grid'
},
{
path: 'colors',
component: ColorsPage,
},
{
path: 'airwatch',
component: AirwatchDemo,
},
{
path: 'csc',
component: Csc,
},
{
path: '*',
redirectTo: 'home',
pathMatch: 'full'
}
];

View file

View file

@ -0,0 +1,23 @@
import { TestBed } from '@angular/core/testing';
import { App } from './app';
describe('App', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [App],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(App);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it('should render title', () => {
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, my-app');
});
});

View file

@ -0,0 +1,22 @@
import {Component, signal} from '@angular/core';
import {RouterOutlet} from '@angular/router';
@Component({
selector: 'app-root',
imports: [RouterOutlet],
template: `
<div id="app_main_page">
<main>
<router-outlet/>
</main>
<footer class="main-footer">
</footer>
</div>
`,
styles: [`
`],
})
export class App {
protected readonly title = signal('Exemple de Boutons');
}

View file

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { AuthService } from './auth-service';
describe('AuthService', () => {
let service: AuthService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AuthService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View file

@ -0,0 +1,35 @@
import {Injectable} from '@angular/core';
import {Inject} from '@angular/core';
import {DOCUMENT} from '@angular/common';
@Injectable({
providedIn: 'root'
})
export class AuthService {
// check if we have auth at load, or redirect to the given app url
app_check_url: string = "https://example.com/check";
app_auth_url: string = "https://example.com/auth";
auth_data: any = null;
private window: WindowProxy & typeof globalThis | null;
constructor(@Inject(DOCUMENT) private document: Document) {
this.window = this.document.defaultView;
this.checkAuthData()
}
checkAuthData() {
if (this.auth_data) {
fetch(this.app_auth_url).then(resp => {
if (resp.status !== 200) {
this.redirectToAuth()
}
})
}
}
redirectToAuth() {
this.window?.open(this.app_auth_url)
}
}

View file

@ -0,0 +1,297 @@
<div [ngClass]="{
'is-expanded-left': appState.displayConversationListPanelLarge,
'is-small-left': ! appState.displayConversationListPanelLarge,
'is-expanded-right': appState.displaySourcesPanelLarge,
'is-small-right': ! appState.displaySourcesPanelLarge,
}" class="visible-imbrication chatbot-land"
id="layout_demo"
>
<div class="demo-airwatch">
<div class="layout-split">
<nav aria-label="main navigation" class="navbar" role="navigation">
<div class="navbar-brand">
<a class="navbar-item" href="/#">
<!-- <i class="ri-robot-2-fill"></i>-->
<img alt="safran logo" class="logo" src="/safran_logo_large.svg">
</a>
<a aria-expanded="false" aria-label="menu" class="navbar-burger" data-target="navbarBasicExample"
role="button">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div class="navbar-menu" id="airwatchNavigation">
<div class="navbar-start">
<a (click)="toggleSidePanelConversationsList()" class="navbar-item aside-toggle-button">
<span class="label">
airwatch
</span>
@if (appState.displayConversationListPanelLarge) {
<i class="ri-sidebar-unfold-line"></i>
} @else {
<i class="ri-sidebar-fold-line"></i>
}
</a>
</div>
<div class="navbar-end">
<a (click)="toggleSourcesPanel()" class="navbar-item aside-toggle-button">
@if (appState.displaySourcesPanelLarge) {
<i class="ri-layout-right-2-line"></i>
} @else {
<i class="ri-layout-right-line"></i>
}
</a>
<a class="navbar-item">
Documentation
</a>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">
<i class="ri-notification-2-line"></i>
</a>
<div class="navbar-dropdown">
<a class="navbar-item">
About
</a>
<a class="navbar-item is-selected">
Jobs
</a>
<a class="navbar-item">
Contact
</a>
<hr class="navbar-divider">
<a class="navbar-item">
Report an issue
</a>
</div>
</div>
</div>
</div>
</nav>
<div class="chatbot-container-box">
<main class="columns ">
<div
[ngClass]="{'is-expanded': appState.displayConversationListPanelLarge, 'is-small': ! appState.displayConversationListPanelLarge}"
class="aside column-conversation ">
<div (click)="newChat()" class="new-button">
<i class="ri-chat-ai-line"></i>
<span class="label">
New chat
</span>
</div>
@if (appState.displayConversationListPanelLarge) {
<div class="search-button is-expanded is-clickable">
<i class="ri-search-line"></i>
<input type="text" class="no-borders" placeholder="Search a chat" value="blah">
<i class="funnel ri-filter-3-line"></i>
</div>
} @else {
<div class="search-button is-clickable">
<i class="ri-search-line"></i>
</div>
}
@if (appState.displayConversationListPanelLarge) {
<div class="conversation-container">
@for (conversation of conversationsList; track conversation) {
<div class="conversation-item"
[ngClass]="{'is-active' : conversation.name == activeConversation?.name }"
(click)="updateActiveConversation(conversation)">
<!-- @if (conversation.pinned) {-->
<!-- }-->
<!-- <i class="ri-arrow-right-s-line"></i>-->
<div class="container-text">
<span class="pinned-icon">
<i class="ri-pushpin-line"></i>
<!-- pinned-->
</span>
<span class="name">
{{ conversation.name || 'New Conversation' }}
</span>
<span class="date">
{{ conversation.lastMessageDate | date: 'dd/MM/yyyy' }}
</span>
<span class="description">
{{ conversation.description || 'No description' }}
</span>
<input type="text" [(ngModel)]="conversation.name"
[ngClass]="{'is-expanded': ! conversation.visibleInput}">
<!-- <i class="ri-pencil-line" (click)="toggleVisibleEditInput(conversation)"></i>-->
</div>
<div class="active-peak">
<svg width="12" height="14" viewBox="0 0 12 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 7L0 13.9282V0.0717969L12 7Z" fill="#3B87CC" fill-opacity="0.1"/>
</svg>
</div>
</div>
}
<app-version-infos [versionInfo]="appVersion"></app-version-infos>
</div>
<!-- <div class="admin-actions debug">-->
<!-- <app-theme-selector></app-theme-selector>-->
<!-- <app-language-selector></app-language-selector>-->
<!-- <br>-->
<!-- <app-main-button (click)="changeTheme()" icon="chat-new-line" label="thème"></app-main-button>-->
<!-- <app-main-button (click)="newChat()" icon="chat-new-line" label="nouveau"></app-main-button>-->
<!-- <app-main-button (click)="addMockMessage('user')" icon="user-line"-->
<!-- label="ajout message utilisateur"></app-main-button>-->
<!-- <app-main-button (click)="addMockMessage('llm')" icon="robot-2-line"-->
<!-- label="ajout message llm"></app-main-button>-->
<!-- <app-tuto-tour></app-tuto-tour>-->
<!-- </div>-->
}
</div>
<div class="chat chat-column ">
<div id="newChatBar">
<div class="new-chat-title">
<div class="title">
{{ translate('newChat') }}
</div>
<div class="chips">
@if (displayChipsTitleConversations) {
<div class="chips-container is-grey">
<i class="ri-pushpin-line"></i>
<span class="label">
Chips land
</span>
</div>
}
</div>
<div class="action">
@if (displayExportConversation) {
<div class="export-chat-button is-clickable">
<i class="ri-download-2-line"></i>
<span class="label">
Export chat
</span>
</div>
}
</div>
</div>
</div>
<!-- tchatt-->
@if (!activeConversation?.messages?.length) {
<app-new-input></app-new-input>
} @else {
<div #conversationContainer class="main-conversation-container">
<!-- main-conversation-container-->
<!-- <div class="top-bar">-->
<!-- top bar-->
<!-- <div class="conversation-title">-->
<!-- {{ activeConversation?.name || 'New Conversation' }}-->
<!-- </div>-->
<!-- <div class="conversation-typing">-->
<!-- typing-->
<!-- </div>-->
<!-- </div>-->
<div class="conversation-messages-container">
@if (activeConversation && activeConversation.messages) {
@for (message of activeConversation.messages; track message) {
<app-message-box [message]="message" [kind]="message.kind"
[content]="message.content"></app-message-box>
}
}
@if (appState.loading) {
<app-loading-notification></app-loading-notification>
}
<!-- <app-time-separator></app-time-separator>-->
<!-- <sae-alert-box _alertKind="error" message="">System error - I couldnt process your request.-->
<!-- Please-->
<!-- try-->
<!-- again in-->
<!-- few moments-->
<!-- </sae-alert-box>-->
</div>
<div class="conversation-bottom">
<app-prompt-input></app-prompt-input>
<app-tools-options [alignLeft]="true" [hideDisabledButtons]="true"></app-tools-options>
</div>
</div>
}
<div class="bottom-warning-container">
<app-warning-bugs></app-warning-bugs>
</div>
</div>
<div [ngClass]="{'expanded': appState.displaySourcesPanelLarge}" class="column panel-more">
<div class="has-text-right">
<div class="export-chat-button is-clickable">
<i class="ri-download-2-line"></i>
<span class="label">
Export all sources
</span>
</div>
</div>
<div class="panel-more-inside">
<div class="main-title">Knowledge Base documents :</div>
<div class="sources-list">
@if (activeConversation && activeConversation.sources && activeConversation.sources.length > 0) {
@for (source of activeConversation.sources; track source) {
<app-source-block [source]="source"></app-source-block>
}
} @else {
<div class="no-sources">
Aucune source disponible
</div>
}
</div>
</div>
</div>
<app-feedback-button></app-feedback-button>
</main>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,93 @@
.panel-more-inside {
border-radius: 10px;
background: #F5F5F5;
padding: 20px 16px;
min-height: 100vh;
margin-top: 14px;
.main-title {
color: #1E1F22;
font-size: 16px;
font-style: normal;
font-weight: 600;
line-height: normal;
}
.sources-list {
margin-top: 17px;
}
.source {
border-radius: 4px;
background: #ECF3FA;
}
}
.chips-container {
display: inline-flex;
padding: 4px 10px 6px 10px;
justify-content: center;
align-items: center;
gap: 10px;
border-radius: 6px;
background: #979797;
margin-left: 12px;
margin-right: 12px;
position: relative;
top: -3px;
i {
color: white;
}
.label {
color: #FFF;
text-align: center;
font-family: Barlow;
font-size: 12px;
font-style: normal;
font-weight: 600;
line-height: 8px; /* 66.667% */
}
}
.export-chat-button {
position: relative;
right: 0;
display: inline-flex;
height: 44px;
padding: 0 20px;
justify-content: center;
align-items: center;
gap: 10px;
flex-shrink: 0;
border-radius: 8px;
border: 1px solid #005AA2;
color: #005AA2;
text-align: center;
font-size: 20px;
font-style: normal;
font-weight: 500;
line-height: 100px; /* 500% */
}
.aside-toggle-button {
color: white;
color: #FFF;
font-family: Barlow;
font-size: 18px;
font-style: normal;
font-weight: 500;
line-height: normal;
text-transform: uppercase;
.label {
margin-right: 22px;
}
}

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Chatbot } from './chatbot';
describe('Chatbot', () => {
let component: Chatbot;
let fixture: ComponentFixture<Chatbot>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Chatbot]
})
.compileComponents();
fixture = TestBed.createComponent(Chatbot);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,323 @@
import {AfterViewChecked, Component, ElementRef, ViewChild} from '@angular/core';
import {PromptInput} from './prompt-input/prompt-input';
import {MessageBox} from './message-box/message-box';
import {NewInput} from './new-input/new-input';
import {FeedbackButton} from './feedback-button/feedback-button';
import {WarningBugs} from './warning-bugs/warning-bugs';
import {VersionInfos} from './version-infos/version-infos';
import {LoadingNotification} from './loading-notification/loading-notification';
import {SourceBlock} from './source-block/source-block';
import {ChatbotConversation, ChatbotSource, ConversationsService} from '../services/conversations.service';
import {Store} from '@ngrx/store';
import {ActionTypes, StateInterface} from '../reducers';
import {FormsModule} from '@angular/forms';
import {ApiService} from '../api-service';
import {CommonModule} from '@angular/common';
import {ChatbotMessage, ChatbotMessageKind} from '../services/chatbot.message.type';
import {ToolsOptions} from './tools-options/tools-options';
import {TranslationService} from '../services/translation.service';
@Component({
selector: 'app-chatbot',
imports: [
PromptInput,
MessageBox,
NewInput,
FeedbackButton,
WarningBugs,
VersionInfos,
LoadingNotification,
SourceBlock,
FormsModule,
CommonModule,
ToolsOptions,
],
templateUrl: './chatbot.html',
styleUrl: './chatbot.scss'
})
export class Chatbot implements AfterViewChecked {
public conversationsList: Array<ChatbotConversation> = [];
public activeConversation: ChatbotConversation | null = null;
public appVersion: string = '';
public appState: any = '';
conversationName: any;
// fonctions d'exports
visibleInput: boolean = false;
// demo tour lors du premier chargement
displayChipsTitleConversations = true;
displayExportConversation: boolean = true;
@ViewChild('conversationContainer') private conversationContainer: ElementRef | null = null;
private shouldScrollToBottom: boolean = false;
constructor(
private conversations: ConversationsService,
private apiService: ApiService,
private store: Store<StateInterface>,
private translationService: TranslationService
) {
// Initialize conversations in the store
this.store.dispatch({
type: ActionTypes.UPDATE_CONVERSATIONS_LIST,
payload: conversations.chatbotConversations
});
// Subscribe to conversations list from store
this.store.select(state => state.conversationsList).subscribe(convList => {
this.conversationsList = convList;
if (!this.conversationsList.length) {
this.newChat();
}
});
// Subscribe to active conversation from store
this.store.select(state => state.activeConversation).subscribe(activeConv => {
if (activeConv && Object.keys(activeConv).length > 0) {
const prevMessagesLength = this.activeConversation?.messages?.length || 0;
this.activeConversation = activeConv as ChatbotConversation;
const newMessagesLength = this.activeConversation?.messages?.length || 0;
console.log('prevMessagesLength', prevMessagesLength, newMessagesLength);
// Set flag to scroll to bottom when active conversation changes or when messages are added
if (prevMessagesLength !== newMessagesLength) {
this.shouldScrollToBottom = true;
}
} else if (this.conversationsList.length > 0) {
this.updateActiveConversation(this.conversationsList[0]);
}
});
// Get app version from store
this.store.select(state => state.app.version).subscribe(version => {
this.appVersion = version;
});
// Get app state from store
this.store.select(state => state.app).subscribe(app => {
this.appState = app;
});
// à désactiver en mode production
this.demoConversation();
}
/**
* Lifecycle hook that is called after the view has been checked
* Used to scroll to the bottom of the conversation container when needed
*/
ngAfterViewChecked(): void {
if (this.shouldScrollToBottom && this.conversationContainer) {
this.scrollToBottom();
this.shouldScrollToBottom = false;
}
}
/**
* Translates a key using the translation service
* @param key The key to translate
* @param defaultValue Optional default value if translation is not found
* @returns The translated string
*/
translate(key: string, defaultValue?: string): string {
return this.translationService.translate(key, defaultValue);
}
demoConversation() {
// Add example sources if in demo mode
if (this.appState.demoMode && this.activeConversation) {
console.log('mode démo: on ajoute des demoConversation');
// Create a proper instance of ChatbotConversation from the active conversation
const updatedConversation: ChatbotConversation = ChatbotConversation.fromObject(this.activeConversation);
this.addMockMessage("user");
// Add three example sources
let source1 = new ChatbotSource();
source1.title = "abc-1258.pdf";
source1.url = "https://example.com/source1";
source1.description = "Admittedly Air Traffic Control in smaller airports are being effected by ...";
let source2 = new ChatbotSource();
source2.title = "abc-45689.pdf";
source2.url = "https://example.com/source1";
source2.description = "DE GAGNE DATE: JANUARY 18, 2008 VEN #: V6-CAW-M2700-10 APPROVED BY: MARTIN SWAN DATE: FEBRUARY 5, 2008 -TITLE- DHC-6 ELEVATOR CONTROL CABLE WEAR SURVEY RESULTS ISSUE: 2 PAGE 2 respondents, representing 16 aircraft, operate outside the tropics and have a cycle/hour ratio of 1.6 to 2.8. Most respondents have reported that carbon steel elevator control cables are more wear resistant than stainless steel cables. Two operators in the tropics, representing 39 aircraft, use.\n" +
"I remember having reconunended while dealing with the Guwahati crash in regard to a Vayudoot aircraft that the National Airports Authority should ensure that only trained and";
updatedConversation.sources = [source1, source2];
const conversation2 = new ChatbotConversation();
conversation2.name = "Liste de courses";
conversation2.addMessage(new ChatbotMessage({
kind: 'user',
user: {},
content: "Comment puis-je utiliser cette application?",
name: "User"
}));
conversation2.addMessage(new ChatbotMessage({
kind: 'llm',
user: {},
content: "Cette application vous permet de discuter avec un assistant IA. Vous pouvez poser des questions et obtenir des réponses.",
name: "Assistant"
}));
// Update the active conversation in the store
this.updateActiveConversation(updatedConversation);
// Update the conversations list in the store
const updatedList = this.conversationsList.map(conv =>
conv === this.activeConversation ? updatedConversation : conv
);
updatedList.push(conversation2)
this.store.dispatch({
type: ActionTypes.UPDATE_CONVERSATIONS_LIST,
payload: updatedList
});
// Set the first conversation as active
this.updateActiveConversation(updatedConversation);
}
}
updateActiveConversation(conversation: ChatbotConversation) {
this.store.dispatch({
type: ActionTypes.UPDATE_ACTIVE_CONVERSATION,
payload: conversation
});
}
addMockMessage(kind: ChatbotMessageKind, content?: string) {
if (this.activeConversation) {
// Create a proper instance of ChatbotConversation from the active conversation
const updatedConversation = ChatbotConversation.fromObject(this.activeConversation);
// Add the message to the copy
updatedConversation.addMessage(new ChatbotMessage({
kind: kind,
user: {},
content: content ? content : "blah",
name: "Mock Message"
}));
// Update the active conversation in the store
this.updateActiveConversation(updatedConversation);
// Update the conversations list in the store
const updatedList = this.conversationsList.map(conv =>
conv === this.activeConversation ? updatedConversation : conv
);
this.store.dispatch({
type: ActionTypes.UPDATE_CONVERSATIONS_LIST,
payload: updatedList
});
// Set flag to scroll to bottom after adding a message
this.shouldScrollToBottom = true;
}
}
newChat() {
const newConv = new ChatbotConversation();
newConv.name = "Other conversation " + (this.conversationsList.length + 1);
// Update the conversations list in the store by adding the new conversation to the existing list
this.store.dispatch({
type: ActionTypes.UPDATE_CONVERSATIONS_LIST,
payload: [...this.conversationsList, newConv]
});
// Set the new conversation as active
this.updateActiveConversation(newConv);
}
toggleSidePanelConversationsList() {
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
displayConversationListPanelLarge: !this.appState.displayConversationListPanelLarge
}
});
}
toggleSourcesPanel() {
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
displaySourcesPanelLarge: !this.appState.displaySourcesPanelLarge
}
});
}
launchDemoTour() {
}
endDemoTour() {
}
exportMessage() {
}
exportConversation() {
}
copyToClipboard(text: string) {
}
toggleVisibleEditInput(conversation: ChatbotConversation) {
// Create a copy of the conversation
const updatedConversation = ChatbotConversation.fromObject(conversation);
// Toggle the visibleInput property
updatedConversation.visibleInput = !conversation.visibleInput;
// Update the active conversation if this is the active one
if (this.activeConversation === conversation) {
this.updateActiveConversation(updatedConversation);
}
// Update the single conversation in the store without replacing the entire list
this.store.dispatch({
type: ActionTypes.UPDATE_SINGLE_CONVERSATION,
payload: {
conversation: updatedConversation
}
});
}
changeTheme() {
// Dispatch the action to switch to the next theme
this.store.dispatch({type: ActionTypes.SWITCH_TO_NEXT_THEME});
}
changeLang() {
// Dispatch the action to switch to the next language
this.store.dispatch({type: ActionTypes.SWITCH_TO_NEXT_LANGUAGE});
}
/**
* Scrolls to the bottom of the conversation container
*/
private scrollToBottom(): void {
try {
const element = this.conversationContainer?.nativeElement;
if (element) {
element.scrollTop = element.scrollHeight;
}
} catch (err) {
console.error('Error scrolling to bottom:', err);
}
}
}

View file

@ -0,0 +1,67 @@
<div class="feedback-button" (click)="toggleModal()">
<span class="text">
Feedback
</span>
<i class="ri-message-2-line"></i>
</div>
<!-- Feedback Modal -->
@if (isModalOpen) {
<div class="feedback-modal-overlay">
<div class="feedback-modal">
<div class="modal-header">
<h3>Send Feedback</h3>
<button class="close-button" (click)="toggleModal()">
<i class="ri-close-line"></i>
</button>
</div>
<div class="modal-body">
<p class="modal-description">
Help us improve by sharing your feedback, suggestions, or reporting issues.
</p>
<textarea
[(ngModel)]="feedbackText"
placeholder="Enter your feedback here..."
[disabled]="isSubmitting"
rows="5"
></textarea>
@if (submitSuccess) {
<div class="success-message">
<i class="ri-check-line"></i> Thank you for your feedback!
</div>
}
@if (submitError) {
<div class="error-message">
<i class="ri-error-warning-line"></i> Failed to submit feedback. Please try again.
</div>
}
</div>
<div class="modal-footer">
<button
class="cancel-button"
(click)="toggleModal()"
[disabled]="isSubmitting"
>
Cancel
</button>
<button
class="submit-button"
(click)="submitFeedback()"
[disabled]="isSubmitting || !feedbackText.trim()"
>
@if (isSubmitting) {
<i class="ri-loader-4-line spinning"></i> Sending...
} @else {
Send Feedback
}
</button>
</div>
</div>
</div>
}

View file

@ -0,0 +1,191 @@
.feedback-button {
background: #ecf3fa;
color: #083b7d;
padding: 12px;
border-radius: 8px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
transform: rotate(270deg);
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
margin-right: -35px;
position: fixed;
right: 0;
top: 240px;
z-index: 100;
&:hover {
background: #d9e8f6;
}
i {
font-size: 16px;
}
}
// Modal styles
.feedback-modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}
.feedback-modal {
background: white;
border-radius: 8px;
width: 90%;
max-width: 500px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
display: flex;
flex-direction: column;
max-height: 90vh;
overflow: hidden;
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 20px;
border-bottom: 1px solid #eee;
h3 {
margin: 0;
font-size: 18px;
font-weight: 600;
color: #083b7d;
}
.close-button {
background: none;
border: none;
cursor: pointer;
font-size: 20px;
color: #666;
padding: 4px;
&:hover {
color: #333;
}
}
}
.modal-body {
padding: 20px;
overflow-y: auto;
.modal-description {
margin-bottom: 16px;
color: #555;
}
textarea {
width: 100%;
padding: 12px;
border: 1px solid #ddd;
border-radius: 4px;
resize: vertical;
font-family: inherit;
font-size: 14px;
&:focus {
outline: none;
border-color: #083b7d;
}
&:disabled {
background-color: #f5f5f5;
cursor: not-allowed;
}
}
.success-message, .error-message {
margin-top: 16px;
padding: 10px;
border-radius: 4px;
display: flex;
align-items: center;
gap: 8px;
i {
font-size: 18px;
}
}
.success-message {
background-color: #e6f7e6;
color: #2e7d32;
}
.error-message {
background-color: #fdecea;
color: #d32f2f;
}
}
.modal-footer {
padding: 16px 20px;
border-top: 1px solid #eee;
display: flex;
justify-content: flex-end;
gap: 12px;
button {
padding: 8px 16px;
border-radius: 4px;
font-weight: 500;
cursor: pointer;
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
}
.cancel-button {
background: none;
border: 1px solid #ddd;
color: #555;
&:hover:not(:disabled) {
background-color: #f5f5f5;
}
}
.submit-button {
background-color: #083b7d;
color: white;
border: none;
display: flex;
align-items: center;
gap: 8px;
&:hover:not(:disabled) {
background-color: #062c5e;
}
}
}
// Spinner animation
.spinning {
animation: spin 1s linear infinite;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FeedbackButton } from './feedback-button';
describe('FeedbackButton', () => {
let component: FeedbackButton;
let fixture: ComponentFixture<FeedbackButton>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [FeedbackButton]
})
.compileComponents();
fixture = TestBed.createComponent(FeedbackButton);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,88 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Store } from '@ngrx/store';
import { ApiService } from '../../api-service';
import { ActionTypes, StateInterface } from '../../reducers';
@Component({
selector: 'app-feedback-button',
imports: [CommonModule, FormsModule],
templateUrl: './feedback-button.html',
styleUrl: './feedback-button.scss'
})
export class FeedbackButton {
isModalOpen: boolean = false;
feedbackText: string = '';
isSubmitting: boolean = false;
submitSuccess: boolean = false;
submitError: boolean = false;
constructor(
private store: Store<StateInterface>,
private apiService: ApiService
) {}
toggleModal() {
this.isModalOpen = !this.isModalOpen;
// Reset state when opening modal
if (this.isModalOpen) {
this.feedbackText = '';
this.submitSuccess = false;
this.submitError = false;
}
// Update app state to show/hide feedback panel
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
displayFeedBackPanel: this.isModalOpen,
feedBackInput: this.feedbackText
}
});
}
async submitFeedback() {
if (!this.feedbackText.trim()) {
return; // Don't submit empty feedback
}
this.isSubmitting = true;
this.submitSuccess = false;
this.submitError = false;
try {
// Update Redux state with feedback text
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
feedBackInput: this.feedbackText
}
});
// Dispatch action to send feedback
this.store.dispatch({
type: ActionTypes.SEND_USER_FEEDBACK,
payload: {
feedback: this.feedbackText
}
});
// Call API service directly
await this.apiService.sendUserFeedback(this.feedbackText);
this.submitSuccess = true;
// Close modal after a short delay
setTimeout(() => {
this.toggleModal();
}, 2000);
} catch (error) {
console.error('Error submitting feedback:', error);
this.submitError = true;
} finally {
this.isSubmitting = false;
}
}
}

View file

@ -0,0 +1 @@
<p>feedback-message works!</p>

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FeedbackMessage } from './feedback-message';
describe('FeedbackMessage', () => {
let component: FeedbackMessage;
let fixture: ComponentFixture<FeedbackMessage>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [FeedbackMessage]
})
.compileComponents();
fixture = TestBed.createComponent(FeedbackMessage);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-feedback-message',
imports: [],
templateUrl: './feedback-message.html',
styleUrl: './feedback-message.scss'
})
export class FeedbackMessage {
}

View file

@ -0,0 +1,9 @@
<div class="language-selector">
<button
(click)="switchToNextLanguage()"
class="language-selector__button"
title="Switch to next language">
<span class="language-selector__current-lang">{{ getLanguageDisplayName(currentLang) }}</span>
<span class="language-selector__icon">🌐</span>
</button>
</div>

View file

@ -0,0 +1,56 @@
.language-selector {
display: inline-block;
margin: 10px;
&__button {
display: flex;
align-items: center;
padding: 8px 12px;
background-color: #f0f0f0;
border: 1px solid #ccc;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s ease;
&:hover {
background-color: #e0e0e0;
}
&:active {
transform: translateY(1px);
}
}
&__current-lang {
margin-right: 8px;
text-transform: capitalize;
}
&__icon {
font-size: 1.2em;
}
}
// Language-specific styles that will be applied when the body has the corresponding class
:host-context(body.app-theme-light) {
.language-selector__button {
background-color: #f8f8f8;
color: #333;
}
}
:host-context(body.app-theme-dark) {
.language-selector__button {
background-color: #333;
color: #f8f8f8;
border-color: #555;
}
}
:host-context(body.app-theme-funky) {
.language-selector__button {
background-color: #ff00ff;
color: #00ffff;
border-color: #ffff00;
}
}

View file

@ -0,0 +1,57 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Store } from '@ngrx/store';
import { Subscription } from 'rxjs';
import { ActionTypes, StateInterface } from '../../reducers';
import { TranslationService } from '../../services/translation.service';
@Component({
selector: 'app-language-selector',
standalone: true,
imports: [CommonModule],
templateUrl: './language-selector.html',
styleUrl: './language-selector.scss'
})
export class LanguageSelector implements OnInit, OnDestroy {
currentLang: string = '';
langsList: string[] = [];
private storeSubscription: Subscription | null = null;
constructor(
private store: Store<StateInterface>,
private translationService: TranslationService
) {}
ngOnInit(): void {
// Subscribe to the store to get the current language and languages list
this.storeSubscription = this.store.select(state => state.app)
.subscribe(app => {
this.currentLang = app.lang;
this.langsList = app.langsList;
});
}
ngOnDestroy(): void {
// Unsubscribe to prevent memory leaks
if (this.storeSubscription) {
this.storeSubscription.unsubscribe();
}
}
// Method to switch to the next language
switchToNextLanguage(): void {
this.store.dispatch({ type: ActionTypes.SWITCH_TO_NEXT_LANGUAGE });
}
// Helper method to display a friendly language name
getLanguageDisplayName(langCode: string): string {
switch (langCode) {
case 'fr_FR':
return 'Français';
case 'en_US':
return 'English';
default:
return langCode;
}
}
}

View file

@ -0,0 +1,10 @@
<div class="loading-notification">
<div class="progress-container">
<div [style.animation-duration.ms]="averageResponseTime" class="progress-bar"></div>
</div>
<!-- <span class="text">-->
<!-- ça charge-->
<!-- </span>-->
</div>

View file

@ -0,0 +1,40 @@
.loading-notification {
display: flex;
flex-direction: column;
align-items: center;
padding: 10px;
.text {
margin-top: 8px;
font-size: 14px;
color: #666;
}
.progress-container {
width: 100%;
height: 4px;
background-color: #f0f0f0;
border-radius: 2px;
overflow: hidden;
margin-bottom: 8px;
}
.progress-bar {
height: 100%;
width: 100%;
background-color: #083b7d; // Same blue color as in the feedback button
transform: translateX(-100%);
animation-name: progress;
animation-timing-function: linear;
animation-fill-mode: forwards;
}
}
@keyframes progress {
0% {
transform: translateX(-100%);
}
100% {
transform: translateX(0);
}
}

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoadingNotification } from './loading-notification';
describe('LoadingNotification', () => {
let component: LoadingNotification;
let fixture: ComponentFixture<LoadingNotification>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [LoadingNotification]
})
.compileComponents();
fixture = TestBed.createComponent(LoadingNotification);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,27 @@
import {Component} from '@angular/core';
import {Store} from '@ngrx/store';
import {StateInterface} from '../../reducers';
import {CommonModule} from '@angular/common';
@Component({
selector: 'app-loading-notification',
imports: [CommonModule],
templateUrl: './loading-notification.html',
styleUrl: './loading-notification.scss'
})
export class LoadingNotification {
protected loading: boolean = false;
protected averageResponseTime: number = 500; // Default value
constructor(private store: Store<StateInterface>) {
// Subscribe to the app state to get the loading state
this.store.select(state => state.app.loading).subscribe(loading => {
this.loading = loading;
});
// Subscribe to the app state to get the average response time
this.store.select(state => state.app.averageResponseTime).subscribe(time => {
this.averageResponseTime = time;
});
}
}

View file

@ -0,0 +1,62 @@
<div class="message {{kind}}" id="message_{{id}}">
<div class="actions ">
@if (kind === 'user') {
<button (click)="editMessage()" class="button edit">
<i class="ri-edit-box-line"></i>
</button>
} @else {
<div class="">
<div class="action-feedback">
<app-feedback-button></app-feedback-button>
</div>
</div>
<div class=" has-text-right">
<button (click)="generateResponse()" class="button generate-response">
<i class="ri-refresh-line"></i>
<span class="label">
Generate Response
</span>
</button>
<app-copy [textToCopy]="content"></app-copy>
<button (click)="bookmark()" class="button bookmark">
<i class="ri-bookmark-line"></i>
</button>
</div>
}
</div>
<div class="user-infos ">
<div class="avatar">
<!-- avatar-->
</div>
<div class="user-more-infos">
<span class="user-name ">
<!-- user name-->
@if (kind === 'user') {
You
} @else {
Response
}
</span>
<span class="time-ago">
<!-- time ago-->
Il y a 5 min
</span>
</div>
</div>
<div class="message-content is-{{kind}}">
@if (content) {
<div [innerHTML]="sanitizedContent"></div>
} @else {
@if (kind === 'llm') {
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur, consectetur cum eaque iure optio recusandae vel.
} @else {
Delectus, est, molestiae! Asperiores at consequatur cupiditate dicta iure neque pariatur perspiciatis, quia ut?
}
}
</div>
</div>

View file

@ -0,0 +1,28 @@
.avatar {
width: 32px;
height: 32px;
flex-shrink: 0;
border-radius: 8px;
background-size: contain !important;
.user & {
background-size: contain;
background: yellow url('../../../../public/user.png');
}
.llm & {
background: yellow url('../../../../public/chatbot.png');
}
}
.user-more-infos {
margin-top: -35px;
margin-left: 39px;
}

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MessageBox } from './message-box';
describe('MessageBox', () => {
let component: MessageBox;
let fixture: ComponentFixture<MessageBox>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MessageBox]
})
.compileComponents();
fixture = TestBed.createComponent(MessageBox);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,53 @@
import {Component, Input, OnChanges, SimpleChanges} from '@angular/core';
import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
import {Copy} from 'sae-lib/buttons/copy/copy';
import {FeedbackButton} from '../feedback-button/feedback-button';
import {ChatbotMessage} from '../../services/chatbot.message.type';
type MessageKind = "user" | "llm";
@Component({
selector: 'app-message-box',
imports: [
Copy,
FeedbackButton
],
templateUrl: './message-box.html',
styleUrl: './message-box.scss'
})
export class MessageBox implements OnChanges {
@Input() kind: MessageKind = <"user" | "llm">""
@Input() conf: any = {}
@Input() content: any = ""
@Input() message: ChatbotMessage = {} as ChatbotMessage;
id: string = "00122121221312";
sanitizedContent: SafeHtml = "";
constructor(private sanitizer: DomSanitizer) {}
ngOnChanges(changes: SimpleChanges): void {
if (changes['content']) {
this.sanitizeContent();
}
}
sanitizeContent(): void {
this.sanitizedContent = this.sanitizer.bypassSecurityTrustHtml(this.content);
}
bookmark() {
console.log("TODO bookmark")
}
generateResponse() {
console.log("TODO generateResponse")
}
editMessage() {
console.log("TODO editMessage")
}
}

View file

@ -0,0 +1,18 @@
<div class="new-input">
<!-- new input-->
<div class="welcome-text">
<div class="welcome-icon">
<!-- <i class="ri-robot-2-line"></i>-->
<img alt="chatbot image" src="/chatbot.png">
</div>
How can we
<span class="emphasis">
assist
</span>
you today?
</div>
<app-prompt-input></app-prompt-input>
<app-tools-options></app-tools-options>
</div>

View file

@ -0,0 +1,23 @@
.new-input {
min-height: 80vh;
padding: 0 200px;
.welcome-text {
margin: 100px;
font-size: 38px;
font-weight: 500;
letter-spacing: -7%;
}
.welcome-icon {
i {
font-size: 3rem;
}
margin-bottom: 1rem;
}
.emphasis {
color: #083b7d;
}
}

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NewInput } from './new-input';
describe('NewInput', () => {
let component: NewInput;
let fixture: ComponentFixture<NewInput>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [NewInput]
})
.compileComponents();
fixture = TestBed.createComponent(NewInput);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import {PromptInput} from "../prompt-input/prompt-input";
import {ToolsOptions} from "../tools-options/tools-options";
@Component({
selector: 'app-new-input',
imports: [
PromptInput,
ToolsOptions
],
templateUrl: './new-input.html',
styleUrl: './new-input.scss'
})
export class NewInput {
}

View file

@ -0,0 +1,29 @@
<div class="selected-mode-{{inputMode}}">
<span class="indicator"></span>
<div class="dropdown" [ngClass]="{'is-active': isDropdownActive }">
<div class="dropdown-trigger">
<button (click)="toggleDropdown()" class="button">
<span>{{inputMode}}</span>
<span class="icon is-small">
<i class="ri-arrow-down-s-line" [ngClass]="{'ri-arrow-up-s-line': isDropdownActive}"></i>
</span>
</button>
</div>
<div class="dropdown-menu" role="menu">
<div class="dropdown-content">
<a (click)="changeInputMode('auto')" [ngClass]="{'is-active': inputMode === 'auto'}" class="dropdown-item">
Auto
</a>
<a (click)="changeInputMode('structured')" [ngClass]="{'is-active': inputMode === 'structured'}"
class="dropdown-item">
Structured
</a>
<a (click)="changeInputMode('specific')" [ngClass]="{'is-active': inputMode === 'specific'}"
class="dropdown-item">
Specific
</a>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,99 @@
:host {
display: block;
position: relative;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-menu {
position: absolute;
top: 100%;
left: 0;
z-index: 20;
min-width: 12rem;
}
.dropdown-content {
background-color: white;
border-radius: 4px;
box-shadow: 0 0.5em 1em -0.125em rgba(10, 10, 10, 0.1), 0 0px 0 1px rgba(10, 10, 10, 0.02);
padding: 0.5rem 0;
}
.dropdown-item {
color: #4a4a4a;
display: block;
font-size: 0.875rem;
line-height: 1.5;
padding: 0.375rem 1rem;
position: relative;
cursor: pointer;
text-decoration: none;
&:hover {
background-color: #f5f5f5;
color: #363636;
}
&.is-active {
background-color: #3273dc;
color: #fff;
}
}
.indicator {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 0.5rem;
}
.selected-mode-auto .indicator {
background-color: #48c774;
}
.selected-mode-structured .indicator {
background-color: #ffdd57;
}
.selected-mode-specific .indicator {
background-color: #f14668;
}
.button {
background-color: white;
border: 1px solid #dbdbdb;
border-radius: 4px;
color: #363636;
cursor: pointer;
justify-content: center;
padding: 0.5em 0.75em;
text-align: center;
white-space: nowrap;
display: inline-flex;
align-items: center;
&:hover {
border-color: #b5b5b5;
color: #363636;
}
.icon {
height: 1.5rem;
width: 1.5rem;
margin-left: 0.25rem;
}
}
// Ensure dropdown is displayed when active
.dropdown.is-active .dropdown-menu {
display: block;
}
.dropdown:not(.is-active) .dropdown-menu {
display: none;
}

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PromptIndicator } from './prompt-indicator';
describe('PromptIndicator', () => {
let component: PromptIndicator;
let fixture: ComponentFixture<PromptIndicator>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PromptIndicator]
})
.compileComponents();
fixture = TestBed.createComponent(PromptIndicator);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,52 @@
import {Component} from '@angular/core';
import {inputModeChoicesType} from '../../services/AirWatchState';
import {Store} from '@ngrx/store';
import {ActionTypes, StateInterface} from '../../reducers';
import {ApiService} from '../../api-service';
import {NgClass} from '@angular/common';
@Component({
selector: 'app-prompt-indicator',
imports: [NgClass],
templateUrl: './prompt-indicator.html',
styleUrl: './prompt-indicator.scss'
})
export class PromptIndicator {
inputMode: inputModeChoicesType = 'auto';
isDropdownActive: boolean = false;
constructor(private store: Store<StateInterface>, private apiService: ApiService) {
// Subscribe to the app state to get the current input mode
this.store.select(state => state.app.inputMode).subscribe(mode => {
if (mode) {
this.inputMode = mode;
}
});
}
// Toggle dropdown menu
toggleDropdown() {
this.isDropdownActive = !this.isDropdownActive;
}
// Change input mode
changeInputMode(mode
:
inputModeChoicesType
) {
this.inputMode = mode;
this.isDropdownActive = false; // Close dropdown after selection
// Update the app state with the new input mode
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
inputMode: mode
}
});
}
}

View file

@ -0,0 +1,22 @@
<div class="prompt-input">
<!-- bottom input-->
<div class="columns">
<div class="column is-four-fifths">
<div class="magic">
<i class="ri-sparkling-2-line"></i>
</div>
<input (keydown)="handleKeyEvent($event)" [(ngModel)]="userInput"
placeholder="Ask questions, request or a web search" type="text">
</div>
<div class="column is-one-fifth">
<app-prompt-indicator></app-prompt-indicator>
<button (click)="submitMessage()" class="submit">
<i class="ri-send-plane-fill"></i>
</button>
</div>
</div>
</div>

View file

@ -0,0 +1,121 @@
@use 'sae-lib/src/styles/variables.scss';
.prompt-input {
margin: 20px auto;
max-width: 914px;
background: variables.$neutral-white;
border-radius: 0.5rem;
padding: 10px 10px;
box-shadow: 0 5px 10px #ededed;
.column {
padding-top: 10px;
}
input {
width: 100%;
border: 0;
padding: 10px;
@extend .is-shadowed !optional;
float: left;
margin-left: 50px;
margin-top: -40px;
&:focus {
outline: none;
}
}
button {
background: white;
padding: 10px;
border: 1px solid transparent;
cursor: pointer;
border-radius: 10px;
&:hover {
background: grey;
border: 1px solid black;
}
}
.magic {
padding: 10px;
border: 1px solid transparent;
border-radius: 10px;
background: #f5f5f5;
width: 40px;
height: 40px;
float: left;
}
// Dropdown styles
.dropdown {
position: relative;
display: inline-block;
&.is-active {
.dropdown-menu {
display: block;
}
}
.dropdown-trigger {
display: inline-block;
}
.dropdown-menu {
display: none;
position: absolute;
z-index: 20;
top: 100%;
left: 0;
min-width: 12rem;
background-color: white;
border-radius: 4px;
box-shadow: 0 0.5em 1em -0.125em rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.02);
padding-bottom: 0.5rem;
padding-top: 0.5rem;
}
.dropdown-content {
padding: 0.5rem 0;
}
.dropdown-item {
color: #4a4a4a;
display: block;
font-size: 0.875rem;
line-height: 1.5;
padding: 0.375rem 1rem;
position: relative;
cursor: pointer;
&:hover {
background-color: #f5f5f5;
color: #0a0a0a;
}
&.is-active {
background-color: #3273dc;
color: white;
}
}
}
.selected-mode-specific,
.selected-mode-structured {
.indicator {
background: red;
border-radius: 100%;
width: 10px;
height: 10px;
display: block;
right: 0;
top: 0.3rem;
position: absolute;
}
}
}

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PromptInput } from './prompt-input';
describe('PromptInput', () => {
let component: PromptInput;
let fixture: ComponentFixture<PromptInput>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [PromptInput]
})
.compileComponents();
fixture = TestBed.createComponent(PromptInput);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,313 @@
import {Component, OnDestroy, OnInit} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {Store} from '@ngrx/store';
import {ActionTypes, StateInterface} from '../../reducers';
import {ChatbotMessage} from '../../services/chatbot.message.type';
import {ChatbotConversation} from '../../services/conversations.service';
import {ApiService, OpenMeteoResponse} from '../../api-service';
import {interval, Subscription} from 'rxjs';
import {PromptIndicator} from '../prompt-indicator/prompt-indicator';
@Component({
selector: 'app-prompt-input',
imports: [CommonModule, FormsModule, PromptIndicator],
templateUrl: './prompt-input.html',
styleUrl: './prompt-input.scss'
})
export class PromptInput implements OnInit, OnDestroy {
// Static counter to track API calls
static apiCallCounter: number = 0;
userInput: string = '';
activeConversation: ChatbotConversation | null = null;
private appState: any = '';
private ollamaCheckSubscription: Subscription | null = null;
// Check interval in milliseconds (30 seconds)
private readonly CHECK_INTERVAL = 30000;
constructor(private store: Store<StateInterface>, private apiService: ApiService) {
// Get the active conversation from the store
this.store.select(state => state.activeConversation).subscribe(activeConv => {
if (activeConv && Object.keys(activeConv).length > 0) {
this.activeConversation = activeConv as ChatbotConversation;
}
})
this.store.select(state => state.app).subscribe(app => {
this.appState = app;
});
// Check if Ollama is available when the component is initialized
this.checkOllamaAvailability();
}
/**
* Check if the Ollama backend is available
* This will update the Redux store with the result
*/
checkOllamaAvailability(): void {
this.apiService.checkOllamaAvailability().subscribe({
next: (isAvailable) => {
console.log('Ollama availability:', isAvailable);
// The store is already updated in the ApiService
},
error: (error) => {
console.error('Error checking Ollama availability:', error);
}
});
}
/**
* Angular lifecycle hook that is called after the component is initialized
* Sets up periodic checking for Ollama availability
*/
ngOnInit(): void {
// Set up periodic checking for Ollama availability
this.ollamaCheckSubscription = interval(this.CHECK_INTERVAL).subscribe(() => {
console.log('Performing periodic Ollama availability check');
this.checkOllamaAvailability();
});
}
/**
* Angular lifecycle hook that is called when the component is destroyed
* Cleans up subscriptions to prevent memory leaks
*/
ngOnDestroy(): void {
// Clean up the subscription when the component is destroyed
if (this.ollamaCheckSubscription) {
this.ollamaCheckSubscription.unsubscribe();
this.ollamaCheckSubscription = null;
}
}
submitMessage() {
console.log(this.userInput);
if (!this.userInput.trim() || !this.activeConversation) {
console.info('no input to send')
return;
}
// Store the user input in a local variable before clearing it
const userInputText = this.userInput.trim();
console.log('userInputText', userInputText)
// Create a new message
const newMessage = new ChatbotMessage({
kind: 'user',
user: {},
content: userInputText,
name: 'User Message'
});
// Update the active conversation in the store
this.store.dispatch({
type: ActionTypes.POST_MESSAGE_TO_ACTIVE_CONVERSATION,
payload: newMessage
});
// Clear the input
this.userInput = '';
const elemFound: HTMLInputElement | null = document.querySelector('.prompt-input input') as HTMLInputElement
if (elemFound) {
elemFound.focus();
}
// Check if Ollama is available
if (this.appState.ollamaAvailable) {
// If Ollama is available, use it regardless of demo mode
console.log('Using Ollama backend for response');
// Query Ollama with the stored user input
this.apiService.queryOllama(userInputText).subscribe({
error: (error) => {
console.error('Error querying Ollama:', error);
}
});
} else if (this.appState.demoMode) {
// If Ollama is not available and we're in demo mode, use the demo response
console.log('Using demo response (Ollama not available)');
// Static counter to track API calls
if (!PromptInput.apiCallCounter) {
PromptInput.apiCallCounter = 0;
}
PromptInput.apiCallCounter++;
// Set loading state to true before API call
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
loading: true
}
});
this.apiService.fetchDemoResponse().subscribe({
next: (resp: OpenMeteoResponse) => {
console.log('fetchDemoResponse', resp);
// Set loading state to false after API call
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
loading: false
}
});
// Every third call, show an error instead of the actual response
if (PromptInput.apiCallCounter % 3 === 0) {
// Set error state to true
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
displayErrorResponse: true
}
});
// Send error message to chat
const errorMessage = new ChatbotMessage({
kind: 'llm',
user: {},
content: "System error - I couldn't process your request. Please try again in few moments",
name: 'Assistant'
});
this.store.dispatch({
type: ActionTypes.POST_MESSAGE_TO_ACTIVE_CONVERSATION,
payload: errorMessage
});
// Reset error state after 3 seconds
setTimeout(() => {
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
displayErrorResponse: false
}
});
}, 3000);
return;
}
// Format the weather data in a readable way
const currentTemp = resp.hourly.temperature_2m[new Date().getHours()];
const minTemp = Math.min(...resp.hourly.temperature_2m);
const maxTemp = Math.max(...resp.hourly.temperature_2m);
const weatherApiDemoResult = `
<h2>
Météo pour aujourd'hui à Corbeil-Essonne
</h2>
<br>
- <strong>Température actuelle:</strong> ${currentTemp}${resp.hourly_units.temperature_2m}
<br>
<ul>
<li>
Élévation: ${resp.elevation}m<br>
</li>
</ul>
<br>
<table class="table is-striped">
<thead>
<th>label</th>
<th>valeur</th>
</thead>
<tbody>
<tr>
<td>
Température min
</td>
<td>
${minTemp}${resp.hourly_units.temperature_2m}
</td>
</tr>
<tr>
<td>
Température max
</td>
<td>
${maxTemp}${resp.hourly_units.temperature_2m}
</td>
</tr>
</tbody>
</table>
<a href="https://www.open-meteo.com">
*Données fournies par Open-Meteo API*
</a>
`;
const newMessage = new ChatbotMessage({
kind: 'llm',
user: {},
content: `Voici les données météo que vous avez demandées:\n${weatherApiDemoResult}`,
name: 'Assistant'
});
// Update the active conversation in the store
this.store.dispatch({
type: ActionTypes.POST_MESSAGE_TO_ACTIVE_CONVERSATION,
payload: newMessage
});
},
error: (error) => {
console.error('Error fetching weather data:', error);
// Set loading state to false after API call
this.store.dispatch({
type: ActionTypes.UPDATE_APP,
payload: {
loading: false
}
});
// Send error message to chat
const errorMessage = new ChatbotMessage({
kind: 'llm',
user: {},
content: "Désolé, je n'ai pas pu récupérer les données météo. Veuillez réessayer plus tard.",
name: 'Assistant'
});
this.store.dispatch({
type: ActionTypes.POST_MESSAGE_TO_ACTIVE_CONVERSATION,
payload: errorMessage
});
}
});
} else {
// Not in demo mode and Ollama is not available
console.error('Error: Ollama is not available and not in demo mode');
// Send error message to chat
const errorMessage = new ChatbotMessage({
kind: 'llm',
user: {},
content: "Error: The AI backend is not available. Please check your configuration or try again later.",
name: 'System'
});
this.store.dispatch({
type: ActionTypes.POST_MESSAGE_TO_ACTIVE_CONVERSATION,
payload: errorMessage
});
}
}
// Handle key events for Ctrl+Enter
handleKeyEvent(event: KeyboardEvent) {
// Check if Ctrl key is pressed and Enter key is pressed
if (event.ctrlKey && event.key === 'Enter') {
this.submitMessage();
event.preventDefault(); // Prevent default behavior
}
}
}

View file

@ -0,0 +1,16 @@
<div class="source">
<i class="ri-file-3-line"></i>
<span class="title">{{ source.title || 'Source sans nom' }}</span>
<div class="actions has-text-right">
<i class="ri-file-add-line"></i>
<i class="ri-arrow-down-s-line"></i>
</div>
<div class="description">
{{ source.description || description }}
</div>
</div>

View file

@ -0,0 +1,31 @@
.source {
padding: 10px;
margin-bottom: 10px;
background: white;
color: #000;
font-size: 14px;
font-weight: 400;
line-height: 20px;
cursor: pointer;
border-radius: 4px;
.title {
color: #1E1F22;
font-size: 14px;
font-weight: 600;
margin-left: 3px;
}
.actions {
color: #005AA2;
float: right;
}
&:hover {
background: #ECF3FA;
}
.description {
margin-top: 7px;
}
}

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SourceBlock } from './source-block';
describe('SourceBlock', () => {
let component: SourceBlock;
let fixture: ComponentFixture<SourceBlock>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SourceBlock]
})
.compileComponents();
fixture = TestBed.createComponent(SourceBlock);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,14 @@
import {Component, Input} from '@angular/core';
import {ChatbotSource} from '../../services/conversations.service';
@Component({
selector: 'app-source-block',
imports: [],
templateUrl: './source-block.html',
styleUrl: './source-block.scss'
})
export class SourceBlock {
@Input() source: ChatbotSource = {} as ChatbotSource;
description: string = "lorem blah blah";
}

View file

@ -0,0 +1,9 @@
<div class="theme-selector">
<button
class="theme-selector__button"
(click)="switchToNextTheme()"
title="Switch to next theme">
<span class="theme-selector__current-theme">{{ activeTheme }}</span>
<span class="theme-selector__icon">🎨</span>
</button>
</div>

View file

@ -0,0 +1,56 @@
.theme-selector {
display: inline-block;
margin: 10px;
&__button {
display: flex;
align-items: center;
padding: 8px 12px;
background-color: #f0f0f0;
border: 1px solid #ccc;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s ease;
&:hover {
background-color: #e0e0e0;
}
&:active {
transform: translateY(1px);
}
}
&__current-theme {
margin-right: 8px;
text-transform: capitalize;
}
&__icon {
font-size: 1.2em;
}
}
// Theme-specific styles that will be applied when the body has the corresponding class
:host-context(body.app-theme-light) {
.theme-selector__button {
background-color: #f8f8f8;
color: #333;
}
}
:host-context(body.app-theme-dark) {
.theme-selector__button {
background-color: #333;
color: #f8f8f8;
border-color: #555;
}
}
:host-context(body.app-theme-funky) {
.theme-selector__button {
background-color: #ff00ff;
color: #00ffff;
border-color: #ffff00;
}
}

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ThemeSelector } from './theme-selector';
describe('ThemeSelector', () => {
let component: ThemeSelector;
let fixture: ComponentFixture<ThemeSelector>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ThemeSelector]
})
.compileComponents();
fixture = TestBed.createComponent(ThemeSelector);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,55 @@
import {Component, OnDestroy, OnInit} from '@angular/core';
import {CommonModule} from '@angular/common';
import {Store} from '@ngrx/store';
import {Subscription} from 'rxjs';
import {ActionTypes, StateInterface} from '../../reducers';
@Component({
selector: 'app-theme-selector',
standalone: true,
imports: [CommonModule],
templateUrl: './theme-selector.html',
styleUrl: './theme-selector.scss'
})
export class ThemeSelector implements OnInit, OnDestroy {
activeTheme: string = '';
themesList: string[] = [];
private storeSubscription: Subscription | null = null;
constructor(private store: Store<StateInterface>) {
}
ngOnInit(): void {
// Subscribe to the store to get the active theme and themes list
this.storeSubscription = this.store.select(state => state.app)
.subscribe(app => {
// If the active theme has changed, update the body class
if (this.activeTheme !== app.activeTheme) {
// Remove the previous theme class if it exists
if (this.activeTheme) {
document.body.classList.remove(`app-theme-${this.activeTheme}`);
}
document.body.classList.add(`app-theme-${app.activeTheme}`);
this.activeTheme = app.activeTheme;
}
this.themesList = app.themesList;
});
}
ngOnDestroy(): void {
// Unsubscribe to prevent memory leaks
if (this.storeSubscription) {
this.storeSubscription.unsubscribe();
}
// Remove the theme class from the body when the component is destroyed
if (this.activeTheme) {
document.body.classList.remove(this.activeTheme);
}
}
// Method to switch to the next theme
switchToNextTheme(): void {
this.store.dispatch({type: ActionTypes.SWITCH_TO_NEXT_THEME});
}
}

View file

@ -0,0 +1,16 @@
<div class="time-separator">
<div class="columns">
<div class="column ">
<div class="line"></div>
</div>
<div class="column time-ago">
<!-- some time ago-->
{{timeAgo}}
</div>
<div class="column">
<div class="line"></div>
</div>
</div>
</div>

View file

@ -0,0 +1,21 @@
.time-separator {
padding: 0 16px;
font-size: 0.8rem;
color: grey;
margin-top: 2rem;
margin-bottom: 2rem;
.column {
padding: 0;
}
.time-ago {
margin-top: -1rem;
text-align: center;
}
.line {
border-bottom: 1px solid grey;
margin-top: -0.25rem;
}
}

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TimeSeparator } from './time-separator';
describe('TimeSeparator', () => {
let component: TimeSeparator;
let fixture: ComponentFixture<TimeSeparator>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [TimeSeparator]
})
.compileComponents();
fixture = TestBed.createComponent(TimeSeparator);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,12 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-time-separator',
imports: [],
templateUrl: './time-separator.html',
styleUrl: './time-separator.scss'
})
export class TimeSeparator {
timeAgo: string = 'today';
}

View file

@ -0,0 +1,7 @@
<button (click)="toggleState()"
class="togglable-button {{kind}} {{active ? 'is-active' : ''}}">
@if (icon) {
<span class="icon ri-{{icon}}"></span>
}
{{ label }}
</button>

View file

@ -0,0 +1,48 @@
.togglable-button {
cursor: pointer;
font-size: 12px;
line-height: 8px;
font-weight: 600;
border-radius: 20px;
padding: 10px;
border-width: 2px;
background: transparent;
margin-right: 10px;
margin-bottom: 10px;
&:first-letter {
text-transform: capitalize;
}
&.local {
border: solid 1px #005aa2;
color: #005aa2;
&.is-active {
background: #083b7d;
color: white;
}
}
&.outside {
border: solid 1px #50d494;
color: #50d494;
&.is-active {
background: #159256;
color: white;
}
}
&:hover {
border: solid 1px black;
color: black;
&.is-active {
color: black;
}
}
}

View file

@ -0,0 +1,22 @@
import {Component, EventEmitter, Input, Output} from '@angular/core';
type ToggleButtonKind = "local" | "outside";
@Component({
selector: 'app-toggle-button',
imports: [],
templateUrl: './toggle-button.html',
styleUrl: './toggle-button.scss'
})
export class ToggleButton {
@Input() label: string = "(sans label)";
@Input() kind: ToggleButtonKind = "local";
@Input() active: boolean = false;
@Input() icon: string = "";
@Output() stateChanged = new EventEmitter<boolean>();
toggleState() {
this.active = !this.active;
this.stateChanged.emit(this.active);
}
}

Some files were not shown because too many files have changed in this diff Show more