+
-
+
HELMET OPERATIONS
{{ currentNav.label }}
{{ descriptions[view] }}
{{ lastRefresh ? '갱신 '+clock(lastRefresh) : '갱신 대기' }}
@@ -30,17 +30,16 @@
장치 운영 현황 {{ devices.length }}
{{ demo ? '전체 장치의 연결 상태와 최신 데이터를 확인하세요.' : '현재 서버 연결 목록 기준 · 등록 장치 목록은 연동 예정' }}
-
+
{{ view==='devices'?'선택 장치 상세':'장치별 '+currentNav.label }}
장치를 선택하여 운영 데이터를 확인하세요.
- 조회할 장치가 없습니다연결 설정에서 서버 상태를 확인하세요.
+ 조회할 장치가 없습니다장치 연결 상태를 확인하세요.
- 수신이 중단된 장치입니다. 아래 값은 마지막 수신값이며, 현재 상태와 다를 수 있습니다. 마지막 수신: {{ dateTime(selected.last) }}
장치 정보
{{ isRecent(selected)?'수신 정상':'미수신' }}- 장치명
- {{ selected.name }}
- {{ demo?'장치 ID':'연결 식별자' }}
- {{ selected.key }}
- 최종 수신 시각
- {{ dateTime(selected.last) }}
- 안전모 보관
- {{ binary(latest.helmet,'보관 중','없음') }}
- 잠금 상태
- {{ binary(latest.lock,'잠김','해제') }}
최신 센서값
온도{{ value(latest.temp) }}°C
습도{{ value(latest.humi) }}%
배터리{{ value(latest.batt_pct) }}%
- 안전모 상태 진단
연동 예정{{ selected.diagnosis || '진단 결과 미연동' }}
진단 결과 수신 대기
{{ demo ? dateTime(selected.last) : '진단 시각: —' }}장치 제어
{{ demo?'시뮬레이션':'실제 장비' }}{{ c.label }}{{ c.key==='lock' ? binary(latest.lock,'잠김','해제') : state(latest[c.key]) }}
+ 안전모 상태 진단
연동 예정{{ selected.diagnosis || '진단 결과 미연동' }}
진단 결과 수신 대기
{{ demo ? dateTime(selected.last) : '진단 시각: —' }}장치 제어
{{ c.label }}{{ c.key==='lock' ? binary(latest.lock,'잠김','해제') : state(latest[c.key]) }}
{{ c.label }}{{ binary(latest[c.key],'가동 중','대기 중') }}
최종 수신 {{ dateTime(selected.last) }}
{{ state(latest[c.key]) }}
@@ -53,13 +52,10 @@
-
- 데이터 연결
데이터 소스와 서버 연결을 관리합니다.
연동 준비 현황
- 장치 연결 목록 · 최신 센서값기존 서버 API 연결 가능지원
- FAN · UV · 잠금 해제선택 장치에 제어 명령 전달지원
- {{ item }}연동 예정
프론트 UI 개발 버전관리자 인증과 접근 제한은 아직 적용되지 않았습니다. 운영용 공개 전에 서버 인증·HTTPS 구성을 완료해야 합니다. 기존 서버의 데이터 조회 API는 DB 저장도 수행합니다.
-
-
+
-
{{ demo?'제어 시뮬레이션':'장치 제어 확인' }}
{{ pendingControl.name }} ({{ pendingControl.target }})
{{ pendingControl.label }} {{ pendingControl.action }}
{{ demo?'시뮬레이션 상태만 변경됩니다.':'확인하면 선택한 실제 장비에 명령을 전송합니다.' }}
+
장치 제어 확인
{{ pendingControl.name }} ({{ pendingControl.target }})
{{ pendingControl.label }} {{ pendingControl.action }}
{{ demo?'화면의 장치 상태를 변경합니다.':'확인하면 선택한 실제 장비에 명령을 전송합니다.' }}
@@ -67,17 +63,18 @@
import Icon from '@/components/ConsoleIcon.vue';
import SensorTrend from '@/components/SensorTrend.vue';
import { createDemo } from '@/data/consoleDemo';
+import { signOut } from '@/auth';
const API_DEFAULT = process.env.VUE_APP_MODBUS_API || `${window.location.protocol}//${window.location.hostname}:8182`;
export default {
components: { Icon, SensorTrend },
data() {
return {
- demo: true, devices: createDemo(), selectedKey: 'PM-001', apiBase: API_DEFAULT, apiDraft: API_DEFAULT,
+ sidebarCollapsed: false, monitorOpen: true, demo: true, devices: createDemo(), selectedKey: 'PM-001', apiBase: API_DEFAULT, apiDraft: API_DEFAULT,
connected: false, loading: false, sending: false, error: '', notice: '', pendingControl: null,
search: '', statusFilter: 'all', trendField: 'temp', lastRefresh: new Date().toISOString(), now: Date.now(), timer: null, requestEpoch: 0,
startDate: '', endDate: '', historyPage: 1,
- nav: [{id:'overview',label:'통합 현황',icon:'grid'},{id:'devices',label:'장치 관리',icon:'device'},{id:'hygiene',label:'위생관리',icon:'shield'},{id:'energy',label:'에너지 현황',icon:'bolt'},{id:'history',label:'운영 이력',icon:'history'},{id:'settings',label:'연결 설정',icon:'settings'}],
- descriptions: {overview:'모든 장치의 운영 현황을 한눈에 확인하세요.',devices:'장치별 센서와 작동 상태를 확인하고 관리하세요.',hygiene:'UV 살균과 FAN 건조 상태를 확인하세요.',energy:'배터리와 에너지 운영 상태를 모니터링하세요.',history:'장치별 수신 데이터를 기간별로 살펴보세요.',settings:'데이터 연결과 플랫폼 연동 상태를 확인하세요.'},
+ nav: [{id:'overview',label:'통합 현황',icon:'grid'},{id:'devices',label:'장치 관리',icon:'device'},{id:'hygiene',label:'위생관리',icon:'shield'},{id:'energy',label:'에너지 현황',icon:'bolt'},{id:'history',label:'운영 이력',icon:'history'}],
+ descriptions: {overview:'모든 장치의 운영 현황을 한눈에 확인하세요.',devices:'장치별 센서와 작동 상태를 확인하고 관리하세요.',hygiene:'UV 살균과 FAN 건조 상태를 확인하세요.',energy:'배터리와 에너지 운영 상태를 모니터링하세요.',history:'장치별 수신 데이터를 기간별로 살펴보세요.'},
filters: [{id:'all',label:'전체'},{id:'online',label:'수신 정상'},{id:'offline',label:'미수신'},{id:'attention',label:'확인 필요'}],
controls: [{key:'uv_state',label:'UV 살균',icon:'sun',addr:20},{key:'fan_state',label:'FAN 건조',icon:'fan',addr:21},{key:'lock',label:'잠금',icon:'lock',addr:22}]
};
@@ -108,12 +105,13 @@ export default {
mounted() { this.resetDates(); this.timer=setInterval(()=>{this.now=Date.now();this.refresh();},60000); },
beforeDestroy() { clearInterval(this.timer); this.requestEpoch++; },
methods: {
+ logout() { signOut(); this.pendingControl=null; this.$router.replace('/login'); },
navigate(view) { if(this.view!==view)this.$router.push({path:'/dashboard',query:{view}}); },
sample(d) { const a=d.samples||[]; return a.length?a[a.length-1]:{}; },
value(v) { return v===null||v===undefined||v===''||!Number.isFinite(Number(v))?'—':Number(v); },
binary(v,yes,no) { return v===1?yes:v===0?no:'미수신'; },
state(v) { return this.binary(v,'ON','OFF'); },
- isRecent(d) { const t=Date.parse(d.last); return Number.isFinite(t)&&this.now-t<=180000; },
+ isRecent(d) { if(this.demo)return true; const t=Date.parse(d.last); return Number.isFinite(t)&&this.now-t<=180000; },
lowBattery(d) { const b=this.sample(d).batt_pct;return b!==null&&b!==undefined&&Number.isFinite(Number(b))&&Number(b)<20; },
needsAttention(d) { return !this.isRecent(d)||this.lowBattery(d)||Boolean(d.diagnosis&&d.diagnosis!=='정상'); },
matchesFilter(d,f) { return f==='all'||(f==='online'&&this.isRecent(d))||(f==='offline'&&!this.isRecent(d))||(f==='attention'&&this.needsAttention(d)); },
@@ -163,7 +161,7 @@ export default {
requestControl(c) {if(!this.selected)return;const on=c.key==='lock'?1:this.latest[c.key]===1?0:1;this.pendingControl={...c,target:this.selectedKey,name:this.selected.name,value:on,action:c.key==='lock'?'해제':on?'켜기':'끄기'};this.$nextTick(()=>this.$refs.confirmButton&&this.$refs.confirmButton.focus());},
async executeControl() {
const c=this.pendingControl;if(!c||this.sending)return;this.pendingControl=null;
- if(this.demo){const d=this.devices.find(d=>d.key===c.target);if(d){d.samples.push({...this.sample(d),ts:new Date().toISOString(),[c.key]:c.key==='lock'?0:c.value});d.last=d.samples[d.samples.length-1].ts;}this.notice=c.label+' '+c.action+' 시뮬레이션이 적용되었습니다.';return;}
+ if(this.demo){const d=this.devices.find(d=>d.key===c.target);if(d){d.samples.push({...this.sample(d),ts:new Date().toISOString(),[c.key]:c.key==='lock'?0:c.value});d.last=d.samples[d.samples.length-1].ts;}this.notice=c.label+' '+c.action+' 상태가 화면에 반영되었습니다.';return;}
this.sending=true;this.error='';
try{const result=await this.api('/modbus/write',{target:c.target,unit:1,addr:c.addr,value:c.value});if(!result.ok||!result.rx||result.rx.error||result.rx.crc_ok!==true||result.rx.fc!==6||result.rx.addr!==c.addr||result.rx.value!==c.value)throw new Error('제어 응답을 확인할 수 없습니다.');this.notice=c.label+' '+c.action+' 명령을 전송했습니다. 실제 작동 상태는 다음 센서 수신값으로 확인하세요.';await this.refresh();}catch(e){this.error='제어 실패: '+e.message+' 장치 상태를 확인하세요.';}finally{this.sending=false;}
},
diff --git a/src/pages/Login.vue b/src/pages/Login.vue
new file mode 100644
index 0000000..4b69b42
--- /dev/null
+++ b/src/pages/Login.vue
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+ 공유 PM 통합 관제 플랫폼
+
+
+
+
+
+
+
+
diff --git a/src/router/index.js b/src/router/index.js
index 1670c1f..667d719 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -1,5 +1,6 @@
import VueRouter from "vue-router";
import routes from "./routes";
+import { isAuthenticated, safeDestination } from '@/auth';
// configure router
const router = new VueRouter({
@@ -14,4 +15,12 @@ const router = new VueRouter({
}
});
+router.beforeEach((to, from, next) => {
+ if (to.matched.some(record => record.meta.requiresAuth) && !isAuthenticated()) {
+ next({ path: '/login', query: { redirect: to.fullPath }, replace: true });
+ } else if (to.name === 'login' && isAuthenticated()) {
+ next({ path: safeDestination(to.query.redirect), replace: true });
+ } else next();
+});
+
export default router;
diff --git a/src/router/routes.js b/src/router/routes.js
index acdbda2..967deda 100644
--- a/src/router/routes.js
+++ b/src/router/routes.js
@@ -1,6 +1,8 @@
import Dashboard from '@/pages/Dashboard.vue';
+import Login from '@/pages/Login.vue';
export default [
{ path: '/', redirect: '/dashboard' },
- { path: '/dashboard', name: 'dashboard', component: Dashboard },
+ { path: '/login', name: 'login', component: Login },
+ { path: '/dashboard', name: 'dashboard', component: Dashboard, meta: { requiresAuth: true } },
{ path: '*', redirect: '/dashboard' }
];
diff --git a/vue.config.js b/vue.config.js
index 32bd5c6..614dc14 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -26,7 +26,7 @@ module.exports = {
]
},
pwa: {
- name: 'METACU PM Control Center',
+ name: 'METAQLAB PM Control Center',
themeColor: '#101722',
msTileColor: '#101722',
appleMobileWebAppCapable: 'yes',