Skip to content

Commit

Permalink
Dividends module
Browse files Browse the repository at this point in the history
  • Loading branch information
demuskov committed Mar 25, 2018
1 parent a75b73b commit cea95da
Show file tree
Hide file tree
Showing 50 changed files with 858 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ tmp
/config/markets.yml
/config/amqp.yml
/config/banks.yml
/config/nginx.conf

# Ignore translations.js
/public/javascripts/translations.js
Expand Down Expand Up @@ -58,3 +59,6 @@ tags
enable_ssl.txt
run_slanger.sh
/utils/add_coin_config.json
/app/models/admin/ability.rb
.gitignore

38 changes: 38 additions & 0 deletions app/assets/javascripts/dividends.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#= require jquery
#= require pusher.min

#= require ./lib/tiny-pubsub
#= require angular
#= require angular-resource
#= require ./lib/angular-ui-router
#= require ./lib/peatio_model
#= require ./lib/ajax

#= require ./lib/pusher_connection
#= require ./lib/pusher_subscriber

#= require ngDialog/ngDialog

#= require_self
#= require ./dividends/dividends

#= require es5-shim.min
#= require es5-sham.min
#= require jquery_ujs
#= require bootstrap
#
#= require bignumber
#= require moment
#= require ZeroClipboard
#= require underscore
#= require flight.min
#= require list
#= require qrcode

#= require_tree ./helpers
#= require_tree ./component_mixin
#= require_tree ./component_data
#= require_tree ./component_ui



Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
app.controller 'DailyController', ($scope, $stateParams, $http) ->
ctrl = @
@list = gon.daily_list

@noRecords = ->
@list.length == 0

@refresh = ->
@list = gon.daily_list
$scope.$apply()

do @event = ->
Dividend.bind "create update destroy", ->
ctrl.refresh()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app.controller 'DividendsController', ['$scope', '$stateParams', '$http', '$filter', '$gon', 'ngDialog', ($scope, $stateParams, $http, $filter, $gon, ngDialog) ->
@dividend = {}

@signContracs = () ->
console.log "signContract"

]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
app.controller 'IntradayController', ($scope, $stateParams, $http) ->
ctrl = @
@list = gon.intraday_list

@noRecords = ->
@list.length == 0

@refresh = ->
@list = gon.intraday_list
$scope.$apply()

do @event = ->
Dividend.bind "create update destroy", ->
ctrl.refresh()
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#= require bootstrap
#= require bootstrap-switch.min

app.directive 'dividends', ->
return {
restrict: 'E'
templateUrl: '/templates/dividends/dividends.html'
scope: { localValue: '=dividends' }
controller: ($scope, $state, $http, $filter, $gon, ngDialog) ->
console.log Product.all()[0]

ctrl = @
@state = $state

$scope.product = Product.all()[0]
$scope.dividend = Dividend.all()[0]
$scope.asset = Asset.all()[0]
$scope.interest = Interest.all()[0]
$scope.interest_intraday = gon.interest_intraday
$scope.interest_total = gon.interest_total
$scope.error = false

if $scope.dividend.aasm_state == 'accepted'
$('div[name="product-panel"]').removeClass('hide')
else
$('div[name="product-panel"]').addClass('hide')

$('input[name="sign-checkbox"]').bootstrapSwitch
labelText: 'Signed'
state: $scope.dividend.aasm_state == 'accepted'
onText: 'YES'
offText: 'NO'
onSwitchChange: (event, state) ->
if $scope.error
$scope.error = false
return

if state
$scope.acceptAgreement(event)
else
$scope.revokeAgreement(event)

$scope.$apply()

$scope.acceptAgreement = (event) ->
$http.post("/dividends/accept_agreement", {})
.error (responseText) ->
$scope.error = true
$.publish 'flash', {message: responseText.errors }
.finally ->
if !$scope.error
$('div[name="product-panel"]').removeClass('hide')
if $scope.error
$('input[name="sign-checkbox"]').bootstrapSwitch('state', false);

$scope.revokeAgreement = (event) ->
$http.post("/dividends/revoke_agreement", {})
.error (responseText) ->
$scope.error = true
$.publish 'flash', {message: responseText.errors }
.finally ->
if !$scope.error
$('div[name="product-panel"]').addClass('hide')
if $scope.error
$('input[name="sign-checkbox"]').bootstrapSwitch('state', true);

do @event = ->
Dividend.bind "create update destroy", ->
$scope.$apply()

controllerAs: 'dividendsCtrl'
}

20 changes: 20 additions & 0 deletions app/assets/javascripts/dividends/dividends.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#= require_tree ./models
#= require_tree ./filters
#= require_self
#= require_tree ./services
#= require_tree ./directives
#= require_tree ./controllers
#= require ./router
#= require ./events

$ ->
window.pusher_subscriber = new PusherSubscriber()

Member.initData [gon.current_user]
Product.initData gon.product
Dividend.initData gon.dividend
Asset.initData gon.asset
Interest.initData gon.interest

window.app = app = angular.module 'dividends', ["ui.router", "ngResource", "translateFilters", "textFilters", "precisionFilters", "smallPrecisionFilters", "ngDialog"]

15 changes: 15 additions & 0 deletions app/assets/javascripts/dividends/events.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$(window).load ->

# flash message
$.subscribe 'flash', (event, data) ->
$('.flash-messages').show()
$('#flash-content').html(data.message)
setTimeout(->
$('.flash-messages').hide(1000)
, 10000)

# init the two factor auth
$.subscribe 'two_factor_init', (event, data) ->
TwoFactorAuth.attachTo('.two-factor-auth-container')

