How to use driver.log method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

dashboard.js

Source:dashboard.js Github

copy

Full Screen

1function getLatestDateAddedToDashboard() {2 return $(".list-group-item").first().data('added-to-dashboard');3}4function addTestItem(item) {5 let platformLogo = "";6 if (item.platform.toLowerCase().includes("mac")) {7 platformLogo = "apple";8 } else if (item.platform.toLowerCase().includes("windows")) {9 platformLogo = "windows";10 } else {11 platformLogo = item.platform.toLowerCase();12 }13 let buildDirectory = item.videoFolderPath.replace("/home/seluser/videos", "");14 buildDirectory = buildDirectory.trim().length > 0 ? buildDirectory.replace("/", "").concat("/") : "";15 const fileName = buildDirectory.concat(item.fileName);16 const seleniumLogFileName = buildDirectory.concat(item.seleniumLogFileName);17 const browserDriverLogFileName = buildDirectory.concat(item.browserDriverLogFileName);18 const testItem =19 "<a href=\"#\" class=\"list-group-item list-group-item-action flex-column align-items-start p-2\"" +20 " data-video=\"" + fileName + "\"" +21 " data-test-name=\"" + item.testName + "\"" +22 " data-test-selenium-session-id=\"" + item.seleniumSessionId + "\"" +23 " data-test-status=\"" + item.testStatus + "\"" +24 " data-browser=\"" + item.browser + "\"" +25 " data-browser-version=\"" + item.browserVersion + "\"" +26 " data-platform=\"" + platformLogo + "\"" +27 " data-proxy-name=\"" + item.proxyName + "\"" +28 " data-date-time=\"" + item.timestamp + "\"" +29 " data-added-to-dashboard=\"" + item.addedToDashboardTime + "\"" +30 " data-screen-dimension=\"" + item.screenDimension + "\"" +31 " data-time-zone=\"" + item.timeZone + "\"" +32 " data-test-build=\"" + item.build + "\"" +33 " data-selenium-log=\"" + seleniumLogFileName + "\"" +34 " data-browser-driver=\"" + browserDriverLogFileName + "\"" +35 " data-retention-date=\"" + item.retentionDate + "\">" +36 "<div class=\"d-flex w-100 justify-content-between\">" +37 "<small class=\"font-weight-bold text-truncate\">" + item.testName + "</small>" +38 "</div>" +39 "<div class=\"d-flex w-100 justify-content-between\">" +40 "<small>" + item.timestamp + "</small>" +41 "<small>" +42 "<img alt=\"" + item.proxyName + "\" src=\"img/" + item.proxyName.toLowerCase() + ".png\" width=\"24px\" height=\"24px\">" +43 "</small>" +44 "</div>" +45 "<div class=\"d-flex w-100 justify-content-between\">" +46 "<span>" +47 "<img alt=\"" + platformLogo + "\" src=\"img/" + platformLogo + ".png\" width=\"24px\" height=\"24px\">" +48 "<img alt=\"" + item.browser + "\" src=\"img/" + item.browser.toLowerCase() + ".png\" width=\"24px\" height=\"24px\">" +49 "<small class=\"pl-1\">" + item.browserVersion + "</small>" +50 "</span>" +51 "<span>" +52 "<img alt=\"" + item.testStatus + "\" src=\"img/" + item.testStatus.toLowerCase() + ".png\" width=\"24px\" height=\"24px\">" +53 "</span>" +54 "</div>" +55 "</a>";56 $('#tests').prepend(testItem);57 const testCount = $(".list-group-item").length;58 const testCountElement = $('#testCount');59 testCountElement.removeClass("btn-dark");60 testCountElement.addClass("btn-light");61 testCountElement.html("Tests <span class=\"badge badge-primary\">" + testCount + "</span>");62}63function loadDashboardItems() {64 let latestDateAdded = getLatestDateAddedToDashboard();65 if (latestDateAdded === undefined) {66 latestDateAdded = 0;67 }68 const newDashboardItems = [location.protocol, '//', location.host, location.pathname].join('') +69 'information?lastDateAddedToDashboard=' + latestDateAdded;70 $.getJSON(newDashboardItems, function(data) {71 $.each(data, function (i, item) {72 addTestItem(item);73 });74 searchTestsList();75 });76}77function playVideo($video) {78 const video = $('#video');79 const source = $('#video-source');80 source.attr("src", $video);81 source.attr("type", "video/mp4");82 video.get(0).pause();83 video.get(0).load();84 video.get(0).play();85}86function setTestInformation($testName, $browser, $browserVersion, $platform, $proxyName, $dateTime,87 $screenDimension, $timeZone, $build, $testStatus, $retentionDate) {88 const testName = $("#test-name");89 testName.html("");90 testName.append("<img alt=\"" + $testStatus + "\" src=\"img/" + $testStatus.toLowerCase() + ".png\" class=\"mr-1\" " +91 "width=\"48px\" height=\"48px\">");92 testName.append($testName);93 testName.append("<small class=\"float-right\">" + $dateTime + "</small>");94 const browserPlatformProxy = $("#browser-platform-proxy");95 browserPlatformProxy.html("");96 browserPlatformProxy.append("<img alt=\"" + $platform + "\" src=\"img/" + $platform.toLowerCase() + ".png\" class=\"mr-1\" " +97 "width=\"48px\" height=\"48px\">");98 browserPlatformProxy.append("<img alt=\"" + $browser + "\" src=\"img/" + $browser.toLowerCase() + ".png\" class=\"mr-1\" " +99 "width=\"48px\" height=\"48px\">");100 browserPlatformProxy.append($browserVersion);101 browserPlatformProxy.append("<img alt=\"" + $proxyName + "\" src=\"img/" + $proxyName.toLowerCase() + ".png\" class=\"float-right\" " +102 "width=\"48px\" height=\"48px\">");103 const screenResolutionTimeZone = $("#screen-resolution-time-zone");104 screenResolutionTimeZone.html("");105 if ($screenDimension.length > 0) {106 screenResolutionTimeZone.append("<img alt=\"Screen Resolution\" src=\"img/screen-resolution.png\" class=\"mr-1\" " +107 "width=\"48px\" height=\"48px\">");108 screenResolutionTimeZone.append("<small class=\"mr-1\">" + $screenDimension + "</small>");109 }110 if ($timeZone.length > 0) {111 screenResolutionTimeZone.append("<img alt=\"Time Zone\" src=\"img/timezone.png\" class=\"mr-1\" " +112 "width=\"48px\" height=\"48px\">");113 screenResolutionTimeZone.append("<small class=\"mr-1\">" + $timeZone + "</small>");114 }115 screenResolutionTimeZone.append("<span class=\"float-right\"><img alt=\"Retention Date\" src=\"img/retention-date.png\" " +116 "class=\"mr-1\" width=\"48px\" height=\"48px\"><small>" + $retentionDate + "</small></span>");117 if ($build.toString().length > 0) {118 const buildElement = $("#build");119 buildElement.html("");120 buildElement.removeClass("p-0");121 buildElement.addClass("p-1");122 buildElement.parent().removeClass("invisible");123 buildElement.append("<img alt=\"Build\" src=\"img/build.png\" class=\"mr-1\" width=\"48px\" height=\"48px\">");124 buildElement.append("<small class=\"mr-1\">" + $build + "</small>");125 } else {126 const buildElement = $("#build");127 buildElement.html("");128 buildElement.removeClass("p-1");129 buildElement.addClass("p-0");130 buildElement.parent().addClass("invisible");131 }132 $("#main-container").removeClass("invisible");133}134function loadLogs($seleniumLogFile, $browserDriverLogFile) {135 $("#collapseOne").removeClass("show");136 $("#collapseTwo").removeClass("show");137 const seleniumLog = $("#seleniumLog");138 seleniumLog.html("Selenium Log not loaded yet...");139 const browserDriverLog = $("#browserDriverLog");140 browserDriverLog.html("Browser Driver Log not loaded yet...");141 if ($seleniumLogFile.length > 0) {142 seleniumLog.load($seleniumLogFile);143 }144 if ($browserDriverLogFile.length > 0) {145 browserDriverLog.load($browserDriverLogFile);146 }147}148function blockUi() {149 const overlay = document.getElementById("ui_blocker");150 if (overlay != null) {151 overlay.style.display = "block";152 overlay.style.right = "0px";153 overlay.style.bottom = "0px";154 overlay.addEventListener("click", function(event) {155 event.preventDefault();156 return false;157 }, false);158 }159}160function unblockUi() {161 const overlay = document.getElementById("ui_blocker");162 if (overlay != null) {163 overlay.style.display = "none";164 }165}166function searchTestsList() {167 const currentQuery = $("#search").val().toUpperCase();168 if (currentQuery !== "") {169 const tokensCrtQuery = currentQuery.split(" ");170 $(".list-group-item").each(function(){171 $(this).hide();172 const currentKeyword = $(this).text().toUpperCase() + $(this).data("browser").toUpperCase() +173 $(this).data("platform").toUpperCase() + $(this).data("test-build").toString().toUpperCase() +174 $(this).data("test-status").toUpperCase() + $(this).data("proxy-name").toUpperCase() +175 $(this).data("time-zone").toUpperCase();176 let allTokensFound = true;177 for (let i = 0; i < tokensCrtQuery.length; i++) {178 const crtToken = tokensCrtQuery[i];179 if (currentKeyword.indexOf(crtToken) < 0) {180 allTokensFound = false;181 break;182 }183 }184 if (allTokensFound) {185 $(this).show();186 }187 });188 } else {189 $(".list-group-item").show();190 }191}192$(document).ready(function() {193 // Load items as soon as the page loads194 loadDashboardItems();195 // Retrieve deltas every 15 seconds196 setInterval(function() {197 loadDashboardItems();198 }, 15000);199 $("#tests").on("click", ".list-group-item", function() {200 const $this = $(this);201 const $video = $this.data("video");202 const $testName = $this.data("test-name");203 const $browser = $this.data("browser");204 const $browserVersion = $this.data("browser-version");205 const $platform = $this.data("platform");206 const $proxyName = $this.data("proxy-name");207 const $dateTime = $this.data("date-time");208 const $retentionDate = $this.data("retention-date");209 const $seleniumLogFile = $this.data("selenium-log");210 const $browserDriverLogFile = $this.data("browser-driver");211 const $screenDimension = $this.data("screen-dimension");212 const $timeZone = $this.data("time-zone");213 const $build = $this.data("test-build");214 const $testStatus = $this.data("test-status");215 $('.active').removeClass("active");216 $this.toggleClass("active");217 // Set test info to be displayed218 setTestInformation($testName, $browser, $browserVersion, $platform, $proxyName, $dateTime,219 $screenDimension, $timeZone, $build, $testStatus, $retentionDate);220 // Pass clicked link element to another function221 playVideo($video);222 // Load logs223 loadLogs($seleniumLogFile, $browserDriverLogFile);224 // Select first tab225 $("#testTabs").find("a:first").tab("show");226 });227 $("#search").on("keyup", function () {228 searchTestsList();229 });230 $(function() {231 const url = new URL(window.location);232 const params = url.searchParams;233 const q = params.get('q');234 if (q !== null && q !== '') {235 $('#search').val(decodeURIComponent(q));236 searchTestsList();237 }238 });239 $("#cleanupButton").click(function () {240 $("#cleanupModal").modal("show");241 });242 $("#resetButton").click(function () {243 $("#resetModal").modal("show");244 });245 $("#cleanupModalConfirm").click(function () {246 $("#cleanupModal").modal("hide");247 blockUi();248 const targetUrl = [location.protocol, "//", location.host, location.pathname].join("") + "cleanup?action=doCleanup";249 $.ajax({250 type: "POST",251 url: targetUrl,252 statusCode: {253 200: function(response){254 unblockUi();255 window.location.reload();256 }257 }258 });259 });260 $("#resetModalConfirm").click(function () {261 $("#resetModal").modal("hide");262 blockUi();263 const targetUrl = [location.protocol, "//", location.host, location.pathname].join("") + "cleanup?action=doReset";264 $.ajax({265 type: "POST",266 url: targetUrl,267 statusCode: {268 200: function(response){269 unblockUi();270 window.location.reload();271 }272 }273 });274 });...

Full Screen

Full Screen

driverLogComponent.js

Source:driverLogComponent.js Github

copy

Full Screen

1"use strict";2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);5 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;6 return c > 3 && r && Object.defineProperty(target, key, r), r;7};8var __metadata = (this && this.__metadata) || function (k, v) {9 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);10};11var core_1 = require('@angular/core');12//import {ROUTER_DIRECTIVES} from '@angular/router-deprecated';13var driverLogService_1 = require('./driverLogService');14var DriverLogComponent = (function () {15 // constructor to loop the products in product service file and disply in html16 function DriverLogComponent(_driverLogService) {17 this._driverLogService = _driverLogService;18 this.driverEachDayEventNames = [];19 this.driverEachDayEventStart = [];20 this.driverEachDayEventStop = [];21 this.logEventTableData = [];22 }23 ;24 DriverLogComponent.prototype.ngOnInit = function () {25 this.driverLog = false;26 this.showMoreDriverDetails = false;27 this.dateFound = false;28 this.noLogDetails = false;29 };30 DriverLogComponent.prototype.getDriversLog = function () {31 var _this = this;32 this._driverLogService.getDriverLog().subscribe(function (response) {33 _this.driverAllLogs = response.json();34 _this.readDriversLogsFunction(_this.driverAllLogs);35 console.log(" drivers logs: ", _this.driverAllLogs);36 if (response.status == 200) {37 _this.showError = false;38 }39 else {40 _this.broadcastErrorCode = response.status;41 _this.showError = true;42 if (_this.showError = true) {43 window.scrollTo(0, 0);44 }45 }46 }, function (error) {47 _this.errorMessage = error;48 if (error != null) {49 _this.broadcastErrorCode = error;50 _this.showError = true;51 if (_this.showError = true) {52 window.scrollTo(0, 0);53 }54 }55 console.log("Options request Error : ", error.status);56 });57 };58 DriverLogComponent.prototype.readDriversLogsFunction = function (data) {59 var i;60 var j;61 var convertedDate;62 var splittedDate;63 this.driverLogKeys = Object.keys((data[0]['driverLogs']));64 if (this.driverAllLogs != null) {65 for (i = 0; i < this.driverLogKeys.length; i++) {66 //the three lines below will convert the date or list of dates recieved from driver list template to 67 // this format YYYY-MM-DD68 var dateString = new Date(this.userChoosenDate).toString();69 dateString = dateString.split(' ').slice(0, 4).join(' ');70 convertedDate = moment(dateString).format('YYYY-MM-DD');71 //this line will split date recieved from the service file in other to comapre the date with72 // the conver date above73 splittedDate = this.driverLogKeys[i].split("T");74 if (convertedDate == splittedDate[0]) {75 this.getDriverDailyLogs(data[0]['driverLogs'][this.driverLogKeys[i]]);76 this.driverLog = true;77 this.dateFound = true;78 this.displayGrapgh = true;79 this.noLogDetails = false;80 }81 }82 if (!this.dateFound) {83 this.driverLog = false;84 this.displayGrapgh = false;85 this.logEventTableData = [];86 this.noLogDetails = true;87 }88 }89 };90 DriverLogComponent.prototype.onClickRODS = function () {91 };92 DriverLogComponent.prototype.onClickYesterday = function () {93 this.dateFound = false;94 var currentDate = new Date();95 var yesterdayDate = new Date();96 yesterdayDate.setDate(currentDate.getDate() - 1);97 this.userChoosenDate = yesterdayDate;98 this.getDriversLog();99 };100 DriverLogComponent.prototype.onClickToday = function () {101 this.activeToday = true;102 this.dateFound = false;103 var currentDate = new Date();104 this.userChoosenDate = currentDate;105 this.getDriversLog();106 };107 DriverLogComponent.prototype.getDriverDailyLogs = function (data) {108 var i;109 var length = data.length;110 var localConvertedEventStartTime;111 var localConvertedEventStopTime;112 var location;113 var odometer;114 var note;115 var eventName;116 this.driverDailyLogs = data;117 this.logEventTableData = [];118 for (i = 0; i < this.driverDailyLogs.length; i++) {119 eventName = this.driverDailyLogs[i]['logEvent'];120 location = this.driverDailyLogs[i]['location'];121 odometer = this.driverDailyLogs[i]['fleetOdometerReading'];122 note = this.driverDailyLogs[i]['notes'];123 this.driverEachDayEventNames[i] = eventName;124 localConvertedEventStartTime = moment.utc(this.driverDailyLogs[i]['eventTimestamp']).zone("-05:00").format('YYYY-MM-DD HH:mm:ss');125 this.driverEachDayEventStart[i] = localConvertedEventStartTime;126 if ((this.driverDailyLogs[i]['eventEndTimestamp'] == null) && (i + 1) != length) {127 localConvertedEventStopTime = moment.utc(this.driverDailyLogs[i + 1]['eventTimestamp']).zone("-05:00").format('YYYY-MM-DD HH:mm:ss');128 this.driverEachDayEventStop[i] = localConvertedEventStopTime;129 }130 else if ((this.driverDailyLogs[i]['eventEndTimestamp'] == null) && (i + 1) == length) {131 localConvertedEventStopTime = moment.utc(this.driverDailyLogs[0]['eventTimestamp']).zone("-05:00").format('YYYY-MM-DD HH:mm:ss');132 this.driverEachDayEventStop[i] = localConvertedEventStopTime;133 }134 else {135 localConvertedEventStopTime = moment.utc(this.driverDailyLogs[i]['eventEndTimestamp']).zone("-05:00").format('YYYY-MM-DD HH:mm:ss');136 this.driverEachDayEventStop[i] = localConvertedEventStopTime;137 }138 this.getlogEventTableData(localConvertedEventStartTime, localConvertedEventStopTime, location, odometer, note, eventName);139 }140 };141 DriverLogComponent.prototype.getlogEventTableData = function (eventStartTime, eventStopTime, location, odometer, note, eventName) {142 var duration;143 var calTimeDifference;144 var splitedStartTime = eventStartTime.split(" ")[1];145 var splitedStop = eventStopTime.split(" ")[1];146 calTimeDifference = new Date(eventStopTime).getTime() - new Date(eventStartTime).getTime();147 duration = this.convertMillSecondsToTimeString(calTimeDifference);148 this.logEventTableData.push({ "eventTimestamp": splitedStartTime, "location": location, "fleetOdometerReading": odometer, "logEvent": eventName, "duration": duration, "notes": note });149 };150 DriverLogComponent.prototype.convertMillSecondsToTimeString = function (duration) {151 var oneSecond = 1000;152 var oneMinute = oneSecond * 60;153 var oneHour = oneMinute * 60;154 var seconds = Math.floor((duration % oneMinute) / oneSecond);155 var minutes = Math.floor((duration % oneHour) / oneMinute);156 var hours = Math.floor(duration / oneHour);157 var timeString = '';158 if (hours !== 0) {159 timeString += (hours !== 1) ? (hours + ' hours ') : (hours + ' hour ');160 }161 if (minutes !== 0) {162 timeString += (minutes !== 1) ? (minutes + ' minutes ') : (minutes + ' minute ');163 }164 if (seconds !== 0 || duration < 1000) {165 timeString += (seconds !== 1) ? (seconds + ' seconds ') : (seconds + ' second ');166 }167 return timeString;168 };169 // render driverLog on constant changes170 DriverLogComponent.prototype.ngOnChanges = function () {171 console.log("driverData in driver rods...", this.driverData);172 /*for (var i = 0; i < this.driverList.length; i++) {173 var logData = this.driverList[i];174 if (logData.driverId == this.selectedDriverID.driverId) {175 this.driverLog = logData;176 // console.log(this.fleetSummary);177 break;178 } else {179 this.driverLog = null;180 }181 }*/182 };183 __decorate([184 core_1.Input(), 185 __metadata('design:type', Array)186 ], DriverLogComponent.prototype, "driverData", void 0);187 __decorate([188 core_1.Input(), 189 __metadata('design:type', Object)190 ], DriverLogComponent.prototype, "sendDriverData", void 0);191 DriverLogComponent = __decorate([192 core_1.Component({193 selector: 'driver-log',194 templateUrl: 'app/dashboard/features/drivers/driverLog/driverLogTemplate.html',195 }), 196 __metadata('design:paramtypes', [driverLogService_1.DriverLogService])197 ], DriverLogComponent);198 return DriverLogComponent;199}());...

