@chat21/chat21-ionic 3.4.13-rc2 → 3.4.13-rc4
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 +8 -0
- package/package.json +1 -1
- package/src/app/app.component.ts +7 -6
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +3 -28
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +12 -7
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +2 -1
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +5 -30
- package/src/app/chatlib/conversation-detail/message/options/options.component.html +4 -1
- package/src/app/chatlib/conversation-detail/message/options/options.component.scss +7 -0
- package/src/app/chatlib/conversation-detail/message/options/options.component.ts +41 -8
- package/src/app/components/canned-response/canned-response.component.html +8 -3
- package/src/app/components/canned-response/canned-response.component.scss +26 -0
- package/src/app/components/canned-response/canned-response.component.ts +8 -28
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +3 -4
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +11 -0
- 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 +9 -11
- package/src/app/components/conversation-info/info-group/info-group.component.ts +2 -10
- package/src/app/components/copilot-popover/copilot-popover.component.html +25 -0
- package/src/app/components/copilot-popover/copilot-popover.component.scss +101 -0
- package/src/app/components/copilot-popover/copilot-popover.component.spec.ts +24 -0
- package/src/app/components/copilot-popover/copilot-popover.component.ts +81 -0
- package/src/app/components/copilot-suggestions/copilot-suggestions.component.ts +37 -18
- 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 +1 -1
- package/src/app/pages/contacts-directory/contacts-directory.page.ts +5 -4
- package/src/app/pages/conversation-detail/conversation-detail.module.ts +3 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.html +6 -3
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +29 -28
- package/src/app/pages/conversations-list/conversations-list.page.ts +1 -1
- package/src/app/services/canned-responses/canned-responses.service.ts +22 -16
- package/src/app/services/contacts/contacts.service.ts +23 -20
- package/src/app/services/copilot/copilot.service.ts +46 -19
- 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 +0 -35
- package/src/app/utils/project-utils.ts +140 -0
- package/src/assets/i18n/en.json +4 -1
- package/src/assets/i18n/it.json +4 -1
- package/src/chat21-core/utils/constants.ts +3 -0
- package/src/global.scss +6 -0
- package/src/variables.scss +1 -0
- package/src/app/services/projects/projects.service.ts +0 -43
|
@@ -6,38 +6,44 @@ 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
|
@Injectable({
|
|
11
12
|
providedIn: 'root'
|
|
12
13
|
})
|
|
13
14
|
export class CannedResponsesService {
|
|
14
15
|
|
|
15
|
-
private
|
|
16
|
+
private SERVER_BASE_URL: string;
|
|
17
|
+
private tiledeskToken: string;
|
|
18
|
+
|
|
16
19
|
private logger: LoggerService = LoggerInstance.getInstance();
|
|
17
20
|
|
|
18
21
|
constructor(
|
|
19
22
|
public http: HttpClient,
|
|
20
|
-
public
|
|
23
|
+
public appStorageService: AppStorageService
|
|
21
24
|
) {
|
|
22
|
-
|
|
23
25
|
this.logger.log('[CANNED-RESPONSES-SERVICE] HELLO !');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
initialize(serverBaseUrl: string) {
|
|
29
|
+
this.logger.log('[CANNED-RESPONSES-SERVICE] - initialize serverBaseUrl', serverBaseUrl);
|
|
30
|
+
this.SERVER_BASE_URL = serverBaseUrl;
|
|
31
|
+
this.tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
|
|
29
|
-
public getAll(
|
|
30
|
-
const
|
|
31
|
-
this.logger.log('[CANNED-RESPONSES-SERVICE] getCannedResponses - URL ',
|
|
35
|
+
public getAll(projectid: string) {
|
|
36
|
+
const url = this.SERVER_BASE_URL + projectid + "/canned/";
|
|
37
|
+
this.logger.log('[CANNED-RESPONSES-SERVICE] getCannedResponses - URL ', url);
|
|
32
38
|
|
|
33
39
|
const httpOptions = {
|
|
34
40
|
headers: new HttpHeaders({
|
|
35
41
|
'Content-Type': 'application/json',
|
|
36
|
-
Authorization:
|
|
42
|
+
Authorization: this.tiledeskToken
|
|
37
43
|
})
|
|
38
44
|
};
|
|
39
45
|
|
|
40
|
-
return this.http.get(
|
|
46
|
+
return this.http.get(url, httpOptions).pipe(map((res: any) => {
|
|
41
47
|
this.logger.log('[CANNED-RESPONSES-SERVICE] getCannedResponses - RES ', res);
|
|
42
48
|
return res
|
|
43
49
|
}))
|
|
@@ -46,14 +52,14 @@ export class CannedResponsesService {
|
|
|
46
52
|
// -------------------------------------------------------------------------------------
|
|
47
53
|
// @ Create - Save (POST) new canned response
|
|
48
54
|
// -------------------------------------------------------------------------------------
|
|
49
|
-
public add(
|
|
50
|
-
const url = this.
|
|
55
|
+
public add(projectid: string, title: string, message: string) {
|
|
56
|
+
const url = this.SERVER_BASE_URL + projectid + '/canned/'
|
|
51
57
|
this.logger.log('[TILEDESK-SERVICE] - CREATE CANNED-RES - URL', url);
|
|
52
58
|
|
|
53
59
|
const httpOptions = {
|
|
54
60
|
headers: new HttpHeaders({
|
|
55
61
|
'Content-Type': 'application/json',
|
|
56
|
-
Authorization:
|
|
62
|
+
Authorization: this.tiledeskToken
|
|
57
63
|
})
|
|
58
64
|
};
|
|
59
65
|
|
|
@@ -70,13 +76,13 @@ export class CannedResponsesService {
|
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
public edit(token: string, projectid: string, canned: any){
|
|
73
|
-
const cannedResponsesURL = this.
|
|
79
|
+
const cannedResponsesURL = this.SERVER_BASE_URL + projectid + "/canned/"+ canned._id;
|
|
74
80
|
this.logger.log('[CANNED-RESPONSES-SERVICE] editCannedResponses - URL ', cannedResponsesURL);
|
|
75
81
|
|
|
76
82
|
const httpOptions = {
|
|
77
83
|
headers: new HttpHeaders({
|
|
78
84
|
'Content-Type': 'application/json',
|
|
79
|
-
Authorization:
|
|
85
|
+
Authorization: this.tiledeskToken
|
|
80
86
|
})
|
|
81
87
|
};
|
|
82
88
|
|
|
@@ -92,7 +98,7 @@ export class CannedResponsesService {
|
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
public delete(token: string, projectid: string, cannedID: string){
|
|
95
|
-
const cannedResponsesURL = this.
|
|
101
|
+
const cannedResponsesURL = this.SERVER_BASE_URL + projectid + "/canned/"+cannedID;
|
|
96
102
|
this.logger.log('[CANNED-RESPONSES-SERVICE] deleteCannedResponses - URL ', cannedResponsesURL);
|
|
97
103
|
|
|
98
104
|
const httpOptions = {
|
|
@@ -14,6 +14,7 @@ import { map } from 'rxjs/operators';
|
|
|
14
14
|
// Logger
|
|
15
15
|
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
16
16
|
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
17
|
+
import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
|
|
17
18
|
|
|
18
19
|
@Injectable({
|
|
19
20
|
providedIn: 'root'
|
|
@@ -26,36 +27,41 @@ export class ContactsService {
|
|
|
26
27
|
BScontactDetail: BehaviorSubject<UserModel> = new BehaviorSubject<UserModel>(null);
|
|
27
28
|
|
|
28
29
|
// private
|
|
29
|
-
private
|
|
30
|
+
private SERVER_BASE_URL: string;
|
|
31
|
+
private tiledeskToken: string;
|
|
32
|
+
|
|
30
33
|
private contacts: UserModel[];
|
|
31
34
|
private logger: LoggerService = LoggerInstance.getInstance();
|
|
32
35
|
|
|
33
36
|
constructor(
|
|
34
37
|
public http: HttpClient,
|
|
35
|
-
public
|
|
38
|
+
public appStorageService: AppStorageService
|
|
36
39
|
) {
|
|
37
|
-
this.
|
|
40
|
+
this.logger.log('[COPILOT-SERVICE] HELLO !');
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
initialize(serverBaseUrl: string) {
|
|
44
|
+
this.logger.log('[COPILOT-SERVICE] - initialize serverBaseUrl', serverBaseUrl);
|
|
45
|
+
this.SERVER_BASE_URL = serverBaseUrl;
|
|
46
|
+
this.tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
47
|
+
}
|
|
40
48
|
|
|
41
|
-
// initialize() {}
|
|
42
49
|
|
|
43
50
|
/** */
|
|
44
|
-
public loadContactsFromUrl(
|
|
45
|
-
this.
|
|
46
|
-
this.logger.log('[CONTACT-SERVICE] loadContactsFromUrl
|
|
47
|
-
this.logger.log('[CONTACT-SERVICE] loadContactsFromUrl urlRemoteContacts', this.urlRemoteContacts)
|
|
51
|
+
public loadContactsFromUrl() {
|
|
52
|
+
const url = this.SERVER_BASE_URL + 'chat21/contacts';
|
|
53
|
+
this.logger.log('[CONTACT-SERVICE] loadContactsFromUrl urlRemoteContacts', url)
|
|
48
54
|
// if (this.urlRemoteContacts.startsWith('http') && token) {
|
|
49
55
|
const that = this;
|
|
50
56
|
const httpOptions = {
|
|
51
57
|
headers: new HttpHeaders({
|
|
52
58
|
'Content-Type': 'application/json',
|
|
53
|
-
Authorization:
|
|
59
|
+
Authorization: this.tiledeskToken
|
|
54
60
|
})
|
|
55
61
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.http.get<any[]>(
|
|
62
|
+
|
|
63
|
+
this.contacts = [];
|
|
64
|
+
this.http.get<any[]>(url, httpOptions).subscribe(users => {
|
|
59
65
|
this.logger.log('[CONTACT-SERVICE] loadContactsFromUrl users ', users);
|
|
60
66
|
users.forEach(user => {
|
|
61
67
|
const member = that.createCompleteUser(user);
|
|
@@ -103,24 +109,21 @@ export class ContactsService {
|
|
|
103
109
|
* @param token
|
|
104
110
|
* @param uid
|
|
105
111
|
*/
|
|
106
|
-
public loadContactDetail(
|
|
112
|
+
public loadContactDetail(uid: string) {
|
|
107
113
|
this.contacts = [];
|
|
114
|
+
const url = this.SERVER_BASE_URL + 'chat21/contacts/' + uid;
|
|
108
115
|
this.logger.log('[CONTACT-SERVICE] - loadContactDetail - uid ', uid);
|
|
109
|
-
this.logger.log('[CONTACT-SERVICE] - loadContactDetail - token ', token);
|
|
110
|
-
const urlRemoteContactDetail = this.urlRemoteContacts + '/' + uid;
|
|
111
116
|
// if (urlRemoteContactDetail.startsWith('http') && token) {
|
|
112
117
|
|
|
113
118
|
const httpOptions = {
|
|
114
119
|
headers: new HttpHeaders({
|
|
115
120
|
'Content-Type': 'application/json',
|
|
116
|
-
Authorization:
|
|
121
|
+
Authorization: this.tiledeskToken
|
|
117
122
|
})
|
|
118
123
|
};
|
|
119
124
|
// const postData = {};
|
|
120
|
-
this.logger.log('[CONTACT-SERVICE] - loadContactDetail url ',
|
|
121
|
-
return this.http
|
|
122
|
-
.get(urlRemoteContactDetail, httpOptions)
|
|
123
|
-
.pipe(map((res: any) => {
|
|
125
|
+
this.logger.log('[CONTACT-SERVICE] - loadContactDetail url ', url);
|
|
126
|
+
return this.http.get(url, httpOptions).pipe(map((res: any) => {
|
|
124
127
|
this.logger.log('[CONTACT-SERVICE] - loadContactDetail - loadContactDetail RES ', res);
|
|
125
128
|
if (res.uid) {
|
|
126
129
|
let user = this.createCompleteUser(res)
|
|
@@ -5,40 +5,67 @@ 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
|
-
|
|
42
|
-
|
|
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
|
+
}))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public getAllFromQuestion(question: string, projectid: string, conversWith: string) {
|
|
51
|
+
const url = this.SERVER_BASE_URL + projectid + "/copilot?request_id=" + conversWith;
|
|
52
|
+
this.logger.log('[COPILOT-SERVICE] getAllSuggestions - URL ', url);
|
|
53
|
+
|
|
54
|
+
const httpOptions = {
|
|
55
|
+
headers: new HttpHeaders({
|
|
56
|
+
'Content-Type': 'application/json',
|
|
57
|
+
Authorization: this.tiledeskToken
|
|
58
|
+
})
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const body = {
|
|
62
|
+
text: question
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return this.http.post(url, body, httpOptions).pipe(map((res: [any]) => {
|
|
66
|
+
let suggestions = res.filter(el => el !== null).map(el => ({ ...el, _id: uuid.v4()} ));
|
|
67
|
+
return suggestions
|
|
68
|
+
}))
|
|
69
|
+
}
|
|
43
70
|
|
|
44
71
|
}
|
|
@@ -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
|
+
}
|
|
@@ -89,41 +89,6 @@ export class TiledeskService {
|
|
|
89
89
|
}))
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
public getProjects(token: string) {
|
|
93
|
-
const url = this.apiUrl + 'projects/';
|
|
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
92
|
public getProjectUsersByProjectId(project_id: string, token: string) {
|
|
128
93
|
const url = this.apiUrl + project_id + '/project_users/';
|
|
129
94
|
this.logger.log('[TILEDESK-SERVICE] - GET PROJECT-USER URL', url);
|
|
@@ -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
|
+
}
|
package/src/assets/i18n/en.json
CHANGED
|
@@ -305,8 +305,11 @@
|
|
|
305
305
|
"SUBJECT_OFFLINE_MESSAGE":"Tiledesk Offline message 💬",
|
|
306
306
|
"SEND_EMAIL_SUCCESS_OFFLINE_MESSAGE":"Message also sent by email 📩"
|
|
307
307
|
},
|
|
308
|
+
"HELLO":"Hello",
|
|
308
309
|
"COPILOT": {
|
|
309
310
|
"ASK_AI":"Ask to AI",
|
|
310
|
-
"NO_SUGGESTIONS_PRESENT":"No suggestions found"
|
|
311
|
+
"NO_SUGGESTIONS_PRESENT":"No suggestions found",
|
|
312
|
+
"INSERT_PROMPT_HERE":"Inster a prompt here",
|
|
313
|
+
"HOW_CAN_I_HELP_YOU":"How can i help you?"
|
|
311
314
|
}
|
|
312
315
|
}
|
package/src/assets/i18n/it.json
CHANGED
|
@@ -305,8 +305,11 @@
|
|
|
305
305
|
"SUBJECT_OFFLINE_MESSAGE":"Messaggio offline di Tiledesk 💬",
|
|
306
306
|
"SEND_EMAIL_SUCCESS_OFFLINE_MESSAGE":"Messaggio inviato anche via mail 📩"
|
|
307
307
|
},
|
|
308
|
+
"HELLO":"Ciao",
|
|
308
309
|
"COPILOT": {
|
|
309
310
|
"ASK_AI":"Chiedi all'AI",
|
|
310
|
-
"NO_SUGGESTIONS_PRESENT":"Nessun suggerimento trovato"
|
|
311
|
+
"NO_SUGGESTIONS_PRESENT":"Nessun suggerimento trovato",
|
|
312
|
+
"INSERT_PROMPT_HERE":"Inserisci un prompt qui",
|
|
313
|
+
"HOW_CAN_I_HELP_YOU":"Come posso aiutarti?"
|
|
311
314
|
}
|
|
312
315
|
}
|
|
@@ -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']
|
package/src/global.scss
CHANGED
package/src/variables.scss
CHANGED
|
@@ -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
|
-
}
|