$.publish 'two_factor_init'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
angular.module('precisionFilters', []).filter 'round_down', ->
(number) ->
if number == null
return 0.00000000
BigNumber(number).round(9, BigNumber.ROUND_DOWN).toF(9)

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
angular.module('smallPrecisionFilters', []).filter 'round_down_small', ->
(number) ->
if number == null
return 0.0000
BigNumber(number).round(4, BigNumber.ROUND_DOWN).toF(4)

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
angular.module('textFilters', []).filter 'truncate', ->
(text, size) ->
if text.length > 20
text.slice(0, size) + '...'
else
text
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
angular.module('translateFilters', []).filter 't', ->
(key, args={}) ->
I18n.t(key, args)
Empty file.
8 changes: 8 additions & 0 deletions app/assets/javascripts/dividends/models/asset.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Asset extends PeatioModel.Model
@configure 'Asset', 'member_id', 'currency', 'balance', 'locked', 'created_at', 'updated_at', 'in', 'out', 'deposit_address', 'name_text', 'is_online', 'blocks', 'headers', 'blocktime', 'gio_discount', 'coin_home', 'coin_btt', 'coin_be'

@initData: (record) ->
PeatioModel.Ajax.disable ->
Asset.create(record)

window.Asset = Asset
8 changes: 8 additions & 0 deletions app/assets/javascripts/dividends/models/dividend.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Dividend extends PeatioModel.Model
@configure 'Dividend', 'member_id', 'product_id', 'aasm_state', 'created_at', 'updated_at'

@initData: (record) ->
PeatioModel.Ajax.disable ->
Dividend.create(record)

window.Dividend = Dividend
8 changes: 8 additions & 0 deletions app/assets/javascripts/dividends/models/interest.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Interest extends PeatioModel.Model
@configure 'Interest', 'member_id', 'currency', 'balance', 'locked', 'created_at', 'updated_at', 'in', 'out', 'deposit_address', 'name_text', 'is_online', 'blocks', 'headers', 'blocktime', 'gio_discount', 'coin_home', 'coin_btt', 'coin_be'

@initData: (record) ->
PeatioModel.Ajax.disable ->
Interest.create(record)

window.Interest = Interest
10 changes: 10 additions & 0 deletions app/assets/javascripts/dividends/models/member.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Member extends PeatioModel.Model
@configure 'Member', 'sn', 'display_name', 'created_at', 'updated_at', 'state',
'country_code', 'phone_number', 'name', 'app_activated', 'sms_activated', 'has_gio_deposite_50', 'two_fa_require_signin'

@initData: (records) ->
PeatioModel.Ajax.disable ->
$.each records, (idx, record) ->
Member.create(record)

window.Member = Member
8 changes: 8 additions & 0 deletions app/assets/javascripts/dividends/models/product.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Product extends PeatioModel.Model
@configure 'Product', 'name', 'description', 'asset', 'interest', 'maturation', 'amount', 'rate', 'contract', 'created_at', 'updated_at'

@initData: (record) ->
PeatioModel.Ajax.disable ->
Product.create(record)

window.Product = Product
7 changes: 7 additions & 0 deletions app/assets/javascripts/dividends/router.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app.config ($stateProvider, $urlRouterProvider) ->
$stateProvider
.state('dividends', {
url: '/dividends'
templateUrl: "/templates/dividends/dividends.html"
})

1 change: 1 addition & 0 deletions app/assets/javascripts/dividends/services/gon.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
app.factory '$gon', ['$window', (win)-> win.gon]
7 changes: 7 additions & 0 deletions app/assets/javascripts/dividends/services/ng_dialog.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app.config ['ngDialogProvider', (ngDialogProvider) ->
ngDialogProvider.setDefaults
closeByDocument: false
closeByEscape: false
trapFocus: false
cache: false
]
4 changes: 4 additions & 0 deletions app/assets/javascripts/locales/en.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@










Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@import 'features/id_document';
@import 'features/history';
@import 'features/funds';
@import 'features/dividends';
@import 'features/documents';
@import 'features/simple_captcha';
@import 'features/custom';
Expand Down
87 changes: 87 additions & 0 deletions app/assets/stylesheets/features/dividends.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
.table-dividends {
border-radius: 5px;
right: -1px;
margin-bottom: 0;
> tbody > tr > td {
border-top: none;
border-bottom: none;
padding: 20px;
}
}
.currency-dividend-item {
margin: 0;
.currency-dividend-label {
font-size: 12px;
text-transform: uppercase;
color: #fff;
padding: 3px 10px;
border-radius: 3px;
background-color: #333;
&.label-cny {
background-color: #EC6060;
}
&.label-btc {
background-color: #DDCD1B;
}
}
.currency-dividend-logo {
text-align: center;
max-width: 60px;
min-width: 10px;
img {
max-height: 64px;
max-width: 64px;
}
.currency-dividend-symbol {
display: block;
margin-top: 5px;
text-transform: uppercase;
color: #999;
font-size: 16px;
}
.currency-dividend-state {
text-align: center;
max-width: 16px;
max-height: 16px;
padding: 3px 0px 0;
img {
max-height: 12px;
}
}
}
.currency-dividend-balance-col {
padding-left: 0;
padding-right: 0;
}
.currency-dividend-balance {
font-size: 24px;
font-weight: bold;
font-family: monospace;
padding: -10px 0px 0;
margin: 0;
.currency-dividend-sign {
display: none;
font-size: 20px;
margin-left: -4px;
}
}
.currency-dividend-balance-locked {
display: block;
color: #999;
font-size: 14px;
font-weight: normal;
}
.currency-dividend-info-ext {
color: #999;
font-size: 14px;
font-weight: normal;
}
.currency-dividend-info {
padding: 5px 0px 0;
display: block;
color: #999;
font-size: 12px;
font-weight: normal;
}
}

Loading

0 comments on commit cea95da

Please sign in to comment.