All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ui5.controller.Consumer.controller Maven / Gradle / Ivy

showFooter : function() {
	return true;
},
init : function() {
	var oModel = new JSONModel();
	var that = this;
	oModel.attachRequestFailed(function(oEvent) {
			that.displayError(JSON.parse(oEvent.getParameter("responseText")));
	});
	var sConnectionname = jQuery.sap.getUriParameters().get("connectionname");
	if (!!sConnectionname) {
		var sConsumername = jQuery.sap.getUriParameters().get("consumername");
		if (!sConsumername) {
			oModel.loadData("../rest/connections/" + encodeURI(sConnectionname) + "/consumer/template");
			oStateModel.setProperty("/title", "New Consumer");
			oStateModel.setProperty("/new", true);
		} else {
			oModel.loadData("../rest/connections/" + encodeURI(sConnectionname) + "/consumers/" + sConsumername);
			oStateModel.setProperty("/title", "Consumer settings");
			oStateModel.setProperty("/new", false);
		}
		this.getView().setModel(oModel);
		oStateModel.setProperty("/breadcrumbs", [ 
			{"text" : "Homepage", "link" : "./Home"}, 
			{"text" : "Connections", "link" : "./Connections"},
			{"text" : "Consumers", "link" : "./Consumers?connectionname=" + encodeURI(sConnectionname) }
		] );
		
		var oModelSchemas = new JSONModel();
		oModelSchemas.attachRequestFailed(function(oEvent) {
				that.displayError(JSON.parse(oEvent.getParameter("responseText")));
		});
		oModelSchemas.loadData("../rest/connections/" + encodeURI(sConnectionname) + "/remoteschemas");
		this.getView().setModel(oModelSchemas, "schemas");

		var oModelTopics = new JSONModel();
		oModelTopics.attachRequestFailed(function(oEvent) {
				that.displayError(JSON.parse(oEvent.getParameter("responseText")));
		});
		oModelTopics.loadData("../rest/topics");
		this.getView().setModel(oModelTopics, "topics");
	}
},
save : function(oEvent) {
	var oModel = this.getView().getModel();
	var data = JSON.stringify(oModel.getJSON());
	var sConnectionname = jQuery.sap.getUriParameters().get("connectionname");
	var sConsumername = oModel.getProperty("/name");
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("POST", "../rest/connections/" + encodeURI(sConnectionname) + "/consumers/" + encodeURI(sConsumername));
	xmlhttp.setRequestHeader("Content-Type", "application/json");
	var that = this;
	xmlhttp.onreadystatechange = function() {
	    if (xmlhttp.readyState == 4) {
	    	if (xmlhttp.status == 200) {
		        that.displaySuccess(JSON.parse(xmlhttp.responseText));
		    } else {
		        that.displayError(JSON.parse(xmlhttp.responseText));
		    }
		}
	}
	xmlhttp.send(oModel.getJSON());
},
cancel : function(oEvent) {
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy