Skip to content
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
wants to merge 13 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@types/shelljs": "^0.8.0",
"angular-google-charts": "0.0.9",
"core-js": "^2.5.4",
"element-angular": "^0.7.6",
"firebase": "^5.5.4",
"rxjs": "~6.2.0",
"shelljs": "^0.8.2",
Expand Down
4 changes: 4 additions & 0 deletions src/app/app.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.footer{
position: relative;
top: -160px
}
67 changes: 34 additions & 33 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,37 @@ <h1>
<app-cad-board>
</app-cad-board>


<b>
CAD-BOARD PROJECT IS HIRING!
</b>

<ol>
<li>
Database Administrator: TBH
</li>
<li>
Angular Developer: Hui KONG
</li>
<li>
Node JS Developer: TBH
</li>
<li>
System Administrator: Min LIN
</li>
<li>
UI Designer: TBH
</li>
</ol>


<p>
Contact Huan LI for details.
</p>

<div align="center">

<h3>Advertisement space for rent!</h3>

</div>
<div class="footer">
<b>
CAD-BOARD PROJECT IS HIRING!
</b>

<ol>
<li>
Database Administrator: TBH
</li>
<li>
Angular Developer: Hui KONG
</li>
<li>
Node JS Developer: TBH
</li>
<li>
System Administrator: Min LIN
</li>
<li>
UI Designer: TBH
</li>
</ol>


<p>
Contact Huan LI for details.
</p>

<div align="center">

<h3>Advertisement space for rent!</h3>

</div>
</div>
6 changes: 6 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { GoogleChartsModule } from 'angular-google-charts'

import { AppComponent } from './app.component'
import { CadScreenComponent } from './cad-board/cad-board.component'
// import module
import { ElModule } from 'element-angular'

// if you use webpack, import style
import 'element-angular/theme/index.css'
Copy link
Contributor

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 into app.module.ts is a good idea.

Copy link
Author

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


@NgModule({
declarations: [
Expand All @@ -16,6 +21,7 @@ import { CadScreenComponent } from './cad-board/cad-board.component'
],
imports: [
BrowserModule,
ElModule.forRoot(),
GoogleChartsModule,
FirebaseModule,
HttpClientModule,
Expand Down
21 changes: 21 additions & 0 deletions src/app/cad-board/cad-board.component.css
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;
}
31 changes: 21 additions & 10 deletions src/app/cad-board/cad-board.component.html
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 -->
69 changes: 49 additions & 20 deletions src/app/cad-board/cad-board.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Please keep the original format: vertical align the :, thanks.

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 {

Expand Down Expand Up @@ -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;
}
}

}