Browse Source

[完善]摄像头名字格式

develop
邵佳豪 3 years ago
parent
commit
0aa47209a0
  1. 1
      src/app/system-management/condition-monitoring/condition-monitoring.component.html
  2. 27
      src/app/system-management/host-config/addcamera/addcamera.component.ts
  3. 4
      src/app/system-management/host-config/editcamera/editcamera.component.ts
  4. 38
      src/app/system-management/host-config/host-config.component.ts

1
src/app/system-management/condition-monitoring/condition-monitoring.component.html

@ -128,6 +128,7 @@
<span *ngIf="data.monitorUpdatingState == 'Never'">未更新</span>
<span *ngIf="data.monitorUpdatingState == 'Updating'">更新中</span>
<span *ngIf="data.monitorUpdatingState == 'Updated'">已更新</span>
<span *ngIf="data.monitorUpdatingState == 'UpdatingTimeout'">更新超时</span>
</td>
<td>
<span>{{data.monitorUpdatingStartedTime ? (data.monitorUpdatingStartedTime | date:"yyyy-MM-dd HH:mm:ss") :

27
src/app/system-management/host-config/addcamera/addcamera.component.ts

@ -1,7 +1,8 @@
import { Component, OnInit, Input } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
@Component({
selector: 'app-addcamera',
templateUrl: './addcamera.component.html',
@ -13,8 +14,9 @@ export class AddcameraComponent implements OnInit {
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { }
ngOnInit(): void {
const { namevalidate } = MyValidators;
this.validateForm = this.fb.group({
name: [null, [Validators.required]],
name: [null, [Validators.required, namevalidate]],
user: [null, [Validators.required]],
password: [null, [Validators.required]],
uri: [null, [Validators.required]],
@ -25,3 +27,24 @@ export class AddcameraComponent implements OnInit {
}
export type MyErrorsOptions = { 'zh-cn': string; en: string } & Record<string, NzSafeAny>;
export type MyValidationErrors = Record<string, MyErrorsOptions>;
export class MyValidators extends Validators {
static namevalidate(control: AbstractControl): MyValidationErrors | null {
const value = control.value;
if (isEmptyInputValue(value)) {
return null;
}
return isPassword(value) ? null : { mobile: { 'zh-cn': `名称只能是汉字、大小写英文、数字,不能使用特殊字符`, en: `Password phone number is not valid` } };
}
}
function isEmptyInputValue(value: NzSafeAny): boolean {
return value == null || value.length === 0;
}
function isPassword(value: string): boolean {
return typeof value === 'string' && /^[\u4E00-\u9FA5A-Za-z0-9]+$/.test(value);
}

4
src/app/system-management/host-config/editcamera/editcamera.component.ts

@ -2,6 +2,7 @@ import { Component, OnInit, Input } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { MyValidators } from '../addcamera/addcamera.component';
@Component({
selector: 'app-editcamera',
@ -15,10 +16,11 @@ export class EditcameraComponent implements OnInit {
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { }
ngOnInit(): void {
const { namevalidate } = MyValidators;
let datacopy = JSON.parse(JSON.stringify(this.data))
console.log('编辑数据', datacopy)
this.validateForm = this.fb.group({
name: [datacopy.name, [Validators.required]],
name: [datacopy.name, [Validators.required,namevalidate]],
user: [datacopy.user, [Validators.required]],
password: [datacopy.password, [Validators.required]],
uri: [datacopy.uri, [Validators.required]],

38
src/app/system-management/host-config/host-config.component.ts

@ -189,7 +189,7 @@ export class HostConfigComponent implements OnInit {
if (data.configFiles) {
this.isSourceYaml = true
const element = document.documentElement
if(element.requestFullscreen) { //进入全屏
if (element.requestFullscreen) { //进入全屏
element.requestFullscreen();
}
const modal = this.modal.create({
@ -208,7 +208,7 @@ export class HostConfigComponent implements OnInit {
data: item.id
},
nzOnOk: async () => {
}
});
const instance = modal.getContentComponent();
@ -241,23 +241,23 @@ export class HostConfigComponent implements OnInit {
// this.message.create('error', '存在摄像头未标注的情况');
// return
// }
let ids = []
this.listOfData.forEach((item: any) => {
ids.push(item.id)
})
this.http.get('/api/Cameras/Statuses', {
params: { ids: ids }
}).subscribe({
next: (data) => {
console.log('连接状态', data)
this.disposalData()
this.router.navigate(['/system/host/camera/configForm'], { queryParams: { 'hostId': this.hostId, 'orId': this.orId } })
},
error: (err) => {
console.log('连接失败', err)
}
})
// let ids = []
// this.listOfData.forEach((item: any) => {
// ids.push(item.id)
// })
// this.http.get('/api/Cameras/Statuses', {
// params: { ids: ids }
// }).subscribe({
// next: (data) => {
// console.log('连接状态', data)
// },
// error: (err) => {
// console.log('连接失败', err)
// }
// })
this.disposalData()
this.router.navigate(['/system/host/camera/configForm'], { queryParams: { 'hostId': this.hostId, 'orId': this.orId } })
}

Loading…
Cancel
Save