Giter Site home page Giter Site logo

sam6942069 / ngx-chat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pazznetwork/ngx-chat

0.0 0.0 0.0 7.43 MB

Angular XMPP Client & Chat UI

License: MIT License

JavaScript 1.59% TypeScript 87.27% HTML 7.86% CSS 0.31% Shell 0.22% Less 2.75%

ngx-chat's Introduction

@pazznetwork/ngx-chat Build status Coverage

This library provides an out-of-the-box usable XMPP chat component. It is customizable and offers an API to integrate it with your application.

Features

  • connect to XMPP servers via websocket
  • send and receive messages
  • load messages from message history (XEP-0313)
  • use the server side buddy list or use your own data source for that, API methods for adding / removing buddies available
  • supports multi user chat

Compatibility

  • Angular 11 (ngx-chat 0.11.x)
  • Angular 10 (ngx-chat 0.10.x)
  • Angular 9 (ngx-chat 0.9.x)
  • Angular 8 (ngx-chat 0.4.x)
  • Angular 6 (ngx-chat 0.3.x)
  • requires node >= 10.13 && npm >= 5 for build

Demo

Have a look at our demo (valid XMPP credentials required) screenshot

Documentation

Below you will find some instructions to getting started. Have a look at the wiki for FAQ's and the API documentation.

Installation and usage

This instructions require Angular 11.

First of all, install ngx-chat and its dependencies via npm:

npm install --save @pazznetwork/ngx-chat @xmpp/client@~0.9.2 @angular/cdk@~11.0.0

After that, import ngx-chat in your root module:

@NgModule({
    ...
    imports: [
        ...
        NgxChatModule.forRoot(),
        BrowserAnimationsModule, // alternatively NoopAnimationsModule 
    ],
    ...
})

Add the ngx-chat-component at the end of your root component template:

<ngx-chat></ngx-chat>

You are now ready to go. You will not see anything until you log in. Log in via ngx-chat wherever you want (e.g. in a component or a service) by injecting ChatService and calling login:

constructor(@Inject(ChatServiceToken) chatService: ChatService) {
    chatService.logIn({
        domain: 'ngx-chat.example',
        service: 'wss://ngx-chat.example:5280/websocket',
        password: 'password',
        username: 'someuser',
    });
}

Add the following to polyfills.ts:

/***************************************************************************************************
 * APPLICATION IMPORTS
 */
(window as any).global = window;

Optional: body padding when roster list is expanded

Add css styling like the following to your main styles.css if you want to resize your main content when the roster is expanded.

body {
    transition-property: padding-right;
    transition-duration: 0.4s;
    padding-right: 0px;
}

body.has-roster {
    padding-right: 14em;
}

FAQ

Q: Which browsers are supported? A: It is tested in Chrome, Safari and Firefox.

Q: Does ngx-chat work with self signed certificates? A: Yes, if the following criteria are met:

  • the certificate has to be trusted by the browser you are using. Chrome uses the operating system trust store for certificates while Firefox has a custom implementation.
  • the common name (CN) matches the uri of the service you are connecting to

Q: Can ngx-chat be used without the UI? A: Yes. Inject the chat service via @Inject(ChatServiceToken) public chatService: ChatService, login via logIn and start sending messages via the sendMessage method.

Q: My question is not answered A: No problem, feel free to raise an issue.

Development

Pull requests are welcome!

The source code for ngx-chat can be found in the projects/pazznetwork/ngx-chat folder. The demo application is in the src folder in the project root.

# clone this repository
git clone [email protected]:pazznetwork/ngx-chat.git
cd ngx-chat

# install dependencies
npm install

# build the library continuously
ng build @pazznetwork/ngx-chat --watch

# (in another terminal) build the sample app continuously
# will run the demo application on
# http://localhost:4200
ng serve

Build the plugin

npm run build-lib

Run the plugin tests

npm run test:once

Releasing

# increment version number in projects/pazznetwork/ngx-chat/package.json
VERSION=0.11.4 # change accordingly
npm run changelog
git add .
git commit -m "docs: release $VERSION"
git tag v$VERSION
git push origin master --tags
./push-release.sh

ngx-chat's People

Contributors

trampi avatar codebast4rd avatar dependabot[bot] avatar bendingbender avatar cnalax avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.