Full Screen

Full Screen

socketController.js

Source:socketController.js Github

copy

Full Screen

1/* Server에서 event 를 emit 하고 on하는 파일 */2const events = require("./events");3const Station = require("db/models/Station");4const Course = require("db/models/Course");5const CourseLog = require("db/models/CourseLog");6const DriverLog = require("db/models/DriverLog");7// socket: 연결된 소켓, io: 전역소켓(Server Socket)8const socketController = (socket, io) => {9 let room = '';10 let group = '';11 console.log("❤ socket connecting success!!");12 // Driver가 활성화 되어있는지에 대하여 받는다.13 socket.on(events.driverActive, ({ driver, active }) => {14 // driver: 드라이버 유저정보 객체15 // 해당 Driver를 즐겨찾기한 User들에게(집단) 이를 알린다.16 socket.emit(events.sendNotifDriverActive, { driver, active }); // 보내는 Data는 딱히 없다.17 });18 socket.on(events.joinRoom, async ({ roomName, driver }) => {19 console.log(driver);20 room = roomName;21 if (driver) {22 CourseLog.register({ courseId: roomName });23 }24 socket.join(roomName, function () {25 console.log("enter Romm", roomName);26 });27 });28 /* 29 socket Listening to user 30 */31 socket.on(events.isDriverActive, ({ roomName }) => {32 io.to(roomName).emit(events.findDriver);33 });34 socket.on("disconnect", (a)=>{35 // io.to(room).emit("driverDeActive");36 console.log(a._id)37 });38 socket.on("asd", (a)=>{39 // io.to(room).emit("driverDeActive");40 console.log(a)41 console.log("asdasd")42 });43 socket.on(events.findedDriver, ({ roomName, groupId }) => {44 group = groupId;45 io.to(roomName).emit(events.driverActive, { roomName, groupId });46 });47 // refresh에 대한 이벤트48 socket.on(events.requestLocation, ({ roomName, driverLogId, name }) => {49 io.to(roomName).emit(events.requestLocationToDriver, {50 roomName,51 driverLogId,52 name,53 });54 console.log("send to ", roomName, driverLogId, name);55 });56 socket.on(57 events.receiveGPS,58 async ({ data, driverId, driverLogId, name }) => {59 console.log("asdasdawdasd", driverLogId, "and", name);60 const course = await Course.findById({ _id: data.roomName });61 const locations = await Station.getNearStation({62 longitude: data.longitude,63 latitude: data.latitude,64 });65 // const result = await locations.findByCourseId({66 // courseId: data.roomName,67 // });68 console.log(data.aa,'정보')69 console.log(data.longitude, data.latitude,'위치정보')70 console.log("가까운 정류장", locations);71 /* 계산 과정이 들어갈곳 */72 let driverLog = "";73 console.log("course::::::", course);74 const locationName = locations;75 // DriverLog 최초생성76 if (driverId) {77 /* 해야할 일 : location만들기 */78 const firstStation = course.stations[0];79 // const name = firstStation.get("stationName");80 // const location = {81 // longitude: firstStation.get("longitude"),82 // latitude: firstStation.get("latitude"),83 // };84 // console.log("location::::::::", firstStation);85 // driverLog = DriverLog.register({ driverId, name, location });86 // io.to(data.roomName).emit(events.driverLogSave, { driverLog });87 // io.to(data.roomName).emit(events.sendLocation, {88 // locationName,89 // driverLog,90 // });91 // *****************임시*******************92 if(locations.length != 0) {93 const locationList = locations.filter(94 (obj) => obj.courseId == data.roomName95 );96 location = {97 longitude: locationList[0].location.coordinates[0],98 latitude: locationList[0].location.coordinates[1],99 }100 // console.log("같아요", locationList[0].name, name);101 102 if (locationList[0].name !== name || !driverLog) {103 driverLog = await DriverLog.register({104 driverId,105 name: locationList[0].name,106 location,107 });108 io.to(data.roomName).emit(events.driverLogSave, { driverLog });109 }110 111 const groupId = await Course.findById({ _id: data.roomName });112 console.log("testGRIPPPPPPPPPPPPPPPPPPP", groupId.group);113 // 서버 -> 같은 룸안의 유저들 [위치정보+드라이버로그]114 io.to(data.roomName).emit(events.sendLocation, {115 locationName: locationList[0].name,116 data,117 driverLog,118 distance: locationList[0].distance,119 groupId: groupId.group,120 });121 }else { 122 const groupId = await Course.findById({ _id: data.roomName });123 io.to(data.roomName).emit(events.sendLocation, {124 locationName: null,125 data,126 driverLog: null,127 distance: null,128 groupId: groupId.group,129 });130 }131 // 서버 -> 드라이버 [드라이버로그]132 // if (locations[k].courseId == data.roomName) {133 // console.log("first:::::::", locations[k].location.coordinates);134 // driverLog = await DriverLog.register({135 // driverId,136 // name: locations[k].name,137 // location,138 // });139 // // 서버 -> 같은 룸안의 유저들 [위치정보+드라이버로그]140 // io.to(data.roomName).emit(events.sendLocation, {141 // locationName: locations[k].name,142 // data,143 // driverLog,144 // });145 // // 서버 -> 드라이버 [드라이버로그]146 // io.to(data.roomName).emit(events.driverLogSave, { driverLog });147 // }148 // ****************************************149 }150 // 드라이버 로그가 있을때151 if (driverLogId) {152 console.log("location:::::", locations);153 }154 /* DriverLog 업데이트: 로컬저장소에서 DriverLog _id를 가져다 활용 */155 /* DriverLog를 갱신하는 조건: DriverLog 아이디가 있다면...*/156 // DriverLogId로 DriverLog 불러오기157 // 불러온 정보의 name과 가장가까운 정거장 Name을 비교158 // 같다면 locationLog만 업데이트, 아니라면 새로운 DriverLog 생성후 Client에게 새로운 DriverLog까지 전달159 // console.log(locationName);160 // // 나중에 계산된 내용을 locationName에 넣어 보내주자 + DriverLog까지161 console.log("log_______________:", driverLog);162 // io.to(data.roomName).emit(events.sendLocation, {163 // locationName,164 // });165 }166 );167 socket.on(events.courseActive, async ({ courseId }) => {168 console.log(courseId);169 const course = await Course.findById({ _id: courseId });170 console.log(courseName.courseName);171 io.sockets.emit(events.notifiCourseActive, {172 courseName: course.courseName,173 });174 });175 176};...

