diff --git a/front-end/meteor-device-spy/client/client.js b/front-end/meteor-device-spy/client/client.js index 1791158..5f03a4d 100644 --- a/front-end/meteor-device-spy/client/client.js +++ b/front-end/meteor-device-spy/client/client.js @@ -10,6 +10,10 @@ Template.devices_list.get_name_by_id = function () { if (!owner) return "Не известно"; return owner.name + " " + owner.surname; }; + +Template.devices_list.get_checkin_date = function () { + return GetTimeAndDateFromDate(this.checkin_date); +}; // ---------- // ---------- diff --git a/front-end/meteor-device-spy/html/table.html b/front-end/meteor-device-spy/html/table.html index 0ed6229..006f87d 100644 --- a/front-end/meteor-device-spy/html/table.html +++ b/front-end/meteor-device-spy/html/table.html @@ -28,7 +28,7 @@ {{get_name_by_id}}
- {{checkin_date}} + {{get_checkin_date}}
diff --git a/front-end/meteor-device-spy/lib/helper.js b/front-end/meteor-device-spy/lib/helper.js new file mode 100644 index 0000000..8ffe715 --- /dev/null +++ b/front-end/meteor-device-spy/lib/helper.js @@ -0,0 +1,18 @@ +GetTimeAndDateFromDate = function(date) { + + if (!date) return ""; + + var hours = date.getHours(); + if (hours < 10) hours = "0" + hours; + + var minutes = date.getMinutes(); + if (minutes < 10) minutes = "0" + minutes; + + var days = date.getDate(); + if (days < 10) days = "0" + days; + + var months = date.getMonth() + 1; + if (months < 10) months = "0" + months; + + return hours + ":" + minutes + " " + days + "." + months + "." + date.getFullYear(); +}; \ No newline at end of file diff --git a/front-end/meteor-device-spy/server/checkindevice_api.js b/front-end/meteor-device-spy/server/checkindevice_api.js index ab95ef2..768f4d3 100644 --- a/front-end/meteor-device-spy/server/checkindevice_api.js +++ b/front-end/meteor-device-spy/server/checkindevice_api.js @@ -17,8 +17,7 @@ Meteor.startup(function () { console.log("-------- Устройство: ", device.name); - var checkinDate = GetCurrentDateAndTime (); - Devices.update(device._id, {$set: {checkin_date: checkinDate, owner_id: user._id}}); + Devices.update(device._id, {$set: {checkin_date: new Date(), owner_id: user._id}}); }); }); diff --git a/front-end/meteor-device-spy/server/checkinuser_api.js b/front-end/meteor-device-spy/server/checkinuser_api.js index 1243928..6cb53f5 100644 --- a/front-end/meteor-device-spy/server/checkinuser_api.js +++ b/front-end/meteor-device-spy/server/checkinuser_api.js @@ -9,7 +9,7 @@ Meteor.startup(function () { return "Can't find such MAC-addreses"; var date = new Date(); - Log_User_Login.insert({name: user.name, surname: user.sername, login_date: date}); + Log_User_Login.insert({name: user.name, surname: user.surname, login_date: date}); }); }); \ No newline at end of file