# AngularJS Chat with SignalR

## Front-End

- `npm install`
- **Dev**: `npm start`
- **Prod**: `npm run build`

## Development setup (Imob Project)

- Clone the project inside `Gaia/src/web/`
  ![Image 1](./docs-imgs/img1.jpg)

- Change the chat script path `Gaia/src/web/vendor.json`

  ![Image 2](./docs-imgs/img2.jpg)

  If you are using default css, you need to add the stylesheet path
  ![Image 3](./docs-imgs/img3.jpg)

  You can also use the sass file to set your color scheme (only when not using `ingaia-chat.min.css` from `vendor.json`)

  ![Image 4](./docs-imgs/img4.jpg)

- Initializing chat needs to call global instance passing the arguments: \
   The first argument are data of user, and the second are data of properties or the default message

  ```javascript
  window.inGaiaChat_API.inviteToChat(
    {
      id: 123,
      name: 'User Name',
      productTag: 'valuegaia',
      role: '',
      status: 3,
      company: { id: 123, name: 'inGaia' },
    },
    {
      message: 'Teste message',
      productTag: -1,
      origin: 'radar-clientes',
    }
  );
  ```

  ```javascript
  window.inGaiaChat_API.start(data);
  ```

  ![Image 4](./img5.jpg)

  - To start a chat between two users with a property subject
  - property object should looks like:
    ```json
    {
      "reference": "AP2566",
      "neighborhood": "Jardim América",
      "city": "São José dos Campos",
      "smallpicture": "http://..."
    }
    ```

  ```javascript
  window.inGaiaChat_API.inviteToChat(data.user, property);
  ```

- Updating package [(after publishing on npm)](#publishing-via-npm)
  - Change package version, correspondig to the last published version, inside package.json
    `"ingaia-chat": "x.x.x"`
  - Then you need to run `npm update ingaia-chat`

## Publishing via NPM

- link [https://www.npmjs.com/package/ingaia-chat](https://www.npmjs.com/package/ingaia-chat)
- Change package.json version
- Build project with `npm run build` and publishthe new version on `npm publish` (need npm permission on [https://www.npmjs.com/package/ingaia-chat](https://www.npmjs.com/package/ingaia-chat))

## Dependencies

- hubs (provided from backend)
- signalr (included as dependencies in package.json)
