mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into developer
This commit is contained in:
@@ -28,6 +28,8 @@ import { CalendarModule, DateAdapter } from 'angular-calendar';
|
||||
import { adapterFactory } from 'angular-calendar/date-adapters/date-fns';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { MessagesPage } from './pages/chat/messages/messages.page';
|
||||
import { WebsocketService } from './services/websocket.service'
|
||||
import { ChatService } from './services/chat.service'
|
||||
|
||||
// import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
|
||||
|
||||
@@ -57,7 +59,9 @@ import { MessagesPage } from './pages/chat/messages/messages.page';
|
||||
//File,
|
||||
WebView,
|
||||
FilePath,
|
||||
//FCM
|
||||
//FCM,
|
||||
WebsocketService,
|
||||
ChatService,
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface Message {
|
||||
author: string;
|
||||
message: string;
|
||||
}
|
||||
@@ -90,6 +90,7 @@
|
||||
|
||||
</ion-list>
|
||||
</div>
|
||||
<button (click)="sendMsg()">Send message</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Aside right -->
|
||||
|
||||
@@ -21,6 +21,9 @@ import { NewchatPage } from './newchat/newchat.page';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { AlertService } from 'src/app/services/alert.service';
|
||||
import { EditGroupPage } from 'src/app/shared/chat/edit-group/edit-group.page';
|
||||
import * as Rx from "rxjs/Rx";
|
||||
import { Message } from 'src/app/models/message.model';
|
||||
import { Observable, Subject } from "rxjs/Rx";
|
||||
|
||||
@Component({
|
||||
selector: 'app-chat',
|
||||
@@ -78,8 +81,15 @@ export class ChatPage implements OnInit {
|
||||
|
||||
*/
|
||||
|
||||
SERVER_URL = 'wss://www.tabularium.pt/websocket';
|
||||
ws:any;
|
||||
subject: any;
|
||||
public messages: Subject<any>;
|
||||
|
||||
message = {
|
||||
"msg": "connect",
|
||||
"version": "1",
|
||||
"support": ["1"]
|
||||
};
|
||||
|
||||
|
||||
/* Fim websockets variables*/
|
||||
constructor(
|
||||
@@ -89,12 +99,11 @@ export class ChatPage implements OnInit {
|
||||
private authService: AuthService,
|
||||
private storage:Storage,
|
||||
private resolver: ComponentFactoryResolver,
|
||||
|
||||
) {
|
||||
){
|
||||
this.headers = new HttpHeaders();
|
||||
/* this.headers = this.headers.set('X-User-Id', 'GqjNWiLrGEHRna7Zn');
|
||||
this.headers = this.headers.set('X-Auth-Token', 'SJwIgtlqfloPK696fpc2VBvyDluipuIHKB_0Q6-9ycJ'); */
|
||||
this.loadMessage();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.segment = "Contactos";
|
||||
|
||||
@@ -103,49 +112,21 @@ export class ChatPage implements OnInit {
|
||||
console.log(this.loggedUser);
|
||||
this.load();
|
||||
});
|
||||
this.storage.get('userDataKey').then(val=> {
|
||||
let t = JSON.parse(unescape(atob(val)));
|
||||
this.loggedUser=t;
|
||||
//this.load();
|
||||
})
|
||||
|
||||
console.log(this.roomId);
|
||||
this.connect();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* websocket functions */
|
||||
connect() {
|
||||
this.ws = new WebSocket(this.SERVER_URL, []);
|
||||
console.log(this.ws);
|
||||
|
||||
/* this.ws.onmessage = handleMessageReceived;
|
||||
this.ws.onerror = handleError; */
|
||||
}
|
||||
handleMessageReceived(data) {
|
||||
// Simply call logMessage(), passing the received data.
|
||||
/* logMessage(data.data); */
|
||||
}
|
||||
handleConnected(data) {
|
||||
// Create a log message which explains what has happened and includes
|
||||
// the url we have connected too.
|
||||
var logMsg = 'Connected to server: ' + data.target.url;
|
||||
// Add the message to the log.
|
||||
/* logMessage(logMsg) */
|
||||
}
|
||||
handleError(err) {
|
||||
// Print the error to the console so we can debug it.
|
||||
console.log("Error: ", err);
|
||||
}
|
||||
logMessage(msg) {
|
||||
// $apply() ensures that the elements on the page are updated
|
||||
// with the new message.
|
||||
/* $scope.$apply(function() { */
|
||||
//Append out new message to our message log. The \n means new line.
|
||||
/* $scope.messageLog = $scope.messageLog + msg + "\n"; */
|
||||
// Update the scrolling (defined below).
|
||||
/*updateScrolling();*/
|
||||
/* S */
|
||||
//this.sendMsg();
|
||||
|
||||
/* Fim websocket functions */
|
||||
}
|
||||
loadMessage(){
|
||||
this.chatService.messages.subscribe(msg => {
|
||||
console.log("Response from websocket: " + msg);
|
||||
});
|
||||
}
|
||||
sendMsg() {
|
||||
console.log("new message from client to websocket: ", this.message);
|
||||
this.chatService.messages.next(this.message);
|
||||
this.message.msg = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +159,7 @@ export class ChatPage implements OnInit {
|
||||
}
|
||||
openMessagesPage(rid) {
|
||||
if( window.innerWidth <= 1024){
|
||||
this.openMessagesModal(rid);
|
||||
//this.openMessagesModal(rid);
|
||||
}
|
||||
else{
|
||||
this.closeAllDesktopComponents();
|
||||
@@ -236,9 +217,8 @@ export class ChatPage implements OnInit {
|
||||
onSegmentChange(){
|
||||
this.load();
|
||||
}
|
||||
doRefresh(ev:any){
|
||||
doRefresh(){
|
||||
this.load();
|
||||
ev.target.complete();
|
||||
}
|
||||
load(){
|
||||
switch (this.segment)
|
||||
@@ -310,6 +290,7 @@ export class ChatPage implements OnInit {
|
||||
await modal.present();
|
||||
modal.onDidDismiss();
|
||||
}
|
||||
|
||||
async selectContact(){
|
||||
const modal = await this.modalController.create({
|
||||
component: ContactsPage,
|
||||
@@ -318,6 +299,7 @@ export class ChatPage implements OnInit {
|
||||
await modal.present();
|
||||
modal.onDidDismiss();
|
||||
}
|
||||
|
||||
async newGroup(){
|
||||
const modal = await this.modalController.create({
|
||||
component: NewGroupPage,
|
||||
@@ -383,4 +365,5 @@ export class ChatPage implements OnInit {
|
||||
await modal.present();
|
||||
modal.onDidDismiss();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,13 +76,12 @@ openExpedientDetailPage(data){
|
||||
async LoadList(){
|
||||
|
||||
|
||||
let result = await this.processes.GetTasksList("Despacho", false).toPromise();
|
||||
|
||||
console.log(result);
|
||||
let result = await this.processes.GetTasksList("Despacho", false).toPromise();
|
||||
//let despachos = result.reverse().filter(data => data.activityInstanceName == "Despacho (Paralelo)");
|
||||
|
||||
console.log(result);
|
||||
|
||||
this.despachoList = new Array();
|
||||
|
||||
await result.forEach( (element, index) => {
|
||||
await result.forEach( (element, index) => {
|
||||
|
||||
let task = {
|
||||
"SerialNumber": element.serialNumber,
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from "rxjs"
|
||||
import { AuthService } from './auth.service';
|
||||
import { HttpService } from './http.service';
|
||||
import { StorageService } from './storage.service';
|
||||
import { HttpClient, HttpHeaderResponse } from '@angular/common/http';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { Message } from 'src/app/models/message.model';
|
||||
import { Observable, Subject } from "rxjs/Rx";
|
||||
import { WebsocketService } from './websocket.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -17,6 +19,9 @@ export class ChatService {
|
||||
options1:any;
|
||||
X_User_Id:any;
|
||||
X_Auth_Token:any;
|
||||
|
||||
SERVER_URL = 'wss://www.tabularium.pt/websocket';
|
||||
public messages: Subject<any>;
|
||||
|
||||
|
||||
constructor(
|
||||
@@ -24,11 +29,11 @@ export class ChatService {
|
||||
private httpService: HttpService,
|
||||
private authService: AuthService,
|
||||
private storage: Storage,
|
||||
private storageService:StorageService,) {
|
||||
private storageService:StorageService,
|
||||
private wsService: WebsocketService,
|
||||
)
|
||||
{
|
||||
this.headers = new HttpHeaders();
|
||||
/* this.headers = this.headers.set('X-User-Id', 'GqjNWiLrGEHRna7Zn');
|
||||
this.headers = this.headers.set('X-Auth-Token', 'dAM0ZOTAy8jzQA_vS25z2IrnSc6sYLfi5rmaa35YNUz'); */
|
||||
-
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
this.headers = this.headers.set('X-User-Id', res.userId);
|
||||
this.headers = this.headers.set('X-Auth-Token', res.authToken);
|
||||
@@ -36,6 +41,12 @@ export class ChatService {
|
||||
this.options = {
|
||||
headers: this.headers,
|
||||
};
|
||||
|
||||
this.messages = <Subject<any>>this.wsService.connect(this.SERVER_URL).map((response: MessageEvent): any => {
|
||||
let data = JSON.parse(response.data);
|
||||
console.log(data);
|
||||
return (JSON.stringify(data));
|
||||
});
|
||||
}
|
||||
|
||||
/* getUser(){
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import * as io from 'socket.io-client';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Socket } from 'ngx-socket-io';
|
||||
import * as Rx from "rxjs/Rx";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -11,11 +9,38 @@ export class WebsocketService {
|
||||
message = '';
|
||||
messages = [];
|
||||
currentUser = '';
|
||||
private subject: Rx.Subject<MessageEvent>;
|
||||
|
||||
constructor(private socket: Socket) { }
|
||||
constructor() { }
|
||||
|
||||
connect(){
|
||||
return this.socket.connect();
|
||||
public connect(url): Rx.Subject<MessageEvent> {
|
||||
if (!this.subject) {
|
||||
this.subject = this.create(url);
|
||||
console.log("Successfully connected: " + url);
|
||||
}
|
||||
return this.subject;
|
||||
}
|
||||
|
||||
private create(url): Rx.Subject<MessageEvent> {
|
||||
let ws = new WebSocket(url);
|
||||
|
||||
console.log(ws);
|
||||
|
||||
|
||||
let observable = Rx.Observable.create((obs: Rx.Observer<MessageEvent>) => {
|
||||
ws.onmessage = obs.next.bind(obs);
|
||||
ws.onerror = obs.error.bind(obs);
|
||||
ws.onclose = obs.complete.bind(obs);
|
||||
return ws.close.bind(ws);
|
||||
});
|
||||
let observer = {
|
||||
next: (data: Object) => {
|
||||
if (ws.readyState === WebSocket.OPEN) {
|
||||
ws.send(JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Rx.Subject.create(observer, observable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,9 +56,13 @@ export class DespachosPage implements OnInit {
|
||||
//Inicializar segment
|
||||
this.segment = "despachos";
|
||||
this.LoadList();
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
console.log(res);
|
||||
});
|
||||
/* this.authService.userData$.subscribe((res:any)=>{
|
||||
//console.log(res);
|
||||
}); */
|
||||
|
||||
let u = this.authService.userData$.toPromise();
|
||||
console.log(u);
|
||||
|
||||
}
|
||||
segmentChanged(ev: any) {
|
||||
this.LoadList();
|
||||
@@ -77,6 +81,7 @@ export class DespachosPage implements OnInit {
|
||||
this.despachoList = new Array();
|
||||
|
||||
let result = await this.processes.GetTasksList("Despacho", false).toPromise();
|
||||
//let despachos = result.reverse().filter(data => data.activityInstanceName == "Despacho (Paralelo)");
|
||||
|
||||
console.log(result);
|
||||
|
||||
|
||||
@@ -18,19 +18,16 @@ export class HeaderPage implements OnInit {
|
||||
loggeduser: User;
|
||||
|
||||
constructor(
|
||||
private router: Router,private modalController: ModalController,
|
||||
private router: Router,
|
||||
private modalController: ModalController,
|
||||
private animationController: AnimationController,
|
||||
authService: AuthService) {
|
||||
|
||||
authService: AuthService
|
||||
) {
|
||||
this.loggeduser = authService.ValidatedUser;
|
||||
|
||||
|
||||
router.events.subscribe((val) => {
|
||||
this.showSearch=false;
|
||||
this.modalController.dismiss()
|
||||
});
|
||||
|
||||
|
||||
router.events.subscribe((val) => {
|
||||
this.showSearch=false;
|
||||
//this.modalController.dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
Reference in New Issue
Block a user