-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHelpService.js
49 lines (44 loc) · 1.14 KB
/
HelpService.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import Service from '../abc/Service';
import {HELP_CONTENT} from "../actions";
export default class HelpService extends Service {
constructor(app, serviceName="HeaderService"){
super(app, serviceName);
this.App = app;
this.HelpCache = {};
}
async setData(path) {
if (this.HelpCache[path] != undefined) {
if (this.HelpCache[path] != "") {
this.App.Store.dispatch({
type: HELP_CONTENT,
content: this.HelpCache[path]
});
return;
}
this.App.Store.dispatch({
type: HELP_CONTENT,
content: ""
});
return;
}
try {
const ASABLibraryAPI = this.App.axiosCreate('asab_library');
let response = await ASABLibraryAPI.get(`/library/item/Help/${path}`);
if ((response.status == 200) && response.data) {
this.App.Store.dispatch({
type: HELP_CONTENT,
content: response.data.content
});
this.HelpCache[path] = response.data.content;
}
} catch (e) {
console.warn(`Help service can't retrieve data for ${path}`, e);
// Remove data from the TenantDataCache eventually
this.App.Store.dispatch({
type: HELP_CONTENT,
content: ""
});
this.HelpCache[path] = "";
}
}
}