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

$(()=>{
    montList = $(".mont-list").dxSelectBox({
        width       : 300,
        dataSource  : null,
        height      : 27,
        valueExpr   : 'monitoring_nm',
        displayExpr : 'monitoring_nm',
        stylingMode : 'outlined',
        onItemClick(e){
            partData = [];
            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('./monitoring-popup-manager.html','모니터링 화면 관리','width = 1300, height = 650, top = 150, left = 250, resizable=yes, scrollbars=no')
        }
    });

    fetchBaseData();
})
function fetchBaseData() {
    getDataAsync(commonUri + '/list', recvListData);
}
function recvListData(jsonData){
    _listData = jsonData;
    dataSorting(_listData, 'monitoring_nm');
    console.log(_listData);
    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, 'istl_lctn_nm');
}
