Тема: Calculation to Determine Value for "svc":"user/update_user_flags" API
Dear Wialon Dev Support,
We are trying to understand and implement the following API:
API reference URL: https://sdk.wialon.com/wiki/en/sidebar/ … user_flags
The issue we’re facing is a simple understanding of proper calculation to determine from wialon api when Change Create Item, Can Change Password, Can Send SMS, Enable, Can Change Settings are Checked (enabled) or Unchecked (disabled).
Wialon API accepts a single digit value. This value can be calculated with the sum of all user permission property value’s shown in the screenshot below.
We are not able to calculate the sum. Below is our code example that we have come up with to calculate sum:
var user_flag = 0;
var user_flag_mask = 0;
if($("#can_create_items").prop("checked")){
user_flag = + 4;
user_flag_mask = +4;
}
if($("#can_change_password").prop("checked")){
user_flag = + user_flag + 2;
user_flag_mask = + user_flag_mask + 2;
}
if($("#can_send_sms").prop("checked")){
user_flag = + user_flag + 0;
user_flag_mask = + user_flag_mask + 0;
}
if($("#enable").prop("checked")){
user_flag = + user_flag + 1;
user_flag_mask = + user_flag_mask + 1;
}
if($("#can_change_settings").prop("checked")){
user_flag = + user_flag + 16;
user_flag_mask = + user_flag_mask + 16;
}
If there is anyway you can edit our code above or a portion of it to help give us a better understanding, we would sincerely appreciate it. I don’t mean to ask you to do our homework, but we’re stuck.
I look forward to hearing from you.