1
|
Ext.define('sitools.clientportal.Application', {
|
2
|
name: 'clientportal',
|
3
|
extend: 'Ext.app.Application',
|
4
|
|
5
|
controllers: ['sitools.clientportal.controller.portal.PortalController',
|
6
|
'sitools.user.controller.component.datasets.opensearch.OpensearchController'],
|
7
|
|
8
|
useQuickTips: true,
|
9
|
|
10
|
requires: [
|
11
|
|
12
|
|
13
|
'sitools.public.utils.LoginDef',
|
14
|
'sitools.public.utils.def',
|
15
|
'sitools.public.widget.vtype',
|
16
|
'sitools.public.utils.loadUrl',
|
17
|
'sitools.public.utils.i18n',
|
18
|
'sitools.public.utils.sql2ext',
|
19
|
'sitools.public.utils.console',
|
20
|
'sitools.public.utils.LoginUtils',
|
21
|
'sitools.public.utils.Logout',
|
22
|
'sitools.public.utils.Locale',
|
23
|
'sitools.public.utils.UserStorage',
|
24
|
'sitools.public.utils.PopupMessage',
|
25
|
|
26
|
|
27
|
'sitools.public.widget.StatusBar',
|
28
|
'sitools.public.crypto.Base64',
|
29
|
'sitools.public.version.Version',
|
30
|
|
31
|
],
|
32
|
|
33
|
controllers : ['sitools.clientportal.controller.portal.PortalController'],
|
34
|
|
35
|
init: function () {
|
36
|
|
37
|
if (!Ext.isEmpty(Ext.util.Cookies.get('userLogin'))) {
|
38
|
var auth = Ext.util.Cookies.get('hashCode');
|
39
|
|
40
|
Ext.Ajax.defaultHeaders = {
|
41
|
"Authorization": auth,
|
42
|
"Accept": "application/json",
|
43
|
"X-User-Agent": "Sitools"
|
44
|
};
|
45
|
taskCheckSessionExpired.delay(COOKIE_DURATION * 60 * 1000);
|
46
|
|
47
|
} else {
|
48
|
Ext.Ajax.defaultHeaders = {
|
49
|
"Accept": "application/json",
|
50
|
"X-User-Agent": "Sitools"
|
51
|
};
|
52
|
}
|
53
|
this.initSiteMap();
|
54
|
},
|
55
|
|
56
|
|
57
|
initSiteMap: function () {
|
58
|
loadUrl.load('/sitools/client-user/siteMap', this.initLanguages, this);
|
59
|
},
|
60
|
|
61
|
|
62
|
initLanguages: function () {
|
63
|
locale.initLocale();
|
64
|
locale.load(loadUrl.get('APP_URL') + loadUrl.get('APP_CLIENT_PUBLIC_URL') + '/res/statics/langues.json', this.initi18n, this);
|
65
|
},
|
66
|
|
67
|
|
68
|
initi18n: function () {
|
69
|
i18n.load(
|
70
|
loadUrl.get("APP_URL") + loadUrl.get("APP_CLIENT_PUBLIC_URL") + '/res/i18n/' + locale.getLocale() + '/gui.properties',
|
71
|
function () {
|
72
|
if(!checkCookieDuration()){
|
73
|
Ext.Msg.show({
|
74
|
title: i18n.get('label.warning'),
|
75
|
msg : i18n.get("label.wrongcookieduration.configuration")
|
76
|
});
|
77
|
this.removeMask();
|
78
|
return;
|
79
|
}
|
80
|
this.initSql2ext();
|
81
|
}
|
82
|
, this);
|
83
|
},
|
84
|
|
85
|
|
86
|
initSql2ext: function () {
|
87
|
sql2ext.load(loadUrl.get('APP_URL') + loadUrl.get('APP_CLIENT_PUBLIC_URL') + '/conf/sql2ext.properties', this.initUser, this);
|
88
|
},
|
89
|
|
90
|
|
91
|
initUser: function () {
|
92
|
var storeUser = Ext.create('sitools.user.store.UserStore', {
|
93
|
storeId: 'UserStore'
|
94
|
});
|
95
|
|
96
|
storeUser.setCustomUrl(loadUrl.get('APP_URL') + loadUrl.get('APP_USER_ROLE_URL'));
|
97
|
|
98
|
storeUser.load({
|
99
|
scope: this,
|
100
|
callback: function (records, operation, success) {
|
101
|
if (Ext.isEmpty(records)) {
|
102
|
storeUser.add({
|
103
|
firstName: "public",
|
104
|
identifier: "public",
|
105
|
email: " "
|
106
|
});
|
107
|
}
|
108
|
this.initProjects();
|
109
|
}
|
110
|
});
|
111
|
},
|
112
|
|
113
|
|
114
|
initProjects : function () {
|
115
|
Ext.Ajax.request({
|
116
|
method : 'GET',
|
117
|
url : loadUrl.get('APP_URL') + loadUrl.get('APP_PORTAL_URL') + '/projects?media=json',
|
118
|
scope : this,
|
119
|
success : function (response) {
|
120
|
try {
|
121
|
this.projects = Ext.decode(response.responseText).data;
|
122
|
} catch (err) {
|
123
|
Ext.Msg.alert(i18n.get('label.error'), err);
|
124
|
}
|
125
|
},
|
126
|
callback : function () {
|
127
|
this.loadPortalView();
|
128
|
},
|
129
|
failure : function (response) {
|
130
|
Ext.Msg.alert('Status', i18n.get('warning.serverError'));
|
131
|
}
|
132
|
});
|
133
|
},
|
134
|
|
135
|
|
136
|
loadPortalView : function () {
|
137
|
Ext.create('sitools.clientportal.view.portal.PortalView', {
|
138
|
projects : this.projects,
|
139
|
languages : locale.languages
|
140
|
});
|
141
|
}
|
142
|
});
|