-
Notifications
You must be signed in to change notification settings - Fork 0
/
Component.js
95 lines (81 loc) · 3.01 KB
/
Component.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
jQuery.sap.declare("ch.saphirnet.Component");
jQuery.sap.require("ch.saphirnet.MyRouter");
sap.ui.core.UIComponent.extend("ch.saphirnet.Component", {
metadata : {
name : "Domorcier Cockpit",
version : "1.0",
includes : [],
dependencies : {
libs : ["sap.m", "sap.ui.layout"],
components : []
},
rootView : "ch.saphirnet.view.v_main",
config : {
resourceBundle : "i18n/messageBundle.properties",
serviceConfig : {
name : "IoTHana",
serviceUrl : "https://s7hanaxs.hanatrial.ondemand.com/p175998trial/jbetrialhana/iot/dbaccess/iotservice.xsodata/"
}
},
routing: {
config : {
routerClass : ch.saphirnet.MyRouter,
viewType : "XML",
viewPath : "ch.saphirnet.view",
targetControl: "idAppControl",
targetAggregation : "pages",
clearTarget : false
},
routes : [
{
pattern : "",
name : "main",
view : "v_dashboard",
targetControl : "idAppControl"/*,
subroutes : [
{
pattern : "{deviceID}/:tab:",
name : "temperature",
view : "v_TemperatureGraph"
}
]*/
},
{
pattern : "temp",
name : "temperature",
//viewPath: "ch.saphirnet.view",
view : "v_TemperatureGraph",
targetControl: "idAppControl"
}
]
}
},
init : function() {
sap.ui.core.UIComponent.prototype.init.apply(this, arguments);
var mConfig = this.getMetadata().getConfig();
// always use absolute paths relative to our own component
// (relative paths will fail if running in the Fiori Launchpad)
var rootPath = jQuery.sap.getModulePath("ch.saphirnet");
// set i18n model
var i18nModel = new sap.ui.model.resource.ResourceModel({
bundleUrl : [rootPath, mConfig.resourceBundle].join("/")
});
this.setModel(i18nModel, "i18n");
// Create and set domain model to the component
var sServiceUrl = mConfig.serviceConfig.serviceUrl;
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);
this.setModel(oModel);
// set device model
var deviceModel = new sap.ui.model.json.JSONModel({
isTouch : sap.ui.Device.support.touch,
isNoTouch : !sap.ui.Device.support.touch,
isPhone : sap.ui.Device.system.phone,
isNoPhone : !sap.ui.Device.system.phone,
listMode : sap.ui.Device.system.phone ? "None" : "SingleSelectMaster",
listItemType : sap.ui.Device.system.phone ? "Active" : "Inactive"
});
deviceModel.setDefaultBindingMode("OneWay");
this.setModel(deviceModel, "device");
this.getRouter().initialize();
}
});