Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function init() {
- const res_flags = wialon.item.Item.dataFlag.base | wialon.item.Resource.dataFlag.reports;
- const unit_flags = wialon.item.Item.dataFlag.base;
- const initProps = [
- { type: "type", data: "avl_resource", flags: res_flags, mode: 0 },
- { type: "type", data: "avl_unit", flags: unit_flags, mode: 0 }
- ];
- let getterResult;
- const sess = wialon.core.Session.getInstance();
- sess.loadLibrary("resourceReports");
- function getterFunc(code) {
- if (code) {
- msg(wialon.core.Errors.getErrorText(code));
- return;
- }
- const res = sess.getItems("avl_resource");
- if (!res || !res.length) {
- msg("Resources not found");
- return
- }
- for (let i = 0; i < res.length; i++) {
- $("#res").append(`<option value='${res[i].getId()}'>${res[i].getName()}</option>`);
- }
- const units = sess.getItems("avl_unit");
- if (!units || !units.length) {
- msg("Units not found");
- return
- }
- for (let i = 0; i < units.length; i++) {
- const u = units[i];
- $("#units").append(`<p id='pbox'><input class='inpcheck' type='checkbox' value='${u.getId()}'/> ${u.getName()}</p>`);
- };
- getterResult = units
- }
- sess.updateDataFlags(initProps, getterFunc);
- return getterResult;
- }
- const bbb = init()
- // bbb === units
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement