@cypress/core-desktop-gui
Version:
Desktop GUI for managing Cypress projects.
41 lines (30 loc) • 887 B
text/coffeescript
@App.module "Entities", (Entities, App, Backbone, Marionette, $, _) ->
class Entities.Log extends Entities.Model
mutators:
dataFormatted: ->
return "" if _.isEmpty(@get("data"))
try
data = JSON.stringify(@get("data"))
_.str.truncate(data, 85)
catch
""
timestampFormatted: ->
if date = @get("timestamp")
moment(date).fromNow(true)
class Entities.LogsCollection extends Entities.Collection
model: Entities.Log
comparator: (log) ->
if date = log.get("timestamp")
-moment(date).unix()
refresh: ->
@reset()
@fetch()
fetch: ->
App.ipc("get:logs").bind(@).then(@add)
API =
getLogs: ->
logs = new Entities.LogsCollection
logs.fetch()
logs
App.reqres.setHandler "log:entities", (transport) ->
API.getLogs(transport)