<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:micro="sap.suite.ui.microchart"
controllerName="cl.paguilas.flp_tile_demo.controller.App" displayBlock="true">
<GenericTile header="Argentina" subheader="Buenos Aires">
<tileContent>
<TileContent>
<content>
<micro:HarveyBallMicroChart showTotal="false" total="12" size="Responsive" totalScale="Hr">
<micro:items>
<micro:HarveyBallMicroChartItem fractionLabel="{/desc}" fraction="{/hora}" color="Good" fractionScale="Hr"/>
</micro:items>
</micro:HarveyBallMicroChart>
</content>
</TileContent>
</tileContent>
</GenericTile>
</mvc:View>
TimerTile: function () {
var self = this;
var sRefresh = 5; //Segundos cada cuanto se actualizará
this.intervalHandle = setInterval(function () {
self.getInfoTile();
}, sRefresh * 1000);
},
getInfoTile: function () {
var that = this;
$.ajax({
type: "GET",
url: "https://worldtimeapi.org/api/timezone/America/Argentina/Buenos_Aires",
success: function (data) {
var d = data.datetime.split("T")[1].split(".")[0];
var a = d.split(":");
var info = {};
if (Number(a[0]) > 12) {
info.hora = a[0] -= 12;
info.desc = d;
} else {
info.hora = a[0];
info.desc = d;
}
that._oTileModel.setData(info);
},
error: function (error) {
console.log("Tile: ", error);
}
});
},
onInit: function () {
this._oTileModel = new sap.ui.model.json.JSONModel([]);
this.getView().setModel(this._oTileModel);
this.TimerTile();
},
TimerTile: function () {
var self = this;
var sRefresh = 5; //Segundos cada cuanto se actualizará
try {
//Código que busca propiedades del Tile
sRefresh = Number.isInteger(Number(self.getOwnerComponent().getComponentData().properties.refresh)) ? self.getOwnerComponent()
.getComponentData().properties.refresh : 5;
} catch (error) {
console.log("TimerTile: ", error);
}
this.intervalHandle = setInterval(function () {
self.getInfoTile();
}, sRefresh * 1000);
},
onInit: function () {
this._oTileModel = new sap.ui.model.json.JSONModel([]);
this.getView().setModel(this._oTileModel);
this.TimerTile();
//Obtenemos las "Custom Propperties"
var h = this.getOwnerComponent().getComponentData().properties.header;
var sh = this.getOwnerComponent().getComponentData().properties.subheader;
var sHeader = h ? h : "No Ingresado",
sSubheader = sh ? sh : "No Ingresado";
//Aplicamos al GenericTile las propiedades
var oGTile = this.getView().getContent()[0];
oGTile.setHeader(sHeader);
oGTile.setSubheader(sSubheader);
}
getInfoTile: function () {
var that = this;
//Obtenemos las "Custom Propperties"
var h = this.getOwnerComponent().getComponentData().properties.header;
var sh = this.getOwnerComponent().getComponentData().properties.subheader;
var info = {};
$.ajax({
type: "GET",
url: "https://worldtimeapi.org/api/timezone/America/" + h + "/" + sh.split(" ").join("_"), //El split y join es por que el servicio necesita un _
success: function (data) {
var d = data.datetime.split("T")[1].split(".")[0];
var a = d.split(":");
if (Number(a[0]) > 12) {
info.hora = a[0] -= 12;
info.desc = d;
} else {
info.hora = a[0];
info.desc = d;
}
that._oTileModel.setData(info);
},
error: function (error) {
console.log("Tile: ", error);
info.hora = 0;
info.desc = "ERR";
that._oTileModel.setData(info);
}
});
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
9 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |