Release Fixes
This commit is contained in:
		@@ -31,8 +31,11 @@ class UserManager
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public function getAvatarUrl(){
 | 
			
		||||
	public function getAvatarUrl($userId = null){
 | 
			
		||||
		$email = self::getUserData('email');
 | 
			
		||||
		if ($userId != null){
 | 
			
		||||
			$email = self::getUserData('email',$userId);
 | 
			
		||||
		}
 | 
			
		||||
		return 'https://secure.gravatar.com/avatar/' . md5( strtolower( trim( $email ) ) );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,7 @@ return $lang = [
 | 
			
		||||
	'b_restart' => 'Restart',
 | 
			
		||||
	'b_disable' => 'Deaktivovat',
 | 
			
		||||
	'b_select' => 'Zvolit',
 | 
			
		||||
	'b_ota' => 'ota',
 | 
			
		||||
 | 
			
		||||
	//labels
 | 
			
		||||
	'l_choseDevice' => 'Zvolte zařízení:',
 | 
			
		||||
@@ -57,6 +58,10 @@ return $lang = [
 | 
			
		||||
	'l_password' => 'Heslo',
 | 
			
		||||
	'l_oldPassword' => 'Staré Heslo',
 | 
			
		||||
	'l_newPassword' => 'Nové Heslo',
 | 
			
		||||
	'l_uploadFirmware' => 'Nahrát Firmware',
 | 
			
		||||
	'l_userAvatar' => 'Avatar',
 | 
			
		||||
	'l_userEmail' => 'Email',
 | 
			
		||||
	'l_roomName' => 'Jméno Místnosti',
 | 
			
		||||
 | 
			
		||||
	//Title
 | 
			
		||||
	't_createScene' => 'Vytvořit scénu',
 | 
			
		||||
@@ -70,6 +75,14 @@ return $lang = [
 | 
			
		||||
	't_experimental' => 'Experimental',
 | 
			
		||||
	't_createuser' => 'Vytvořit Uživatele',
 | 
			
		||||
	't_changePassword' => 'Změnit Heslo',
 | 
			
		||||
	't_networkSetting' => 'Nastavení Sítě',
 | 
			
		||||
	't_deviceVersion' => 'Nastavení Verze',
 | 
			
		||||
	't_ota' => 'OTA',
 | 
			
		||||
	't_listUsers' => 'Seznam Uživatelů',
 | 
			
		||||
	't_avatar' => 'Avatar',
 | 
			
		||||
	't_listRooms' => 'Seznam Místností',	
 | 
			
		||||
	't_roomName' => 'Jméno Místnosti',
 | 
			
		||||
	't_createRoom' => 'Vytvořit Místnost',
 | 
			
		||||
 | 
			
		||||
	//constants
 | 
			
		||||
	'temp' => 'Teplota',
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,7 @@ return $lang = [
 | 
			
		||||
	'b_restart' => 'Restart',
 | 
			
		||||
	'b_disable' => 'disabele',
 | 
			
		||||
	'b_select' => 'Select',
 | 
			
		||||
	'b_ota' => 'ota',
 | 
			
		||||
 | 
			
		||||
	//labels
 | 
			
		||||
	'l_choseDevice' => 'Chose device:',
 | 
			
		||||
@@ -57,6 +58,10 @@ return $lang = [
 | 
			
		||||
	'l_password' => 'Password',
 | 
			
		||||
	'l_oldPassword' => 'Old Password',
 | 
			
		||||
	'l_newPassword' => 'New Password',
 | 
			
		||||
	'l_uploadFirmware' => 'Upload Firmware',
 | 
			
		||||
	'l_userAvatar' => 'Avatar',
 | 
			
		||||
	'l_userEmail' => 'Email',
 | 
			
		||||
	'l_roomName' => 'Room Name',
 | 
			
		||||
 | 
			
		||||
	//Title
 | 
			
		||||
	't_createScene' => 'Create Scene',
 | 
			
		||||
@@ -70,6 +75,14 @@ return $lang = [
 | 
			
		||||
	't_experimental' => 'Experimental',
 | 
			
		||||
	't_createuser' => 'Create User',
 | 
			
		||||
	't_changePassword' => 'Change Password',
 | 
			
		||||
	't_networkSetting' => 'Network Setting',
 | 
			
		||||
	't_deviceVersion' => 'Version Setting',
 | 
			
		||||
	't_ota' => 'OTA',
 | 
			
		||||
	't_listUsers' => 'User List',
 | 
			
		||||
	't_avatar' => 'Avatar',
 | 
			
		||||
	't_listRooms' => 'Room List',	
 | 
			
		||||
	't_roomName' => 'Room Name',
 | 
			
		||||
	't_createRoom' => 'Create Rom',
 | 
			
		||||
 | 
			
		||||
	//constants
 | 
			
		||||
	'humi' => 'Humidity',
 | 
			
		||||
 
 | 
			
		||||
@@ -17,23 +17,24 @@ if ('serviceWorker' in navigator) {
 | 
			
		||||
        navigator.serviceWorker.register('serviceWorker.js')
 | 
			
		||||
        .then(registration => {
 | 
			
		||||
            console.log('Service Worker is registered', registration);
 | 
			
		||||
            
 | 
			
		||||
            messaging.useServiceWorker(registration);
 | 
			
		||||
            messaging.usePublicVapidKey('BDYQ7X7J7PX0aOFNqB-CivQeqLq4-SqCxQJlDfJ6yNnQeYRoK8H2KOqxHRh47fLrbUhC8O3tve67MqJAIqox7Ng');
 | 
			
		||||
            messaging.requestPermission().then(function () {
 | 
			
		||||
                console.log("Notification permission granted.");
 | 
			
		||||
                return messaging.getToken()
 | 
			
		||||
            })
 | 
			
		||||
            .then(function(token) {
 | 
			
		||||
            .then(function (token) {
 | 
			
		||||
                console.log("token is : " + token);
 | 
			
		||||
                $.ajax({
 | 
			
		||||
                    url: 'ajax',
 | 
			
		||||
                    type: 'POST',
 | 
			
		||||
                    data: {
 | 
			
		||||
                        "notification" : 'X',
 | 
			
		||||
                        "notification": 'X',
 | 
			
		||||
                        "action": 'subscribe',
 | 
			
		||||
                        "token": token
 | 
			
		||||
                    },
 | 
			
		||||
                    success: function(data){
 | 
			
		||||
                    success: function (data) {
 | 
			
		||||
                        console.log('saved', data);
 | 
			
		||||
                    },
 | 
			
		||||
                    error: function (request, status, error) {
 | 
			
		||||
@@ -44,15 +45,6 @@ if ('serviceWorker' in navigator) {
 | 
			
		||||
            .catch(function (err) {
 | 
			
		||||
                console.log("Unable to get permission to notify.", err);
 | 
			
		||||
            });
 | 
			
		||||
            messaging.onMessage(function(payload) {
 | 
			
		||||
                console.log("Message received. ", payload);
 | 
			
		||||
                var notification = new Notification('hello', {
 | 
			
		||||
                    body: "Hey there!",
 | 
			
		||||
                });
 | 
			
		||||
                notification.onclick = function () {
 | 
			
		||||
                    window.open("http://google.com");
 | 
			
		||||
                };
 | 
			
		||||
            });
 | 
			
		||||
        })
 | 
			
		||||
        .catch(err => {
 | 
			
		||||
            console.error('Registration failed:', err);
 | 
			
		||||
@@ -61,34 +53,34 @@ if ('serviceWorker' in navigator) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
$('select[name="atSelector"]').change(function(e) {
 | 
			
		||||
$('select[name="atSelector"]').change(function (e) {
 | 
			
		||||
    console.log($(this).val());
 | 
			
		||||
    if( $(this).val() == 'time') {
 | 
			
		||||
 | 
			
		||||
        $('input[name="atTime"]').prop( "disabled", false );
 | 
			
		||||
 | 
			
		||||
        $('select[name="atDeviceValueInt"]').prop( "disabled", true );
 | 
			
		||||
        $('input[name="atDeviceValue"]').prop( "disabled", true );
 | 
			
		||||
    } else if( $(this).val() == 'atDeviceValue') {
 | 
			
		||||
 | 
			
		||||
        $('select[name="atDeviceValue"]').prop( "disabled", false );
 | 
			
		||||
        $('input[name="atDeviceValueInt"]').prop( "disabled", false );
 | 
			
		||||
 | 
			
		||||
        $('input[name="atTime"]').prop( "disabled", true );
 | 
			
		||||
    if ($(this).val() == 'time') {
 | 
			
		||||
        
 | 
			
		||||
        $('input[name="atTime"]').prop("disabled", false);
 | 
			
		||||
        
 | 
			
		||||
        $('select[name="atDeviceValueInt"]').prop("disabled", true);
 | 
			
		||||
        $('input[name="atDeviceValue"]').prop("disabled", true);
 | 
			
		||||
    } else if ($(this).val() == 'atDeviceValue') {
 | 
			
		||||
        
 | 
			
		||||
        $('select[name="atDeviceValue"]').prop("disabled", false);
 | 
			
		||||
        $('input[name="atDeviceValueInt"]').prop("disabled", false);
 | 
			
		||||
        
 | 
			
		||||
        $('input[name="atTime"]').prop("disabled", true);
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
var pressTimer;
 | 
			
		||||
var touch = 0;
 | 
			
		||||
var touchSubId = "";
 | 
			
		||||
$("div.square-content").on('touchend', function (e){
 | 
			
		||||
$("div.square-content").on('touchend', function (e) {
 | 
			
		||||
    clearTimeout(pressTimer);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$("div.square-content").on('touchstart', function (eTarget) {
 | 
			
		||||
    navigator.vibrate([500]);
 | 
			
		||||
    var id = '';
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    var windowLoc = $(location).attr('pathname');
 | 
			
		||||
    windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/"));
 | 
			
		||||
    console.log(windowLoc);
 | 
			
		||||
@@ -99,17 +91,17 @@ $("div.square-content").on('touchstart', function (eTarget) {
 | 
			
		||||
    } else if (windowLoc == "/automation") {
 | 
			
		||||
        id = $(this).attr('id').replace('automation-', '');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    var subId = $(this).attr('data-sub-device-id');
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    touch++;
 | 
			
		||||
    if(touch == 2 && touchSubId == subId){
 | 
			
		||||
    if (touch == 2 && touchSubId == subId) {
 | 
			
		||||
        console.log("Detail");
 | 
			
		||||
        if (windowLoc == "/") {
 | 
			
		||||
            $("#modal-detail-"+subId).removeClass('modal-container-hiden').show();
 | 
			
		||||
            $("#modal-detail-" + subId).removeClass('modal-container-hiden').show();
 | 
			
		||||
            ajaxChart(subId);
 | 
			
		||||
        } else if (windowLoc == "/scene") {
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
        } else if (windowLoc == "/automation") {
 | 
			
		||||
        }
 | 
			
		||||
        touch = 0;
 | 
			
		||||
@@ -117,15 +109,15 @@ $("div.square-content").on('touchstart', function (eTarget) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    touchSubId = subId;
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    pressTimer = window.setTimeout(function (e) {
 | 
			
		||||
        console.log("Setting");
 | 
			
		||||
        $("#modal-setting-"+id).removeClass('modal-container-hiden').show();
 | 
			
		||||
        $("#modal-setting-" + id).removeClass('modal-container-hiden').show();
 | 
			
		||||
        touch = 0;
 | 
			
		||||
    }, 500);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$("div.square-content").mousedown(function(e) {
 | 
			
		||||
$("div.square-content").mousedown(function (e) {
 | 
			
		||||
    if (event.which == 3) {
 | 
			
		||||
        var windowLoc = $(location).attr('pathname');
 | 
			
		||||
        windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/"));
 | 
			
		||||
@@ -138,7 +130,7 @@ $("div.square-content").mousedown(function(e) {
 | 
			
		||||
        } else if (windowLoc == "/automation") {
 | 
			
		||||
            id = $(this).attr('id').replace('automation-', '');
 | 
			
		||||
        }
 | 
			
		||||
        $("#modal-setting-"+id).removeClass('modal-container-hiden').show();
 | 
			
		||||
        $("#modal-setting-" + id).removeClass('modal-container-hiden').show();
 | 
			
		||||
        console.log("Setting");
 | 
			
		||||
        console.log("modal" + id);
 | 
			
		||||
    }
 | 
			
		||||
@@ -149,7 +141,7 @@ $(".close").on('click', function (e) {
 | 
			
		||||
    a.hide();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$(this).bind("contextmenu", function(e) {
 | 
			
		||||
$(this).bind("contextmenu", function (e) {
 | 
			
		||||
    e.preventDefault();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -159,11 +151,11 @@ $("div.square-content").on('dblclick', function (eTarget) {
 | 
			
		||||
        console.log("Detail");
 | 
			
		||||
        var subId = $(this).attr('data-sub-device-id');
 | 
			
		||||
        ajaxChart(subId);
 | 
			
		||||
        $("#modal-detail-"+subId).removeClass('modal-container-hiden').show();
 | 
			
		||||
        $("#modal-detail-" + subId).removeClass('modal-container-hiden').show();
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$("input#sleepTime").change(function() {
 | 
			
		||||
$("input#sleepTime").change(function () {
 | 
			
		||||
    console.log("Input text changed!");
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
@@ -175,7 +167,7 @@ $("a#remove").on('click', function (e) {
 | 
			
		||||
    element.toggle();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function ajaxChart(id, period = 'day', group = 'hour'){
 | 
			
		||||
function ajaxChart(id, period = 'day', group = 'hour') {
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: 'ajax',
 | 
			
		||||
        type: 'POST',
 | 
			
		||||
@@ -186,9 +178,9 @@ function ajaxChart(id, period = 'day', group = 'hour'){
 | 
			
		||||
            "period": period,
 | 
			
		||||
            "group": group
 | 
			
		||||
        },
 | 
			
		||||
        success: function(data){
 | 
			
		||||
            console.log('ID: ',id, 'DATA: ', data);
 | 
			
		||||
            var ctx = document.getElementById('canvas-'+id).getContext('2d');
 | 
			
		||||
        success: function (data) {
 | 
			
		||||
            console.log('ID: ', id, 'DATA: ', data);
 | 
			
		||||
            var ctx = document.getElementById('canvas-' + id).getContext('2d');
 | 
			
		||||
            var myChart = new Chart(ctx, data);
 | 
			
		||||
        },
 | 
			
		||||
        error: function (request, status, error) {
 | 
			
		||||
@@ -202,38 +194,38 @@ var windowLoc = $(location).attr('pathname');
 | 
			
		||||
windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/"));
 | 
			
		||||
console.log();
 | 
			
		||||
if (windowLoc == "/") {
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    var selectRoomId = localStorage.getItem("selectedRoomId");
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    if (selectRoomId == null) {
 | 
			
		||||
        selectRoomId = 'all';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    console.log('Saved Selected Room ID '+ selectRoomId);
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    console.log('Saved Selected Room ID ' + selectRoomId);
 | 
			
		||||
    $('[name="room"]').val(selectRoomId);
 | 
			
		||||
    $('.device-button').each(function(){
 | 
			
		||||
        if (selectRoomId != 'all'){
 | 
			
		||||
            if($(this).data('room-id') != selectRoomId){
 | 
			
		||||
    $('.device-button').each(function () {
 | 
			
		||||
        if (selectRoomId != 'all') {
 | 
			
		||||
            if ($(this).data('room-id') != selectRoomId) {
 | 
			
		||||
                $(this).hide();
 | 
			
		||||
            } else {
 | 
			
		||||
                $(this).show();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Room selector
 | 
			
		||||
$( '[name="room"]' ).change(function (e) {
 | 
			
		||||
$('[name="room"]').change(function (e) {
 | 
			
		||||
    console.log('Selected Room ID ' + this.value)
 | 
			
		||||
    var roomId = this.value;
 | 
			
		||||
    localStorage.setItem("selectedRoomId", roomId);
 | 
			
		||||
    $('.device-button').show();
 | 
			
		||||
    if (roomId != 'all'){
 | 
			
		||||
        $('.device-button').each(function(){
 | 
			
		||||
            if($(this).data('room-id') != roomId){
 | 
			
		||||
    if (roomId != 'all') {
 | 
			
		||||
        $('.device-button').each(function () {
 | 
			
		||||
            if ($(this).data('room-id') != roomId) {
 | 
			
		||||
                $(this).hide();
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
@@ -287,11 +279,11 @@ $('.graph-period').on('click', function (e) {
 | 
			
		||||
    var subId = $(this).attr('data-sub-device-id');
 | 
			
		||||
    var period = $(this).attr('data-period');
 | 
			
		||||
    var groupBy = $(this).attr('data-group');
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    ajaxChart(subId, period, groupBy);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$( "button[name=remove]" ).click(function(e) {
 | 
			
		||||
$("button[name=remove]").click(function (e) {
 | 
			
		||||
    if (confirm('Are you shure ?')) {
 | 
			
		||||
        var windowLoc = $(location).attr('pathname');
 | 
			
		||||
        windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/"));
 | 
			
		||||
@@ -299,7 +291,7 @@ $( "button[name=remove]" ).click(function(e) {
 | 
			
		||||
        var id = null;
 | 
			
		||||
        if (windowLoc == "/scene") {
 | 
			
		||||
            id = $(this).data('scene-id');
 | 
			
		||||
            $("#scene-"+id+"-content").remove();
 | 
			
		||||
            $("#scene-" + id + "-content").remove();
 | 
			
		||||
        } else if (windowLoc == "/automation") {
 | 
			
		||||
            $(this).parent().remove();
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -84,12 +84,6 @@
 | 
			
		||||
                    <input class="input" type="text" name="deviceGateway" value="<?php echo $DEVICE['gateway']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <?php //TODO: ADD DNS TO DB MAKE ALL NETWORK SETTING EDITABLE ?>
 | 
			
		||||
                <div class="field">
 | 
			
		||||
                    <div class="label">DNS:</div>
 | 
			
		||||
                    <input class="input" type="text" name="deviceDns" value="<?php echo $DEVICE['dns']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <h4 class="mb-4"><?php $LANGMNG->echo('t_deviceVersion'); ?></h4>
 | 
			
		||||
                <div class="field">
 | 
			
		||||
                    <div class="label"><?php $LANGMNG->echo('l_uploadFirmware'); ?></div>
 | 
			
		||||
 
 | 
			
		||||
@@ -115,6 +115,7 @@
 | 
			
		||||
				<table class="table is-fluid">
 | 
			
		||||
					<thead>
 | 
			
		||||
						<tr>
 | 
			
		||||
							<th><?php $LANGMNG->echo('t_avatar');?></th>
 | 
			
		||||
							<th><?php $LANGMNG->echo('t_userName');?></th>
 | 
			
		||||
							<th><?php $LANGMNG->echo('t_ota');?></th>
 | 
			
		||||
							<th><?php $LANGMNG->echo('t_action');?></th>
 | 
			
		||||
@@ -123,6 +124,7 @@
 | 
			
		||||
					<tbody>
 | 
			
		||||
						<?php foreach ($USERS as $key => $user) { ?>
 | 
			
		||||
							<tr>
 | 
			
		||||
								<td><img src="<?php echo $user['gavatar_url']; ?>" /></td>
 | 
			
		||||
								<td><?php echo $user['username']; ?></td>
 | 
			
		||||
								<td><?php echo ($user['ota'] ? '<span class="fa"></span>' : ''); ?></td>
 | 
			
		||||
								<td><button name="deleteUser" type="button" class="button is-danger fa"></button></td>
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,9 @@ class Setting extends Template
 | 
			
		||||
		$template->prepare('automations', $automations);
 | 
			
		||||
 | 
			
		||||
		$users = $userManager->getUsers();
 | 
			
		||||
		foreach ($users as $key => $value) {
 | 
			
		||||
			$users[$key]['gavatar_url'] = $userManager->getAvatarUrl($value['user_id']);
 | 
			
		||||
		}
 | 
			
		||||
		$template->prepare('users', $users);
 | 
			
		||||
 | 
			
		||||
		$template->prepare('userName', $userManager->getUserData('username'));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user