Skip to content

Commit

Permalink
Add a worker creation form
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed Jun 12, 2017
1 parent d9a524a commit ea8b144
Show file tree
Hide file tree
Showing 16 changed files with 320 additions and 14 deletions.
2 changes: 2 additions & 0 deletions web/app/Routes-dev.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import Brainkey from "./components/Wallet/Brainkey";
import Help from "./components/Help";
import InitError from "./components/InitError";
import LoginSelector from "./components/LoginSelector";
import CreateWorker from "./components/Account/CreateWorker";

const history = __HASH_HISTORY__ ? hashHistory : browserHistory;

Expand Down Expand Up @@ -121,6 +122,7 @@ const routes = (
</Route>

<Route path="deposit-withdraw" component={AccountDepositWithdraw} />
<Route path="create-worker" component={CreateWorker} />
<Route path="/init-error" component={InitError} />
<Route path="/help" component={Help} >
<Route path=":path1" component={Help} >
Expand Down
3 changes: 3 additions & 0 deletions web/app/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ const routes = (
<Route path="deposit-withdraw" getComponent={(location, cb) => {
System.import("components/Account/AccountDepositWithdraw").then(loadRoute(cb)).catch(errorLoading);
}}/>
<Route path="create-worker" getComponent={(location, cb) => {
System.import("components/Account/WorkerCreate").then(loadRoute(cb)).catch(errorLoading);
}}/>
<Route path="/init-error" getComponent={(location, cb) => {
System.import("components/InitError").then(loadRoute(cb)).catch(errorLoading);
}}/>
Expand Down
36 changes: 35 additions & 1 deletion web/app/api/ApplicationApi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import WalletUnlockActions from "actions/WalletUnlockActions";
import WalletDb from "stores/WalletDb";
import {Aes, ChainValidation, TransactionBuilder, TransactionHelper, FetchChain} from "bitsharesjs/es";
import {Aes, ChainValidation, TransactionBuilder, TransactionHelper, ops, FetchChain, ChainStore} from "bitsharesjs/es";

class ApplicationApi {

Expand Down Expand Up @@ -273,6 +273,40 @@ class ApplicationApi {
return WalletDb.process_transaction(tr, null, true)
})
}

createWorker(options, account) {

console.log("template:", TransactionHelper.template("worker_create"));
return new Promise((resolve, reject) => {
let tr = new TransactionBuilder();
console.log("ops:", ops["worker_initializer"], ops["vesting_balance_worker_initializer"].toObject(undefined));
const core = ChainStore.getAsset("1.3.0");
if (!core) reject(new Error("Can't find core asset, please try again"));
let precision = Math.pow(10, core.get("precision"));

const owner = ChainStore.getAccount(account).get("id");
if (!owner) reject(new Error("Can't find the owner account, please try again"));

try {
tr.add_type_operation("worker_create", {
fee: {
amount: 0,
asset_id: 0
},
owner,
work_begin_date: options.start,
work_end_date: options.end,
daily_pay: options.pay * precision,
name: options.title,
url: options.url,
initializer: [1, {pay_vesting_period_days: options.vesting}]
});
} catch(err) {
reject(err);
}
WalletDb.process_transaction(tr, null, true).then(resolve).catch(reject);
});
}
}

