type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
|---|---|---|---|---|
MethodDeclaration
|
GetDataforEdit() {
this.http
.get(Services.getUrl('main_claim_request', 'filter=CLAIM_REQUEST_GUID=' + this.claimRequestGUID))
.map(res => res.json())
.subscribe(data => {
this.claimRequestData = data["resource"];
console.log(this.claimRequestData)
if (this.claimRequestData[0].SOC_GUID === null) {
this.claimFor = 'customer'
this.storeCustomers.forEach(element => {
if (element.CUSTOMER_GUID === this.claimRequestData[0].CUSTOMER_GUID) {
this.Customer_Lookup_ngModel = element.NAME
}
});
}
else {
this.claimFor = 'project'
this.storeProjects.forEach(element => {
if (element.SOC_GUID === this.claimRequestData[0].SOC_GUID) {
this.Project_Lookup_ngModel = element.project_name
this.Travel_SOC_No_ngModel = element.soc
}
});
}
this.Travel_Date_ngModel = this.claimRequestData[0].TRAVEL_DATE;
this.Travel_From_ngModel = this.claimRequestData[0].FROM;
this.Travel_Destination_ngModel = this.claimRequestData[0].DESTINATION;
this.Travel_Distance_ngModel = this.claimRequestData[0].DISTANCE_KM;
//this.travelAmount = this.claimRequestData[0].MILEAGE_AMOUNT
this.Travel_Amount_ngModel = this.claimRequestData[0].CLAIM_AMOUNT;
this.Travel_Description_ngModel = this.claimRequestData[0].DESCRIPTION;
this.vehicles.forEach(element => {
if (element.MILEAGE_GUID === this.claimRequestData[0].MILEAGE_GUID) {
this.Travel_Mode_ngModel = element.CATEGORY
}
});
console.table(this.claimRequestData)
console.log(this.claimRequestData[0].SOC_GUID)
console.log(this.claimRequestData[0].MILEAGE_GUID)
console.log(this.claimRequestData[0].DESCRIPTION)
}
);
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
GetSocNo(item: any){
this.Travel_SOC_No_ngModel = item.soc;
this.Project_Lookup_ngModel = item.project_name;
this.Soc_GUID = item.SOC_GUID;
this.CloseProjectLookup();
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
GetCustomer(guid: any, name: any) {
this.Customer_Lookup_ngModel = name;
this.Customer_GUID = guid;
this.CloseCustomerLookup();
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
public translateToEnglish() {
this.translate.use('en');
this.translateToMalayClicked = !this.translateToMalayClicked;
this.translateToEnglishClicked = !this.translateToEnglishClicked;
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
public translateToMalay() {
this.translate.use('ms');
this.translateToEnglishClicked = !this.translateToEnglishClicked;
this.translateToMalayClicked = !this.translateToMalayClicked;
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
//---------------------Language module end---------------------//
claimForChanged() {
// console.log(this.claimFor)
if (this.claimFor == 'customer') this.isCustomer = true;
else this.isCustomer = false;
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
LoadProjects() {
this.http
.get(Services.getUrl('soc_registration'))
.map(res => res.json())
.subscribe(data => {
this.storeProjects= this.projects = data["resource"];
console.table(this.projects)
}
);
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
LoadCustomers() {
this.http
.get(Services.getUrl('main_customer'))
.map(res => res.json())
.subscribe(data => {
this.storeCustomers = this.customers = data["resource"];
console.table(this.projects)
}
);
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
//console.log(TenantGUID);
LoadVehicles() {
console.log(this.TenantGUID);
this.http
.get(Services.getUrl('main_mileage', 'filter=TENANT_GUID=' + this.TenantGUID))
.map(res => res.json())
.subscribe(data => {
this.vehicles = data["resource"];
console.table(this.vehicles);
}
);
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
GetDistance() {
var origin = this.Travel_From_ngModel;
var destination;
var url = 'http://api.zen.com.my/api/v2/google/distancematrix/json?destinations=place_id:' + this.DestinationPlaceID + '&origins=place_id:' + this.OriginPlaceID + '&api_key=' + constants.DREAMFACTORY_API_KEY;
this.http.get(url).map(res => res.json()).subscribe(data => {
let temp = data["rows"][0]["elements"][0];
// console.table(data)
if (temp["distance"] != null) {
let DistKm: string = data["rows"][0]["elements"][0]["distance"]["text"];
// console.log(DistKm)
DistKm = DistKm.replace(',', '')
this.Travel_Distance_ngModel = DistKm.substring(0, DistKm.length - 2)
}
else
alert('Please select Valid Origin & Destination Places');
});
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
public CloseTravelClick() {
this.AddToLookupClicked = false;
this.AddTravelClicked = false;
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
public CloseLookupClick() {
if (this.AddLookupClicked == true) {
this.AddLookupClicked = false;
}
if (this.AddToLookupClicked == true) {
this.AddToLookupClicked = false;
}
let origin = this.Travel_From_ngModel;
let destination = this.Travel_Distance_ngModel;
if (origin != '' && destination != '') {
this.GetDistance();
// this.Travel_Mode_ngModel = this.vehicleCategory ;
}
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
public CloseProjectLookup() {
if (this.ProjectLookupClicked == true) {
this.ProjectLookupClicked = false;
}
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
public CloseCustomerLookup() {
if (this.CustomerLookupClicked == true) {
this.CustomerLookupClicked = false;
}
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
public AddLookupClick() {
this.AddLookupClicked = true;
this.currentItems = null;
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
public AddToLookupClick() {
this.AddLookupClicked = true;
this.AddToLookupClicked = true;
this.currentItems = null;
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
public ProjectLookup() {
this.ProjectLookupClicked = true;
// this.projects = null;
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
public CustomerLookup() {
this.CustomerLookupClicked = true;
// this.projects = null;
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
openItem(item: any) {
if (this.AddToLookupClicked) {
this.Travel_Destination_ngModel = item.description;
this.DestinationPlaceID = item.place_id
}
else {
this.Travel_From_ngModel = item.description;
this.OriginPlaceID = item.place_id;
}
this.CloseLookupClick();
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
searchLocation(searchLocationString: any) {
let val = searchLocationString.target.value;
val = val.replace(/ /g, '');
if (!val || !val.trim()) {
this.currentItems = [];
return;
}
var url = 'http://api.zen.com.my/api/v2/google/place/autocomplete/json?json?radius=50000&input=' + val + '&api_key=' + constants.DREAMFACTORY_API_KEY;
this.http.get(url).map(res => res.json()).subscribe(data => {
this.currentItems = data["predictions"];
console.table(this.currentItems);
});
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
// onSearchInput(ev: any) {
// let val = ev.target.value;
// if (val && val.trim() != '') {
// this.projects = this.projects.filter((item) => {
// console.log(item);
// return ((item.FULLNAME.toLowerCase().indexOf(val.toLowerCase()) > -1)
// || ((item.MONTH.toString().toLowerCase().indexOf(val.toLowerCase()) > -1)
// || (item.YEAR.toString().toLowerCase().indexOf(val.toLowerCase()) > -1))
// || (item.CLAIM_AMOUNT.toString().toLowerCase().indexOf(val.toLowerCase()) > -1
// )
// );
// })
// }
// else
// {
// // this.BindData();
// return null;
// }
// }
// Search project start:
searchProject(searchString: any) {
let val = searchString.target.value;
if (!val || !val.trim()) {
this.projects = this.storeProjects;
return;
}
this.projects= this.filterProjects({
project_name: val
});
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
filterProjects(params?: any) {
if (!params) {
return this.storeProjects;
}
return this.projects.filter((item) => {
for (let key in params) {
let field = item[key];
if (typeof field == 'string' && field.toLowerCase().indexOf(params[key].toLowerCase()) >= 0) {
return item;
} else if (field == params[key]) {
return item;
}
}
return null;
});
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
searchCustomer(searchString: any) {
let val = searchString.target.value;
if (!val || !val.trim()) {
this.customers = this.storeCustomers;
return;
}
this.customers = this.filterCustomer({
NAME: val
});
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
filterCustomer(params?: any) {
if (!params) {
return this.storeCustomers;
}
return this.customers.filter((item) => {
for (let key in params) {
let field = item[key];
if (typeof field == 'string' && field.toLowerCase().indexOf(params[key].toLowerCase()) >= 0) {
return item;
} else if (field == params[key]) {
return item;
}
}
return null;
});
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
takePhoto() {
// Camera.getPicture().then((imageData) => {
// this.imageURL = imageData
// }, (err) => {
// console.log(err);
// });
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
SetPrice(vehicle: any) {
this.VehicleId = vehicle.MILEAGE_GUID;
this.VehicleRate = vehicle.RATE_PER_UNIT;
this.vehicleCategory = vehicle.CATEGORY;
console.log(vehicle.MILEAGE_GUID);
console.log(vehicle.RATE_PER_UNIT);
console.log(vehicle.CATEGORY);
console.log(this.VehicleId);
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
// fileChange(){
// alert('file change');
// let fileList: FileList = event.target.files;
// if(fileList.length > 0) {
// let file: File = fileList[0];
// let formData:FormData = new FormData();
// formData.append('uploadFile', file, file.name);
// let headers = new Headers();
// /** No need to include Content-Type in Angular 4 */
// headers.append('Content-Type', 'multipart/form-data');
// headers.append('Accept', 'application/json');
// let options = new RequestOptions({ headers: headers });
// this.http.post(`${this.apiEndPoint}`, formData, options)
// .map(res => res.json())
// .catch(error => Observable.throw(error))
// .subscribe(
// data => console.log('success'),
// error => console.log(error)
// )
// }
// }
save(value: any) {
let tenantGUID = localStorage.getItem('g_TENANT_GUID');
let month = new Date(value.travel_date).getMonth() + 1;
let year = new Date(value.travel_date).getFullYear();
let claimRefGUID;
let url = Services.getUrl('main_claim_ref', 'filter=(USER_GUID=' + this.userGUID + ')AND(MONTH=' + month + ')AND(YEAR=' + year + ')');
this.http
.get(url)
.map(res => res.json())
.subscribe(claimRefdata => {
if (claimRefdata["resource"][0] == null) {
let claimReqRef: ClaimRefMain_Model = new ClaimRefMain_Model();
claimReqRef.CLAIM_REF_GUID = UUID.UUID();
claimReqRef.USER_GUID = this.userGUID;
claimReqRef.TENANT_GUID = tenantGUID;
claimReqRef.REF_NO = this.userGUID + '/' + month + '/' + year;
claimReqRef.MONTH = month;
claimReqRef.YEAR = year;
claimReqRef.CREATION_TS = new Date().toISOString();
claimReqRef.UPDATE_TS = new Date().toISOString();
this.api.postData('main_claim_ref', claimReqRef.toJson(true)).subscribe((response) => {
var postClaimRef = response.json();
claimRefGUID = postClaimRef["resource"][0].CLAIM_REF_GUID;
let claimReqMainRef: ClaimReqMain_Model = new ClaimReqMain_Model();
claimReqMainRef.CLAIM_REQUEST_GUID = UUID.UUID();
claimReqMainRef.TENANT_GUID = tenantGUID;
claimReqMainRef.CLAIM_REF_GUID = claimRefGUID;
claimReqMainRef.MILEAGE_GUID = this.VehicleId;
claimReqMainRef.CLAIM_TYPE_GUID = '58c59b56-289e-31a2-f708-138e81a9c823';
claimReqMainRef.TRAVEL_DATE = value.travel_date;
claimReqMainRef.START_TS = value.start_DT;
claimReqMainRef.END_TS = value.end_DT;
claimReqMainRef.DESCRIPTION = value.description;
claimReqMainRef.MILEAGE_AMOUNT = this.Travel_Amount_ngModel
claimReqMainRef.CLAIM_AMOUNT = this.Travel_Amount_ngModel
claimReqMainRef.CREATION_TS = new Date().toISOString();
claimReqMainRef.UPDATE_TS = new Date().toISOString();
claimReqMainRef.FROM = this.Travel_From_ngModel;
claimReqMainRef.DESTINATION = this.Travel_Destination_ngModel;
claimReqMainRef.DISTANCE_KM = this.Travel_Distance_ngModel;
claimReqMainRef.ASSIGNED_TO = this.assignedTo;
claimReqMainRef.PROFILE_LEVEL = this.profileLevel;
claimReqMainRef.PROFILE_JSON = this.profileJSON;
claimReqMainRef.STATUS = 'Pending';
claimReqMainRef.STAGE = this.stage;
// claimReqMainRef.SOC_GUID = this.Travel_SOC_No_ngModel;
if(this.isCustomer){
claimReqMainRef.CUSTOMER_GUID = this.Customer_GUID ;
}
else{
claimReqMainRef.SOC_GUID = this.Soc_GUID;
}
// claimReqMainRef.CUSTOMER_GUID = this.isCustomer ? this.Customer_GUID : this.Soc_GUID;
// claimReqMainRef.SOC_GUID = this.isCustomer ? this.Customer_GUID : this.Soc_GUID;
this.api.postData('main_claim_request', claimReqMainRef.toJson(true)).subscribe((response) => {
var postClaimMain = response.json();
this.ClaimRequestMain = postClaimMain["resource"][0].CLAIM_REQUEST_GUID;
this.MainClaimSaved = true;
console.table( claimReqMainRef);
alert('Claim Has Registered.')
})
})
}
else {
claimRefGUID = claimRefdata["resource"][0].CLAIM_REF_GUID;
let claimReqMainRef: ClaimReqMain_Model = new ClaimReqMain_Model();
claimReqMainRef.CLAIM_REQUEST_GUID = UUID.UUID();
claimReqMainRef.TENANT_GUID = tenantGUID;
claimReqMainRef.CLAIM_REF_GUID = claimRefGUID;
claimReqMainRef.MILEAGE_GUID = this.VehicleId;
claimReqMainRef.CLAIM_TYPE_GUID = '58c59b56-289e-31a2-f708-138e81a9c823';
claimReqMainRef.TRAVEL_DATE = value.travel_date;
claimReqMainRef.START_TS = value.start_DT;
claimReqMainRef.END_TS = value.end_DT;
claimReqMainRef.DESCRIPTION = value.description;
claimReqMainRef.MILEAGE_AMOUNT = this.Travel_Amount_ngModel;
claimReqMainRef.CLAIM_AMOUNT = this.Travel_Amount_ngModel;
claimReqMainRef.CREATION_TS = new Date().toISOString();
claimReqMainRef.UPDATE_TS = new Date().toISOString();
claimReqMainRef.FROM = this.Travel_From_ngModel;
claimReqMainRef.DESTINATION = this.Travel_Destination_ngModel;
claimReqMainRef.ASSIGNED_TO = this.assignedTo;
claimReqMainRef.DISTANCE_KM = this.Travel_Distance_ngModel;
claimReqMainRef.PROFILE_LEVEL = this.profileLevel;
claimReqMainRef.PROFILE_JSON = this.profileJSON;
claimReqMainRef.STATUS = 'Pending';
//claimReqMainRef.STATUS = 'Pending';
claimReqMainRef.STAGE = this.stage;
//claimReqMainRef.SOC_GUID = this.Travel_SOC_No_ngModel;
if(this.isCustomer){
claimReqMainRef.CUSTOMER_GUID = this.Customer_GUID ;
}
else{
claimReqMainRef.SOC_GUID = this.Soc_GUID;
}
this.api.postData('main_claim_request', claimReqMainRef.toJson(true)).subscribe((response) => {
var postClaimMain = response.json();
this.ClaimRequestMain = postClaimMain["resource"][0].CLAIM_REQUEST_GUID;
this.MainClaimSaved = true;
alert('Claim Has Registered.')
})
}
})
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
sendEmail() {
let name: string; let email: string
name = 'shabbeer'; email = 'shabbeer@zen.com.my'
var queryHeaders = new Headers();
queryHeaders.append('Content-Type', 'application/json');
queryHeaders.append('X-Dreamfactory-Session-Token', localStorage.getItem('session_token'));
queryHeaders.append('X-Dreamfactory-API-Key', constants.DREAMFACTORY_API_KEY);
let options = new RequestOptions({ headers: queryHeaders });
let body = {
"template": "",
"template_id": 0,
"to": [
{
"name": name,
"email": email
}
],
"cc": [
{
"name": name,
"email": email
}
],
"bcc": [
{
"name": name,
"email": email
}
],
"subject": "Test",
"body_text": "",
"body_html": '<HTML><HEAD> <META name=GENERATOR content="MSHTML 10.00.9200.17606"></HEAD> <BODY> <DIV style="FONT-FAMILY: Century Gothic"> <DIV style="MIN-WIDTH: 500px"><BR> <DIV style="PADDING-BOTTOM: 10px; TEXT-ALIGN: center; PADDING-TOP: 10px; PADDING-LEFT: 10px; PADDING-RIGHT: 10px"><IMG style="WIDTH: 130px" alt=zen2.png src="http://zentranet.zen.com.my/_catalogs/masterpage/Layout/images/zen2.png"></DIV> <DIV style="MARGIN: 0px 100px; BACKGROUND-COLOR: #ec008c"> <DIV style="FONT-SIZE: 30px; COLOR: white; PADDING-BOTTOM: 10px; TEXT-ALIGN: center; PADDING-TOP: 10px; PADDING-LEFT: 20px; PADDING-RIGHT: 20px"><B><I>Notification</I></B></DIV></DIV><BR> <DIV style="FONT-SIZE: 12px; TEXT-ALIGN: center; PADDING-TOP: 20px">Dear [%Variable: @Employee%]<BR><BR>Your [%Variable: @LeaveType%] application has been forwarded to your superior for approval. <H1 style="FONT-SIZE: 14px; TEXT-ALIGN: center; PADDING-TOP: 10px"><BR><B>Leave Details :</B><BR></H1> <TABLE style="FONT-SIZE: 12px; FONT-FAMILY: Century Gothic; MARGIN: 0px auto"> <TBODY> <TR> <TD style="TEXT-ALIGN: left">EMPLOYEE</TD> <TD style="PADDING-BOTTOM: 6px; PADDING-TOP: 6px; PADDING-LEFT: 6px; PADDING-RIGHT: 6px">:</TD> <TD colSpan=2>[%Variable: @Employee%]</TD></TR> <TR> <TD>START DATE</TD> <TD>:</TD> <TD style="TEXT-ALIGN: left" colSpan=2>[%Variable: @StartDate%]</TD></TR> <TR> <TD style="TEXT-ALIGN: left">END DATE </TD> <TD>:</TD> <TD style="TEXT-ALIGN: left" colSpan=2>[%Variable: @EndDate%]</TD></TR> <TR> <TD style="TEXT-ALIGN: left">APPLIED DATE</TD> <TD style="PADDING-BOTTOM: 6px; PADDING-TOP: 6px; PADDING-LEFT: 6px; PADDING-RIGHT: 6px">:</TD> <TD colSpan=2>[%Variable: @AppliedDate%]</TD></TR> <TR> <TD style="TEXT-ALIGN: left">DAYS</TD> <TD>:</TD> <TD style="TEXT-ALIGN: left">[%Variable: @NoOfDays%] </TD> <TD style="TEXT-ALIGN: left">[%Variable: @HalfDay%]</TD></TR></TR> <TR> <TD>LEAVE TYPE</TD> <TD>:</TD> <TD style="TEXT-ALIGN: left" colSpan=2>[%Variable: @LeaveType%]</TD></TR> <TR> <TD style="TEXT-ALIG: left">REASON</TD> <TD>: </TD> <TD style="TEXT-ALIGN: left" colSpan=2>[%Current Item:Reason%]</TD></TR></TBODY></TABLE><BR> <DIV style="TEXT-ALIGN: center; PADDING-TOP: 20px">Thank you.</DIV></DIV></DIV></DIV></BODY></HTML>',
"from_name": "Ajay DAV",
"from_email": "ajay1591ani@gmail.com",
"reply_to_name": "",
"reply_to_email": ""
};
this.http.post(this.emailUrl, body, options)
.map(res => res.json())
.subscribe(data => {
// this.result= data["resource"];
alert(JSON.stringify(data));
});
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
showAddToll() {
//let AddTollModal = this.modalCtrl.create(AddTollPage);
//AddTollModal.present;
this.navCtrl.push(AddTollPage, {
DetailsType: 'Toll',
MainClaim: this.ClaimRequestMain,
ClaimMethod: '03048acb-037a-11e8-a50c-00155de7e742'
});
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
showAddParking() {
this.navCtrl.push(AddTollPage, {
DetailsType: 'Parking',
MainClaim: this.ClaimRequestMain,
ClaimMethod: '0ebb7e5f-037a-11e8-a50c-00155de7e742'
});
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
MethodDeclaration
|
readProfile() {
return this.http.get('assets/profile.json').map((response) => response.json()).subscribe(data => {
this.profileJSON = JSON.stringify(data);
//levels: any[];
let levels: any[] = data.profile.levels.level
console.table(levels)
levels.forEach(element => {
if (element['-id'] == '1') {
this.profileLevel = '1';
if (element['approver']['-directManager'] === '1') {
this.http
.get(Services.getUrl('user_info', 'filter=USER_GUID=' + this.userGUID))
.map(res => res.json())
.subscribe(data => {
let userInfo: any[] = data["resource"]
userInfo.forEach(userElm => {
this.assignedTo = userElm.MANAGER_USER_GUID
this.http
.get(Services.getUrl('user_info', 'filter=USER_GUID=' + userElm.MANAGER_USER_GUID))
.map(res => res.json())
.subscribe(data => {
let userInfo: any[] = data["resource"]
userInfo.forEach(approverElm => {
this.stage = approverElm.DEPT_GUID
});
});
});
// console.log('Direct Manager Exists')
});
// console.log('Direct Manager ' + element['approver']['-directManager'])
let varf: any[]= element['conditions']['condition']
varf.forEach(condElement => {
if (condElement['-status'] === 'approved') {
console.log('Next Level ' + condElement['nextlevel']['#text'])
}
console.log('Status ' + condElement['-status'])
});
}
else {
this.assignedTo = element['approver']['#text']
this.http
.get(Services.getUrl('user_info', 'filter=USER_GUID=' + this.assignedTo))
.map(res => res.json())
.subscribe(data => {
let userInfo: any[] = data["resource"]
userInfo.forEach(approverElm => {
this.stage = approverElm.DEPT_GUID
});
});
}
}
});
});
}
|
Pratap-Singh/eClaim
|
src/pages/travel-claim/travel-claim.component.ts
|
TypeScript
|
ArrowFunction
|
() => {
beforeAll(() => {
(window as any)['crypto'] = window.crypto || { getRandomValues };
});
it(
'should create an array of random 4-byte numbers by default',
observe(() => {
return fromRandomCrypto().pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
);
}),
);
it(
'should create an array of random 1-byte integer',
observe(() =>
fromRandomCrypto(0, { bytes: 1 }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
),
),
);
it(
'should create an array of random 1-byte unsigned integer',
observe(() =>
fromRandomCrypto(0, { bytes: 1, unsigned: true }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
),
),
);
it(
'should create an array of random 2-byte integer',
observe(() =>
fromRandomCrypto(0, { bytes: 2 }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
),
),
);
it(
'should create an array of random 2-byte unsigned integer',
observe(() =>
fromRandomCrypto(0, { bytes: 2, unsigned: true }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
),
),
);
it(
'should create an array of random 4-byte integer',
observe(() =>
fromRandomCrypto(0, { bytes: 4 }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
),
),
);
it(
'should create an array of random 4-byte unsigned integer',
observe(() =>
fromRandomCrypto(0, { bytes: 4, unsigned: true }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
),
),
);
}
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
(window as any)['crypto'] = window.crypto || { getRandomValues };
}
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
return fromRandomCrypto().pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
);
}
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
(acc, val) => [...acc, val]
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
(value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
(v) => typeof v === 'number' && Number.isInteger(v)
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
() =>
fromRandomCrypto(0, { bytes: 1 }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
)
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
() =>
fromRandomCrypto(0, { bytes: 1, unsigned: true }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
)
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
() =>
fromRandomCrypto(0, { bytes: 2 }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
)
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
() =>
fromRandomCrypto(0, { bytes: 2, unsigned: true }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
)
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
() =>
fromRandomCrypto(0, { bytes: 4 }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
)
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
() =>
fromRandomCrypto(0, { bytes: 4, unsigned: true }).pipe(
take(5),
reduce<number, number[]>((acc, val) => [...acc, val], []),
tap((value) => {
const check = value.filter((v) => typeof v === 'number' && Number.isInteger(v));
expect(check.length).toBe(5);
}),
)
|
rxjs-ninja/rxjs-ninja
|
libs/rxjs/random/src/lib/from-random-crypto.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
let page: AppPage;
let map: Map;
beforeEach(() => {
page = new AppPage();
map = new Map();
page.navigateTo();
browser.driver.manage().window().maximize();
});
it('should open a dropdown on click', () => {
const dropdown = map.selectElement();
dropdown.click();
expect(element(by.css('ul.dropdown-menu')).isPresent()).toBeTruthy();
});
it('should display the slider on selecting a layer', () => {
expect(map.sliderElement().isPresent()).toBeFalsy();
const dropdown = map.selectElement();
dropdown.click();
element(by.css('ul.dropdown-menu li:nth-child(3)')).click();
expect(map.sliderElement().isPresent()).toBeTruthy();
});
}
|
EvictionLab/eviction-maps
|
e2e/map.e2e-spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
page = new AppPage();
map = new Map();
page.navigateTo();
browser.driver.manage().window().maximize();
}
|
EvictionLab/eviction-maps
|
e2e/map.e2e-spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const dropdown = map.selectElement();
dropdown.click();
expect(element(by.css('ul.dropdown-menu')).isPresent()).toBeTruthy();
}
|
EvictionLab/eviction-maps
|
e2e/map.e2e-spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(map.sliderElement().isPresent()).toBeFalsy();
const dropdown = map.selectElement();
dropdown.click();
element(by.css('ul.dropdown-menu li:nth-child(3)')).click();
expect(map.sliderElement().isPresent()).toBeTruthy();
}
|
EvictionLab/eviction-maps
|
e2e/map.e2e-spec.ts
|
TypeScript
|
ArrowFunction
|
({ isVisible, children }: Props) => (
<AnimatedContainer
animate={isVisible ? 'visible' : 'hidden'}
|
CwirL/wilmercantillo.com
|
src/components/animations/fade.tsx
|
TypeScript
|
TypeAliasDeclaration
|
type Props = {
isVisible: boolean
children: ReactNode
}
|
CwirL/wilmercantillo.com
|
src/components/animations/fade.tsx
|
TypeScript
|
FunctionDeclaration
|
export default function useVModel<T, P extends (...args: any) => void>(
value: Ref<T>,
modelValue: Ref<T>,
defaultValue: T,
onChange: P,
propName = 'value',
// emit 和 eventName 用于支持 v-model 和 xxx.sync 语法糖
): [Ref<T>, ChangeHandler<T>] {
const { emit, attrs } = getCurrentInstance();
const internalValue: Ref<T> = ref();
// 非受控模式,defaultValue 只消费一次
internalValue.value = defaultValue;
if (typeof value.value !== 'undefined') {
// 受控模式 v-model:propName
internalValue.value = value.value;
} else if (typeof modelValue.value !== 'undefined') {
// 受控模式:modelValue v-model
internalValue.value = modelValue.value;
}
// 监听value与modelValue的变化
watch(value, (newVal) => {
internalValue.value = newVal;
});
watch(modelValue, (newVal) => {
internalValue.value = newVal;
});
return [
internalValue,
(newValue, ...args) => {
if (attrs[`onUpdate:${propName}`]) {
// 受控模式 v-model:propName
emit?.(`update:${propName}`, newValue, ...args);
} else if (attrs['onUpdate:modelValue']) {
// 受控模式:modelValue v-model
emit?.(`update:modelValue`, newValue, ...args);
}
if (typeof value.value === 'undefined' && typeof modelValue.value === 'undefined') {
internalValue.value = newValue;
}
onChange?.(newValue, ...args);
},
];
}
|
BigLiao/tdesign-vue-next
|
src/hooks/useVModel.ts
|
TypeScript
|
ArrowFunction
|
(newVal) => {
internalValue.value = newVal;
}
|
BigLiao/tdesign-vue-next
|
src/hooks/useVModel.ts
|
TypeScript
|
ArrowFunction
|
(newValue, ...args) => {
if (attrs[`onUpdate:${propName}`]) {
// 受控模式 v-model:propName
emit?.(`update:${propName}`, newValue, ...args);
} else if (attrs['onUpdate:modelValue']) {
// 受控模式:modelValue v-model
emit?.(`update:modelValue`, newValue, ...args);
}
if (typeof value.value === 'undefined' && typeof modelValue.value === 'undefined') {
internalValue.value = newValue;
}
onChange?.(newValue, ...args);
}
|
BigLiao/tdesign-vue-next
|
src/hooks/useVModel.ts
|
TypeScript
|
TypeAliasDeclaration
|
export type ChangeHandler<T> = (value: T, ...args: any) => void;
|
BigLiao/tdesign-vue-next
|
src/hooks/useVModel.ts
|
TypeScript
|
ArrowFunction
|
({ theme }) => theme.application().lowContrast().hex()
|
microsoft/data-wrangling-components
|
javascript/react/src/components/StepSelector.styles.ts
|
TypeScript
|
ArrowFunction
|
resolve => resolve(this.isAuthenticated)
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
ArrowFunction
|
(res) => {
this.user = res;
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
ArrowFunction
|
error1 => {
console.log(error1);
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
ArrowFunction
|
(resolve) => {
if(typeof this.user === "undefined"){
setTimeout(()=>{
if(typeof this.user === "undefined"){
setTimeout(()=>{
if(!(typeof this.user === "undefined"))
resolve(this.user.name)
},100)
}else
resolve(this.user.name)
}, 100);
}
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
ArrowFunction
|
()=>{
if(typeof this.user === "undefined"){
setTimeout(()=>{
if(!(typeof this.user === "undefined"))
resolve(this.user.name)
},100)
}else
resolve(this.user.name)
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
ArrowFunction
|
()=>{
if(!(typeof this.user === "undefined"))
resolve(this.user.name)
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
ArrowFunction
|
() => {
this.router.navigate(['/login']);
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
ArrowFunction
|
(error) => {
console.log(error);
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
ArrowFunction
|
(res) => {}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
ArrowFunction
|
error1 => console.log("error updating: " + error1)
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
ClassDeclaration
|
@Injectable()
export class UserService {
isAuthenticated = false;
user: User;
userNamePromise;
private REGISTER_API = api_address + user_endpoint + register_endpoint;
constructor(private httpClient : HttpClient, private router: Router){}
checkAuthenticated () {
return new Promise(
resolve => resolve(this.isAuthenticated));
}
fetchUserByUserkey(userkey : string) {
let address :string = api_address + userByKey_endpoint + userkey;
console.log(address);
this.httpClient
.get<any>(address)
.subscribe(
(res) => {
this.user = res;
},
(error1 => {
console.log(error1);
}));
}
getUserByUserKey(userkey : string){
let address :string = api_address + userByKey_endpoint + userkey;
console.log(address);
return this.httpClient
.get<User>(address);
}
getUserName(){
return new Promise((resolve) => {
if(typeof this.user === "undefined"){
setTimeout(()=>{
if(typeof this.user === "undefined"){
setTimeout(()=>{
if(!(typeof this.user === "undefined"))
resolve(this.user.name)
},100)
}else
resolve(this.user.name)
}, 100);
}
});
}
registerUser(info : RegistrationModel){
this.httpClient
.post<LoginModel>(this.REGISTER_API, info)
.subscribe(
() => {
this.router.navigate(['/login']);
},
(error) => {
console.log(error);
}
);
}
updateUser(updatedUser: User) {
let address :string = api_address + user_endpoint;
console.log("updating at: " + address);
this.httpClient
.post<User>(address, updatedUser)
.subscribe(
(res) => {},
(error1 => console.log("error updating: " + error1))
)
}
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
MethodDeclaration
|
checkAuthenticated () {
return new Promise(
resolve => resolve(this.isAuthenticated));
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
MethodDeclaration
|
fetchUserByUserkey(userkey : string) {
let address :string = api_address + userByKey_endpoint + userkey;
console.log(address);
this.httpClient
.get<any>(address)
.subscribe(
(res) => {
this.user = res;
},
(error1 => {
console.log(error1);
}));
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
MethodDeclaration
|
getUserByUserKey(userkey : string){
let address :string = api_address + userByKey_endpoint + userkey;
console.log(address);
return this.httpClient
.get<User>(address);
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
MethodDeclaration
|
getUserName(){
return new Promise((resolve) => {
if(typeof this.user === "undefined"){
setTimeout(()=>{
if(typeof this.user === "undefined"){
setTimeout(()=>{
if(!(typeof this.user === "undefined"))
resolve(this.user.name)
},100)
}else
resolve(this.user.name)
}, 100);
}
});
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
MethodDeclaration
|
registerUser(info : RegistrationModel){
this.httpClient
.post<LoginModel>(this.REGISTER_API, info)
.subscribe(
() => {
this.router.navigate(['/login']);
},
(error) => {
console.log(error);
}
);
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
MethodDeclaration
|
updateUser(updatedUser: User) {
let address :string = api_address + user_endpoint;
console.log("updating at: " + address);
this.httpClient
.post<User>(address, updatedUser)
.subscribe(
(res) => {},
(error1 => console.log("error updating: " + error1))
)
}
|
milowedo/task-dispatching
|
angular/src/app/services/user.service.ts
|
TypeScript
|
ClassDeclaration
|
export default class {
config: AiryWidgetConfiguration;
constructor(config: AiryWidgetConfiguration) {
this.config = config;
}
render(target: HTMLElement) {
render(<Chat {...this.config} />, target);
}
}
|
olia-la/airy
|
frontend/chat-plugin/src/AiryWidget.tsx
|
TypeScript
|
MethodDeclaration
|
render(target: HTMLElement) {
render(<Chat {...this.config} />, target);
}
|
olia-la/airy
|
frontend/chat-plugin/src/AiryWidget.tsx
|
TypeScript
|
ArrowFunction
|
p => p.theme.fontFamily.heading
|
AdamTranquilla/brave-core
|
components/brave_rewards/resources/ui/components/mobile/walletInfoHeader/style.ts
|
TypeScript
|
ArrowFunction
|
async ({ commit, dispatch, rootState }, { token, type, payload }) => {
commit('SEND_REQUEST');
try {
const msg: any = {
address: rootState.web3.account,
msg: JSON.stringify({
version,
timestamp: (Date.now() / 1e3).toFixed(),
token,
type,
payload
})
};
msg.sig = await dispatch('signMessage', msg.msg);
const result = await client.request('message', msg);
commit('SEND_SUCCESS');
dispatch('notify', ['green', `Your ${type} is in!`]);
return result;
} catch (e) {
commit('SEND_FAILURE', e);
const errorMessage =
e && e.error_description
? `Oops, ${e.error_description}`
: 'Oops, something went wrong!';
dispatch('notify', ['red', errorMessage]);
return;
}
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
async ({ commit }, space) => {
commit('GET_PROPOSALS_REQUEST');
try {
let proposals: any = await client.request(`${space.address}/proposals`);
if (proposals) {
const scores: any = await getScores(
space.strategies,
space.chainId,
getProvider(space.chainId),
Object.values(proposals).map((proposal: any) => proposal.address)
);
proposals = Object.fromEntries(
Object.entries(proposals).map((proposal: any) => {
proposal[1].score = scores.reduce(
(a, b) => a + b[proposal[1].address],
0
);
return [proposal[0], proposal[1]];
})
);
}
commit('GET_PROPOSALS_SUCCESS');
return formatProposals(proposals);
} catch (e) {
commit('GET_PROPOSALS_FAILURE', e);
}
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(proposal: any) => proposal.address
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(proposal: any) => {
proposal[1].score = scores.reduce(
(a, b) => a + b[proposal[1].address],
0
);
return [proposal[0], proposal[1]];
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(a, b) => a + b[proposal[1].address]
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
async ({ commit, rootState }, payload) => {
commit('GET_PROPOSAL_REQUEST');
try {
const result: any = {};
const [proposal, votes] = await Promise.all([
ipfs.get(payload.id),
client.request(`${payload.space.address}/proposal/${payload.id}`)
]);
result.proposal = formatProposal(proposal);
result.proposal.ipfsHash = payload.id;
result.votes = votes;
const { snapshot } = result.proposal.msg.payload;
const blockTag =
snapshot > rootState.web3.blockNumber ? 'latest' : parseInt(snapshot);
const scores: any = await getScores(
payload.space.strategies,
payload.space.chainId,
getProvider(payload.space.chainId),
Object.keys(result.votes),
// @ts-ignore
blockTag
);
console.log('Scores', scores);
result.votes = Object.fromEntries(
Object.entries(result.votes)
.map((vote: any) => {
vote[1].scores = payload.space.strategies.map(
(strategy, i) => scores[i][vote[1].address] || 0
);
vote[1].balance = vote[1].scores.reduce((a, b: any) => a + b, 0);
return vote;
})
.sort((a, b) => b[1].balance - a[1].balance)
.filter(vote => vote[1].balance > 0)
);
result.results = {
totalVotes: result.proposal.msg.payload.choices.map(
(choice, i) =>
Object.values(result.votes).filter(
(vote: any) => vote.msg.payload.choice === i + 1
).length
),
totalBalances: result.proposal.msg.payload.choices.map((choice, i) =>
Object.values(result.votes)
.filter((vote: any) => vote.msg.payload.choice === i + 1)
.reduce((a, b: any) => a + b.balance, 0)
),
totalScores: result.proposal.msg.payload.choices.map((choice, i) =>
payload.space.strategies.map((strategy, sI) =>
Object.values(result.votes)
.filter((vote: any) => vote.msg.payload.choice === i + 1)
.reduce((a, b: any) => a + b.scores[sI], 0)
)
),
totalVotesBalances: Object.values(result.votes).reduce(
(a, b: any) => a + b.balance,
0
)
};
commit('GET_PROPOSAL_SUCCESS');
return result;
} catch (e) {
commit('GET_PROPOSAL_FAILURE', e);
}
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(vote: any) => {
vote[1].scores = payload.space.strategies.map(
(strategy, i) => scores[i][vote[1].address] || 0
);
vote[1].balance = vote[1].scores.reduce((a, b: any) => a + b, 0);
return vote;
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(strategy, i) => scores[i][vote[1].address] || 0
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(a, b: any) => a + b
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(a, b) => b[1].balance - a[1].balance
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
vote => vote[1].balance > 0
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(choice, i) =>
Object.values(result.votes).filter(
(vote: any) => vote.msg.payload.choice === i + 1
).length
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(vote: any) => vote.msg.payload.choice === i + 1
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(choice, i) =>
Object.values(result.votes)
.filter((vote: any) => vote.msg.payload.choice === i + 1)
.reduce((a, b: any) => a + b.balance, 0)
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(a, b: any) => a + b.balance
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(choice, i) =>
payload.space.strategies.map((strategy, sI) =>
Object.values(result.votes)
.filter((vote: any) => vote.msg.payload.choice === i + 1)
.reduce((a, b: any) => a + b.scores[sI], 0)
)
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(strategy, sI) =>
Object.values(result.votes)
.filter((vote: any) => vote.msg.payload.choice === i + 1)
.reduce((a, b: any) => a + b.scores[sI], 0)
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(a, b: any) => a + b.scores[sI]
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
async ({ commit, rootState }, { space, address, snapshot }) => {
commit('GET_POWER_REQUEST');
try {
const blockTag =
snapshot > rootState.web3.blockNumber ? 'latest' : parseInt(snapshot);
let scores: any = await getScores(
space.strategies,
space.chainId,
getProvider(space.chainId),
[address],
// @ts-ignore
blockTag
);
scores = scores.map((score: any) =>
Object.values(score).reduce((a, b: any) => a + b, 0)
);
commit('GET_POWER_SUCCESS');
return {
scores,
totalScore: scores.reduce((a, b: any) => a + b, 0)
};
} catch (e) {
commit('GET_POWER_FAILURE', e);
}
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
ArrowFunction
|
(score: any) =>
Object.values(score).reduce((a, b: any) => a + b, 0)
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
MethodDeclaration
|
SEND_REQUEST() {
console.debug('SEND_REQUEST');
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
MethodDeclaration
|
SEND_SUCCESS() {
console.debug('SEND_SUCCESS');
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
MethodDeclaration
|
SEND_FAILURE(_state, payload) {
console.debug('SEND_FAILURE', payload);
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
MethodDeclaration
|
GET_PROPOSALS_REQUEST() {
console.debug('GET_PROPOSALS_REQUEST');
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
MethodDeclaration
|
GET_PROPOSALS_SUCCESS() {
console.debug('GET_PROPOSALS_SUCCESS');
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
MethodDeclaration
|
GET_PROPOSALS_FAILURE(_state, payload) {
console.debug('GET_PROPOSALS_FAILURE', payload);
}
|
build-finance/snapshot
|
src/store/modules/app.ts
|
TypeScript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.