Commit e531973c authored by Aïssa Benhamida's avatar Aïssa Benhamida

project

parent b5a782c5
Pipeline #29951 failed with stages
in 44 seconds
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<ScalaCodeStyleSettings>
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
</ScalaCodeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_14" project-jdk-name="14" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/oneManyRelation.iml" filepath="$PROJECT_DIR$/.idea/oneManyRelation.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
import Adapter from '@ember-data/adapter';
import GraphQLAdapter from 'ember-graphql-adapter';
import ENV from 'one-many-relation/config/environment';
export default class ApplicationAdapter extends GraphQLAdapter {
//endpoint = 'https://cors-anywhere.herokuapp.com/https://nuiq3isr44.execute-api.eu-west-1.amazonaws.com/deploy/myResource' /** Insert API endpoint */
endpoint = 'https://cors-anywhere.herokuapp.com/https://uy7rjj9np5.execute-api.eu-west-1.amazonaws.com/deploy/myResource'
dataType = 'json'
httpMethod = 'POST'
request(store, type, options) {
if(ENV["ember-cli-mirage"].enabled){
this.endpoint = "/mirage"
}
let compiledQuery = this.compile(store, type, options);
console.log(compiledQuery)
let url = this.endpoint;
let ajaxOpts = this.ajaxOptions({ query: compiledQuery });
ajaxOpts.contentType = 'application/json; charset=utf-8';
return this.ajax(url, ajaxOpts);
}
}
import {layout as templateLayout} from '@ember-decorators/component';
import Component from '@ember/component';
import layout from '../templates/components/edit-row-comp';
import { inject as service } from '@ember/service';
export default
@templateLayout(layout)
class DisplayTableComponent extends Component {
@service router;
record = null;
lst = "[]";
init() {
super.init(...arguments);
this.lst = this.getTable();
}
getTable(){
let lst = this.record[this.column.propertyName]
let s = "["
lst.forEach(x => {
s += x.id + ", "
})
s = s.substring(0, s.length-2)
if(s.length == 0)
s += "["
s += "]"
return s;
}
}
import {layout as templateLayout} from '@ember-decorators/component';
import Component from '@ember/component';
import layout from '../templates/components/edit-row-comp';
import { inject as service } from '@ember/service';
export default
@templateLayout(layout)
class EditRowComponent extends Component {
@service router;
record = null;
click(event) {
this.router.transitionTo('update.' + this.record._internalModel.modelName, this.record);
}
}
import Component from '@ember/component';
export default Component.extend({
classNames: ['employe'],
columns: [ {propertyName: "id",
title: "id"},
{
propertyName: "email",
title: "email"
},
{
propertyName: "firstName",
title: "firstName"
},
{
propertyName: "lastName",
title: "lastName"
},
{
propertyName: "login",
title: "login"
},
{
propertyName: "password",
title: "password"
},
{
propertyName: "workInfo.id",
title: "workInfo"
},
{
title: 'Edit',
component: 'edit-row-comp',
editable: false
}
]
});
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
export default class MyComponent extends Component {
@service notify;
@action
sayHello() {
this.notify.info('Hello there!');
}
}
import Component from '@ember/component';
export default Component.extend({
classNames: ['work'],
columns: [ {propertyName: "id",
title: "id"},
{
propertyName: "job",
title: "job"
},
{
propertyName: "salary",
title: "salary"
},
{
title: "empl",
propertyName: "empl",
component: 'display-table',
editable: false
},
{
title: 'Edit',
component: 'edit-row-comp',
editable: false
}
]
});
import Controller from '@ember/controller';
import { action } from '@ember/object';
import EmployeValidations from '../../validations/employe'
import { inject as service } from '@ember/service';
export default Controller.extend({
router: service(),
ajax: service(),
notify: service(),
chain: "lol",
isLoad: false,
allwork : [],
firstwork : "",
nextId : 0,
EmployeValidations,
init() {
this._super(...arguments);
this.findAllwork()
this.initNextId()
this.output()
},
initNextId: action(async function() {
this.store.query('employe', {}).then(
x => {
x.forEach(y => {
this.nextId++
})
})
}),
output: action(async function() {
this.set(this.chain, "ok")
return "ok"
}),
findAllwork: action(async function() {
this.store.query('work', {}).then(
x => {
x.forEach(y => {
if(y.id != 5) // condition to keep work
this.allwork.push(y)
})
let fields = []
this.allwork[0].eachAttribute(x => fields.push(x))
this.firstwork = fields[0]
this.set('isLoad', true);
return this.allwork;
}
)
}),
submit: action(async function(model, fields) {
let emp = this.store.createRecord('employe', {id : this.nextId++, email : fields["email"], firstName : fields["firstName"], lastName : fields["lastName"], login : fields["login"], password : fields["password"], workInfo : fields["workInfo"]});
emp.save().then(e => this.router.transitionTo('display-employe'))
console.log("ok")
//this.get("dialog").alert("error-message");
this.notify.info('Hello there!');
}),
});
import Controller from '@ember/controller';
import { action } from '@ember/object';
import WorkValidations from '../../validations/work'
import $ from 'jquery';
import { inject as service } from '@ember/service';
export default Controller.extend({
router: service(),
notify: service(),
allemploye : [],
firstemploye : "",
nextId : 0,
WorkValidations,
init() {
this._super(...arguments);
console.log("find..")
this.findAllemploye()
console.log("find !")
this.initNextId()
},
initNextId: action(async function() {
this.store.query('work', {}).then(
x => {
x.forEach(y => {
this.nextId++
})
})
}),
findAllemploye: action(async function() {
this.store.query('employe', {}).then(
x => {
x.forEach(y => {
this.allemploye.push(y)
})
let fields = []
this.allemploye[0].eachAttribute(x => fields.push(x))
this.firstemploye = fields[0]
return this.allemploye;
}
)
}),
submit: action(async function(model, fields) {
let work = this.store.createRecord('work', {id : this.nextId++, job : fields["job"], salary : fields["salary"], empl : fields["empl"]});
work.save().then(x => this.router.transitionTo('display-work')).catch(e => {
let message = this.notify.alert('Error ! Employe not available', {
closeAfter: 10000 // or set to null to disable auto-hiding
});
})
})
});
import $ from 'jquery';
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
export default Controller.extend({
createTables: action(async function(model, fields) {
/* let work = this.store.createRecord('work', {id : this.nextId++, job : fields["job"], salary : fields["salary"], empl : [fields["empl"]]});
work.save().then(x => this.router.transitionTo('display-work')).catch(e => {
let message = this.notify.alert('Error ! Employe not available', {
closeAfter: 10000 // or set to null to disable auto-hiding
});
})*/
$.ajax({
url:'https://cors-anywhere.herokuapp.com/https://nuiq3isr44.execute-api.eu-west-1.amazonaws.com/deploy/myResource',
type: "POST",
data: JSON.stringify({
initTable: 'ok'
})
}).then(function(resp){
console.log(resp)
// handle your server response here
}).catch(function(error){
console.log(error)
// handle errors here
});
}),
fillTables: action(async function(model, fields) {
/* let work = this.store.createRecord('work', {id : this.nextId++, job : fields["job"], salary : fields["salary"], empl : [fields["empl"]]});
work.save().then(x => this.router.transitionTo('display-work')).catch(e => {
let message = this.notify.alert('Error ! Employe not available', {
closeAfter: 10000 // or set to null to disable auto-hiding
});
})*/
$.ajax({
url:'https://cors-anywhere.herokuapp.com/https://nuiq3isr44.execute-api.eu-west-1.amazonaws.com/deploy/myResource',
type: "POST",
data: JSON.stringify({
fillTable: 'ok'
})
}).then(function(resp){
console.log(resp)
// handle your server response here
}).catch(function(error){
console.log(error)
// handle errors here
});
})
})
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
export default Controller.extend({
router: service(),
allwork : [],
firstwork : "",
nextId : 0,
init() {
this._super(...arguments);
this.findAllwork()
this.initNextId()
},
initNextId: action(async function() {
this.store.query('employe', {}).then(
x => {
x.forEach(y => {
this.nextId++
})
})
}),
findAllwork: action(async function() {
this.store.query('work', {}).then(
x => {
x.forEach(y => {
this.allwork.push(y)
})
let fields = []
this.allwork[0].eachAttribute(x => fields.push(x))
this.firstwork = fields[0]
return this.allwork;
}
)
}),
submit: action(async function(model, fields) {
this.store.findRecord('employe', fields["id"]).then(function(employe) {
// ...after the record has loaded
employe.email = fields["email"];employe.firstName = fields["firstName"];employe.lastName = fields["lastName"];employe.login = fields["login"];employe.password = fields["password"];employe.workInfo = fields["workInfo"];
employe.save()
});
this.router.transitionTo('display-employe')
})
});
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { set } from '@ember/object';
export default Controller.extend({
router: service(),
isUpdating: false,
allemploye : [],
firstemploye : "",
nextId : 0,
init() {
this._super(...arguments);
this.findAllemploye()
this.initNextId()
},
initNextId: action(async function() {
this.store.query('work', {}).then(
x => {
x.forEach(y => {
this.nextId++
})
})
}),
findAllemploye: action(async function() {
this.store.query('employe', {}).then(
x => {
x.forEach(y => {
this.allemploye.push(y)
})
let fields = []
this.allemploye[0].eachAttribute(x => fields.push(x))
this.firstemploye = fields[0]
return this.allemploye;
}
)
}),
update_arrays: action (async function (tab, value){
for(let employe of tab){
let tmp = await this.store.findRecord('employe', employe.id)
console.log(tmp)
tmp.set('workInfo', null)
console.log("here")
tmp.save()
}
/*this.store.findRecord('employe', 11).then(function(employe) {
employe.set('workInfo', null)
console.log("here")
employe.save()
});*/
//this.set('isUpdating', false)
}),
/*delete_arrays: action (async function (tab){
tab.forEach(x => {
this.store.findRecord('employe', x.id).then(function(employe) {
employe.set('workInfo', null)
employe.save()
});
})
}),
add_arrays: action (async function (tab, work_id){
tab.forEach(x => {
this.store.findRecord('employe', x.id).then(function(employe) {
employe.set('workInfo', work_id)
employe.save()
});
})
}),*/
submit: action(async function(model, fields) {
console.log("update")
let new_employes = fields["empl"]
this.set('isUpdating', true)
console.log(this.isUpdating)
let work = await this.store.findRecord('work', fields["id"])
let old_employes = work.empl
let employes_to_delete = []
let employes_to_add = []
new_employes.forEach(
x => {
if(!old_employes.includes(x)){
employes_to_add.push(x)
}
}
)
old_employes.forEach(
x => {
if(!new_employes.includes(x)){
employes_to_delete.push(x)
}
}
)
this.update_arrays(employes_to_delete, null)
/*this.update_arrays(employes_to_add, work.id)
console.log("old : ", old_employes)
console.log(" new : ", new_employes)
console.log("add : ", employes_to_add)
console.log("delete : ", employes_to_delete)
work.set("job", fields["job"]);
work.set("salary", fields["salary"]);*/
/* let arr_id = []