Skip to content

Commit 978a921

Browse files
committed
* 'master' of https://github.com/frontiere21/chat21-web-widget: relative /api/ redirect /api to proxy changelog aggiunto il parametro 'departmentID' bug fix translations # Conflicts: # package-lock.json # package.json # src/app/components/list-all-conversations/list-all-conversations.component.html # src/app/utils/globals.ts
2 parents 71cccc8 + 405209f commit 978a921

File tree

5 files changed

+65
-10
lines changed

5 files changed

+65
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# chat21-web-widget ver 3.0
22

3+
### 3.0.26
4+
- new: added parameter 'departmentID'
5+
6+
### 3.0.25
7+
- bug fix: translate
8+
39
### 3.0.24
410
- bug fix: setupMyPresence on logout/login
511
- bug fix: css border 0 on iframe

nginx-redirect.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ http {
2424
location /firebase-config.json {
2525
proxy_pass http://proxy/api/chat21/config;
2626
}
27+
location /api/ {
28+
proxy_pass http://proxy/api/;
29+
}
2730
}
2831
}

src/app/app.component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,14 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
567567
this.g.setParameter('isOpenPrechatForm', true);
568568
this.isOpenConversation = false;
569569
this.isOpenSelectionDepartment = false;
570-
if (departments.length > 1) {
570+
if (departments.length > 1 && this.g.departmentID == null) {
571571
this.isOpenSelectionDepartment = true;
572572
}
573573
} else {
574574
this.g.setParameter('isOpenPrechatForm', false);
575575
this.isOpenConversation = false;
576576
this.isOpenSelectionDepartment = false;
577-
if (departments.length > 1) {
577+
if (departments.length > 1 && !this.g.departmentID == null) {
578578
this.isOpenSelectionDepartment = true;
579579
} else {
580580
this.isOpenConversation = true;
@@ -1077,7 +1077,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
10771077
this.g.setParameter('isOpenPrechatForm', true);
10781078
// this.settingsSaverService.setVariable('isOpenPrechatForm', true);
10791079
this.isOpenSelectionDepartment = false;
1080-
if (departments && departments.length > 1) {
1080+
if (departments && departments.length > 1 && this.g.departmentID == null) {
10811081
this.isOpenSelectionDepartment = true;
10821082
}
10831083
} else {
@@ -1086,12 +1086,13 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
10861086
// this.settingsSaverService.setVariable('isOpenPrechatForm', false);
10871087
this.isOpenConversation = false;
10881088
this.isOpenSelectionDepartment = false;
1089-
if (departments && departments.length > 1) {
1089+
if (departments && departments.length > 1 && this.g.departmentID == null) {
10901090
this.isOpenSelectionDepartment = true;
10911091
} else {
10921092
this.isOpenConversation = true;
10931093
}
10941094
}
1095+
console.log('this.g.departmentID' + this.g.departmentID + ' isOpenSelectionDepartment:' + this.isOpenSelectionDepartment);
10951096
this.startNwConversation();
10961097
}
10971098

src/app/providers/global-settings.service.ts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { StorageService } from './storage.service';
1111
import { AppConfigService } from './app-config.service';
1212
import { __core_private_testing_placeholder__ } from '@angular/core/testing';
1313

14+
1415
@Injectable()
1516
export class GlobalSettingsService {
1617
globals: Globals;
@@ -171,6 +172,12 @@ export class GlobalSettingsService {
171172
} catch (error) {
172173
this.globals.wdLog(['> Error :' + error]);
173174
}
175+
try {
176+
const departmentID = tiledeskSettings['departmentID'];
177+
if (typeof departmentID !== 'undefined') { this.globals.departmentID = departmentID; }
178+
} catch (error) {
179+
// this.globals.wdLog(['> Error is handled: ', error);
180+
}
174181

175182
// -------------------------------------- //
176183
// const windowContext = globals.windowContext;
@@ -275,7 +282,7 @@ export class GlobalSettingsService {
275282
this.setVariablesFromAttributeHtml(this.globals, this.el);
276283
this.setVariablesFromUrlParameters(this.globals);
277284
this.setVariableFromStorage(this.globals);
278-
285+
this.setDepartmentFromExternal();
279286
/** set color with gradient from theme's colors */
280287
this.globals.setColorWithGradient();
281288
/** set css iframe from parameters */
@@ -767,6 +774,10 @@ export class GlobalSettingsService {
767774
if (TEMP !== null) {
768775
this.globals.hideAttachButton = (TEMP === true) ? true : false;
769776
}
777+
TEMP = el.nativeElement.getAttribute('departmentID');
778+
if (TEMP !== null) {
779+
this.globals.departmentID = TEMP;
780+
}
770781

771782
}
772783

@@ -979,6 +990,11 @@ export class GlobalSettingsService {
979990
globals.hideAttachButton = stringToBoolean(TEMP);
980991
}
981992

993+
TEMP = getParameterByName(windowContext, 'tiledesk_departmentID');
994+
if (TEMP) {
995+
globals.departmentID = TEMP;
996+
}
997+
982998
}
983999

9841000
/**
@@ -1065,7 +1081,34 @@ export class GlobalSettingsService {
10651081
} else {
10661082
// DEPARTMENT DEFAULT NON RESTITUISCE RISULTATI !!!!
10671083
this.globals.wdLog(['DEPARTMENT DEFAULT NON RESTITUISCE RISULTATI ::::']);
1068-
return;
1084+
// return;
1085+
}
1086+
1087+
this.setDepartmentFromExternal(); // chiamata ridondante viene fatta nel setParameters come ultima operazione
1088+
}
1089+
1090+
1091+
setDepartmentFromExternal() {
1092+
// se esiste un departmentID impostato dall'esterno,
1093+
// creo un department di default e lo imposto come department di default
1094+
this.globals.wdLog(['EXTERNAL departmentID ::::' + this.globals.departmentID]);
1095+
let isValidID = false;
1096+
if (this.globals.departmentID) {
1097+
this.globals.departments.forEach(department => {
1098+
if (department._id === this.globals.departmentID) {
1099+
this.globals.wdLog(['EXTERNAL DEPARTMENT ::::' + department._id]);
1100+
this.globals.setParameter('departmentDefault', department);
1101+
this.setDepartment(department);
1102+
isValidID = true;
1103+
return;
1104+
}
1105+
});
1106+
if (isValidID === false) {
1107+
// se l'id passato non corrisponde a nessun id dipartimento esistente viene annullato
1108+
// per permettere di passare dalla modale dell scelta del dipartimento se necessario (+ di 1 dipartimento presente)
1109+
this.globals.departmentID = null;
1110+
}
1111+
this.globals.wdLog(['END departmentID ::::' + this.globals.departmentID + isValidID]);
10691112
}
10701113
}
10711114

src/testi.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
// Handler for .ready() called.
1515
window.tiledeskSettings =
1616
{
17-
projectid: "5b55e806c93dde00143163dd",//'5d022a9b8fb8450017c67a37', //
17+
projectid: "5d9dae4c8d26040017fa5d91",//'5d022a9b8fb8450017c67a37', //
1818
persistence:"local", /** local/session/none **/
19-
userEmail: "czone555@gmail.com",
20-
userPassword:"123456",
19+
// userEmail: "czone555@gmail.com",
20+
// userPassword:"123456",
2121
// userToken: 'eyJhbGciOiJSUzI1NiIsImtpZCI6Ijk4MGVkMGQ3ODY2ODk1Y2E0M2MyMGRhZmM4NTlmMThjNjcwMWU3OTYiLCJ0eXAiOiJKV1QifQ.eyJwcm92aWRlcl9pZCI6ImFub255bW91cyIsImlzcyI6Imh0dHBzOi8vc2VjdXJldG9rZW4uZ29vZ2xlLmNvbS9jaGF0LXYyLWRldiIsImF1ZCI6ImNoYXQtdjItZGV2IiwiYXV0aF90aW1lIjoxNTYxMDIwNTg2LCJ1c2VyX2lkIjoicllXQmgwd2c2TE05U1drT2lMY0tySmdWVldkMiIsInN1YiI6InJZV0JoMHdnNkxNOVNXa09pTGNLckpnVlZXZDIiLCJpYXQiOjE1NjEwMjA1ODYsImV4cCI6MTU2MTAyNDE4NiwiZmlyZWJhc2UiOnsiaWRlbnRpdGllcyI6e30sInNpZ25faW5fcHJvdmlkZXIiOiJhbm9ueW1vdXMifX0.SID7kHLV0v5t0fd18WtlX_HfZ2nU2Qg6GU3HB2nNx9J7yaQQdZv1zkvXMmtJGIMCXw1Z_HMVDkbjqPOGOS-Wz8AF_Vdrxj2ePX6K6amE_DfZz2ECG-VrOghOPjggYwMCykmJu6k2IOHc3Z1jq9rTqCanHqmElUXTwDwUIub4OQ_fn6Ak1krotdNNUbdoFFDiPKt_39UC92Z3jbUf-2FQgxOWSJg7h8pjShe6anEFtdmjX50hl0dtbKhMNNacWtczAtRBrr1u7QCL0D8K-dzzxuduQUEMlnGPzYyQtaYfAxjWRQ8PP1BUBPeTNLiYtj4oprcCUS61qr3lBdw6tumtMw',
2222
// userId: "5b55e806c93dde00143163df",
2323
isLogEnabled: true, /** true/false **/
@@ -61,7 +61,9 @@
6161
// showWidgetNameInConversation: true,
6262

6363
customAttributes: '{"url_proxy": "https://bariapp.herokuapp.com/proxy", "agent": "supporto-anagrafe-vcqvkb", "recipient": "bari_bot", "recipient_fullname": "Hal 9000", "button_label": "Chiedi a Ernesto", "immagine_benvenuto": "https://user-images.githubusercontent.com/9556761/64190907-aec3ac00-ce77-11e9-8ce7-8935e43d15cb.png", "messaggio_benvenuto": "Ciao, mi chiamo Ernesto e sono il tuo assistente virtuale sul sito della Città Metropolitana di Bari. Per richiedere il mio aiuto premi il pulsante \'Chiedi a Ernesto\'"}',
64-
hideAttachButton: false // nasconde il pulsante allegati
64+
hideAttachButton: false, // nasconde il pulsante allegati
65+
66+
departmentID: '5d9db0698d26040017fa5d9d' /** l'id di un dipartimento esistente **/
6567

6668
};
6769

0 commit comments

Comments
 (0)