Skip to content

Commit

Permalink
1.Auto generate seed while creating board
Browse files Browse the repository at this point in the history
2.Improve style of thread page
  • Loading branch information
vyloy committed Jul 15, 2017
1 parent 853f24c commit 9fbb725
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 31 deletions.
13 changes: 13 additions & 0 deletions static/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion static/src/components/boards/boards-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h4 class="modal-title">New Board</h4>
</div>
<div class="form-group">
<label for="seed">Board seed</label>
<input type="text" class="form-control" placeholder="seed" id="seed" formControlName="seed">
<textarea class="form-control" rows="3" id="seed" style="resize:none" formControlName="seed"></textarea>
</div>
<div class="form-group">
<label for="addresses">Board addresses (optional)</label>
Expand Down
41 changes: 23 additions & 18 deletions static/src/components/boards/boards-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class BoardsListComponent implements OnInit {
public addForm = new FormGroup({
name: new FormControl('', Validators.required),
description: new FormControl('', Validators.required),
seed: new FormControl('', Validators.required),
seed: new FormControl({ value: '', disabled: true }, Validators.required),
addresses: new FormControl(''),
});
public tmpBoard: Board = null;
Expand All @@ -52,7 +52,7 @@ export class BoardsListComponent implements OnInit {
}

setSort() {
this.sort = this.sort === 'desc' ? 'esc' : 'desc';
this.sort = this.sort === 'desc' ? 'asc' : 'desc';
}

getBoards() {
Expand Down Expand Up @@ -123,24 +123,29 @@ export class BoardsListComponent implements OnInit {

openAdd(content) {
this.addForm.reset();
this.modal.open(content).result.then((result) => {
if (result === true) {
if (!this.addForm.valid) {
this.common.showErrorAlert('Parameter error');
return;
this.api.generateSeed().subscribe(seed => {
this.addForm.patchValue({ seed: seed });
this.modal.open(content).result.then((result) => {
if (result === true) {
if (!this.addForm.valid) {
this.common.showErrorAlert('Parameter error');
return;
}
const data = new FormData();
data.append('name', this.addForm.get('name').value);
data.append('description', this.addForm.get('description').value);
data.append('seed', this.addForm.get('seed').value);
data.append('submission_addresses', this.addForm.get('addresses').value);
this.api.addBoard(data).subscribe(res => {
this.getBoards();
this.common.showSucceedAlert('Added Successfully');
});
}
const data = new FormData();
data.append('name', this.addForm.get('name').value);
data.append('description', this.addForm.get('description').value);
data.append('seed', this.addForm.get('seed').value);
data.append('submission_addresses', this.addForm.get('addresses').value);
this.api.addBoard(data).subscribe(res => {
this.getBoards();
this.common.showSucceedAlert('Added Successfully');
});
}
}, err => {
});
}, err => {
});
this.common.showErrorAlert('Unable to create,Please try again later');
})
}

delAddress(ev: Event, key: string, address: string) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<i class="fa fa-reply"></i>
<i class="fa fa-pencil"></i>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ app-fixed-button {
position: fixed;
display: flex;
cursor: pointer;
bottom: 10%;
bottom: 15%;
right: 5%;
width: 60px;
height: 60px;
Expand All @@ -17,4 +17,4 @@ app-fixed-button {
font-size: 1.5em;
color: #fff;
}
}
}
3 changes: 2 additions & 1 deletion static/src/components/thread-page/threadPage.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ app-threadpage {
display: inline-block;
background-repeat: no-repeat;
width: 1rem;
height: 1rem;
height: 1rem;
min-width: 20px;
min-height: 20px;
}
Expand Down Expand Up @@ -141,6 +141,7 @@ app-threadpage {
bottom: 0;
left: 0;
right: 0;
z-index: 9999;
background-color: transparent;
}
.author-menu {
Expand Down
12 changes: 5 additions & 7 deletions static/src/components/thread-page/threadPage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,17 @@ export class ThreadPageComponent implements OnInit, OnDestroy {
this.threadKey = res['thread'];
this.open(this.boardKey, this.threadKey);
});
setTimeout(() => {
this.common.fb.display = 'flex';
this.common.fb.handle = () => {
this.openReply(this.replyBox);
}
}, 2000);
this.common.fb.display = 'flex';
this.common.fb.handle = () => {
this.openReply(this.replyBox);
}
}
ngOnDestroy() {
this.common.fb.display = 'none';
this.common.fb.handle = null;
}
public setSort() {
this.sort = this.sort === 'desc' ? 'esc' : 'desc';
this.sort = this.sort === 'desc' ? 'asc' : 'desc';
}
addThreadVote(mode: string, thread: Thread, ev: Event) {
ev.stopImmediatePropagation();
Expand Down
2 changes: 1 addition & 1 deletion static/src/pipes/orderBy/order-by.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class OrderByPipe implements PipeTransform {
return 0;
});
break;
case 'esc':
case 'asc':
values.sort((a, b) => {
if (a.created > b.created) {
return -1;
Expand Down

0 comments on commit 9fbb725

Please sign in to comment.