-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add table, Support multiply boards and slide them periodly #11
Open
KongHuihui-CAD
wants to merge
13
commits into
BUPT:master
Choose a base branch
from
KongHuihui-CAD:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
536cd43
Add table, Support multiply boards and slide them periodly
62c5134
#10 modify style
8aae602
#10 modify code style
ee269bd
Update app.component.spec.ts
75af0f0
Update app.component.spec.ts
3a123f4
Add ElModule dependency
f3db5db
Remove async
8f02ec8
Add ElModule dependency
f80bc4d
fix #10 Add ElModule dependency
a20b539
Change allScriptsTimeout from 11s to 60 s
076082e
Change repeat time from 10s to 2s
0b66de7
Remove the repeat function
a0a0a0c
Update cad-board.component.ts
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.footer{ | ||
position: relative; | ||
top: -160px | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@import "~element-angular/theme/index.css"; | ||
.header{ | ||
position: relative; | ||
} | ||
.tableContent{ | ||
width: 300px; | ||
position: relative; | ||
left: 600px; | ||
top: 20px; | ||
} | ||
.chartContent{ | ||
position: relative; | ||
top: -170px; | ||
} | ||
|
||
.tableContent{ | ||
border: 1px solid #ddd; | ||
padding: 8px; | ||
line-height: 2; | ||
border-radius: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
<google-chart | ||
width="800" | ||
[title]="changingChart.title" | ||
[type]="changingChart.type" | ||
[data]="changingChart.data" | ||
[columnNames]="changingChart.columnNames" | ||
[options]="changingChart.options"> | ||
</google-chart> | ||
|
||
<!-- button (click)="changeChart()">Change Data</button --> | ||
<div class="header"> | ||
<div class="tableContent"> | ||
<el-table [model]="tableData" [border]="true" center="all"> | ||
<el-table-column model-key="key" label="GPU" width="200"> | ||
</el-table-column> | ||
<el-table-column model-key="value" label="IP" width="100"> | ||
</el-table-column> | ||
</el-table> | ||
</div> | ||
<div class="chartContent"> | ||
<google-chart width="600" [title]="changingChart.title" [type]="changingChart.type" [data]="changingChart.data" | ||
[columnNames]="changingChart.columnNames" [options]="changingChart.options"> | ||
</google-chart> | ||
</div> | ||
|
||
</div> | ||
|
||
|
||
|
||
|
||
<!-- button (click)="changeChart()">Change Data</button --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,30 +3,31 @@ import { | |
OnInit, | ||
ViewChild, | ||
OnDestroy, | ||
} from '@angular/core' | ||
} from '@angular/core' | ||
import { Subscription } from 'rxjs' | ||
|
||
import { | ||
GoogleChartComponent, | ||
} from 'angular-google-charts' | ||
} from 'angular-google-charts' | ||
|
||
import { | ||
GpuService, | ||
} from '../gpu.service' | ||
} from '../gpu.service' | ||
import 'element-angular/theme/index.css' | ||
|
||
interface GoogleChart { | ||
title : string, | ||
type : string, | ||
data : Array<Array<string | number | {}>>, | ||
roles : Array<{type: string, role: string}>, | ||
title: string, | ||
type: string, | ||
data: Array<Array<string | number | {}>>, | ||
roles: Array<{ type: string, role: string }>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
columnNames?: Array<string>, | ||
options? : {}, | ||
options?: {}, | ||
} | ||
|
||
@Component({ | ||
selector : 'app-cad-board', | ||
selector: 'app-cad-board', | ||
templateUrl: './cad-board.component.html', | ||
styleUrls : ['./cad-board.component.css'] | ||
styleUrls: ['./cad-board.component.css'] | ||
}) | ||
export class CadScreenComponent implements OnInit, OnDestroy { | ||
|
||
|
@@ -57,38 +58,66 @@ export class CadScreenComponent implements OnInit, OnDestroy { | |
// chart: GoogleChartComponent | ||
|
||
subscription: Subscription | ||
newData = [] | ||
pos = 0 | ||
tableData = [] | ||
totalData = {} | ||
|
||
constructor( | ||
private gpu: GpuService, | ||
) { } | ||
|
||
ngOnInit() { | ||
this.subscription = this.gpu.getGpus().subscribe(data => { | ||
console.log(data); | ||
const newData = [] | ||
this.totalData = data; | ||
console.log(this.totalData); | ||
for (const [key, value] of Object.entries(data)) { | ||
console.log('changed:', key, value) | ||
const numberValue = parseInt(value, 10) | ||
newData.push([key, numberValue]) | ||
var flag = 0; | ||
for (var i = 0; i < key.length; i++) { | ||
if (key[i] == "I" && key[i + 1] == "P") { | ||
flag = 1; | ||
delete (data[key]); | ||
if (this.tableData.length < 4) { | ||
this.tableData.push({ "key": key, "value": value }) | ||
} | ||
} | ||
} | ||
if (flag == 0) { | ||
newData.push([key, numberValue]); | ||
} | ||
} | ||
|
||
console.log(newData) | ||
this.newData = newData; | ||
this.changingChart.data = newData | ||
}) | ||
this.repeat(); | ||
} | ||
|
||
ngOnDestroy () { | ||
ngOnDestroy() { | ||
if (this.subscription) { | ||
this.subscription.unsubscribe() | ||
} | ||
} | ||
|
||
repeat() { | ||
let timer = setInterval(() => { this.changeChart() }, 10000); | ||
} | ||
changeChart() { | ||
this.changingChart.data = [ | ||
['Copper', Math.random() * 20.0], | ||
['Silver', Math.random() * 20.0], | ||
['Gold', Math.random() * 20.0], | ||
['Platinum', Math.random() * 20.0], | ||
] | ||
this.changingChart.data = []; | ||
for (var i = this.pos; i < this.pos + 7; i++) { | ||
if (i >= this.newData.length) { | ||
break; | ||
} else { | ||
this.changingChart.data.push(this.newData[i]) | ||
} | ||
} | ||
this.pos += 7; | ||
if (this.pos >= this.newData.length) { | ||
this.pos = 0; | ||
} | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we only include the
css
in the component files?Because I do not think include
css
intoapp.module.ts
is a good idea.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,I will amend as soon as possible