From d3a17dd93bbe947b0cd4ae38a29791fff6a316b4 Mon Sep 17 00:00:00 2001 From: fazo96 Date: Mon, 29 Sep 2014 10:14:30 +0200 Subject: [PATCH] fix #21, also fixed #13 sometime in the past --- client/client.coffee | 34 ++++++++++++++++++++++++++++++---- client/view/style.css | 4 ++++ client/view/templates.html | 30 ++++++++++++++++++++++-------- 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/client/client.coffee b/client/client.coffee index 660dc62..1e7f7b9 100644 --- a/client/client.coffee +++ b/client/client.coffee @@ -1,8 +1,10 @@ # Homework - Client Side -homework_version = "1.0" # Utilities +tick = new Deps.Dependency() +Meteor.setInterval (-> tick.changed();), 15000 + notes = new Meteor.Collection "notes" -Meteor.subscribe 'user' +userSub = Meteor.subscribe 'user' getUser = -> Meteor.user() deleteAccount = -> Meteor.call 'deleteMe', (r) -> if r is yes then Router.go 'home' @@ -11,7 +13,9 @@ amIValid = -> return yes for mail in getUser().emails when mail.verified is yes; no # Common Helpers for the Templates -UI.registerHelper "loggingIn", -> Meteor.loggingIn() +UI.registerHelper "version", -> "1.1.1" +UI.registerHelper "status", -> Meteor.status() +UI.registerHelper "loading", -> Meteor.loggingIn() or !Meteor.status().connected UI.registerHelper "email", -> if getUser() then return getUser().emails[0].address UI.registerHelper "verified", -> amIValid() @@ -27,13 +31,28 @@ Router.configure layoutTemplate: 'layout' loadingTemplate: 'loading' notFoundTemplate: '404' + action: -> + if Meteor.status().connected is no + @render 'reconnect' + else if Meteor.loggingIn() + @render 'loading' + else @render() loggedInController = RouteController.extend - action: -> if @ready then @render() else @render 'loading' + action: -> + if Meteor.status().connected is no + @render 'reconnect' + else if !@ready() or Meteor.loggingIn() + @render 'loading' + else @render() onBeforeAction: -> if not getUser() then Router.go 'home' if not amIValid() then Router.go 'verifyEmail' guestController = RouteController.extend + action: -> + if Meteor.status().connected is no + @render 'reconnect' + else @render() onBeforeAction: -> if getUser() if not amIValid() then Router.go 'verifyEmail' else Router.go 'home' @@ -63,6 +82,7 @@ Router.map -> @route 'verifyEmail', path: '/verify/:token?' template: 'verifyEmail' + controller: guestController onBeforeAction: -> # Automatic verification if @params.token? and @params.token isnt "" @@ -93,6 +113,11 @@ errCallback = (err) -> showError msg: err.reason else showErrror msg: err +Template.reconnect.time = -> + tick.depend() + if Meteor.status().retryTime + '(retrying '+moment(Meteor.status().retryTime).fromNow()+')' + # 3 Buttons navigation Menu Template.menu.events 'click .go-home': -> Router.go 'home' @@ -118,6 +143,7 @@ Template.notelist.active = -> Template.notelist.empty = -> Template.notelist.notelist().length is 0 Template.notelist.getDate = -> return unless @date + tick.depend() #dif = moment(@date, getUser().dateformat).diff(moment(), 'days') dif = moment.unix(@date).diff(moment(), 'days') color = "primary" diff --git a/client/view/style.css b/client/view/style.css index 3737503..10fef3f 100644 --- a/client/view/style.css +++ b/client/view/style.css @@ -9,6 +9,10 @@ input { text-align: center; } +.links { + margin-bottom: 10px; +} + .close { clear:both; } diff --git a/client/view/templates.html b/client/view/templates.html index e860df9..2eab2f1 100644 --- a/client/view/templates.html +++ b/client/view/templates.html @@ -105,13 +105,13 @@


Sign In

{{> error}} - {{#if loggingIn}} + {{#if loading}} {{> loading}} {{else}} {{/if}} - {{#unless loggingIn}} + {{#unless loading}} Sign Up @@ -126,7 +126,7 @@ + + @@ -249,7 +263,7 @@