Skip to content

Commit

Permalink
display current version of lantern in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd Blose committed Feb 24, 2015
1 parent d4288fc commit 04e0dce
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/github.com/getlantern/flashlight/flashlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/getlantern/flashlight/geolookup"
"github.com/getlantern/flashlight/proxiedsites"
"github.com/getlantern/flashlight/server"
"github.com/getlantern/flashlight/settings"
"github.com/getlantern/flashlight/statreporter"
"github.com/getlantern/flashlight/statserver"
"github.com/getlantern/flashlight/ui"
Expand Down Expand Up @@ -135,6 +136,8 @@ func runClientProxy(cfg *config.Config) {
ui.Show()
}

settings.Configure(version, buildDate)

proxiedsites.Configure(cfg.ProxiedSites)
if hqfd == nil {
log.Errorf("No fronted dialer available, not enabling geolocation or stats")
Expand Down
41 changes: 41 additions & 0 deletions src/github.com/getlantern/flashlight/settings/settings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// service for exchanging current user settings with UI
package settings

import (
"github.com/getlantern/flashlight/ui"
"github.com/getlantern/golog"
)

const (
messageType = `Settings`
)

var (
log = golog.LoggerFor("flashlight.settings")
service *ui.Service
)

type Settings struct {
Version string
BuildDate string
}

func Configure(version, buildDate string) {
// base settings are always written
baseSettings := &Settings{
Version: version,
BuildDate: buildDate,
}
start(baseSettings)
}

func start(baseSettings *Settings) error {
var err error
helloFn := func(write func(interface{}) error) error {
log.Debugf("Sending Lantern settings to new client")
return write(baseSettings)
}

service, err = ui.Register(messageType, nil, helloFn)
return err
}
4 changes: 4 additions & 0 deletions src/github.com/getlantern/lantern-ui/app/_css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -8040,6 +8040,10 @@ body.giveMode #npending {
color: red;
}

#appInfo span.version {
color: #eeeeee;
}

@-webkit-keyframes defaultPulse {
from {
opacity: 1;
Expand Down
17 changes: 0 additions & 17 deletions src/github.com/getlantern/lantern-ui/app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,29 +157,12 @@ var app = angular.module('app', [
prettyUserFltr = $filter('prettyUser'),
reportedStateFltr = $filter('reportedState');

// configure settings
// set default client to get-mode
model.settings = {};
model.settings.mode = 'get';

// for easier inspection in the JavaScript console
$window.rootScope = $rootScope;
$window.model = model;

$rootScope.EXTERNAL_URL = EXTERNAL_URL;

$http.get('data/package.json').
success(function(pkg, status, headers, config) {
var version = pkg.version,
components = version.split('.'),
major = components[0],
minor = components[1],
patch = (components[2] || '').split('-')[0];
$rootScope.lanternUiVersion = [major, minor, patch].join('.');
}).error(function(data, status, headers, config) {
console.log("Error retrieving UI version!");
});

$rootScope.model = model;
$rootScope.DEFAULT_AVATAR_URL = 'img/default-avatar.png';
$rootScope.CONTACT_FORM_MAXLEN = CONTACT_FORM_MAXLEN;
Expand Down
10 changes: 10 additions & 0 deletions src/github.com/getlantern/lantern-ui/app/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ angular.module('app.services', [])
model.location.resolved = true;
}
},
'Settings': function(data) {
console.log('Got Lantern default settings: ', data);
if (data && data.Version) {
// configure settings
// set default client to get-mode
model.settings = {};
model.settings.mode = 'get';
model.settings.version = data.Version + "(" + data.BuildDate + ")";
}
},
'ProxiedSites': function(data) {
if (!$rootScope.entries) {
console.log("Initializing proxied sites entries", data.Additions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@

<div id="appInfo">
<a ng-click="showModal('welcome')">{{ 'LANTERN' | translate }}</a>
{{ model.version.installed | version:true }}
<span ng-show="model.version.updateAvailable" class="update-available">
· <i class="icon-exclamation-sign"></i>
<a ng-click="interaction(INTERACTION.updateAvailable)">{{ 'UPDATE_AVAILABLE_TITLE' | translate }}</a>
</span>
<span class="version">{{ model.settings.version }}</span>
<span>
· <a ng-click="showModal('about')">{{ 'ABOUT' | translate }}</a>
</span>
Expand Down

0 comments on commit 04e0dce

Please sign in to comment.