@chat21/chat21-ionic 3.4.13-rc3 → 3.4.13-rc5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/app/app.component.ts +15 -6
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +1 -26
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +1 -1
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +1 -0
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +1 -0
- package/src/app/chatlib/conversation-detail/message/options/options.component.html +1 -1
- package/src/app/chatlib/conversation-detail/message/options/options.component.ts +1 -0
- package/src/app/components/canned-response/canned-response.component.ts +4 -9
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +3 -3
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +1 -0
- package/src/app/components/conversation-info/info-content/info-content.component.ts +10 -14
- package/src/app/components/conversation-info/info-group/info-group.component.ts +2 -10
- package/src/app/components/copilot-popover/copilot-popover.component.html +1 -1
- package/src/app/components/copilot-popover/copilot-popover.component.ts +1 -2
- package/src/app/components/copilot-suggestions/copilot-suggestions.component.ts +14 -12
- package/src/app/components/navbar/navbar.component.ts +4 -4
- package/src/app/components/project-item/project-item.component.ts +3 -4
- package/src/app/modals/create-canned-response/create-canned-response.page.ts +6 -12
- package/src/app/modals/create-ticket/create-ticket.page.ts +10 -23
- package/src/app/modals/send-email/send-email.page.ts +1 -3
- package/src/app/pages/contacts-directory/contacts-directory.page.ts +3 -5
- package/src/app/pages/conversation-detail/conversation-detail.page.html +4 -2
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +15 -32
- package/src/app/pages/conversations-list/conversations-list.page.ts +8 -16
- package/src/app/pages/create-requester/create-requester.page.ts +5 -10
- package/src/app/services/canned-responses/canned-responses.service.ts +25 -19
- package/src/app/services/contacts/contacts.service.ts +23 -20
- package/src/app/services/copilot/copilot.service.ts +27 -23
- package/src/app/services/projects/{projects.service.spec.ts → project.service.spec.ts} +2 -2
- package/src/app/services/projects/project.service.ts +68 -0
- package/src/app/services/tiledesk/tiledesk.service.ts +48 -82
- package/src/app/utils/project-utils.ts +140 -0
- package/src/chat21-core/utils/constants.ts +3 -0
- package/src/app/services/projects/projects.service.ts +0 -43
|
@@ -5,61 +5,65 @@ import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service
|
|
|
5
5
|
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
6
6
|
import { map, filter } from 'rxjs/operators';
|
|
7
7
|
import * as uuid from 'uuid';
|
|
8
|
+
import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
|
|
8
9
|
|
|
9
10
|
@Injectable({
|
|
10
11
|
providedIn: 'root'
|
|
11
12
|
})
|
|
12
13
|
export class CopilotService {
|
|
13
14
|
|
|
14
|
-
private
|
|
15
|
+
private SERVER_BASE_URL: string;
|
|
16
|
+
private tiledeskToken: string;
|
|
17
|
+
|
|
15
18
|
private logger: LoggerService = LoggerInstance.getInstance();
|
|
16
19
|
|
|
17
20
|
constructor(
|
|
18
21
|
public http: HttpClient,
|
|
19
|
-
public
|
|
22
|
+
public appStorageService: AppStorageService
|
|
20
23
|
) {
|
|
21
24
|
this.logger.log('[COPILOT-SERVICE] HELLO !');
|
|
22
|
-
this.apiUrl = appConfigProvider.getConfig().apiUrl;
|
|
23
|
-
this.logger.log('[COPILOT-SERVICE] apiUrl ', this.apiUrl);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
initialize(serverBaseUrl: string) {
|
|
28
|
+
this.logger.log('[COPILOT-SERVICE] - initialize serverBaseUrl', serverBaseUrl);
|
|
29
|
+
this.SERVER_BASE_URL = serverBaseUrl;
|
|
30
|
+
this.tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public getAll(projectid: string, conversWith: string) {
|
|
34
|
+
const url = this.SERVER_BASE_URL + projectid + "/copilot?request_id=" + conversWith;
|
|
35
|
+
this.logger.log('[COPILOT-SERVICE] getAllSuggestions - URL ', url);
|
|
29
36
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
const httpOptions = {
|
|
38
|
+
headers: new HttpHeaders({
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
Authorization: this.tiledeskToken
|
|
41
|
+
})
|
|
42
|
+
};
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}))
|
|
44
|
+
return this.http.get(url, httpOptions).pipe(map((res: [any]) => {
|
|
45
|
+
let suggestions = res.filter(el => el !== null).map(el => ({ ...el, _id: uuid.v4()} ));
|
|
46
|
+
return suggestions
|
|
47
|
+
}))
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
public getAllFromQuestion(question: string,
|
|
45
|
-
const url = this.
|
|
50
|
+
public getAllFromQuestion(question: string, projectid: string, conversWith: string) {
|
|
51
|
+
const url = this.SERVER_BASE_URL + projectid + "/copilot?request_id=" + conversWith;
|
|
46
52
|
this.logger.log('[COPILOT-SERVICE] getAllSuggestions - URL ', url);
|
|
47
53
|
|
|
48
54
|
const httpOptions = {
|
|
49
55
|
headers: new HttpHeaders({
|
|
50
56
|
'Content-Type': 'application/json',
|
|
51
|
-
Authorization:
|
|
57
|
+
Authorization: this.tiledeskToken
|
|
52
58
|
})
|
|
53
59
|
};
|
|
54
60
|
|
|
55
|
-
console.log('questionnnn', question)
|
|
56
61
|
const body = {
|
|
57
62
|
text: question
|
|
58
63
|
};
|
|
59
64
|
|
|
60
65
|
return this.http.post(url, body, httpOptions).pipe(map((res: [any]) => {
|
|
61
66
|
let suggestions = res.filter(el => el !== null).map(el => ({ ...el, _id: uuid.v4()} ));
|
|
62
|
-
this.logger.log('[COPILOT-SERVICE] getCannedResponses - RES ', suggestions);
|
|
63
67
|
return suggestions
|
|
64
68
|
}))
|
|
65
69
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { TestBed } from '@angular/core/testing';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ProjectService } from './project.service';
|
|
4
4
|
|
|
5
5
|
describe('ProjectsService', () => {
|
|
6
6
|
beforeEach(() => TestBed.configureTestingModule({}));
|
|
7
7
|
|
|
8
8
|
it('should be created', () => {
|
|
9
|
-
const service:
|
|
9
|
+
const service: ProjectService = TestBed.get(ProjectService);
|
|
10
10
|
expect(service).toBeTruthy();
|
|
11
11
|
});
|
|
12
12
|
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
2
|
+
import { Injectable } from '@angular/core';
|
|
3
|
+
import { map } from 'rxjs/operators';
|
|
4
|
+
import { Project } from 'src/chat21-core/models/projects';
|
|
5
|
+
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
6
|
+
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
7
|
+
import { AppConfigProvider } from '../app-config';
|
|
8
|
+
import { Observable } from 'rxjs';
|
|
9
|
+
import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
|
|
10
|
+
|
|
11
|
+
@Injectable({
|
|
12
|
+
providedIn: 'root'
|
|
13
|
+
})
|
|
14
|
+
export class ProjectService {
|
|
15
|
+
|
|
16
|
+
private SERVER_BASE_URL: string;
|
|
17
|
+
private tiledeskToken: string;
|
|
18
|
+
|
|
19
|
+
private logger: LoggerService = LoggerInstance.getInstance();
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
public http: HttpClient,
|
|
23
|
+
public appStorageService: AppStorageService
|
|
24
|
+
) {
|
|
25
|
+
|
|
26
|
+
this.logger.log('[PROJECTS-SERVICE] HELLO !');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
initialize(serverBaseUrl: string) {
|
|
30
|
+
this.logger.log('[TILEDESK-PROJECTS-SERV] - initialize serverBaseUrl', serverBaseUrl);
|
|
31
|
+
this.SERVER_BASE_URL = serverBaseUrl;
|
|
32
|
+
this.tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public getProjects(): Observable<Project[]> {
|
|
36
|
+
const url = this.SERVER_BASE_URL + "projects/";
|
|
37
|
+
this.logger.log('[PROJECTS-SERVICE] getProjects - URL ', url);
|
|
38
|
+
|
|
39
|
+
const httpOptions = {
|
|
40
|
+
headers: new HttpHeaders({
|
|
41
|
+
'Content-Type': 'application/json',
|
|
42
|
+
Authorization: this.tiledeskToken
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return this.http.get(url, httpOptions).pipe(map((res: Project[]) => {
|
|
47
|
+
this.logger.log('[PROJECTS-SERVICE] getProjects - RES ', res);
|
|
48
|
+
return res
|
|
49
|
+
}))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public getProjectById(id: string): Observable<Project> {
|
|
53
|
+
const url = this.SERVER_BASE_URL + 'projects/' + id;
|
|
54
|
+
this.logger.log('[TILEDESK-SERVICE] - GET PROJECT BY ID URL', url);
|
|
55
|
+
|
|
56
|
+
const httpOptions = {
|
|
57
|
+
headers: new HttpHeaders({
|
|
58
|
+
'Content-Type': 'application/json',
|
|
59
|
+
Authorization: this.tiledeskToken
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
return this.http.get(url, httpOptions).pipe(map((project: Project) => {
|
|
63
|
+
this.logger.log('[TILEDESK-SERVICE] GET PROJECT BY ID URL - RES ', project);
|
|
64
|
+
return project
|
|
65
|
+
}))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
@@ -6,6 +6,7 @@ import { map } from 'rxjs/operators';
|
|
|
6
6
|
// Logger
|
|
7
7
|
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
8
8
|
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
9
|
+
import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
@Injectable({
|
|
@@ -13,38 +14,41 @@ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
|
|
|
13
14
|
})
|
|
14
15
|
export class TiledeskService {
|
|
15
16
|
|
|
16
|
-
private
|
|
17
|
+
// private
|
|
18
|
+
private SERVER_BASE_URL: string;
|
|
19
|
+
private tiledeskToken: string;
|
|
20
|
+
|
|
17
21
|
private logger: LoggerService = LoggerInstance.getInstance();
|
|
18
22
|
|
|
19
23
|
constructor(
|
|
20
24
|
public http: HttpClient,
|
|
21
|
-
public
|
|
22
|
-
) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
public appStorageService: AppStorageService
|
|
26
|
+
) {}
|
|
27
|
+
|
|
28
|
+
initialize(serverBaseUrl: string) {
|
|
29
|
+
this.logger.log('[TILEDESK-SERVICE] - initialize serverBaseUrl', serverBaseUrl);
|
|
30
|
+
this.SERVER_BASE_URL = serverBaseUrl;
|
|
31
|
+
this.tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
|
|
29
35
|
// CLOSE SUPPORT GROUP
|
|
30
|
-
public closeSupportGroup(
|
|
36
|
+
public closeSupportGroup(projectid: string, supportgroupid: string) {
|
|
37
|
+
const url = this.SERVER_BASE_URL + projectid + '/requests/' + supportgroupid + '/close';
|
|
38
|
+
this.logger.log('[TILEDESK-SERVICE] - closeSupportGroup URL ', url);
|
|
39
|
+
|
|
31
40
|
const httpOptions = {
|
|
32
41
|
headers: new HttpHeaders({
|
|
33
42
|
'Accept': 'application/json',
|
|
34
43
|
'Content-Type': 'application/json',
|
|
35
|
-
Authorization:
|
|
44
|
+
Authorization: this.tiledeskToken
|
|
36
45
|
})
|
|
37
46
|
};
|
|
38
47
|
|
|
39
48
|
const body = {
|
|
40
49
|
force: true
|
|
41
50
|
};
|
|
42
|
-
// console.log('CLOUD FUNCT CLOSE SUPPORT GROUP REQUEST BODY ', body);
|
|
43
|
-
// https://tiledesk-server-pre.herokuapp.com/
|
|
44
|
-
// const url = 'https://tiledesk-server-pre.herokuapp.com/' + this.project_id + '/requests/' + group_id + '/close';
|
|
45
|
-
const url = this.apiUrl + projectid + '/requests/' + supportgroupid + '/close';
|
|
46
51
|
|
|
47
|
-
this.logger.log('[TILEDESK-SERVICE] - closeSupportGroup URL ', url);
|
|
48
52
|
return this.http.put(url, body, httpOptions).pipe(map((res: any) => {
|
|
49
53
|
this.logger.log('[TILEDESK-SERVICE] - closeSupportGroup - RES ', res);
|
|
50
54
|
return res
|
|
@@ -54,14 +58,14 @@ export class TiledeskService {
|
|
|
54
58
|
// ---------------------------------------------
|
|
55
59
|
// @ GET request by id
|
|
56
60
|
// ---------------------------------------------
|
|
57
|
-
public getRequest(request_id: string, project_id: string
|
|
58
|
-
const url = this.
|
|
61
|
+
public getRequest(request_id: string, project_id: string) {
|
|
62
|
+
const url = this.SERVER_BASE_URL + project_id + '/requests/'+request_id
|
|
59
63
|
this.logger.log('[TILEDESK-SERVICE] - CREATE NEW LEAD url ', url);
|
|
60
64
|
|
|
61
65
|
const httpOptions = {
|
|
62
66
|
headers: new HttpHeaders({
|
|
63
67
|
'Content-Type': 'application/json',
|
|
64
|
-
Authorization:
|
|
68
|
+
Authorization: this.tiledeskToken
|
|
65
69
|
})
|
|
66
70
|
};
|
|
67
71
|
|
|
@@ -71,15 +75,15 @@ export class TiledeskService {
|
|
|
71
75
|
}))
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
public getProjectIdByConvRecipient(
|
|
75
|
-
const lookupUrl = this.
|
|
78
|
+
public getProjectIdByConvRecipient(conversationWith: string ) {
|
|
79
|
+
const lookupUrl = this.SERVER_BASE_URL + 'requests_util/lookup/id_project/' + conversationWith;
|
|
76
80
|
|
|
77
81
|
this.logger.log('[TILEDESK-SERVICE] GET PROJECTID BY CONV RECIPIENT - URL ', lookupUrl);
|
|
78
82
|
|
|
79
83
|
const httpOptions = {
|
|
80
84
|
headers: new HttpHeaders({
|
|
81
85
|
'Content-Type': 'application/json',
|
|
82
|
-
Authorization:
|
|
86
|
+
Authorization: this.tiledeskToken
|
|
83
87
|
})
|
|
84
88
|
};
|
|
85
89
|
|
|
@@ -89,49 +93,14 @@ export class TiledeskService {
|
|
|
89
93
|
}))
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
public
|
|
93
|
-
const url = this.
|
|
94
|
-
this.logger.log('[TILEDESK-SERVICE] - GET PROJECTS URL', url);
|
|
95
|
-
|
|
96
|
-
const httpOptions = {
|
|
97
|
-
headers: new HttpHeaders({
|
|
98
|
-
'Content-Type': 'application/json',
|
|
99
|
-
Authorization: token
|
|
100
|
-
})
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return this.http.get(url, httpOptions).pipe(map((res: any) => {
|
|
104
|
-
this.logger.log('[TILEDESK-SERVICE] GET PROJECTS - RES ', res);
|
|
105
|
-
return res
|
|
106
|
-
}))
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
public getProjectById( token: string , id: string) {
|
|
111
|
-
const url = this.apiUrl + 'projects/' + id;
|
|
112
|
-
this.logger.log('[TILEDESK-SERVICE] - GET PROJECT BY ID URL', url);
|
|
113
|
-
|
|
114
|
-
const httpOptions = {
|
|
115
|
-
headers: new HttpHeaders({
|
|
116
|
-
'Content-Type': 'application/json',
|
|
117
|
-
Authorization: token
|
|
118
|
-
})
|
|
119
|
-
};
|
|
120
|
-
return this.http.get(url, httpOptions).pipe(map((res: any) => {
|
|
121
|
-
this.logger.log('[TILEDESK-SERVICE] GET PROJECT BY ID URL - RES ', res);
|
|
122
|
-
return res
|
|
123
|
-
}))
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
public getProjectUsersByProjectId(project_id: string, token: string) {
|
|
128
|
-
const url = this.apiUrl + project_id + '/project_users/';
|
|
96
|
+
public getProjectUsersByProjectId(project_id: string) {
|
|
97
|
+
const url = this.SERVER_BASE_URL + project_id + '/project_users/';
|
|
129
98
|
this.logger.log('[TILEDESK-SERVICE] - GET PROJECT-USER URL', url);
|
|
130
99
|
|
|
131
100
|
const httpOptions = {
|
|
132
101
|
headers: new HttpHeaders({
|
|
133
102
|
'Content-Type': 'application/json',
|
|
134
|
-
Authorization:
|
|
103
|
+
Authorization: this.tiledeskToken
|
|
135
104
|
})
|
|
136
105
|
};
|
|
137
106
|
return this.http.get(url, httpOptions).pipe(map((res: any) => {
|
|
@@ -140,14 +109,14 @@ export class TiledeskService {
|
|
|
140
109
|
}))
|
|
141
110
|
}
|
|
142
111
|
|
|
143
|
-
public getAllLeadsActiveWithLimit(project_id: string,
|
|
144
|
-
const url = this.
|
|
112
|
+
public getAllLeadsActiveWithLimit(project_id: string, limit: number) {
|
|
113
|
+
const url = this.SERVER_BASE_URL + project_id + '/leads?limit=' + limit + '&with_fullname=true';
|
|
145
114
|
this.logger.log('[TILEDESK-SERVICE] - GET ALL ACTIVE LEADS (LIMIT 10000) - URL', url);
|
|
146
115
|
|
|
147
116
|
const httpOptions = {
|
|
148
117
|
headers: new HttpHeaders({
|
|
149
118
|
'Content-Type': 'application/json',
|
|
150
|
-
Authorization:
|
|
119
|
+
Authorization: this.tiledeskToken
|
|
151
120
|
})
|
|
152
121
|
};
|
|
153
122
|
return this.http.get(url, httpOptions).pipe(map((res: any) => {
|
|
@@ -160,13 +129,13 @@ export class TiledeskService {
|
|
|
160
129
|
// ---------------------------------------------
|
|
161
130
|
// @ Create new project user to get new lead ID
|
|
162
131
|
// ---------------------------------------------
|
|
163
|
-
public createNewProjectUserToGetNewLeadID(project_id: string
|
|
164
|
-
const url = this.
|
|
132
|
+
public createNewProjectUserToGetNewLeadID(project_id: string) {
|
|
133
|
+
const url = this.SERVER_BASE_URL + project_id + '/project_users/'
|
|
165
134
|
this.logger.log('[TILEDESK-SERVICE] - CREATE NEW PROJECT USER TO GET NEW LEAD ID url ', url);
|
|
166
135
|
const httpOptions = {
|
|
167
136
|
headers: new HttpHeaders({
|
|
168
137
|
'Content-Type': 'application/json',
|
|
169
|
-
Authorization:
|
|
138
|
+
Authorization: this.tiledeskToken
|
|
170
139
|
})
|
|
171
140
|
};
|
|
172
141
|
const body = {};
|
|
@@ -179,14 +148,14 @@ export class TiledeskService {
|
|
|
179
148
|
// ---------------------------------------------
|
|
180
149
|
// @ Create new lead
|
|
181
150
|
// ---------------------------------------------
|
|
182
|
-
public createNewLead(leadid: string, fullname: string, leademail: string, project_id: string
|
|
183
|
-
const url = this.
|
|
151
|
+
public createNewLead(leadid: string, fullname: string, leademail: string, project_id: string) {
|
|
152
|
+
const url = this.SERVER_BASE_URL + project_id + '/leads/'
|
|
184
153
|
this.logger.log('[TILEDESK-SERVICE] - CREATE NEW LEAD url ', url);
|
|
185
154
|
|
|
186
155
|
const httpOptions = {
|
|
187
156
|
headers: new HttpHeaders({
|
|
188
157
|
'Content-Type': 'application/json',
|
|
189
|
-
Authorization:
|
|
158
|
+
Authorization: this.tiledeskToken
|
|
190
159
|
})
|
|
191
160
|
};
|
|
192
161
|
|
|
@@ -202,15 +171,14 @@ export class TiledeskService {
|
|
|
202
171
|
// -------------------------------------------------------------------------------------
|
|
203
172
|
// @ Get all bots of the project (with all=true the response return also the identity bot)
|
|
204
173
|
// -------------------------------------------------------------------------------------
|
|
205
|
-
public getAllBotByProjectId(project_id: string
|
|
206
|
-
|
|
207
|
-
const url = this.apiUrl + project_id + '/faq_kb?all=true'
|
|
174
|
+
public getAllBotByProjectId(project_id: string) {
|
|
175
|
+
const url = this.SERVER_BASE_URL + project_id + '/faq_kb?all=true'
|
|
208
176
|
this.logger.log('[TILEDESK-SERVICE] - GET ALL BOTS BY PROJECT ID - URL', url);
|
|
209
177
|
|
|
210
178
|
const httpOptions = {
|
|
211
179
|
headers: new HttpHeaders({
|
|
212
180
|
'Content-Type': 'application/json',
|
|
213
|
-
Authorization:
|
|
181
|
+
Authorization: this.tiledeskToken
|
|
214
182
|
})
|
|
215
183
|
};
|
|
216
184
|
|
|
@@ -223,15 +191,14 @@ export class TiledeskService {
|
|
|
223
191
|
// -------------------------------------------------------------------------------------
|
|
224
192
|
// @ Get all DEPTS of the project
|
|
225
193
|
// -------------------------------------------------------------------------------------
|
|
226
|
-
public getDeptsByProjectId(project_id: string
|
|
227
|
-
|
|
228
|
-
const url = this.apiUrl + project_id + '/departments/allstatus';
|
|
194
|
+
public getDeptsByProjectId(project_id: string) {
|
|
195
|
+
const url = this.SERVER_BASE_URL + project_id + '/departments/allstatus';
|
|
229
196
|
this.logger.log('[TILEDESK-SERVICE] - GET DEPTS (ALL STATUS) - URL', url);
|
|
230
197
|
|
|
231
198
|
const httpOptions = {
|
|
232
199
|
headers: new HttpHeaders({
|
|
233
200
|
'Content-Type': 'application/json',
|
|
234
|
-
Authorization:
|
|
201
|
+
Authorization: this.tiledeskToken
|
|
235
202
|
})
|
|
236
203
|
};
|
|
237
204
|
|
|
@@ -244,15 +211,14 @@ export class TiledeskService {
|
|
|
244
211
|
// -----------------------------------------------------------------------------------------
|
|
245
212
|
// @ Create ticket
|
|
246
213
|
// -----------------------------------------------------------------------------------------
|
|
247
|
-
public createInternalRequest(requester_id: string, request_id: string, subject: string, message: string, departmentid: string, participantid: string, ticketpriority: string, project_id: string
|
|
248
|
-
|
|
249
|
-
const url = this.apiUrl + project_id + '/requests/' + request_id + '/messages'
|
|
214
|
+
public createInternalRequest(requester_id: string, request_id: string, subject: string, message: string, departmentid: string, participantid: string, ticketpriority: string, project_id: string) {
|
|
215
|
+
const url = this.SERVER_BASE_URL + project_id + '/requests/' + request_id + '/messages'
|
|
250
216
|
this.logger.log('[WS-REQUESTS-SERV] - CREATE INTERNAL REQUEST URL ', url)
|
|
251
217
|
|
|
252
218
|
const httpOptions = {
|
|
253
219
|
headers: new HttpHeaders({
|
|
254
220
|
'Content-Type': 'application/json',
|
|
255
|
-
Authorization:
|
|
221
|
+
Authorization: this.tiledeskToken
|
|
256
222
|
})
|
|
257
223
|
};
|
|
258
224
|
// this.logger.log('JOIN FUNCT OPTIONS ', options);
|
|
@@ -275,20 +241,20 @@ export class TiledeskService {
|
|
|
275
241
|
// -----------------------------------------------------------------------------------------
|
|
276
242
|
// @ Send Email
|
|
277
243
|
// -----------------------------------------------------------------------------------------
|
|
278
|
-
public sendEmail(
|
|
244
|
+
public sendEmail(projectid: string, request_id: string, form: { subject: string, text: string}) {
|
|
245
|
+
const url = this.SERVER_BASE_URL + projectid + '/requests/' + request_id + '/email/send';
|
|
246
|
+
this.logger.log('[TILEDESK-SERVICE] - sendEmail URL ', url);
|
|
279
247
|
|
|
280
248
|
const httpOptions = {
|
|
281
249
|
headers: new HttpHeaders({
|
|
282
250
|
'Accept': 'application/json',
|
|
283
251
|
'Content-Type': 'application/json',
|
|
284
|
-
Authorization:
|
|
252
|
+
Authorization: this.tiledeskToken
|
|
285
253
|
})
|
|
286
254
|
};
|
|
287
255
|
|
|
288
256
|
const body = form;
|
|
289
257
|
|
|
290
|
-
const url = this.apiUrl + projectid + '/requests/' + request_id + '/email/send';
|
|
291
|
-
this.logger.log('[TILEDESK-SERVICE] - sendEmail URL ', url);
|
|
292
258
|
return this.http.post(url, body, httpOptions).pipe(map((res: any) => {
|
|
293
259
|
this.logger.log('[TILEDESK-SERVICE] - sendEmail - RES ', res);
|
|
294
260
|
return res
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Injectable, OnInit } from "@angular/core";
|
|
2
|
+
import { PLAN_NAME } from "src/chat21-core/utils/constants";
|
|
3
|
+
import { LoggerService } from "src/chat21-core/providers/abstract/logger.service";
|
|
4
|
+
import { LoggerInstance } from "src/chat21-core/providers/logger/loggerInstance";
|
|
5
|
+
import { Project } from 'src/chat21-core/models/projects';
|
|
6
|
+
import { ProjectService } from "../services/projects/project.service";
|
|
7
|
+
import { AppConfigProvider } from "../services/app-config";
|
|
8
|
+
|
|
9
|
+
@Injectable({
|
|
10
|
+
providedIn: 'root'
|
|
11
|
+
})
|
|
12
|
+
export class ProjectPlanUtils {
|
|
13
|
+
|
|
14
|
+
project: Project
|
|
15
|
+
|
|
16
|
+
private logger: LoggerService = LoggerInstance.getInstance()
|
|
17
|
+
constructor(
|
|
18
|
+
private projectService: ProjectService
|
|
19
|
+
){
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
checkProjectProfileFeature(project: Project, feature: string): boolean{
|
|
23
|
+
|
|
24
|
+
this.logger.log('[PROJECT_PROFILE] checkProjectProfileFeature -->', feature, project)
|
|
25
|
+
|
|
26
|
+
// this.project = await this.projectService.getProjectById(projectId).toPromise()
|
|
27
|
+
this.project = project;
|
|
28
|
+
|
|
29
|
+
if(this.project.profile.type === 'free'){
|
|
30
|
+
this.logger.log('[PROJECT_PROFILE] USECASE: Free Plan')
|
|
31
|
+
if(this.project.trialExpired === false){
|
|
32
|
+
// ------------------------------------------------------------------------
|
|
33
|
+
// USECASE: Free Plan (TRIAL ACTIVE i.e. Scale trial)
|
|
34
|
+
// ------------------------------------------------------------------------
|
|
35
|
+
return true
|
|
36
|
+
}else {
|
|
37
|
+
// ------------------------------------------------------------------------
|
|
38
|
+
// USECASE: Free Plan (TRIAL EXPIRED)
|
|
39
|
+
// ------------------------------------------------------------------------
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
}else if(this.project.profile.type === 'payment'){
|
|
43
|
+
// ------------------------------------------------------------------------
|
|
44
|
+
// USECASE: PAYMENT Plan (TRIAL ACTIVE i.e. Scale trial)
|
|
45
|
+
// ------------------------------------------------------------------------
|
|
46
|
+
this.logger.log('[PROJECT_PROFILE] USECASE: payment')
|
|
47
|
+
|
|
48
|
+
/** check if the subscription is Active or NOT */
|
|
49
|
+
if(this.project.isActiveSubscription === false){
|
|
50
|
+
return false
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** get che current keyName for the current project (usefull to compare later)*/
|
|
54
|
+
/** before: MAKE A COMPARE BETWEEN OLD AND NEW PROJECT TYPE
|
|
55
|
+
* LEGEND:
|
|
56
|
+
* - A --> D
|
|
57
|
+
* - B --> E
|
|
58
|
+
* - C --> F
|
|
59
|
+
*/
|
|
60
|
+
let currentPlanNameKey: string[] = ['A']
|
|
61
|
+
switch(this.project.profile.name.toUpperCase()){
|
|
62
|
+
case PLAN_NAME.A.toUpperCase(): {
|
|
63
|
+
this.logger.log('case A')
|
|
64
|
+
currentPlanNameKey = Object.keys(PLAN_NAME).filter(x => PLAN_NAME[x].toUpperCase() == PLAN_NAME.D.toUpperCase());
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case PLAN_NAME.B.toUpperCase(): {
|
|
68
|
+
this.logger.log('case B')
|
|
69
|
+
currentPlanNameKey = Object.keys(PLAN_NAME).filter(x => PLAN_NAME[x].toUpperCase() == PLAN_NAME.E.toUpperCase());
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case PLAN_NAME.C.toUpperCase(): {
|
|
73
|
+
this.logger.log('case C')
|
|
74
|
+
currentPlanNameKey = Object.keys(PLAN_NAME).filter(x => PLAN_NAME[x].toUpperCase() == PLAN_NAME.F.toUpperCase());
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
default: {
|
|
78
|
+
currentPlanNameKey = Object.keys(PLAN_NAME).filter(x => PLAN_NAME[x].toUpperCase() == this.project.profile.name.toUpperCase());
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** compare enums: current action enum plan >= current prject profile enum name (UPPERCASE) */
|
|
85
|
+
// if(currentPlanNameKey.length>0){
|
|
86
|
+
// let actionPlanNameKey: string[] = Object.keys(PLAN_NAME).filter(x => PLAN_NAME[x].toUpperCase() == actionPlanAvailability.toUpperCase());
|
|
87
|
+
// this.logger.log('check plan availability: currentPlanNameKey VS actionPlanNameKey -->', currentPlanNameKey[0], actionPlanNameKey[0])
|
|
88
|
+
// // this.logger.log('check plan availability: PLAN currentPlanNameKey VS PLAN actionPlanNameKey -->', PLAN_NAME[currentPlanNameKey[0]]> PLAN_NAME[actionPlanNameKey[0]])
|
|
89
|
+
// return currentPlanNameKey[0] >= actionPlanNameKey[0] ? true: false;
|
|
90
|
+
// }
|
|
91
|
+
|
|
92
|
+
/**check only CUSTOM PLAN */
|
|
93
|
+
this.logger.log('[PROJECT_PROFILE] USECASE: currentPlanNameKey', currentPlanNameKey[0], PLAN_NAME.F)
|
|
94
|
+
if(PLAN_NAME[currentPlanNameKey[0]] === PLAN_NAME.F){
|
|
95
|
+
return this.checkIfIsEnabledInProject(feature)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return false
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public checkIfIsEnabledInProject(featureKey: string): boolean{
|
|
104
|
+
|
|
105
|
+
this.logger.log('[PROJECT_PROFILE] checkIfIsEnabledInProject -->', featureKey, this.project)
|
|
106
|
+
if (this.project.profile['customization'] === undefined){
|
|
107
|
+
// ------------------------------------------------------------------------
|
|
108
|
+
// USECASE: customization obj not exist
|
|
109
|
+
// ------------------------------------------------------------------------
|
|
110
|
+
return false
|
|
111
|
+
} else if(this.project.profile['customization'] && this.project.profile['customization'][featureKey]){
|
|
112
|
+
// ------------------------------------------------------------------------
|
|
113
|
+
// USECASE: customization obj exist AND customization.actions obj not exist
|
|
114
|
+
// ------------------------------------------------------------------------
|
|
115
|
+
return true
|
|
116
|
+
}
|
|
117
|
+
return false
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
checkPlanIsExpired(project: Project): boolean {
|
|
121
|
+
let check: boolean = false
|
|
122
|
+
|
|
123
|
+
//case FREE plan
|
|
124
|
+
if(project && project.trialExpired && project.profile.type=== 'trial'){
|
|
125
|
+
check = true
|
|
126
|
+
}else if(project && !project.trialExpired && project.profile.type=== 'trial'){
|
|
127
|
+
check = false
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//case PAYMENT plan
|
|
131
|
+
if(project && project.isActiveSubscription && project.profile.type=== 'payment'){
|
|
132
|
+
check = true
|
|
133
|
+
}else if(project && !project.isActiveSubscription && project.profile.type=== 'payment'){
|
|
134
|
+
check = false
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return check
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
@@ -141,6 +141,9 @@ export enum PLAN_NAME {
|
|
|
141
141
|
A = 'Growth',
|
|
142
142
|
B = 'Scale',
|
|
143
143
|
C = 'Plus',
|
|
144
|
+
D = 'Basic',
|
|
145
|
+
E = 'Premium',
|
|
146
|
+
F = 'Custom'
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
export const tranlatedLanguage = ['it', 'en', 'de', 'es', 'pt', 'fr', 'ru', 'tr', 'sr', 'ar', 'uk', 'sv', 'az', 'kk', 'uz']
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
2
|
-
import { Injectable } from '@angular/core';
|
|
3
|
-
import { map } from 'rxjs/operators';
|
|
4
|
-
import { Project } from 'src/chat21-core/models/projects';
|
|
5
|
-
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
6
|
-
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
7
|
-
import { AppConfigProvider } from '../app-config';
|
|
8
|
-
|
|
9
|
-
@Injectable({
|
|
10
|
-
providedIn: 'root'
|
|
11
|
-
})
|
|
12
|
-
export class ProjectsService {
|
|
13
|
-
|
|
14
|
-
private apiUrl: string;
|
|
15
|
-
private logger: LoggerService = LoggerInstance.getInstance();
|
|
16
|
-
|
|
17
|
-
constructor(
|
|
18
|
-
public http: HttpClient,
|
|
19
|
-
public appConfigProvider: AppConfigProvider
|
|
20
|
-
) {
|
|
21
|
-
|
|
22
|
-
this.logger.log('[PROJECTS-SERVICE] HELLO !');
|
|
23
|
-
this.apiUrl = appConfigProvider.getConfig().apiUrl;
|
|
24
|
-
this.logger.log('[PROJECTS-SERVICE] apiUrl ', this.apiUrl);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public getProjects(token: string) {
|
|
28
|
-
const url = this.apiUrl + "projects/";
|
|
29
|
-
this.logger.log('[PROJECTS-SERVICE] getProjects - URL ', url);
|
|
30
|
-
|
|
31
|
-
const httpOptions = {
|
|
32
|
-
headers: new HttpHeaders({
|
|
33
|
-
'Content-Type': 'application/json',
|
|
34
|
-
Authorization: token
|
|
35
|
-
})
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return this.http.get(url, httpOptions).pipe(map((res: Project[]) => {
|
|
39
|
-
this.logger.log('[PROJECTS-SERVICE] getProjects - RES ', res);
|
|
40
|
-
return res
|
|
41
|
-
}))
|
|
42
|
-
}
|
|
43
|
-
}
|