Skip to content

Commit

Permalink
fix: fix code styles issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed May 17, 2020
1 parent 749d8d4 commit 4d0d88c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
24 changes: 10 additions & 14 deletions src/app/presentation/design/path/path.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,20 @@ export class PathComponent implements OnInit {
if (this.pipeData.length <= 0) {
return;
}
this.maxLength--;
this.pipeData = this.removeLastItem(this.pipeData);
}

const that = this;

function removeLastItem(items) {
// tslint:disable-next-line:prefer-for-of
for (let i = 0; i < items.length; i++) {
for (let j = 0; j <= that.maxLength; j++) {
if (j > that.maxLength - 1) {
items[i].items.splice(-1, 1);
}
removeLastItem(items) {
// tslint:disable-next-line:prefer-for-of
for (let i = 0; i < items.length; i++) {
for (let j = 0; j <= this.maxLength; j++) {
if (j > this.maxLength - 1) {
items[i].items.splice(-1, 1);
}
}

return items;
}

this.maxLength--;
this.pipeData = removeLastItem(this.pipeData);
return items;
}

getContainerStyle(pipe: Item) {
Expand Down
32 changes: 18 additions & 14 deletions src/app/presentation/job/job.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,7 @@ export class JobComponent implements OnInit {
.subscribe(
(res: any[]) => {
const result: any[] = res || [];
const jobList = [];
for (const job of result.reverse()) {
const arr = job.body.replace(/:/g, ':').split('\r\n');
const info = {};
for (const str of arr) {
const [key, value] = this.splitOnFirstColon(str);
info[key] = value;
}
const jobInfo = issueToForm(info);
jobInfo.htmlUrl = job.html_url;
jobInfo.date = format(new Date(job.updated_at), 'yyyy/MM/dd');
jobList.push(jobInfo);
}
this.jobList = jobList;
this.buildJobList(result);
},
() => {},
() => {
Expand All @@ -69,6 +56,23 @@ export class JobComponent implements OnInit {
);
}

private buildJobList(result: any[]) {
const jobList = [];
for (const job of result.reverse()) {
const arr = job.body.replace(/:/g, ':').split('\r\n');
const info = {};
for (const str of arr) {
const [key, value] = this.splitOnFirstColon(str);
info[key] = value;
}
const jobInfo = issueToForm(info);
jobInfo.htmlUrl = job.html_url;
jobInfo.date = format(new Date(job.updated_at), 'yyyy/MM/dd');
jobList.push(jobInfo);
}
this.jobList = jobList;
}

splitOnFirstColon(str) {
const idx = str.indexOf(':');
return [str.substr(0, idx), str.substr(idx + 1)];
Expand Down

0 comments on commit 4d0d88c

Please sign in to comment.