load devices in table
configure popup for devices
This commit is contained in:
		@@ -183,7 +183,7 @@
 | 
			
		||||
                                </h3>
 | 
			
		||||
                            </div><!-- /.card-header -->
 | 
			
		||||
                            <div class="card-body">
 | 
			
		||||
                                <table id="table-pickupdates" class="table table-bordered table-hover">
 | 
			
		||||
                                <table id="table-devices" class="table table-bordered table-hover">
 | 
			
		||||
                                    <thead>
 | 
			
		||||
                                    <tr>
 | 
			
		||||
                                        <th>Device ID</th>
 | 
			
		||||
@@ -193,21 +193,7 @@
 | 
			
		||||
                                        <th>X</th>
 | 
			
		||||
                                    </tr>
 | 
			
		||||
                                    </thead>
 | 
			
		||||
                                    <tbody id="picupdates-tablebody">
 | 
			
		||||
                                    <tr>
 | 
			
		||||
                                        <td>42</td>
 | 
			
		||||
                                        <td>new Device</td>
 | 
			
		||||
                                        <td>
 | 
			
		||||
                                            <button type="button" class="btn btn-primary">Configure</button>
 | 
			
		||||
                                        </td>
 | 
			
		||||
                                    </tr>
 | 
			
		||||
                                    <tr>
 | 
			
		||||
                                        <td>42</td>
 | 
			
		||||
                                        <td>lukis anziges</td>
 | 
			
		||||
                                        <td>htl steyr</td>
 | 
			
		||||
                                        <td>Steyr/2/Plastic</td>
 | 
			
		||||
                                        <td>del</td>
 | 
			
		||||
                                    </tr>
 | 
			
		||||
                                    <tbody id="devices-tablebody">
 | 
			
		||||
                                    </tbody>
 | 
			
		||||
                                    <tfoot>
 | 
			
		||||
                                    <tr>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,127 @@
 | 
			
		||||
