From 5e1554f1d948dd62fcc6dba241880cfebc402947 Mon Sep 17 00:00:00 2001 From: Denis Smirnov Date: Thu, 24 Oct 2013 13:12:07 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=81=20=D0=B4=D0=B0=D1=82=D0=BE=D0=B9=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=83=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B9=D1=81=D1=82=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front-end/meteor-device-spy/client/client.js | 4 ++++ front-end/meteor-device-spy/html/table.html | 2 +- front-end/meteor-device-spy/lib/helper.js | 18 ++++++++++++++++++ .../server/checkindevice_api.js | 3 +-- .../server/checkinuser_api.js | 2 +- 5 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 front-end/meteor-device-spy/lib/helper.js 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