Commit 820df1ca authored by Jie Yuan's avatar Jie Yuan

add service component component

parent 17456670
<div class="serviceComponentContainer">
<div class="table-responsive-sm">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">Tag at Site</th>
<th scope="col">Production Tag</th>
<th scope="col">Service Type</th>
<th scope="col">Last Change on</th>
<th scope="col">History</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let tmp of servComps let i = index">
<th scope="row">{{i}}</th>
<td>{{tmp.name | uppercase}}</td>
<td>{{tmp.tagAtSite | uppercase}}</td>
<td>{{tmp.productionTag | uppercase}}</td>
<td>{{tmp.serviceType | uppercase}}</td>
<td>{{tmp.createdTime}}</td>
<td>
<div>
<button type="button" class="btn btn-info btn-xs" (click)="onHistory(tmp)">
Services
</button>
</div>
</tr>
</tbody>
</table>
</div>
<router-outlet></router-outlet>
</div>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ServiceComponentComponent } from './service-component.component';
describe('ServiceComponentComponent', () => {
let component: ServiceComponentComponent;
let fixture: ComponentFixture<ServiceComponentComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ServiceComponentComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ServiceComponentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import {Component, OnDestroy, OnInit} from '@angular/core';
import {ServiceComponent} from '../../model/service-component';
import {ServiceComponentService} from '../../service-component.service';
import { SiteShortService } from '../../site-short.service';
import {ActivatedRoute, Router} from '@angular/router';
@Component({
selector: 'app-servcomponent',
templateUrl: './service-component.component.html',
styleUrls: ['./service-component.component.css']
})
export class ServiceComponentComponent implements OnInit, OnDestroy {
// export class ServiceCompComponent implements OnDestroy {
servComps: ServiceComponent[];
servName: string;
constructor(private servComponentService: ServiceComponentService, private siteService: SiteShortService,
public router: Router,
public route: ActivatedRoute) {
//this.servComp = new ServiceComponent('default');
//this.servComp = servComponentService.getSelectedServComp();
this.servName = this.siteService.currentService;
this.setServiceComponents();
}
setServiceComponents() {
this.siteService.getServiceComponentsForAHost()
.then(
(list: ServiceComponent[]) => {
console.log('Loaded hostname list: ', list);
this.servComps = list;
}
).catch(
error => {
console.log('Error while loading hosts ');
console.log(error);
this.servComps = [];
}
);
}
ngOnInit() {
}
ngOnDestroy() {
}
onHistory(servComp: ServiceComponent) {
console.log('history clicked');
this.siteService.setCurrentServiceComponent(servComp);
sessionStorage.setItem('currentServComp', JSON.stringify(servComp));
this.router.navigate(['/dashboard/servCompHisComponent'], { relativeTo: this.route });
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment