Commit 7117accf80baf48818c150d76635af71c2b48ac4
1 parent
d3423f8e
add empty bus stop
Showing
5 changed files
with
79 additions
and
76 deletions
 
Show diff stats
src/app/pages/statements/components/busStop2/busStop2.component.ts
| 1 | 1 | import { Component, ViewEncapsulation } from '@angular/core'; | 
| 2 | 2 | |
| 3 | 3 | import { BusStop2Service } from './busStop2.service'; | 
| 4 | - | |
| 4 | +import { busStop2 } from './busStop2'; | |
| 5 | 5 | import { LocalDataSource } from 'ng2-smart-table'; | 
| 6 | 6 | import { GridOptions } from 'ag-grid/main'; | 
| 7 | 7 | |
| 8 | 8 | @Component({ | 
| 9 | 9 | selector: 'statement-table', | 
| 10 | 10 | encapsulation: ViewEncapsulation.None, | 
| 11 | - styleUrls: ['./busStop2.scss'], | |
| 11 | + styleUrls: ['./busStop2.scss', | |
| 12 | + '../../../../../../node_modules/ag-grid/dist/styles/ag-grid.css', | |
| 13 | + '../../../../../../node_modules/ag-grid/dist/styles/theme-dark.css'], | |
| 12 | 14 | templateUrl: './busStop2.html', | 
| 13 | 15 | }) | 
| 14 | 16 | export class BusStop2 { | 
| 15 | - source: LocalDataSource = new LocalDataSource(); | |
| 17 | + // source: LocalDataSource = new LocalDataSource(); | |
| 16 | 18 | |
| 17 | 19 | public showGrid: boolean; | 
| 18 | 20 | public rowData: any[]; | 
| ... | ... | @@ -25,8 +27,14 @@ export class BusStop2 { | 
| 25 | 27 | this.gridOptions = <GridOptions>{}; | 
| 26 | 28 | // this.gridOptions.rowModelType = 'virtual'; | 
| 27 | 29 | this.service.getData().then((data) => { | 
| 28 | - this.source.load(data); | |
| 29 | - this.rowData = data; | |
| 30 | + console.log(data); | |
| 31 | + if(data.length){ | |
| 32 | + // this.source.load(data); | |
| 33 | + this.rowData = data; | |
| 34 | + } else { | |
| 35 | + this.rowData = [new busStop2] | |
| 36 | + } | |
| 37 | + | |
| 30 | 38 | }); | 
| 31 | 39 | this.createColumnDefs(); | 
| 32 | 40 | this.showGrid = true; | ... | ... | 
src/app/pages/statements/components/busStop2/busStop2.html
| 1 | 1 | <div class="widgets"> | 
| 2 | 2 | |
| 3 | - <div class="row"> | |
| 4 | - <ba-card title="Автобусні зупинки" baCardClass="with-scroll"> | |
| 5 | - <ag-grid-ng2 #agGrid style="width: 100%; height: 350px;" class="ag-bootstrap" | |
| 6 | - [gridOptions]="gridOptions" | |
| 7 | - [columnDefs]="columnDefs" | |
| 8 | - [rowData]="rowData" | |
| 3 | + <div class="row"> | |
| 4 | + <ba-card title="Автобусні зупинки" baCardClass="with-scroll"> | |
| 5 | + <ag-grid-ng2 #agGrid style="width: 100%; height: 350px;" class="ag-dark" [gridOptions]="gridOptions" [columnDefs]="columnDefs" [rowData]="rowData" enableColResize enableSorting enableFilter groupHeaders suppressRowClickSelection toolPanelSuppressGroups | |
| 6 | + toolPanelSuppressValues debug rowHeight="22" rowSelection="multiple"> | |
| 7 | + </ag-grid-ng2> | |
| 8 | + </ba-card> | |
| 9 | + </div> | |
| 9 | 10 | |
| 10 | - enableColResize | |
| 11 | - enableSorting | |
| 12 | - enableFilter | |
| 13 | - groupHeaders | |
| 14 | - suppressRowClickSelection | |
| 15 | - toolPanelSuppressGroups | |
| 16 | - toolPanelSuppressValues | |
| 17 | - debug | |
| 18 | - rowHeight="22" | |
| 19 | - rowSelection="multiple" | |
| 20 | - > | |
| 21 | - </ag-grid-ng2> | |
| 22 | - </ba-card> | |
| 23 | - </div> | |
| 24 | - | |
| 25 | -</div> | |
| 11 | +</div> | |
| 26 | 12 | \ No newline at end of file | ... | ... | 
src/app/pages/statements/components/busStop2/busStop2.service.ts
| ... | ... | @@ -3,27 +3,27 @@ import { Headers, Http } from '@angular/http'; | 
| 3 | 3 | |
| 4 | 4 | import 'rxjs/add/operator/toPromise'; | 
| 5 | 5 | |
| 6 | -import { BusStop2 } from './busStop2'; | |
| 6 | +import { busStop2 } from './busStop2'; | |
| 7 | 7 | |
| 8 | 8 | @Injectable() | 
| 9 | 9 | export class BusStop2Service { | 
| 10 | 10 | private url = 'http://localhost:5000/busstop'; | 
| 11 | 11 | private headers = new Headers({'Content-Type': 'application/json'}); | 
| 12 | 12 | constructor(private http: Http) { } | 
| 13 | - getData(): Promise<BusStop2[]> { | |
| 14 | - let busStops: BusStop2[] = [{ | |
| 15 | - id: 1, | |
| 16 | - road: 'Test', | |
| 17 | - region: 'Test', | |
| 18 | - locationLeft: '1', | |
| 19 | - locationRight: '1', | |
| 20 | - state: 'Test' | |
| 21 | - }]; | |
| 22 | - return Promise.resolve(busStops); | |
| 23 | - // return this.http.get(this.url) | |
| 24 | - // .toPromise() | |
| 25 | - // .then(response => response.json().busStopListDsM as BusStop2[]) | |
| 26 | - // .catch(this.handleError); | |
| 13 | + getData(): Promise<busStop2[]> { | |
| 14 | + // let busStops: BusStop2[] = [{ | |
| 15 | + // id: 1, | |
| 16 | + // road: 'Test', | |
| 17 | + // region: 'Test', | |
| 18 | + // locationLeft: '1', | |
| 19 | + // locationRight: '1', | |
| 20 | + // state: 'Test' | |
| 21 | + // }]; | |
| 22 | + // return Promise.resolve(busStops); | |
| 23 | + return this.http.get(this.url) | |
| 24 | + .toPromise() | |
| 25 | + .then(response => response.json().busStopEditDsM as busStop2[]) | |
| 26 | + .catch(this.handleError); | |
| 27 | 27 | } | 
| 28 | 28 | private handleError(error: any): Promise<any> { | 
| 29 | 29 | console.error('An error occured', error); | ... | ... | 
src/app/pages/statements/components/busStop2/busStop2.ts
| 1 | -export class BusStop2 { | |
| 2 | - id: number; | |
| 3 | - road: string; | |
| 4 | - region: string; | |
| 5 | - locationRight: string; | |
| 6 | - locationLeft: string; | |
| 7 | - state: string; | |
| 1 | +export class busStop2 { | |
| 2 | + RoadId: number; | |
| 3 | + RegionId: number; | |
| 4 | + SettlementId: number; | |
| 5 | + LocationLeft: string; | |
| 6 | + LocationRight: string; | |
| 7 | + SurfaceTypeId: string; | |
| 8 | + AreaStopAvailability: string; | |
| 9 | + AreaLandAvailability: string; | |
| 10 | + PocketAvailability: string; | |
| 11 | + ToiletAvailability: string; | |
| 12 | + YearBuild: string; | |
| 13 | + YearRepair: string; | |
| 14 | + StateCommonId: number; | |
| 8 | 15 | } | ... | ... | 
src/index.html
| 1 | 1 | <!DOCTYPE html> | 
| 2 | 2 | <html lang="en"> | 
| 3 | -<head> | |
| 4 | - <meta charset="utf-8"> | |
| 5 | - <meta http-equiv="x-ua-compatible" content="ie=edge"> | |
| 6 | - <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| 7 | - | |
| 8 | - <title><%= htmlWebpackPlugin.options.title %></title> | |
| 9 | 3 | |
| 4 | +<head> | |
| 5 | + <meta charset="utf-8"> | |
| 6 | + <meta http-equiv="x-ua-compatible" content="ie=edge"> | |
| 7 | + <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| 8 | + | |
| 9 | + <title> | |
| 10 | + <%= htmlWebpackPlugin.options.title %> | |
| 11 | + </title> | |
| 12 | + <!-- | |
| 10 | 13 | <link rel="stylesheet" href="/app/pages/statements/ag-grid.css"> | 
| 11 | - <link rel="stylesheet" href="/app/pages/statements/theme-bootstrap.css"> | |
| 12 | - <meta name="description" content="<%= htmlWebpackPlugin.options.metadata.description %>"> | |
| 13 | - <% if (webpackConfig.htmlElements.headTags) { %> | |
| 14 | - <!-- Configured Head Tags --> | |
| 15 | - <%= webpackConfig.htmlElements.headTags %> | |
| 16 | - <% } %> | |
| 14 | + <link rel="stylesheet" href="/app/pages/statements/theme-bootstrap.css">--> | |
| 15 | + <meta name="description" content="<%= htmlWebpackPlugin.options.metadata.description %>"> | |
| 16 | + <% if (webpackConfig.htmlElements.headTags) { %> | |
| 17 | + <!-- Configured Head Tags --> | |
| 18 | + <%= webpackConfig.htmlElements.headTags %> | |
| 19 | + <% } %> | |
| 17 | 20 | |
| 18 | - <!-- base url --> | |
| 19 | - <base href="<%= htmlWebpackPlugin.options.metadata.baseUrl %>"> | |
| 21 | + <!-- base url --> | |
| 22 | + <base href="<%= htmlWebpackPlugin.options.metadata.baseUrl %>"> | |
| 20 | 23 | |
| 21 | 24 | |
| 22 | 25 | </head> | 
| 23 | 26 | |
| 24 | 27 | <body> | 
| 25 | -<app> | |
| 26 | -</app> | |
| 28 | + <app> | |
| 29 | + </app> | |
| 27 | 30 | |
| 28 | -<div id="preloader"> | |
| 29 | - <div></div> | |
| 30 | -</div> | |
| 31 | + <div id="preloader"> | |
| 32 | + <div></div> | |
| 33 | + </div> | |
| 31 | 34 | |
| 32 | -<% if (htmlWebpackPlugin.options.metadata.isDevServer && htmlWebpackPlugin.options.metadata.HMR !== true) { %> | |
| 33 | -<!-- Webpack Dev Server reload --> | |
| 34 | -<script src="/webpack-dev-server.js"></script> | |
| 35 | -<% } %> | |
| 35 | + <% if (htmlWebpackPlugin.options.metadata.isDevServer && htmlWebpackPlugin.options.metadata.HMR !== true) { %> | |
| 36 | + <!-- Webpack Dev Server reload --> | |
| 37 | + <script src="/webpack-dev-server.js"></script> | |
| 38 | + <% } %> | |
| 36 | 39 | |
| 37 | -<link | |
| 38 | - href='https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900italic,900&subset=latin,greek,greek-ext,vietnamese,cyrillic-ext,latin-ext,cyrillic' | |
| 39 | - rel='stylesheet' type='text/css'> | |
| 40 | + <link href='https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900italic,900&subset=latin,greek,greek-ext,vietnamese,cyrillic-ext,latin-ext,cyrillic' rel='stylesheet' type='text/css'> | |
| 40 | 41 | </body> | 
| 41 | -</html> | |
| 42 | + | |
| 43 | +</html> | |
| 42 | 44 | \ No newline at end of file | ... | ... | 
