Skip to content

Commit

Permalink
Merge pull request #496 from DemocracyEarth/simplelogger
Browse files Browse the repository at this point in the history
Simple sing in mechanic.
  • Loading branch information
santisiri authored Feb 7, 2020
2 parents 0b825ff + 029a5b8 commit a5cd0ac
Show file tree
Hide file tree
Showing 13 changed files with 2,625 additions and 1,190 deletions.
11 changes: 6 additions & 5 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,11 @@
"guild-voting-addresses": "Voters",
"replica-person": "Profile.",
"replica-score": "Personhood",
"replica-detail-very-human": "🤠 Definitely a human.",
"replica-detail-likely-human": "🐵 Certainly a human.",
"replica-detail-very-human": "🤠 Definitely human.",
"replica-detail-likely-human": "🐵 Certainly human.",
"replica-detail-maybe-human": "👽 Uncertain if human or robot.",
"replica-detail-unlikely-human": "🤖 Certainly a robot.",
"replica-detail-not-human": "👾 Definitely a robot.",
"replica-detail-unknown-human": "😔 Unknown score."
"replica-detail-unlikely-human": "🤖 Certainly robot.",
"replica-detail-not-human": "👾 Definitely robot.",
"replica-detail-unknown-human": "😔 Unknown score.",
"sign-out-prompt": "Sign out from current account?"
}
2 changes: 2 additions & 0 deletions imports/ui/templates/components/collective/collective.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { Session } from 'meteor/session';
import { Router } from 'meteor/iron:router';

import { $ } from 'meteor/jquery';

import { Collectives } from '/imports/api/collectives/Collectives';
Expand Down
39 changes: 38 additions & 1 deletion imports/ui/templates/layout/authentication/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@ import { $ } from 'meteor/jquery';
import { Meteor } from 'meteor/meteor';
import { Router } from 'meteor/iron:router';

import { TAPi18n } from 'meteor/tap:i18n';
import { displayModal } from '/imports/ui/modules/modal';

import { publishContract, createContract, contractURI, entangle, getURLDate } from '/imports/startup/both/modules/Contract';
import { editorFadeOut } from '/imports/ui/templates/components/decision/editor/editor';
import { displayPopup, animatePopup } from '/imports/ui/modules/popup';

import '/imports/ui/templates/layout/authentication/authentication.html';
import '/imports/ui/templates/components/identity/avatar/avatar.js';


const modal = {
icon: Meteor.settings.public.app.logo,
title: TAPi18n.__('wallet'),
cancel: TAPi18n.__('close'),
alertMode: true,
};

function _isDisabled() {
if (Meteor.user().profile.wallet.reserves) {
return (entangle(Session.get('draftContract')) === undefined) ||
Expand Down Expand Up @@ -106,7 +117,33 @@ Template.authentication.helpers({
Template.authentication.events({
'click #loggedUser'(event) {
event.stopPropagation();
promptLogin((!Session.get('user-login') || !Session.get('user-login').visible), event);
if (Meteor.user()) {
Router.go(`/address/${Meteor.user().username}`);

displayModal(
true,
{
icon: Meteor.settings.public.app.logo,
title: TAPi18n.__('sign-out'),
message: TAPi18n.__('sign-out-prompt'),
cancel: TAPi18n.__('close'),
action: TAPi18n.__('sign-out'),
alertMode: false,
},
() => {
Router.go('/');
Meteor.logout();
}
);
} else {
Session.set('userLoginVisible', true);
Meteor.loginWithMetamask({}, function (err) {
if (err.reason) {
throw new Meteor.Error('Metamask login failed', err.reason);
}
Session.set('userLoginVisible', false);
});
}
},
'click #navbar-post-button'() {
_publish();
Expand Down
2 changes: 2 additions & 0 deletions imports/ui/templates/layout/url/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ Template.homeFeed.onCreated(function () {
if (subscription.ready()) {
_generateReplica(instance);

console.log(Contracts.findOne());

const collectiveId = Contracts.findOne().collectiveId;
Session.set('search', {
input: '',
Expand Down
9 changes: 7 additions & 2 deletions imports/ui/templates/layout/url/topbar/topbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
<div class="hero-menu-link hero-menu-link-signin {{loginMode}}" target="_blank">{{_ 'sign-in'}}</div>
</div>
{{else}}
<div id="collective-login" class="hero-button hero-button-mobile hero-signin">
<div class="hero-menu-link hero-menu-link-signin {{loginMode}}" target="_blank">
<div class="hero-button hero-button-mobile hero-signin">

<div id="sign-out-button" class="hero-menu-link hero-menu-link-signin-simple hero-menu-link-signin-simple-icon" target="_blank">
<img src="{{getImage 'signout'}}" title="{{_ 'sign-out'}}" class="signout">
</div>

<div id="collective-login" class="hero-menu-link hero-menu-link-signin-simple" target="_blank">
{{#with currentUser}}
<div class="hero-crypto-login">
{{> avatar size=24 profile=this._id includeName=false includeNation=false editable=false microFont=true disabled=true includeRole=false imgStyle=this.imgStyle}}
Expand Down
23 changes: 22 additions & 1 deletion imports/ui/templates/layout/url/topbar/topbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { shortenCryptoName } from '/imports/ui/templates/components/identity/ava
import { getTemplate } from '/imports/ui/templates/layout/templater';
import { promptLogin } from '/imports/ui/templates/components/collective/collective.js';
import { validateEmail } from '/imports/startup/both/modules/validations.js';
import { templetize, getImage } from '/imports/ui/templates/layout/templater';

import '/imports/ui/templates/layout/url/topbar/topbar.html';
import '/imports/ui/templates/widgets/warning/warning.js';
Expand Down Expand Up @@ -40,6 +41,9 @@ const _showTopMenu = () => {

Template.topbar.onCreated(function () {
Template.instance().activeSignIn = new ReactiveVar(false);
Template.instance().imageTemplate = new ReactiveVar();
const instance = Template.instance();
templetize(instance);
});


Expand Down Expand Up @@ -92,12 +96,29 @@ Template.topbar.helpers({
cryptoName(address) {
return shortenCryptoName(address);
},
getImage(pic) {
return getImage(Template.instance().imageTemplate.get(), pic);
},
});

Template.topbar.events({
'click #collective-login'() {
event.stopPropagation();
_prompt(Template.instance());
if (Meteor.user()) {
Router.go(`/address/${Meteor.user().username}`);
} else {
Session.set('userLoginVisible', true);
Meteor.loginWithMetamask({}, function (err) {
if (err.reason) {
throw new Meteor.Error('Metamask login failed', err.reason);
}
Session.set('userLoginVisible', false);
});
}
// _prompt(Template.instance());
},
'click #sign-out-button'() {
Meteor.logout();
},
'click #nav-home'(event) {
event.preventDefault();
Expand Down
5 changes: 2 additions & 3 deletions lib/web3.js
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ const _callMethod = async (collective, methodName) => {
const abi = JSON.parse(contract.abi);
const dao = await new web3.eth.Contract(abi, contract.publicAddress);

await dao.methods[methodName].call({}, (err, res) => {
await dao.methods[methodName]().call({}, (err, res) => {
if (err) {
console.log(err);
}
Expand Down Expand Up @@ -1119,7 +1119,7 @@ const _askOracle = async (coin) => {
const abi = JSON.parse(coin.abi);
const contract = await new web3.eth.Contract(abi, coin.contractAddress);
let response;
await contract.methods[coin.method].call({}, (err, res) => {
await contract.methods[coin.method]().call({}, (err, res) => {
if (err) {
console.log(err);
}
Expand Down Expand Up @@ -1162,7 +1162,6 @@ const _getTransfers = async (coin, publicAddress, eventName, fromBlock, toBlock,
const _generateDataset = async (feed, coin) => {
const dataset = [];
let block;
console.log(feed);
for (let i = 0; i < feed.length; i += 1) {
block = await _getEventBlock(feed[i].blockNumber);
dataset.push({
Expand Down
Loading

0 comments on commit a5cd0ac

Please sign in to comment.