From 3734d2a2be95246df799b1d36149bf7c09a701de Mon Sep 17 00:00:00 2001 From: Alessandro Francia Date: Wed, 9 Jan 2019 08:33:29 +0100 Subject: [PATCH] alarm history --- Step/wwwroot/assets/styles/base/alarms.less | 19 ++ Step/wwwroot/assets/styles/style.css | 16 ++ .../alarms/components/alarm-detail.ts | 3 +- .../alarms/components/alarm-history.ts | 195 ++++++++++++++++- .../alarms/components/alarm-history.vue | 206 +++++++++++++----- Step/wwwroot/src/services/alarmsService.ts | 26 ++- Step/wwwroot/src/store/alarms.store.ts | 3 + 7 files changed, 410 insertions(+), 58 deletions(-) diff --git a/Step/wwwroot/assets/styles/base/alarms.less b/Step/wwwroot/assets/styles/base/alarms.less index 5a6a8f86..326ab559 100644 --- a/Step/wwwroot/assets/styles/base/alarms.less +++ b/Step/wwwroot/assets/styles/base/alarms.less @@ -704,6 +704,21 @@ } } } + + .alarm-disable-box-right{ + width: 496px; + height: 760px; + position: absolute; + display: flex; + align-items: center; + justify-content: center; + z-index: 200; + background-color: #ffffffcc; + font-size: 24px; + font-weight: bold; + color: #4b4b4b; + } + .alarm-history-body-right{ width: 496px; height: 760px; @@ -875,6 +890,10 @@ border: 2px solid @color-darkish-blue; color: @color-darkish-blue; } + + .message-box{ + width: 370px; + } } } } diff --git a/Step/wwwroot/assets/styles/style.css b/Step/wwwroot/assets/styles/style.css index 8aeba641..2fc4522b 100644 --- a/Step/wwwroot/assets/styles/style.css +++ b/Step/wwwroot/assets/styles/style.css @@ -4207,6 +4207,19 @@ footer .container button.big:before { .alarm-history-container .alarm-history-body .alarm-history-body-left .alarm-history-table tr:nth-child(odd) { background-color: rgba(23, 145, 255, 0.3); } +.alarm-history-container .alarm-history-body .alarm-disable-box-right { + width: 496px; + height: 760px; + position: absolute; + display: flex; + align-items: center; + justify-content: center; + z-index: 200; + background-color: #ffffffcc; + font-size: 24px; + font-weight: bold; + color: #4b4b4b; +} .alarm-history-container .alarm-history-body .alarm-history-body-right { width: 496px; height: 760px; @@ -4393,6 +4406,9 @@ footer .container button.big:before { border: 2px solid #002680; color: #002680; } +.alarm-history-container .alarm-history-body .alarm-history-body-right .box-right .box-right-action .note .message-box { + width: 370px; +} .hmi-container { position: absolute; left: 0; diff --git a/Step/wwwroot/src/app_modules/alarms/components/alarm-detail.ts b/Step/wwwroot/src/app_modules/alarms/components/alarm-detail.ts index 1e0cdde3..b6ce1fb4 100644 --- a/Step/wwwroot/src/app_modules/alarms/components/alarm-detail.ts +++ b/Step/wwwroot/src/app_modules/alarms/components/alarm-detail.ts @@ -63,7 +63,7 @@ export default class AlarmDetail extends Vue { updateLimitation() { if (this.limitationList > 3) - this.limitationList == 3; + this.limitationList = 3; else this.limitationList = Math.max(this.attaches.length, this.notes.length, 3); } @@ -139,6 +139,7 @@ export default class AlarmDetail extends Vue { } } async saveNote(note) { + debugger if (!note) return; let result = await alarmsService.postNote(this.alarm.id, note.message); diff --git a/Step/wwwroot/src/app_modules/alarms/components/alarm-history.ts b/Step/wwwroot/src/app_modules/alarms/components/alarm-history.ts index b5128ecb..e62f24c5 100644 --- a/Step/wwwroot/src/app_modules/alarms/components/alarm-history.ts +++ b/Step/wwwroot/src/app_modules/alarms/components/alarm-history.ts @@ -6,6 +6,10 @@ import DatePicker from 'vue2-datepicker' import { Watch } from "vue-property-decorator"; import { alarmsService } from "src/services/alarmsService"; import { AlarmModel } from "@/src/store"; +import { ModalHelper } from "../../../components/modals"; +import { getColorFromName, isDarkColor } from "src/_base/utils"; + +import moment from "moment"; @Component({ components: { @@ -32,17 +36,46 @@ export default class AlarmHistory extends Vue { interval?: Date[] } = { type: 0, - user: null, - title: null, + user: 1, + title: "", }; - users: any = []; + types: Array = [ + "NC","PLC" + ]; + + users: Array = []; data: AlarmModel[] = [] paginationData: { firstDate: any, pages: number } = null; + selectedAlarm: AlarmModel = null; + selectedAttach: any = null; + selectedNote: any = null; + attaches = []; + notes = []; + limitationList: number = 3; + newAttach: any = null; + newNote: any = {}; + enableModifyNote = true; + // get filteredAttaches() { + // return this.attaches.filter((v, idx) => idx < this.limitationList); + // } + + get currentUser() { + return this.$store.state.currentUser; + } + + get filteredAttaches() { + return this.attaches.filter((v, idx) => idx < this.limitationList); + } + + + get filteredNotes() { + return this.notes.filter((v, idx) => idx < this.limitationList); + } @Watch("filter", { deep: true }) async filterChanged(n, o) { - + debugger let from = this.filter.interval && this.filter.interval.length ? this.filter.interval[0] : null; let to = this.filter.interval && this.filter.interval.length ? this.filter.interval[1] : null; @@ -50,7 +83,161 @@ export default class AlarmHistory extends Vue { } async mounted() { + var $this = this; this.users = await loginService.getAllUsers(); this.paginationData = await alarmsService.getAlarmsData(); } + + async onChange(e) { + this.newAttach = e.target.files[0]; + let result = await alarmsService.postAttachment(this.selectedAlarm.alarmId, this.newAttach); + this.attaches.push(result.data); + + // new MaintenanceService().uploadFile(this.selectedMaintenance, this.state.file); + } + + user(id: number) + { + return this.users.find(x => x.id == id) || {}; + } + + async selectAlarm(alarm){ + debugger + this.selectedAlarm = alarm; + this.attaches = await alarmsService.getAttachments(this.selectedAlarm.alarmId); + this.notes = await alarmsService.getNote(this.selectedAlarm.alarmId); + } + + updateLimitation() { + debugger + if (this.limitationList > 3) + this.limitationList = 3; + else + this.limitationList = Math.max(this.attaches.length, this.notes.length, 3); + } + + isimage(name) { + if (name.endsWith(".png") || name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".pjpeg") || name.endsWith(".jfif") || name.endsWith(".pjp")) + return true + return false + } + ispdf(name) { + if (name.endsWith(".pdf") || name.endsWith(".pdfa")) + return true + return false + } + + onClickSelectAttach(attach) { + this.selectedAttach = attach; + } + + onClickSelectNote(note) { + this.selectedNote = note; + } + + deselectNote() { + if (!this.enableModifyNote) return; + this.selectedNote = {}; + } + + onClickModifyNote(note) { + if (this.selectedNote == note) { + this.enableModifyNote = false; + this.isDisabled(note); + } + this.enableModifyNote = false; + this.selectedNote = note; + } + + async openAttach(attach) { + if (attach) { + await alarmsService.OpenModal(attach, this.isimage(attach.fileName)); + } + } + + onClickCancelModifyNote() { + this.enableModifyNote = true; + } + + async onClickDeleteNote(note){ + debugger + let $this = this; + if(note){ + ModalHelper.AskConfirm(this.$options.filters.localize("modal_confirm_delete", "Richiesta di conferma"), + this.$options.filters.localize("modal_confirm_delete_note", "Confermi la cancellazione della nota?"), + () => { + alarmsService.deleteNote(this.selectedAlarm.alarmId,note.id).then(response => { + let idx = $this.notes.indexOf(note); + $this.notes.splice(idx, 1); + }); + }, null); + } + } + + deleteAttach(attach) { + + let $this = this; + if (attach) { + ModalHelper.AskConfirm(this.$options.filters.localize("modal_confirm_delete", "Richiesta di conferma"), + this.$options.filters.localize("modal_confirm_delete_attachment", "Confermi la cancellazione dell'allegato?"), + () => { + alarmsService.deleteAttachments(attach.attachmentId).then(response => { + let idx = $this.attaches.indexOf(attach); + $this.attaches.splice(idx, 1); + }); + }, null); + } + } + + async saveModifyNoteMaintenance(note){ + debugger + if(!note){ + this.enableModifyNote = true; + return; + } + + let result = await alarmsService.putNote(this.selectedAlarm.alarmId, note.id, note.message); + + for(let index in this.notes){ + let obj = this.notes[index]; + if(obj.id == note.id){ + this.notes.splice(parseInt(index),1); + this.notes.push(result); + this.enableModifyNote = true; + } + } + } + + async saveNote(note) { + debugger + if (!note) return; + + let result = await alarmsService.postNote(this.selectedAlarm.alarmId, note.message); + this.notes.push(result); + this.newNote = {}; + + } + + isDisabled(note) { + if (this.selectedNote && this.selectedNote.id == note.id && !this.enableModifyNote) { + return false; + } + else { + return true; + } + } + + getColor(nome, cognome) { + return getColorFromName(nome, cognome); + } + isDarkColor(color) { + return isDarkColor(color); + } + + convertDate(date) { + return moment(date).format('L'); + } + convertDateToTime(date) { + return moment(date).format('LT'); + } } diff --git a/Step/wwwroot/src/app_modules/alarms/components/alarm-history.vue b/Step/wwwroot/src/app_modules/alarms/components/alarm-history.vue index aa4a975b..8b583cc0 100644 --- a/Step/wwwroot/src/app_modules/alarms/components/alarm-history.vue +++ b/Step/wwwroot/src/app_modules/alarms/components/alarm-history.vue @@ -48,56 +48,60 @@ {{'alarms_history.ID' | localize("ID")}} {{'alarms_history.Tipo' | localize("Tipo") }} + {{'alarms_history.Titolo' | localize("Titolo Allarme") }} {{'alarms_history.Descrizione'| localize("Descrizione")}} - {{'alarms_history.Start'| localize("Start")}} - {{'alarms_history.Stop'| localize("Stop")}} - {{'alarms_history.TTotale'| localize("T.Totale")}} + {{'alarms_history.Data'| localize("Data")}} {{'alarms_history.Utente'| localize("Utente")}} - - {{row}} - 001 - Allarme - Mandrino 1 non bloccato - 15:24:53 - 15:24:53 - 15:24:53 - User01 + + {{row.id}} + {{types[row.type]}} + {{row.title}} + {{row.description}} + {{row.timeStamp | date('DD-MM-YYYY HH:mm:ss')}} + + + {{user(iduser).username}} + , + +
-
-
+ + +
- -
- - - - NomeFile.pdf -
- - + + -
- -
-
- {{'alarm_history_allattach_strong_label_add_attach' | localize("Aggiungi un allegato")}} -
- + + + +
-
--> +
+
+ +
diff --git a/Step/wwwroot/src/services/alarmsService.ts b/Step/wwwroot/src/services/alarmsService.ts index ba1660bb..89641411 100644 --- a/Step/wwwroot/src/services/alarmsService.ts +++ b/Step/wwwroot/src/services/alarmsService.ts @@ -15,10 +15,13 @@ export class AlarmsService extends baseRestService { let types = []; if (user) users.push(user); - if (type) types.push(type); + // if (type) types.push(type); + if(type != null || type != undefined){ + types.push(type); + } let result = await this.Post(this.BASE_URL + "paginated", { - "page": page +1, + "page": page, "pageSize": pagesize, "title": title, "type": types, @@ -26,7 +29,24 @@ export class AlarmsService extends baseRestService { "endDate": toDate, "userIds": users, language: "en" - }, true); + } + // { + // "page": 0, + // "pageSize": 100, + // "title": "", + // "type": [ + // 0, + // 1 + // ], + // "startDate": "2019-01-03T23:00:00.000Z", + // "endDate": "2019-01-14T10:01:01.686Z", + // "userIds": [ + // 1, + // -1 + // ], + // "language": "en" + // } + , true); debugger return result; } diff --git a/Step/wwwroot/src/store/alarms.store.ts b/Step/wwwroot/src/store/alarms.store.ts index f6b6344c..9eb17f51 100644 --- a/Step/wwwroot/src/store/alarms.store.ts +++ b/Step/wwwroot/src/store/alarms.store.ts @@ -15,9 +15,12 @@ export interface AlarmModel { uid?: string; title: string; description: string; + alarmId?: number; date: Date; restorationIsActive: boolean; + timeStamp?: Date; + source?: string; process?: number;