Skip to content

Commit

Permalink
#11 disabled all inputs for non-team members
Browse files Browse the repository at this point in the history
  • Loading branch information
ryzhak committed Oct 26, 2018
1 parent c2dbc6a commit e18cee7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
16 changes: 8 additions & 8 deletions src/app/dashboard/dao-param-page/dao-param-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1 class="h3 display">Settings</h1>
<input type="number" formControlName="mintTokensPerWeekAmount" class="form-control" placeholder="Amount of DZT created each week">
</div>
<div class="col-md-4">
<button [disabled]="!formDaoParams.controls['mintTokensPerWeekAmount'].valid || !isTeamMember" (click)="runSetParam(devZenDaoService.PARAM_MINT_TOKENS_PER_WEEK_AMOUNT)" type="button" class="btn btn-primary">Update</button>
<button [disabled]="!formDaoParams.controls['mintTokensPerWeekAmount'].valid" (click)="runSetParam(devZenDaoService.PARAM_MINT_TOKENS_PER_WEEK_AMOUNT)" type="button" class="btn btn-primary">Update</button>
</div>
</div>
</div>
Expand All @@ -36,7 +36,7 @@ <h1 class="h3 display">Settings</h1>
<input type="number" formControlName="mintReputationTokensPerWeekAmount" class="form-control" placeholder="Amount of DZTREP created each week">
</div>
<div class="col-md-4">
<button [disabled]="!formDaoParams.controls['mintReputationTokensPerWeekAmount'].valid || !isTeamMember" (click)="runSetParam(devZenDaoService.PARAM_MINT_REPUTATION_TOKENS_PER_WEEK_AMOUNT)" type="button" class="btn btn-primary">Update</button>
<button [disabled]="!formDaoParams.controls['mintReputationTokensPerWeekAmount'].valid" (click)="runSetParam(devZenDaoService.PARAM_MINT_REPUTATION_TOKENS_PER_WEEK_AMOUNT)" type="button" class="btn btn-primary">Update</button>
</div>
</div>
</div>
Expand All @@ -52,7 +52,7 @@ <h1 class="h3 display">Settings</h1>
<input type="number" formControlName="oneTokenPriceInWei" class="form-control" placeholder="Price for 1 DZT in ETH">
</div>
<div class="col-md-4">
<button [disabled]="!formDaoParams.controls['oneTokenPriceInWei'].valid || !isTeamMember" (click)="runSetParam(devZenDaoService.PARAM_ONE_TOKEN_PRICE_IN_WEI)" type="button" class="btn btn-primary">Update</button>
<button [disabled]="!formDaoParams.controls['oneTokenPriceInWei'].valid" (click)="runSetParam(devZenDaoService.PARAM_ONE_TOKEN_PRICE_IN_WEI)" type="button" class="btn btn-primary">Update</button>
</div>
</div>
</div>
Expand All @@ -68,7 +68,7 @@ <h1 class="h3 display">Settings</h1>
<input type="number" formControlName="oneAdSlotPrice" class="form-control" placeholder="Price for 1 ad slot in ETH">
</div>
<div class="col-md-4">
<button [disabled]="!formDaoParams.controls['oneAdSlotPrice'].valid || !isTeamMember" (click)="runSetParam(devZenDaoService.PARAM_ONE_AD_SLOT_PRICE)" type="button" class="btn btn-primary">Update</button>
<button [disabled]="!formDaoParams.controls['oneAdSlotPrice'].valid" (click)="runSetParam(devZenDaoService.PARAM_ONE_AD_SLOT_PRICE)" type="button" class="btn btn-primary">Update</button>
</div>
</div>
</div>
Expand All @@ -84,7 +84,7 @@ <h1 class="h3 display">Settings</h1>
<input type="number" formControlName="becomeGuestStake" class="form-control" placeholder="Guest stake in DZT">
</div>
<div class="col-md-4">
<button [disabled]="!formDaoParams.controls['becomeGuestStake'].valid || !isTeamMember" (click)="runSetParam(devZenDaoService.PARAM_BECOME_GUEST_STAKE)" type="button" class="btn btn-primary">Update</button>
<button [disabled]="!formDaoParams.controls['becomeGuestStake'].valid" (click)="runSetParam(devZenDaoService.PARAM_BECOME_GUEST_STAKE)" type="button" class="btn btn-primary">Update</button>
</div>
</div>
</div>
Expand All @@ -100,7 +100,7 @@ <h1 class="h3 display">Settings</h1>
<input type="number" formControlName="repTokensRewardHost" class="form-control" placeholder="Host reward for episode in DZTREP">
</div>
<div class="col-md-4">
<button [disabled]="!formDaoParams.controls['repTokensRewardHost'].valid || !isTeamMember" (click)="runSetParam(devZenDaoService.PARAM_REP_TOKENS_REWARD_HOST)" type="button" class="btn btn-primary">Update</button>
<button [disabled]="!formDaoParams.controls['repTokensRewardHost'].valid" (click)="runSetParam(devZenDaoService.PARAM_REP_TOKENS_REWARD_HOST)" type="button" class="btn btn-primary">Update</button>
</div>
</div>
</div>
Expand All @@ -116,7 +116,7 @@ <h1 class="h3 display">Settings</h1>
<input type="number" formControlName="repTokensRewardGuest" class="form-control" placeholder="Guest reward for episode in DZTREP">
</div>
<div class="col-md-4">
<button [disabled]="!formDaoParams.controls['repTokensRewardGuest'].valid || !isTeamMember" (click)="runSetParam(devZenDaoService.PARAM_REP_TOKENS_REWARD_GUEST)" type="button" class="btn btn-primary">Update</button>
<button [disabled]="!formDaoParams.controls['repTokensRewardGuest'].valid" (click)="runSetParam(devZenDaoService.PARAM_REP_TOKENS_REWARD_GUEST)" type="button" class="btn btn-primary">Update</button>
</div>
</div>
</div>
Expand All @@ -132,7 +132,7 @@ <h1 class="h3 display">Settings</h1>
<input type="number" formControlName="repTokensRewardTeamMembers" class="form-control" placeholder="Reward of all team members for episode in DZTREP">
</div>
<div class="col-md-4">
<button [disabled]="!formDaoParams.controls['repTokensRewardTeamMembers'].valid || !isTeamMember" (click)="runSetParam(devZenDaoService.PARAM_REP_TOKENS_REWARD_TEAM_MEMBERS)" type="button" class="btn btn-primary">Update</button>
<button [disabled]="!formDaoParams.controls['repTokensRewardTeamMembers'].valid" (click)="runSetParam(devZenDaoService.PARAM_REP_TOKENS_REWARD_TEAM_MEMBERS)" type="button" class="btn btn-primary">Update</button>
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/app/dashboard/dao-param-page/dao-param-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { DevzendaoService, Web3Service } from '../../shared';
export class DaoParamPageComponent implements OnInit {

formDaoParams: FormGroup;
isTeamMember = false;

constructor(
public devZenDaoService: DevzendaoService,
Expand Down Expand Up @@ -51,8 +50,8 @@ export class DaoParamPageComponent implements OnInit {
this.formDaoParams.controls[key].setValue(value);
}
});
// assign isTeamMember
this.isTeamMember = isTeamMember;
// enable form if team member
if(isTeamMember) this.formDaoParams.enable();
},
(err) => { console.error(err); }
);
Expand All @@ -72,6 +71,7 @@ export class DaoParamPageComponent implements OnInit {
repTokensRewardGuest: ['', [Validators.required, Validators.min(1 / (10 ** 18))]],
repTokensRewardTeamMembers: ['', [Validators.required, Validators.min(1 / (10 ** 18))]]
});
this.formDaoParams.disable();
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/app/dashboard/team-page/team-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1 class="h3 display">Team</h1>
<input class="form-control" type="text" formControlName="output" placeholder="Address">
</div>
<div class="col-md-4">
<button [disabled]="!formWithdrawEther.valid || !isTeamMember" (click)="runWithdrawEther()" type="button" class="btn btn-primary">Execute</button>
<button [disabled]="!formWithdrawEther.valid" (click)="runWithdrawEther()" type="button" class="btn btn-primary">Execute</button>
</div>
</div>
</div>
Expand All @@ -40,7 +40,7 @@ <h1 class="h3 display">Team</h1>
<input class="form-control" type="text" formControlName="host" placeholder="Address">
</div>
<div class="col-md-4">
<button [disabled]="!formSelectNextHost.valid || !isTeamMember" (click)="runSelectNextHost()" type="button" class="btn btn-primary">Execute</button>
<button [disabled]="!formSelectNextHost.valid" (click)="runSelectNextHost()" type="button" class="btn btn-primary">Execute</button>
</div>
</div>
</div>
Expand All @@ -66,7 +66,7 @@ <h1 class="h3 display">Team</h1>
placeholder="Address">
</div>
<div class="col-md-4">
<button [disabled]="!formChangeTheGuest.valid || !isTeamMember" (click)="runChangeTheGuest()" type="button" class="btn btn-primary">Execute</button>
<button [disabled]="!formChangeTheGuest.valid" (click)="runChangeTheGuest()" type="button" class="btn btn-primary">Execute</button>
</div>
</div>
</div>
Expand All @@ -92,7 +92,7 @@ <h1 class="h3 display">Team</h1>
placeholder="Address">
</div>
<div class="col-md-4">
<button [disabled]="!formEmergencyChangeTheGuest.valid || !isTeamMember" (click)="runEmergencyChangeTheGuest()" type="button" class="btn btn-primary">Execute</button>
<button [disabled]="!formEmergencyChangeTheGuest.valid" (click)="runEmergencyChangeTheGuest()" type="button" class="btn btn-primary">Execute</button>
</div>
</div>
</div>
Expand All @@ -116,7 +116,7 @@ <h1 class="h3 display">Team</h1>
<span class="text-small text-gray help-block-none">Mint DZTREP to guest?</span>
</div>
<div class="col-md-4">
<button [disabled]="!formMoveToNextEpisode.valid || !isTeamMember" (click)="runMoveToNextEpisode()" type="button" class="btn btn-primary">Execute</button>
<button [disabled]="!formMoveToNextEpisode.valid" (click)="runMoveToNextEpisode()" type="button" class="btn btn-primary">Execute</button>
</div>
</div>
</div>
Expand Down
26 changes: 24 additions & 2 deletions src/app/dashboard/team-page/team-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class TeamPageComponent implements OnInit {
formMoveToNextEpisode: FormGroup;
formSelectNextHost: FormGroup;
formWithdrawEther: FormGroup;
isTeamMember = false;

constructor(
public devZenDaoService: DevzendaoService,
Expand All @@ -36,14 +35,37 @@ export class TeamPageComponent implements OnInit {
}

sub.subscribe(
(isTeamMember) => { this.isTeamMember = isTeamMember; },
(isTeamMember) => { if(isTeamMember) this.enableAllForms(); },
(err) => {
this.messageService.add({severity:'error', summary:'Error', detail:'Error on getting team member status'});
console.error(err);
}
);

this.initForms();
this.disableAllForms();
}

/**
* Disables all forms
*/
disableAllForms() {
this.formWithdrawEther.disable();
this.formSelectNextHost.disable();
this.formChangeTheGuest.disable();
this.formEmergencyChangeTheGuest.disable();
this.formMoveToNextEpisode.disable();
}

/**
* Enables all forms
*/
enableAllForms() {
this.formWithdrawEther.enable();
this.formSelectNextHost.enable();
this.formChangeTheGuest.enable();
this.formEmergencyChangeTheGuest.enable();
this.formMoveToNextEpisode.enable();
}

/**
Expand Down

0 comments on commit e18cee7

Please sign in to comment.