let montList  = null;
let montBtn   = null;
let montData  = [];
let partData  = [];
let nameList  = [];
let _listData = [];
const _videoMap = new Map();
let commonUri = "/api/vms/monitoring/edit/scenario/camera"
let lange     = 0;

$(()=>{
    montList = $(".mont-list").dxSelectBox({
        width       : 300,
        dataSource  : [],
        displayExpr : 'monitoring_nm',
        valueExpr   : 'monitoring_nm',
        height      : 27,
        stylingMode : 'outlined',
        onItemClick(e){
            getDataAsync(commonUri + "/" + e.itemData.monitoring_nm, montSection);
        }
    }).dxSelectBox('instance');

    montBtn = $(".mont-btn").dxButton({
        width       : 110,
        height      : 27,
        text        : '화면 관리',
        icon        : 'preferences',
        stylingMode : 'outlined',
        onClick(){
            window.open('./camera-popup-manager.html','모니터링 화면 관리','width = 1200, height = 650, top = 150, left = 300, resizable=yes, scrollbars=no')
        }
    });

    fetchBaseData();
})
function fetchBaseData(){
    getDataAsync(commonUri + '/list', recvListData);
}
function recvListData(jsonData){
    _listData = jsonData;
    montList.option('dataSource', _listData);
    if (_listData.length > 0) {
        setValue(montList, _listData[0].monitoring_nm);
        getDataAsync(commonUri + "/" + _listData[0].monitoring_nm, montSection);
    }
}

function montSection(data){
    camMonitoringInit(data, _videoMap, 'vms_nm');
}