Full Screen

Full Screen

dthelper.js

Source:dthelper.js Github

copy

Full Screen

1var persist = require("persist"),2 type = persist.type,3 util = require("util"),4 Area = require("./model/area"),5 Driver = require("./model/driver"),6 DriverLog = require("./model/driver_log"),7 Booking = require("./model/booking"),8 events = require('events');9function DataHelper(options) {10 this.options = options;11 this.connection = null;12};13util.inherits(DataHelper, events.EventEmitter);14DataHelper.prototype.initConnection = function(){15 var that = this;16 persist.connect(function(error, pConnection) {17 if(error) {18 that.emit("data_helper_exception", error); 19 } else {20 that.connection = pConnection;21 that.emit("connection_ready");22 }23 })24}25DataHelper.prototype.getNumberOfAvailableTaxiesInTimeBlock = function(blockStart, blockEnd) {26 var numOfDriversPerArea = {};27 var that = this;28 var driverLog = null;29 DriverLog.where("time >= ? and time < ? and isAvailable = ?", [blockStart, blockEnd, DriverLog.DRIVER_STATUS_AVAILABLE])30 .all(that.connection, function(error, driveLogs){31 if(error) {32 //Throw exception33 that.emit("data_helper_exception", error);34 return ;35 }else{36 for(var i = 0 ; i < driveLogs.length ; i++) {37 driverLog = driveLogs[i];38 if(numOfDriversPerArea[driverLog.areaId]) {39 numOfDriversPerArea[driverLog.areaId] += driverCount;40 } else {41 numOfDriversPerArea[driverLog.areaId] = 0;42 }43 }44 that.emit("number_of_drivers_ready", numOfDriversPerArea);45 } 46 });47}48DataHelper.prototype.getNumberOfMissedBookingInTimeBlock = function(blockStart, blockEnd) {49 var numberOfBookingsPerArea = {};50 var numberOfMissedBookingsPerArea = {};51 var that = this;52 Booking.where("time > ? and time < ?", [blockStart, blockEnd])53 .all(that.connection, function (error, bookings){54 if(error) {55 //Throw exception56 that.emit("data_helper_exception", error);57 return;58 }59 var areaId = 0;60 for(var i = 0 ; i < bookings.length; i++) {61 areaId = "" + bookings[i].area_id;62 if(numberOfBookingsPerArea[areaId] >= 0) {63 numberOfBookingsPerArea[areaId]++; 64 } else {65 numberOfBookingsPerArea[areaId] = 1; 66 }67 if(!bookings[i].driver_id) {68 if(numberOfMissedBookingsPerArea[areaId] >= 0) {69 numberOfMissedBookingsPerArea[areaId]++; 70 } else {71 numberOfMissedBookingsPerArea[areaId] = 1; 72 } 73 }74 }75 that.emit("number_of_bookings_ready", [numberOfBookingsPerArea, numberOfMissedBookingsPerArea]);76 });77}78DataHelper.prototype.getAreasDetail = function(areaIds) {79 var that = this;80 Area.whereIn('id', areaIds).all(that.connection,function(error, areas){81 if(error) {82 //Throw exception83 that.emit("data_helper_exception", error);84 return;85 } else {86 that.emit("get_detail_done", areas);87 }88 });89}...

Full Screen

Full Screen

livy-ui.js

Source:livy-ui.js Github

copy

Full Screen

1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17// entityMap and escapeHtml are from mustache.js18var entityMap = {19 '&': '&amp;',20 '<': '&lt;',21 '>': '&gt;',22 '"': '&quot;',23 "'": '&#39;',24 '/': '&#x2F;',25 '`': '&#x60;',26 '=': '&#x3D;'27};28var basePath = "";29function escapeHtml(string) {30 return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {31 return entityMap[s];32 });33}34function uiLink(relativePath, inner) {35 return anchorLink(prependBasePath("/ui/") + relativePath, inner);36}37function anchorLink(link, inner) {38 return '<a href="' + link + '">' + inner + "</a>";39}40function driverLogLink(session) {41 var driverLogUrl = session.appInfo.driverLogUrl;42 if (driverLogUrl != null) {43 return anchorLink(driverLogUrl, "driver");44 } else {45 return "";46 }47}48function logLinks(session, kind) {49 var sessionLog = divWrap(uiLink(kind + "/" + session.id + "/log", "session"));50 var driverLog = divWrap(driverLogLink(session));51 return sessionLog + driverLog;52}53function appIdLink(session) {54 var appUiUrl = session.appInfo.sparkUiUrl;55 if (appUiUrl != null) {56 return anchorLink(appUiUrl, session.appId);57 } else {58 return session.appId;59 }60}61function tdWrap(val) {62 var inner = "";63 if (val != null) {64 inner = val;65 }66 return "<td>" + inner + "</td>";67}68function preWrap(inner) {69 return "<pre>" + escapeHtml(inner) + "</pre>";70}71function divWrap(inner) {72 return "<div>" + inner + "</div>";73}74function progressBar(double) {75 var cent = +(double * 100).toFixed(3);76 return '<div class="progress"><div class="progress-bar" style="width:'77 + cent + '%"><span>' + cent + '%</span></div></div>';78}79function getPathArray() {80 var pathArr = location.pathname.split("/");81 var baseUrlEnd = 2 + (basePath.match(/\//g) || []).length;82 pathArr.splice(0, baseUrlEnd);83 return pathArr;84}85function setBasePath(path) {86 basePath = path;87}88function prependBasePath(path) {89 return basePath + path;90}91$.extend( $.fn.dataTable.defaults, {92 stateSave: true,...

Full Screen

Full Screen

driverSocket.js

Source:driverSocket.js Github

copy

Full Screen

1import storage from "lib/storage.js";2export const baseListening = (socket, roomName, groupId, ListActions) => {3 socket.on("disconnected", () => {4 socket.emit("asd", "asd" );5 });6 socket.on("findDriver", () => {7 socket.emit("findedDriver", { roomName, groupId });8 });9 socket.on("requestLocationToDriver", ({ roomName, driverLogId, name }) => {10 const getLocation = () => {11 if (navigator.geolocation) {12 navigator.geolocation.getCurrentPosition(showPosition,errorAlert,{13 enableHighAccuracy: true,14 timeout: Infinity15 });16 } else {17 console.log("현재 브라우져에서는 위치정보기능을 기원하지 않습니다!");18 }19 };20 const errorAlert = ()=>{21 console.log("error")22 }23 const showPosition = (position) => {24 const data = {25 longitude: position.coords.longitude,26 latitude: position.coords.latitude,27 aa: position.coords.accuracy,28 roomName29 };30 console.log(data.longitude,data.latitude,'현재위치')31 socket.emit("receiveGPS", { data, driverLogId, name });32 };33 getLocation();34 });35 socket.on("driverLogSave", ({ driverLog }) => {36 storage.set("driverLog", driverLog);37 });38};39export const joinRoom = (socket, roomName) => {40 const driver = true;41 socket.emit("joinRoom", { roomName, driver });42};43export const sendDriverGPS = (socket, roomName, driverLogId, name) => {44 const driverLog = storage.get("driverLog");45 const errorAlert = ()=>{46 console.log("error")47 }48 const getLocation = () => {49 if (navigator.geolocation) {50 navigator.geolocation.getCurrentPosition(showPosition,errorAlert,{51 enableHighAccuracy: true,52 timeout: Infinity53 });54 } else {55 console.log("현재 브라우져에서는 위치정보기능을 기원하지 않습니다!");56 }57 };58 const showPosition = (position) => {59 const driverId = storage.get("loggedInfo")._id;60 const data = {61 longitude: position.coords.longitude,62 latitude: position.coords.latitude,63 aa: position.coords.accuracy,64 roomName65 };66 socket.emit("receiveGPS", {67 data,68 driverId,69 name: driverLog ? driverLog.name : driverLog,70 });71 };72 getLocation();73 // 여기 수정하면74 setInterval(() => {75 getLocation();76 }, 2000);...

Full Screen

Full Screen

listSocket.js

Source:listSocket.js Github

copy

Full Screen

1import storage from "../lib/storage";2export const baseEmiter = (socket, mylist, driverLog) => {3 for (let i in mylist.groupList) {4 for (let k in mylist.groupList[i].courses) {5 socket.emit("joinRoom", { roomName: mylist.groupList[i].courses[k] });6 socket.emit("isDriverActive", {7 roomName: mylist.groupList[i].courses[k],8 });9 if (driverLog) {10 socket.emit("requestLocation", {11 roomName: mylist.groupList[i].courses[k],12 driverLogId: driverLog._id,13 name: driverLog.name,14 });15 }16 // console.log("testdddd", driverLog.name, driverLog._id);17 }18 }19};20export const baseListening = (socket, ListActions) => {21 socket.on("driverActive", ({ groupId, roomName }) => {22 console.log("드라이버 있음");23 console.log(roomName, groupId, ListActions);24 ListActions.activeUpdate({ groupId, courseId: roomName });25 });26 socket.on("driverDeActive", ({ groupId, roomName }) => {27 console.log("드라이버 있음");28 console.log(roomName, groupId, ListActions);29 ListActions.activeUpdate({ groupId, courseId: roomName });30 });31 socket.on(32 "sendLocation",33 ({ locationName, data, driverLog, distance, groupId }) => {34 console.log("driverLog:::::::::", driverLog);35 console.log(36 "locations:::::::::::::::::::",37 locationName,38 data,39 distance,40 groupId41 );42 // nextStation, distPer, groupId, courseId43 console.log("ListActions======", ListActions);44 ListActions.courseUpdate({45 nextStation: locationName,46 distPer: distance,47 groupId,48 courseId: data.roomName,49 data,50 });51 ListActions.getDriverLoc({ locData: data });52 if (driverLog) {53 storage.set("driverLog", driverLog);54 }55 // driverLog ? storage.set("driverLog", driverLog) : null;56 }57 );58};59function DriverListSoc(socket, ListActions, mylist) {}...

Full Screen

Full Screen

driverLogService.js

Source:driverLogService.js Github

copy

Full Screen

1"use strict";2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);5 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;6 return c > 3 && r && Object.defineProperty(target, key, r), r;7};8var __metadata = (this && this.__metadata) || function (k, v) {9 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);10};11var core_1 = require('@angular/core');12var http_1 = require('@angular/http');13var Observable_1 = require('rxjs/Observable');14var DriverLogService = (function () {15 function DriverLogService(_http) {16 this._http = _http;17 // private url = 'http://QA-Test-JFS-PlatformService.us-east-1.elasticbeanstalk.com/fleetops/driver/driverLogs?driverId=66&&timestamp=2017-12-09T07:33:20Z';18 this.url = 'app/dashboard/features/drivers/driverLog/driverLogData.json';19 }20 DriverLogService.prototype.extractData = function (response) {21 var requestResponse = response;22 return requestResponse || {};23 };24 DriverLogService.prototype.getDriverLog = function () {25 return this._http.get(this.url)26 .map(this.extractData)27 .catch(this.handleError);28 };29 DriverLogService.prototype.handleError = function (error) {30 console.error(error);31 return Observable_1.Observable.throw(error.json().error || "Server error");32 };33 DriverLogService = __decorate([34 core_1.Injectable(), 35 __metadata('design:paramtypes', [http_1.Http])36 ], DriverLogService);37 return DriverLogService;38}());...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = require('appium-xcuitest-driver');2driver.log('test');3var driver = require('appium-xcuitest-driver');4driver.log('test');5var driver = require('appium-xcuitest-driver');6driver.log('test');7var driver = require('appium-xcuitest-driver');8driver.log('test');9var driver = require('appium-xcuitest-driver');10driver.log('test');11var driver = require('appium-xcuitest-driver');12driver.log('test');13var driver = require('appium-xcuitest-driver');14driver.log('test');15var driver = require('appium-xcuitest-driver');16driver.log('test');17var driver = require('appium-xcuitest-driver');18driver.log('test');19var driver = require('appium-xcuitest-driver');20driver.log('test');21var driver = require('appium-xcuitest-driver');22driver.log('test');23var driver = require('appium-xcuitest-driver');24driver.log('test');25var driver = require('appium-xcuitest-driver');26driver.log('test');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { exec } = require('child_process');2const fs = require('fs');3function sleep(ms) {4 return new Promise(resolve => setTimeout(resolve, ms));5}6async function main() {7 const proc = exec('node ./node_modules/appium/build/lib/main.js --log-level info');8 const logs = fs.createWriteStream('appium.log');9 proc.stdout.pipe(logs);10 proc.stderr.pipe(logs);11 await sleep(5000);12 proc.kill('SIGINT');13}14main();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { driver } = require('./driver');2driver.log('info', 'This is a test log message');3const { remote } = require('webdriverio');4exports.driver = remote({5 capabilities: {6 }7});

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = require('appium-xcuitest-driver').driver;2driver.log('Hello World');3driver.log('Hello World', 'error');4driver.log('Hello World', 'info');5driver.log('Hello World', 'warn');6driver.log('Hello World', 'error');7driver.log('Hello World', 'fatal');

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const assert = require('assert');3const {asserters} = wd;4const { exec } = require('child_process');5const driver = wd.promiseChainRemote('localhost', 4723);6driver.init({7}).then(() => {8 return driver.log('error');9}).then((logs) => {10 console.log(logs);11}).catch((err) => {12 console.log(err);13});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful