Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekn committed Sep 16, 2015
0 parents commit 64a2a8e
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
/node_modules
/.tmp
5 changes: 5 additions & 0 deletions README.md
@@ -0,0 +1,5 @@
# interstellar-simple-client

1. `npm install`
1. `npm install -g interstellar`
1. `interstellar develop`
11 changes: 11 additions & 0 deletions config.json
@@ -0,0 +1,11 @@
{
"modules": {
"interstellar-network": {
"horizon": {
"secure": true,
"hostname": "horizon-testnet.stellar.org",
"port": 443
}
}
}
}
50 changes: 50 additions & 0 deletions controllers/login.controller.es6
@@ -0,0 +1,50 @@
import {Intent} from "interstellar-core";
import {Controller, Inject} from "interstellar-core";
import {Keypair} from 'stellar-base';
import {Alert, AlertGroup} from 'interstellar-ui-messages';

@Controller("LoginController")
@Inject("$scope", "interstellar-core.IntentBroadcast", "interstellar-sessions.Sessions", "interstellar-ui-messages.Alerts")
export default class LoginController {
constructor($scope, IntentBroadcast, Sessions, Alerts) {
this.$scope = $scope;
this.IntentBroadcast = IntentBroadcast;
this.Sessions = Sessions;

if (this.Sessions.hasDefault()) {
this.broadcastShowDashboardIntent();
}

this.alerts = new AlertGroup();
Alerts.registerGroup(this.alerts);
}

broadcastShowDashboardIntent() {
this.IntentBroadcast.sendBroadcast(
new Intent(
Intent.TYPES.SHOW_DASHBOARD
)
);
}

submit() {
this.alerts.clear();
let secret = this.secret;
try {
let keypair = Keypair.fromSeed(secret);
let address = keypair.address();
this.Sessions.createDefault({address, secret})
.then(() => {
this.broadcastShowDashboardIntent();
});
} catch(e) {
let alert = new Alert({
title: 'Secret is invalid',
text: 'Make sure you are using a correct secret to login.',
type: Alert.TYPES.ERROR,
dismissible: false // default true
});
this.alerts.show(alert);
}
}
}
Empty file added head.es6
Empty file.
20 changes: 20 additions & 0 deletions index.html
@@ -0,0 +1,20 @@
<!doctype html>
<html class="no-js">
<head>
<!-- mcs:content-base -->
<meta charset="utf-8">
<title>Stellar Client</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="main.css" />
<script src="vendor.bundle.js"></script>
<script src="head.bundle.js"></script>
</head>
<body>
<div ui-view>
Loading...
</div>

<script src="main.bundle.js"></script>
</body>
</html>
62 changes: 62 additions & 0 deletions main.es6
@@ -0,0 +1,62 @@
require("file?name=index.html!./index.html");

require('./styles/main.header.scss');
require('./styles/main.footer.scss');

import interstellarCore, {App, Intent} from "interstellar-core";
import interstellarNetwork from "interstellar-network";
import interstellarNetworkWidgets from "interstellar-network-widgets";
import interstellarSessions from "interstellar-sessions";
import interstellarUiMessages from "interstellar-ui-messages";

let config = require('./config.json');
const app = new App("interstellar-simple", config);

app.use(interstellarCore);
app.use(interstellarNetwork);
app.use(interstellarNetworkWidgets);
app.use(interstellarSessions);
app.use(interstellarUiMessages);

app.templates = require.context("raw!./templates", true);
app.controllers = require.context("./controllers", true);

app.routes = ($stateProvider) => {
$stateProvider.state('login', {
url: "/",
templateUrl: "interstellar-simple/login"
});
$stateProvider.state('dashboard', {
url: "/dashboard",
templateUrl: "interstellar-simple/dashboard",
requireSession: true
});
};

// Register BroadcastReceivers
let registerBroadcastReceivers = ($state, IntentBroadcast) => {
IntentBroadcast.registerReceiver(Intent.TYPES.SHOW_DASHBOARD, intent => {
$state.go('dashboard');
});

IntentBroadcast.registerReceiver(Intent.TYPES.LOGOUT, intent => {
$state.go('login');
});
};
registerBroadcastReceivers.$inject = ["$state", "interstellar-core.IntentBroadcast"];
app.run(registerBroadcastReceivers);

let goToMainStateWithoutSession = ($state, $rootScope, Sessions) => {
$rootScope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams) => {
let hasDefault = Sessions.hasDefault();
if (toState.requireSession && !hasDefault) {
event.preventDefault();
$state.go('login');
}
})
};

goToMainStateWithoutSession.$inject = ["$state", "$rootScope", "interstellar-sessions.Sessions"];
app.run(goToMainStateWithoutSession);

app.bootstrap();
23 changes: 23 additions & 0 deletions package.json
@@ -0,0 +1,23 @@
{
"name": "interstellar-simple-client",
"version": "0.0.1",
"private": true,
"description": "The stellar.org modular client",
"scripts": {
"test": "gulp test"
},
"author": "Stellar Development Foundation <stellar@stellar.org>",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "http://github.com/stellar/interstellar-client.git"
},
"dependencies": {
"interstellar-core": "~0.0.2",
"interstellar-sessions": "~0.0.4",
"interstellar-network": "~0.0.8",
"interstellar-network-widgets": "~0.0.11",
"interstellar-ui-messages": "~0.0.2",
"stellar-base": "~0.4.2"
}
}
Empty file added styles/main.footer.scss
Empty file.
2 changes: 2 additions & 0 deletions styles/main.header.scss
@@ -0,0 +1,2 @@
@import "solar-css/lib/index";
@import "solar-css/styles/index";
10 changes: 10 additions & 0 deletions templates/dashboard.template.html
@@ -0,0 +1,10 @@
<interstellar-ui-messages-toast></interstellar-ui-messages-toast>

<div class="app-dashboard-webApp">
<div class="app-dashboard-webApp__content app-balances-container">
<p class="app-balances-title">Current balance</p>
<interstellar-network-widgets-balance></interstellar-network-widgets-balance>
<p class="app-balances-title">Send</p>
<interstellar-network-widgets-send></interstellar-network-widgets-send>
</div>
</div>
9 changes: 9 additions & 0 deletions templates/login.template.html
@@ -0,0 +1,9 @@
<div ng-controller="interstellar-simple.LoginController as login">
<form ng-submit="login.submit()">
<interstellar-ui-messages-alerts group="login.alerts"></interstellar-ui-messages-alerts>
Secret:
<input type="password" ng-model="login.secret" />
<br />
<button type="submit">Login</button>
</form>
</div>

0 comments on commit 64a2a8e

Please sign in to comment.