11 files added
5 files modified
New file |
| | |
| | | import { Type } from '@angular/core'; |
| | | import { Types } from '@core/enum/types.enum'; |
| | | export interface Column { |
| | | text?: string; |
| | | name?: string; |
| | | value?: any; |
| | | width?: string; |
| | | sort?: boolean; |
| | | type?: DataType; |
| | | } |
| | | export interface DataType { |
| | | name: Types; |
| | | format?: any; |
| | | } |
| | | // 作为http来回传递参数 |
| | | export interface PageBean { |
| | | pageIndex?: number ; // 页码 |
| | | pageSize?: number ; // 一页多少条 |
| | | total?: number; |
| | | data?: any[]; |
| | | queryParams?: string; |
| | | } |
| | | export class Grid implements PageBean { |
| | | title = ''; |
| | | pageIndex = 0; // 页码 |
| | | pageSize = 10; // 每页几行数据 |
| | | data: any[] = []; |
| | | total = 0; |
| | | queryParams = ''; |
| | | pages = 0; // 总页数 |
| | | queryMap?: any = {}; |
| | | size = 0; // 当前页数据条数 |
| | | sorts?: any[] = []; |
| | | indeterminate = false; |
| | | allChecked = false; |
| | | selectedIndexs?: number[] = []; // 被选中序列号 |
| | | columns?: Column[] = []; |
| | | |
| | | checkAll(value: boolean) { |
| | | this.data.forEach( |
| | | row => {row.checked = value;} |
| | | ) |
| | | this.refreshStatus(); |
| | | } |
| | | getData():any[]{ |
| | | return this.data; |
| | | } |
| | | initData(pageData: {data?: any[], total?: number}) { |
| | | if ( pageData != null && pageData.data != null) { |
| | | let index = 0; |
| | | this.data = pageData.data.map(row => { |
| | | row['index'] = index++; |
| | | return row; |
| | | }); |
| | | this.total = pageData.total; |
| | | } |
| | | } |
| | | refreshStatus() { |
| | | const data = this.data; |
| | | const allChecked = data.every(value => value.checked); |
| | | const allUnChecked = data.every(value => !value.checked); |
| | | this.allChecked = allChecked; |
| | | this.indeterminate = (!allChecked) && (!allUnChecked); |
| | | this.selectedIndexs = data.filter(value => value.checked).map( |
| | | row => { |
| | | return row['index'] != null ? row['index'] : 0; |
| | | } |
| | | ); |
| | | this.selectedIndexs = this.selectedIndexs == null ? [] : this.selectedIndexs; |
| | | } |
| | | constructor(config: object) { |
| | | if (config != null) { |
| | | const keys = Object.getOwnPropertyNames(config); |
| | | for (const index in keys) { |
| | | const key = keys[index]; |
| | | if (this[key] != null) { |
| | | this[key] = config[key]; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | public setColumns(obj: Object) { |
| | | this.columns = this.objectToArray(obj); |
| | | } |
| | | private objectToArray(obj: Object): any[] { |
| | | const arr = []; |
| | | const keys = Object.getOwnPropertyNames(obj); |
| | | for (const index in keys) { |
| | | const key = keys[index]; |
| | | const item = obj[key]; |
| | | if ( item['name'] == null) { |
| | | item['name'] = key; |
| | | } |
| | | arr.push(item); |
| | | } |
| | | return arr; |
| | | } |
| | | } |
New file |
| | |
| | | export enum Types { |
| | | Date,json |
| | | } |
New file |
| | |
| | | import { NgModule } from '@angular/core'; |
| | | import { CommonModule } from '@angular/common'; |
| | | import { TyepHandlePipe } from './tyep-handle.pipe'; |
| | | import { DateService } from '@core/services/date.service'; |
| | | |
| | | @NgModule({ |
| | | imports: [ |
| | | CommonModule |
| | | ], |
| | | declarations: [TyepHandlePipe], |
| | | exports: [TyepHandlePipe], |
| | | providers: [DateService] |
| | | }) |
| | | export class PipeModule { } |
New file |
| | |
| | | import { DatePipe } from '@angular/common/src/pipes/date_pipe'; |
| | | import { Types } from './../enum/types.enum'; |
| | | |
| | | import { Pipe, PipeTransform } from '@angular/core'; |
| | | import { TranslateService } from '@ngx-translate/core'; |
| | | import { NzDatePipe } from 'ng-zorro-antd/src/util/nz-date.pipe'; |
| | | import { DateService } from '@core/services/date.service'; |
| | | import { Column } from '@core/entity/grid'; |
| | | |
| | | |
| | | |
| | | @Pipe({ |
| | | name: 'tyepHandle' |
| | | }) |
| | | export class TyepHandlePipe implements PipeTransform { |
| | | constructor(private dateService: DateService) { |
| | | } |
| | | |
| | | transform(value: any, col?: Column): any { |
| | | const t = Types.Date; |
| | | const type = col.type; |
| | | if(type!=null&&type.name!=null){ |
| | | value = this.transformHandle(value,type.name,type.format); |
| | | } |
| | | return value; |
| | | } |
| | | private transformHandle(value:any,type: Types,format:any):any{ |
| | | switch(type){ |
| | | case Types.Date: |
| | | return this.dateService.date_format(value,format); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | |
| | | import { Injectable } from '@angular/core'; |
| | | import { Column } from '@core/entity/grid'; |
| | | |
| | | export class Criteria{ |
| | | private static CONDITION_SPLIT = "||"; |
| | | private conditions: string[] = []; |
| | | public getConditions(): string[]{ |
| | | return this.conditions; |
| | | } |
| | | |
| | | public addCondition(condition: string,colName:string,...values: any[]){ |
| | | const split = Criteria.CONDITION_SPLIT;//'||' |
| | | this.conditions.push(condition+split+colName+split+ values.join(split)); |
| | | } |
| | | public andLike(col:Column): Criteria{ |
| | | this.addCondition('andLike',col.name,col.value); |
| | | return this; |
| | | } |
| | | public andEqualTo(col:Column): Criteria{ |
| | | this.addCondition('andEqualTo',col.name,col.value); |
| | | return this; |
| | | } |
| | | } |
| | | |
| | | @Injectable() |
| | | export class ExampleService { |
| | | private static OR_SPLIT = "or|"; |
| | | private static CRITERIA_SPLIT = "|||"; |
| | | private criterion: Criteria[]=[]; |
| | | |
| | | public getSqlParam():string{ |
| | | let whereSql = ''; |
| | | for(let cri of this.criterion){ |
| | | const conditions = cri.getConditions(); |
| | | whereSql += ExampleService.OR_SPLIT+conditions.join(ExampleService.CRITERIA_SPLIT); |
| | | } |
| | | return encodeURI(whereSql); |
| | | } |
| | | constructor() { } |
| | | public or(){ |
| | | const cri = new Criteria(); |
| | | this.criterion.push(cri); |
| | | return cri; |
| | | } |
| | | } |
New file |
| | |
| | | import { Injectable } from '@angular/core'; |
| | | |
| | | @Injectable() |
| | | export class ToolsService { |
| | | |
| | | } |
| | |
| | | |
| | | import { ToolsService } from './../../core/services/tools.service'; |
| | | import { NgModule } from '@angular/core'; |
| | | import { CommonModule } from '@angular/common'; |
| | | import { BasicInfoComponent } from './basic-info/basic-info.component'; |
| | | import { VersionComponent } from './version/version.component'; |
| | | import { MonitorPointComponent } from './monitor-point/monitor-point.component'; |
| | | import {RouterModule, Routes} from '@angular/router'; |
| | | import { SharedModule } from '@shared/shared.module'; |
| | | import { VersionService } from 'app/routes/devices/version/version.service'; |
| | | import { Version } from '@angular/compiler/src/util'; |
| | | import { _HttpClient } from '@delon/theme/services/http/http.client'; |
| | | import { AddOrEditComponent } from './version/add-or-edit/add-or-edit.component'; |
| | | import { PipeModule } from '@core/pipe/pipe.module'; |
| | | |
| | | const COMPONENTS_NOROUNT = [ AddOrEditComponent ]; |
| | | |
| | | const routes: Routes = [ |
| | | { |
| | |
| | | |
| | | @NgModule({ |
| | | imports: [ |
| | | //管道模块必须当前模块导入 |
| | | PipeModule, |
| | | CommonModule, |
| | | SharedModule, |
| | | RouterModule.forChild(routes) |
| | | ], |
| | | declarations: [ |
| | | BasicInfoComponent, |
| | | VersionComponent, |
| | | MonitorPointComponent |
| | | ] |
| | | MonitorPointComponent, |
| | | ...COMPONENTS_NOROUNT, |
| | | AddOrEditComponent |
| | | ], |
| | | providers: [ToolsService, VersionService, _HttpClient], |
| | | entryComponents: COMPONENTS_NOROUNT |
| | | }) |
| | | export class DevicesModule { } |
New file |
| | |
| | | <p> |
| | | add-or-edit works! |
| | | </p> |
New file |
| | |
| | | import { Component, OnInit } from '@angular/core'; |
| | | |
| | | @Component({ |
| | | selector: 'app-add-or-edit', |
| | | templateUrl: './add-or-edit.component.html', |
| | | styles: [] |
| | | }) |
| | | export class AddOrEditComponent implements OnInit { |
| | | |
| | | constructor() { } |
| | | |
| | | ngOnInit() { |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | import { DeviceVersion } from './version.service'; |
| | | import { ExampleService } from './../../../core/services/example.service'; |
| | | import { _HttpClient } from '@delon/theme'; |
| | | import { environment } from './../../../../environments/environment.prod'; |
| | | import { RouteConfigLoadStart } from '@angular/router'; |
| | | import { Injectable } from '@angular/core'; |
| | | import { equal } from 'assert'; |
| | | import { Observable } from 'rxjs/Observable'; |
| | | import { PageBean } from '@core/entity/grid'; |
| | | |
| | | |
| | | export interface DeviceVersion { |
| | | createTime?: any; |
| | | description?: string; |
| | | id?: number; |
| | | name?: string; |
| | | version?: number; |
| | | } |
| | | |
| | | @Injectable() |
| | | export class VersionService { |
| | | private urls = { |
| | | edit: environment.SERVER_BASH_URL + '/device-version/page-list' |
| | | }; |
| | | constructor(private http: _HttpClient) { } |
| | | public getPagingList(page: PageBean, queryText: string): Observable<PageBean> { |
| | | const example = new ExampleService(); |
| | | example.or().andLike({name: 'name', value: '%' + queryText + '%'}); |
| | | example.or().andEqualTo({name: 'version', value: queryText}); |
| | | const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, queryParams: example.getSqlParam()}; |
| | | return this.http.get(this.urls.edit, param); |
| | | } |
| | | } |
| | |
| | | import { DevicesModule } from './devices/devices.module'; |
| | | import { _HttpClient } from '@delon/theme'; |
| | | import { NgModule } from '@angular/core'; |
| | | import { RouterModule } from '@angular/router'; |
| | | import { SharedModule } from '@shared/shared.module'; |
| | |
| | | import { DashboardAnalysisComponent } from './dashboard/analysis/analysis.component'; |
| | | import { DashboardMonitorComponent } from './dashboard/monitor/monitor.component'; |
| | | import { DashboardWorkplaceComponent } from './dashboard/workplace/workplace.component'; |
| | | import { CoreModule } from '@core/core.module'; |
| | | |
| | | @NgModule({ |
| | | imports: [ |
| | |
| | | DashboardV1Component, |
| | | DashboardAnalysisComponent, |
| | | DashboardMonitorComponent, |
| | | DashboardWorkplaceComponent, |
| | | DashboardWorkplaceComponent |
| | | ], |
| | | exports: [ |
| | | RouterModule |
| | | ], |
| | | providers: [ |
| | | _HttpClient |
| | | ] |
| | | }) |
| | | |
New file |
| | |
| | | // import 'rxjs/Rx'; // adds ALL RxJS statics & operators to Observable |
| | | |
| | | // See node_module/rxjs/Rxjs.js |
| | | // Import just the rxjs statics and operators we need for THIS app. |
| | | |
| | | // Statics |
| | | import 'rxjs/add/observable/throw'; |
| | | |
| | | // Operators |
| | | import 'rxjs/add/operator/catch'; |
| | | import 'rxjs/add/operator/debounceTime'; |
| | | import 'rxjs/add/operator/distinctUntilChanged'; |
| | | import 'rxjs/add/operator/map'; |
| | | import 'rxjs/add/operator/switchMap'; |
| | | import 'rxjs/add/operator/toPromise'; |
| | |
| | | AdImageModule, |
| | | AdUtilsModule |
| | | } from '@delon/abc'; |
| | | import { _HttpClient } from '@delon/theme/services/http/http.client'; |
| | | import { CoreModule } from '@core/core.module'; |
| | | const ABCMODULES = [ |
| | | AdAvatarListModule, |
| | | AdChartsModule, |
| | |
| | | production: true, |
| | | hmr: false, |
| | | useHash: true, |
| | | SERVER_BASH_URL: 'http://47.96.171.62:8080/screen_api_v2' |
| | | SERVER_BASH_URL: 'http://localhost:8001' |
| | | }; |
| | |
| | | "moduleResolution": "node", |
| | | "emitDecoratorMetadata": true, |
| | | "experimentalDecorators": true, |
| | | "noUnusedLocals": false, |
| | | "noUnusedParameters": false, |
| | | "target": "es5", |
| | | "typeRoots": [ |
| | | "node_modules/@types" |