$(document).ready(function () {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    $.post('/senddata/Devicedata', 'action=getdevices', function (data) {
 | 
			
		||||
 | 
			
		||||
        console.log(data);
 | 
			
		||||
        for (var i = 0; i < data.data.length; i++) {
 | 
			
		||||
            var id = data.data[i].deviceid;
 | 
			
		||||
            var cityid = data.data[i].cityid;
 | 
			
		||||
 | 
			
		||||
            if (cityid == -1) {
 | 
			
		||||
                $("#devices-tablebody").append("<tr><td>" + id + "</td><td>new Device</td><td><button deviceid=\"" + id + "\"type=\"button\" class=\"btn btn-primary configuredevicebutton\">Configure</button></td><td></td><td></td></tr>");
 | 
			
		||||
            } else {
 | 
			
		||||
                var devicename = data.data[i].devicename;
 | 
			
		||||
                var devicelocation = data.data[i].devicelocation;
 | 
			
		||||
 | 
			
		||||
                $("#devices-tablebody").append("<tr><td>" + id + "</td><td>" + devicename + "</td><td>" + devicelocation + "</td><td>" + cityid + "</td><td>DEL</td></tr>");
 | 
			
		||||
            }
 | 
			
		||||
            console.log();
 | 
			
		||||
            //devices-tablebody
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        $(".configuredevicebutton").click(function (event) {
 | 
			
		||||
            var id = event.target.getAttribute("deviceid");
 | 
			
		||||
 | 
			
		||||
            $.post('/senddata/Devicedata', 'action=getCitynames', function (data) {
 | 
			
		||||
                Swal.mixin({
 | 
			
		||||
                    input: 'text',
 | 
			
		||||
                    confirmButtonText: 'Next →',
 | 
			
		||||
                    showCancelButton: true,
 | 
			
		||||
                    progressSteps: ['1', '2', '3']
 | 
			
		||||
                }).queue([
 | 
			
		||||
                    {
 | 
			
		||||
                        title: 'Name of device',
 | 
			
		||||
                        text: 'Please define a device name'
 | 
			
		||||
                    }, {
 | 
			
		||||
                        title: 'Location of device',
 | 
			
		||||
                        text: 'Please define a device location'
 | 
			
		||||
                    }, {
 | 
			
		||||
                        title: 'City',
 | 
			
		||||
                        text: 'Select your City',
 | 
			
		||||
                        input: 'select',
 | 
			
		||||
                        inputOptions: data
 | 
			
		||||
                    }
 | 
			
		||||
                ]).then((result) => {
 | 
			
		||||
                    if (result.value) {
 | 
			
		||||
                        console.log(result.value);
 | 
			
		||||
                        const answers = JSON.stringify(result.value);
 | 
			
		||||
 | 
			
		||||
                        Swal.mixin({
 | 
			
		||||
                            input: 'text',
 | 
			
		||||
                            confirmButtonText: 'Next →',
 | 
			
		||||
                            showCancelButton: true,
 | 
			
		||||
                            progressSteps: ['1']
 | 
			
		||||
                        }).queue([
 | 
			
		||||
                            {
 | 
			
		||||
                                title: 'City',
 | 
			
		||||
                                text: 'Select your City',
 | 
			
		||||
                                input: 'select',
 | 
			
		||||
                                inputOptions: {
 | 
			
		||||
                                    'SRB': 'Serbia',      // How do I dynamically set value?
 | 
			
		||||
                                    'UKR': 'Ukraine',
 | 
			
		||||
                                    'HRV': 'Croatia'
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        ]).then((result) => {
 | 
			
		||||
                            if (result.value) {
 | 
			
		||||
                                console.log(result.value);
 | 
			
		||||
 | 
			
		||||
                                Swal.mixin({
 | 
			
		||||
                                    input: 'text',
 | 
			
		||||
                                    confirmButtonText: 'Next →',
 | 
			
		||||
                                    showCancelButton: true,
 | 
			
		||||
                                    progressSteps: ['1']
 | 
			
		||||
                                }).queue([
 | 
			
		||||
                                    {
 | 
			
		||||
                                        title: 'City',
 | 
			
		||||
                                        text: 'Select your City',
 | 
			
		||||
                                        input: 'select',
 | 
			
		||||
                                        inputOptions: {
 | 
			
		||||
                                            'SRB': 'Serbia',      // How do I dynamically set value?
 | 
			
		||||
                                            'UKR': 'Ukraine',
 | 
			
		||||
                                            'HRV': 'Croatia'
 | 
			
		||||
                                        }
 | 
			
		||||
                                    }
 | 
			
		||||
                                ]).then((result) => {
 | 
			
		||||
                                    if (result.value) {
 | 
			
		||||
                                        console.log(result.value);
 | 
			
		||||
                                    }
 | 
			
		||||
                                });
 | 
			
		||||
                            }
 | 
			
		||||
                        });
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            console.log("click..." + id);
 | 
			
		||||
        });
 | 
			
		||||
        /*
 | 
			
		||||
        ,{
 | 
			
		||||
                    title: 'Zone',
 | 
			
		||||
                    text: 'Select the Waste Zone',
 | 
			
		||||
                    input: 'select',
 | 
			
		||||
                    inputOptions: {
 | 
			
		||||
                        'SRB': 'Serbia',      // How do I dynamically set value?
 | 
			
		||||
                        'UKR': 'Ukraine',
 | 
			
		||||
                        'HRV': 'Croatia'
 | 
			
		||||
                    }
 | 
			
		||||
                },{
 | 
			
		||||
                    title: 'Type',
 | 
			
		||||
                    text: 'Select the Waste type',
 | 
			
		||||
                    input: 'select',
 | 
			
		||||
                    inputOptions: {
 | 
			
		||||
                        'SRB': 'Serbia',      // How do I dynamically set value?
 | 
			
		||||
                        'UKR': 'Ukraine',
 | 
			
		||||
                        'HRV': 'Croatia'
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
         */
 | 
			
		||||
 | 
			
		||||
        var test = $('#table-devices').DataTable();
 | 
			
		||||
    }, 'json');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user