export default ApplicationApi;
14 changes: 13 additions & 1 deletion web/app/assets/locales/locale-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,19 @@
"title": "理事会成员"
},
"workers": {
"title": "预算项目"
"title": "预算项目",
"period": "Worker duration",
"daily_pay": "Daily pay (BTS)",
"website": "Website",
"vesting_pay": "Salary vesting period (days)",
"create": "Create a new worker proposal",
"create_text_1": "In order to create your new worker, please fill in the form below. The worker will be created using your currently active account, which must already be a lifetime member.",
"create_text_2": "Consider carefully the parameters you choose as they can not be changed once you've published your worker.",
"name_text": "The name of your worker should be short and descriptive, something like this: 'Worker Purpose - Account Name'",
"date_text": "The start date should be at least a week into the future in order to allow people the time to discover, evaluate and vote for your worker.",
"pay_text": "The daily pay defines how much you want to be paid per day and is defined in BTS. The current best practice is to define a salary in USD/CNY, and commit to burning whatever surplus you receive as a result of the BTS price increasing. As long as your worker is active and has sufficient votes to be above the refund worker, you will receive this daily salary.",
"url_text": "You should supply a website, github document or google doc that describes in more detail the purpose of the worker and how you intend to use the worker pay.",
"vesting_text": "The vesting period defines the number of days that worker earnings will vest before being fully claimable."
},
"proposals": {
"title": "提案"
Expand Down
14 changes: 13 additions & 1 deletion web/app/assets/locales/locale-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,19 @@
"title": "Kommitteemitglied"
},
"workers": {
"title": "Budgetpunkte"
"title": "Budgetpunkte",
"period": "Worker duration",
"daily_pay": "Daily pay (BTS)",
"website": "Website",
"vesting_pay": "Salary vesting period (days)",
"create": "Create a new worker proposal",
"create_text_1": "In order to create your new worker, please fill in the form below. The worker will be created using your currently active account, which must already be a lifetime member.",
"create_text_2": "Consider carefully the parameters you choose as they can not be changed once you've published your worker.",
"name_text": "The name of your worker should be short and descriptive, something like this: 'Worker Purpose - Account Name'",
"date_text": "The start date should be at least a week into the future in order to allow people the time to discover, evaluate and vote for your worker.",
"pay_text": "The daily pay defines how much you want to be paid per day and is defined in BTS. The current best practice is to define a salary in USD/CNY, and commit to burning whatever surplus you receive as a result of the BTS price increasing. As long as your worker is active and has sufficient votes to be above the refund worker, you will receive this daily salary.",
"url_text": "You should supply a website, github document or google doc that describes in more detail the purpose of the worker and how you intend to use the worker pay.",
"vesting_text": "The vesting period defines the number of days that worker earnings will vest before being fully claimable."
},
"proposals": {
"title": "Vorschlag"
Expand Down
16 changes: 14 additions & 2 deletions web/app/assets/locales/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@
"committee_member_update_global_parameters": "Global parameters update",
"vesting_balance_create": "Create vesting balance",
"vesting_balance_withdraw": "Withdraw vesting balance",
"worker_create": "Create budget item",
"worker_create": "Create worker",
"custom": "Custom",
"assert": "Assert operation",
"balance_claim": "Claim balance",
Expand Down Expand Up @@ -725,7 +725,19 @@
"title": "Committee member"
},
"workers": {
"title": "Budget Items"
"title": "Worker name",
"period": "Worker duration",
"daily_pay": "Daily pay (BTS)",
"website": "Website",
"vesting_pay": "Salary vesting period (days)",
"create": "Create a new worker proposal",
"create_text_1": "In order to create your new worker, please fill in the form below. The worker will be created using your currently active account, which must already be a lifetime member.",
"create_text_2": "Consider carefully the parameters you choose as they can not be changed once you've published your worker.",
"name_text": "The name of your worker should be short and descriptive, something like this: 'Worker Purpose - Account Name'",
"date_text": "The start date should be at least a week into the future in order to allow people the time to discover, evaluate and vote for your worker.",
"pay_text": "The daily pay defines how much you want to be paid per day and is defined in BTS. The current best practice is to define a salary in USD/CNY, and commit to burning whatever surplus you receive as a result of the BTS price increasing. As long as your worker is active and has sufficient votes to be above the refund worker, you will receive this daily salary.",
"url_text": "You should supply a website, github document or google doc that describes in more detail the purpose of the worker and how you intend to use the worker pay.",
"vesting_text": "The vesting period defines the number of days that worker earnings will vest before being fully claimable."
},
"proposals": {
"title": "Proposed transactions"
Expand Down
14 changes: 13 additions & 1 deletion web/app/assets/locales/locale-es.json
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,19 @@
"title": "Miembro del Comité"
},
"workers": {
"title": "Presupuestos por Trabajos"
"title": "Presupuestos por Trabajos",
"period": "Worker duration",
"daily_pay": "Daily pay (BTS)",
"website": "Website",
"vesting_pay": "Salary vesting period (days)",
"create": "Create a new worker proposal",
"create_text_1": "In order to create your new worker, please fill in the form below. The worker will be created using your currently active account, which must already be a lifetime member.",
"create_text_2": "Consider carefully the parameters you choose as they can not be changed once you've published your worker.",
"name_text": "The name of your worker should be short and descriptive, something like this: 'Worker Purpose - Account Name'",
"date_text": "The start date should be at least a week into the future in order to allow people the time to discover, evaluate and vote for your worker.",
"pay_text": "The daily pay defines how much you want to be paid per day and is defined in BTS. The current best practice is to define a salary in USD/CNY, and commit to burning whatever surplus you receive as a result of the BTS price increasing. As long as your worker is active and has sufficient votes to be above the refund worker, you will receive this daily salary.",
"url_text": "You should supply a website, github document or google doc that describes in more detail the purpose of the worker and how you intend to use the worker pay.",
"vesting_text": "The vesting period defines the number of days that worker earnings will vest before being fully claimable."
},
"proposals": {
"title": "Propuestas"
Expand Down
14 changes: 13 additions & 1 deletion web/app/assets/locales/locale-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,19 @@
"title": "CommitteeMember"
},
"workers": {
"title": "Ouvriers"
"title": "Ouvriers",
"period": "Worker duration",
"daily_pay": "Daily pay (BTS)",
"website": "Website",
"vesting_pay": "Salary vesting period (days)",
"create": "Create a new worker proposal",
"create_text_1": "In order to create your new worker, please fill in the form below. The worker will be created using your currently active account, which must already be a lifetime member.",
"create_text_2": "Consider carefully the parameters you choose as they can not be changed once you've published your worker.",
"name_text": "The name of your worker should be short and descriptive, something like this: 'Worker Purpose - Account Name'",
"date_text": "The start date should be at least a week into the future in order to allow people the time to discover, evaluate and vote for your worker.",
"pay_text": "The daily pay defines how much you want to be paid per day and is defined in BTS. The current best practice is to define a salary in USD/CNY, and commit to burning whatever surplus you receive as a result of the BTS price increasing. As long as your worker is active and has sufficient votes to be above the refund worker, you will receive this daily salary.",
"url_text": "You should supply a website, github document or google doc that describes in more detail the purpose of the worker and how you intend to use the worker pay.",
"vesting_text": "The vesting period defines the number of days that worker earnings will vest before being fully claimable."
},
"proposals": {
"title": "Propositions"
Expand Down
14 changes: 13 additions & 1 deletion web/app/assets/locales/locale-ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,19 @@
"title": "위원"
},
"workers": {
"title": "예산 항목"
"title": "예산 항목",
"period": "Worker duration",
"daily_pay": "Daily pay (BTS)",
"website": "Website",
"vesting_pay": "Salary vesting period (days)",
"create": "Create a new worker proposal",
"create_text_1": "In order to create your new worker, please fill in the form below. The worker will be created using your currently active account, which must already be a lifetime member.",
"create_text_2": "Consider carefully the parameters you choose as they can not be changed once you've published your worker.",
"name_text": "The name of your worker should be short and descriptive, something like this: 'Worker Purpose - Account Name'",
"date_text": "The start date should be at least a week into the future in order to allow people the time to discover, evaluate and vote for your worker.",
"pay_text": "The daily pay defines how much you want to be paid per day and is defined in BTS. The current best practice is to define a salary in USD/CNY, and commit to burning whatever surplus you receive as a result of the BTS price increasing. As long as your worker is active and has sufficient votes to be above the refund worker, you will receive this daily salary.",
"url_text": "You should supply a website, github document or google doc that describes in more detail the purpose of the worker and how you intend to use the worker pay.",
"vesting_text": "The vesting period defines the number of days that worker earnings will vest before being fully claimable."
},
"proposals": {
"title": "제안서"
Expand Down
16 changes: 14 additions & 2 deletions web/app/assets/locales/locale-ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,19 @@
"title":"Член комитета"
},
"workers":{
"title":"Элементы бюджета"
"title":"Элементы бюджета",
"period": "Worker duration",
"daily_pay": "Daily pay (BTS)",
"website": "Website",
"vesting_pay": "Salary vesting period (days)",
"create": "Create a new worker proposal",
"create_text_1": "In order to create your new worker, please fill in the form below. The worker will be created using your currently active account, which must already be a lifetime member.",
"create_text_2": "Consider carefully the parameters you choose as they can not be changed once you've published your worker.",
"name_text": "The name of your worker should be short and descriptive, something like this: 'Worker Purpose - Account Name'",
"date_text": "The start date should be at least a week into the future in order to allow people the time to discover, evaluate and vote for your worker.",
"pay_text": "The daily pay defines how much you want to be paid per day and is defined in BTS. The current best practice is to define a salary in USD/CNY, and commit to burning whatever surplus you receive as a result of the BTS price increasing. As long as your worker is active and has sufficient votes to be above the refund worker, you will receive this daily salary.",
"url_text": "You should supply a website, github document or google doc that describes in more detail the purpose of the worker and how you intend to use the worker pay.",
"vesting_text": "The vesting period defines the number of days that worker earnings will vest before being fully claimable."
},
"proposals":{
"title":"Предложенные транзакции"
Expand Down Expand Up @@ -1244,4 +1256,4 @@
"enable":"Включить чат",
"telegram_link":"Более активное обсуждение ведется в группе BitShares в Telegram: <a href='https://t.me/BitSharesDEX' target='blank' rel='noopener noreferrer'>https://t.me/BitSharesDEX</a>"
}
}
}
14 changes: 13 additions & 1 deletion web/app/assets/locales/locale-tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,19 @@
"title": "Kurul üyesi"
},
"workers": {
"title": "Bütçe Öğeleri"
"title": "Bütçe Öğeleri",
"period": "Worker duration",
"daily_pay": "Daily pay (BTS)",
"website": "Website",
"vesting_pay": "Salary vesting period (days)",
"create": "Create a new worker proposal",
"create_text_1": "In order to create your new worker, please fill in the form below. The worker will be created using your currently active account, which must already be a lifetime member.",
"create_text_2": "Consider carefully the parameters you choose as they can not be changed once you've published your worker.",
"name_text": "The name of your worker should be short and descriptive, something like this: 'Worker Purpose - Account Name'",
"date_text": "The start date should be at least a week into the future in order to allow people the time to discover, evaluate and vote for your worker.",
"pay_text": "The daily pay defines how much you want to be paid per day and is defined in BTS. The current best practice is to define a salary in USD/CNY, and commit to burning whatever surplus you receive as a result of the BTS price increasing. As long as your worker is active and has sufficient votes to be above the refund worker, you will receive this daily salary.",
"url_text": "You should supply a website, github document or google doc that describes in more detail the purpose of the worker and how you intend to use the worker pay.",
"vesting_text": "The vesting period defines the number of days that worker earnings will vest before being fully claimable."
},
"proposals": {
"title": "Teklif edilmiş işlemler"
Expand Down
1 change: 0 additions & 1 deletion web/app/assets/stylesheets/components/_help.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.help-content {
max-width: 600px;
margin: auto;
padding: 5px;
}
.help-content > table {
Expand Down
6 changes: 5 additions & 1 deletion web/app/components/Account/AccountVoting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,12 @@ class AccountVoting extends React.Component {

<Tab title="account.votes.workers_short">

<div className={cnames("content-block", {disabled : proxy_is_set})}>
<div className={cnames("content-block")}>
<HelpContent style={{maxWidth: "800px"}} path="components/AccountVotingWorkers" />

<div style={{paddingBottom: 20}}>
<Link to="/create-worker"><div className="button">Create a new worker</div></Link>
</div>
<table>
<tbody>
<tr>
Expand Down
Loading

0 comments on commit ea8b144

Please sign in to comment.