Commit e5d044b8 authored by Adrien PARROT's avatar Adrien PARROT
Browse files

modif userPage with m_ prefix for oData

parent 1816cd9d
......@@ -135,9 +135,12 @@ sap.ui.controller("conceptmapper.searchPage", {
goToConceptDetail : function (oEvt) {
var URL_concept = "http://127.0.0.1:5000/concept/";
//var URL_concept = "http://127.0.0.1:5000/concept/";
var URL_concept = "http://omop-mapper.fgh.ovh/concept/";
var sVal = oEvt.getParameters().rowBindingContext.getProperty('concept_id');
debugger;
if (sVal !== undefined) {
$.ajax({
type:"GET",
......@@ -237,7 +240,9 @@ sap.ui.controller("conceptmapper.searchPage", {
&& oData.concept_code && oData.concept_class_id && oData.vocabulary_id
&& oData.domain_id && oData.invalid_reason && oData.standard_concept ) {
//var URL_concept = "http://127.0.0.1:5000/concept/";
var URL_concept = "http://omop-mapper.fgh.ovh/concept/";
//
// var oModel = sap.ui.getCore().getModel('concept');
// var aData = oModel.getProperty("/names");
......@@ -246,7 +251,7 @@ sap.ui.controller("conceptmapper.searchPage", {
$.ajax({
type:"POST",
url:"http://127.0.0.1:5000/concept/" + oData.concept_id,
url: URL_concept + oData.concept_id,
dataType:"json",
data: oData,
async: false,
......@@ -527,7 +532,10 @@ sap.ui.controller("conceptmapper.searchPage", {
},
searcher : function (oEvt) {
var URL_concepts = "http://127.0.0.1:5000/concepts";
//var URL_concepts = "http://127.0.0.1:5000/concepts";
var URL_concepts = "http://omop-mapper.fgh.ovh/concepts";
var oStandardMCB_ref = sap.ui.getCore().byId('oStandardMCB').getSelectedItems();
var oStandardMCB_list = [];
......
......@@ -69,8 +69,8 @@ sap.ui.jsview("conceptmapper.searchPage", {
label : new sap.ui.commons.Label({
text : "{i18n>concept_name}"
}),
template : new sap.m.Text({
text : "{concept>concept_name}"
template : sap.m.FormattedText({
htmlText : "{concept>concept_name}"
}),
editable : false,
sortProperty : "concept_id"
......@@ -140,7 +140,7 @@ sap.ui.jsview("conceptmapper.searchPage", {
}));
oTable.bindRows({
path : "concept>/names"
path : "concept>/docs"
});
var icoToolbar = new sap.m.IconTabBar({
......
var oItemTemplateAdmin = new sap.ui.core.Item({
key : "{adminModel>key}",
text : "{adminModel>text}",
enabled : "{adminModel>enabled}"
});
function getUsers() {
//var URL_users = "http://omop-mapper.fgh.ovh/users"
var URL_users = "http://127.0.0.1:5000/users";
......@@ -18,7 +12,7 @@ function getUsers() {
},
success: function(oData, response, xhr) {
var oModel = new sap.ui.model.json.JSONModel(oData);
sap.ui.getCore().setModel(oModel, "users");
sap.ui.getCore().setModel(oModel, "usersModel");
console.log("connection");
},
error : function(error) {
......@@ -43,7 +37,7 @@ function getUser(username) {
},
success: function(oData, response, xhr) {
var oModel = new sap.ui.model.json.JSONModel(oData);
sap.ui.getCore().setModel(oModel, "user");
sap.ui.getCore().setModel(oModel, "userModel");
console.log("connection");
},
error : function(error) {
......@@ -54,48 +48,23 @@ function getUser(username) {
})
}
var oItemTemplateAdmin = new sap.ui.core.Item({
key : "{isAdminModel>key}",
text : "{isAdminModel>text}",
enabled : "{isAdminModel>enabled}"
});
sap.ui.controller("conceptmapper.userPage", {
/**
* Called when a controller is instantiated and its View controls (if
* available) are already created. Can be used to modify the View before it
* is displayed, to bind event handlers and do other one-time
* initialization.
*
* @memberOf conceptmapper.userPage
*/
onInit : function() {
var oModel = new sap.ui.model.json.JSONModel();
var mData = {
"selected" : [],
"items" : [{
"key" : "Not Admin",
"text" : "Not Admin"
},
{
"key" : "Admin",
"text" : "Admin"
}]
};
oModel.setData(mData);
sap.ui.getCore().setModel(oModel, "adminModel");
},
sap.ui.controller("conceptmapper.userPage", {
/******* CREATE *******/
openCreateDialog : function (oEvt) {
// var URL_user = "http://omop-mapper.fgh.ovh/user/";
//var URL_user = "http://omop-mapper.fgh.ovh/user/";
var URL_user = "http://127.0.0.1:5000/user/";
......@@ -122,12 +91,12 @@ sap.ui.controller("conceptmapper.userPage", {
// width : "400px",
//placeholder : "Standard Concepts",
items : {
path : "adminModel>/items",
path : "isAdminModel>/items",
template : oItemTemplateAdmin
},
selectedKeys : {
path : "adminModel>/selected",
template : "{adminModel>selected}"
path : "isAdminModel>/selected",
template : "{isAdminModel>selected}"
},
}),new sap.m.Label({
text : "{i18n>password}"
......@@ -165,17 +134,18 @@ sap.ui.controller("conceptmapper.userPage", {
var content = oSimpleForm.getContent();
var oData = {};
oData.username = content[2].getValue();
oData.is_admin = content[4].getValue();
oData.password = content[6].getValue();
oData.firstname = content[8].getValue();
oData.lastname = content[10].getValue();
oData.address = content[12].getValue();
oData.email = content[14].getValue();
oData.m_username = content[2].getValue();
oData.m_is_admin = content[4].getValue();
oData.m_password = content[6].getValue();
oData.m_firstname = content[8].getValue();
oData.m_lastname = content[10].getValue();
oData.m_address = content[12].getValue();
oData.m_email = content[14].getValue();
if (oData.username !== "" && oData.password !== ""
&& oData.firstname && oData.lastname && oData.address && oData.email){
if (oData.m_username !== "" && oData.m_password !== "" && oData.m_password !== ""
&& oData.m_firstname !== "" && oData.m_lastname !== ""
&& oData.m_address !== "" && oData.m_email !== ""){
$.ajax({
......@@ -189,7 +159,7 @@ sap.ui.controller("conceptmapper.userPage", {
},
success: function(data, response, xhr) {
// front update
var oModel = sap.ui.getCore().getModel('users');
var oModel = sap.ui.getCore().getModel('usersModel');
var aData = oModel.getProperty("/names");
aData.push(oData);
oModel.setProperty("/names", aData);
......@@ -229,7 +199,7 @@ sap.ui.controller("conceptmapper.userPage", {
/******* UPDATE *******/
openUpdateDialog : function(oEvt) {
// var URL_user = "http://omop-mapper.fgh.ovh/user/";
var URL_user = "http://omop-mapper.fgh.ovh/user/";
var URL_user = "http://127.0.0.1:5000/user/";
......@@ -261,37 +231,37 @@ sap.ui.controller("conceptmapper.userPage", {
text : "{i18n>username}"
}), new sap.ui.commons.TextField({
enabled: false,
value : "{user>/username}"
value : "{userModel>/m_username}"
}), new sap.m.Label({
text : "{i18n>is_admin}"
}), new sap.m.ComboBox({
// width : "400px",
//placeholder : "Standard Concepts",
items : {
path : "adminModel>/items",
path : "isAdminModel>/items",
template : oItemTemplateAdmin
},
selectedKey : "{user>/is_admin}"
selectedKey : "{userModel>/m_is_admin}"
}), new sap.m.Label({
text : "{i18n>password}"
}), new sap.ui.commons.TextField({
value : "{user>/password}"
value : "{userModel>/m_password}"
}), new sap.m.Label({
text : "{i18n>firstname}"
}), new sap.ui.commons.TextField({
value : "{user>/firstname}"
value : "{userModel>/m_firstname}"
}), new sap.m.Label({
text : "{i18n>lastname}"
}), new sap.ui.commons.TextField({
value : "{user>/lastname}"
value : "{userModel>/m_lastname}"
}), new sap.m.Label({
text : "{i18n>address}"
}), new sap.ui.commons.TextField({
value : "{user>/address}"
value : "{userModel>/m_address}"
}), new sap.m.Label({
text : "{i18n>email}"
}), new sap.ui.commons.TextField({
value : "{user>/email}"
value : "{userModel>/m_email}"
}),
]
});
......@@ -307,41 +277,47 @@ sap.ui.controller("conceptmapper.userPage", {
var content = oSimpleForm.getContent();
var oData = {};
oData.username = content[2].getValue();
oData.is_admin = content[4].getValue();
oData.password = content[6].getValue();
oData.firstname = content[8].getValue();
oData.lastname = content[10].getValue();
oData.address = content[12].getValue();
oData.email = content[14].getValue();
oData.m_username = content[2].getValue();
oData.m_is_admin = content[4].getValue();
oData.m_password = content[6].getValue();
oData.m_firstname = content[8].getValue();
oData.m_lastname = content[10].getValue();
oData.m_address = content[12].getValue();
oData.m_email = content[14].getValue();
$.ajax({
type:"PUT",
url:URL_user + content[2].getValue(),
dataType:"json",
data: oData,
async: false,
header: {
"Content-Type": "application/json",
},
success: function(data, response, xhr) {
// front update
var oModel = sap.ui.getCore().getModel('users');
var aData = oModel.getProperty("/names");
aData.splice(idx[0], 1, oData);
oModel.setProperty("/names", aData);
// backend creation
sap.m.MessageToast.show("New user : '" + oData.username + "' updated");
console.log("connection");
},
error : function(error) {
sap.m.MessageToast.show("Connexion error");
console.log(error);
}
});
if (oData.m_username !== "" && oData.m_password !== "" && oData.m_password !== ""
&& oData.m_firstname !== "" && oData.m_lastname !== ""
&& oData.m_address !== "" && oData.m_email !== ""){
$.ajax({
type:"PUT",
url:URL_user + content[2].getValue(),
dataType:"json",
data: oData,
async: false,
header: {
"Content-Type": "application/json",
},
success: function(data, response, xhr) {
// front update
var oModel = sap.ui.getCore().getModel('usersModel');
var aData = oModel.getProperty("/names");
aData.splice(idx[0], 1, oData);
oModel.setProperty("/names", aData);
// backend creation
sap.m.MessageToast.show("New user : '" + oData.username + "' updated");
console.log("connection");
},
error : function(error) {
sap.m.MessageToast.show("Connexion error");
console.log(error);
}
});
} else {
sap.m.MessageToast.show("Nothing created!! \nYou have to file all the fields");
}
......@@ -368,8 +344,8 @@ sap.ui.controller("conceptmapper.userPage", {
/******* DELETE *******/
openDeleteDialog : function (oEvt) {
// var URL_user = "http://omop-mapper.fgh.ovh/user/";
var URL_user = "http://127.0.0.1:5000/user/";
var URL_user = "http://omop-mapper.fgh.ovh/user/";
// var URL_user = "http://127.0.0.1:5000/user/";
var button_press = oEvt.getParameters().id;
......@@ -414,7 +390,7 @@ sap.ui.controller("conceptmapper.userPage", {
},
success: function(data, response, xhr) {
// front update
var oModel = sap.ui.getCore().getModel('users');
var oModel = sap.ui.getCore().getModel('usersModel');
var aData = oModel.getProperty("/names");
aData.splice(idx[0], 1);
oModel.setProperty("/names", aData);
......@@ -452,6 +428,18 @@ sap.ui.controller("conceptmapper.userPage", {
/**
* Called when a controller is instantiated and its View controls (if
* available) are already created. Can be used to modify the View before it
* is displayed, to bind event handlers and do other one-time
* initialization.
*
* @memberOf conceptmapper.userPage
*/
onInit : function() {
},
/**
* Similar to onAfterRendering, but this hook is invoked before the controller's
* View is re-rendered (NOT before the first rendering! onInit() is used for
......@@ -460,49 +448,26 @@ sap.ui.controller("conceptmapper.userPage", {
* @memberOf conceptmapper.userPage
*/
onBeforeRendering: function() {
//var URL_users = "http://omop-mapper.fgh.ovh/users"
var URL_users = "http://127.0.0.1:5000/users";
// initialisation model for admin template = model "isAdminModel"
var oModel = new sap.ui.model.json.JSONModel();
var mData = {
"selected" : [],
"items" : [{
"key" : "Not Admin",
"text" : "Not Admin"
},
{
"key" : "Admin",
"text" : "Admin"
}]
};
oModel.setData(mData);
sap.ui.getCore().setModel(oModel, "isAdminModel");
// users initialisation = model "usersModel"
getUsers();
$.ajax({
method:"GET",
url: URL_users,
dataType:"json",
async: false,
header: {
"Content-Type": "application/json",
},
success: function(oData, response, xhr) {
var oModel = new sap.ui.model.json.JSONModel(oData);
sap.ui.getCore().setModel(oModel, "users");
console.log("connection");
},
error : function(error) {
alert("pb in the connection");
console.log(error);
}
});
// var oData1 = {
// "names" : [ {
// username : "aparrot",
// password : "toto",
// firstname : "adrien",
// lastname : "parrot",
// address : "142",
// email : "adrien.parrot@caramail.fr",
// } , {
// username : "mpondi",
// password : "toto",
// firstname : "marcy",
// lastname : "pondi",
// address : "142",
// email : "marcy.pondi@caramail.fr",
// } ]
// };
// var oModel = new sap.ui.model.json.JSONModel(oData1);
// sap.ui.getCore().setModel(oModel, "user");
},
/**
* Called when the View has been rendered (so its HTML is part of the document).
......
......@@ -52,7 +52,7 @@ sap.ui.jsview("conceptmapper.userPage", {
text : "{i18n>username}"
}),
template : new sap.m.Text({
text : "{users>username}"
text : "{usersModel>m_username}"
}),
editable : false,
sortProperty : "Username"
......@@ -63,7 +63,7 @@ sap.ui.jsview("conceptmapper.userPage", {
text : "{i18n>is_admin}"
}),
template : new sap.m.Text({
text : "{users>is_admin}"
text : "{usersModel>m_is_admin}"
}),
editable : false,
}));
......@@ -73,7 +73,7 @@ sap.ui.jsview("conceptmapper.userPage", {
text : "{i18n>firstname}"
}),
template : new sap.m.Text({
text : "{users>firstname}"
text : "{usersModel>m_firstname}"
}),
sortProperty : "Firstname",
editable : false,
......@@ -84,7 +84,7 @@ sap.ui.jsview("conceptmapper.userPage", {
text : "{i18n>lastname}"
}),
template : new sap.m.Text({
text : "{users>lastname}"
text : "{usersModel>m_lastname}"
}),
sortProperty : "Lastname",
editable : false,
......@@ -95,7 +95,7 @@ sap.ui.jsview("conceptmapper.userPage", {
text : "{i18n>address}"
}),
template : new sap.m.Text({
text : "{users>address}"
text : "{usersModel>m_address}"
}),
sortProperty : "Address",
editable : false,
......@@ -106,7 +106,7 @@ sap.ui.jsview("conceptmapper.userPage", {
text : "{i18n>email}"
}),
template : new sap.m.Text({
text : "{users>email}"
text : "{usersModel>m_email}"
}),
sortProperty : "Email",
editable : false,
......@@ -114,7 +114,7 @@ sap.ui.jsview("conceptmapper.userPage", {
}));
oTable.bindRows({
path : "users>/names"
path : "usersModel>/names"
});
var oPage = new sap.m.Page({
......
......@@ -17,7 +17,7 @@
// create an app
var app = new sap.m.App({
initialPage : "idHomePage"
initialPage : "idSearchPage"
});
// Adding all the pages to the app
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment