148 files
This commit is contained in:
1 parent
43021c1d3a
commit
94e9f32a43
148 files changed
+15528
-2013
No files matched your search
+271
@@ -0,0 +1,271 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{e as f}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-73EHFI76.js";import{a as p}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-WQXORDNI.js";import{a,b as g,c as i,f as c,h as u,l as v,m as n,q as s,s as m,u as b}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";var r=class extends u{constructor(){super(...arguments);this._open=!1;this._loading=!1;this._adopting=!1;this._error="";this._sensors=[];this._selected=new Set;this._objectNames={};this._objects=[];this._users=[];this._responsible="";this._forMinutes="0";this._localeReady=!1;this._userService=null;this._toggle=e=>{let o=new Set(this._selected);o.has(e)?o.delete(e):o.add(e),this._selected=o};this._toggleAll=()=>{this._selected.size===this._sensors.length?this._selected=new Set:this._selected=new Set(this._sensors.map(e=>e.entity_id))};this._adopt=async()=>{if(!(this._selected.size===0||this._adopting)){this._adopting=!0,this._error="";try{let e=this._sensors.filter(t=>this._selected.has(t.entity_id)).map(t=>({entity_id:t.entity_id,name:t.name,entry_id:this._existingEntryFor(t)??void 0,object_name:this._effectiveName(t),device_id:t.device_id??void 0,part_id:t.suggested_part_id??void 0,responsible_user_id:this._responsible||void 0,for_minutes:parseInt(this._forMinutes,10)>0?parseInt(this._forMinutes,10):void 0})),o=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/problem_sensors/adopt",selections:e});this.dispatchEvent(new CustomEvent("problem-sensors-adopted",{bubbles:!0,composed:!0,detail:o})),this._open=!1}catch(e){this._error=p(e,this._lang)}finally{this._adopting=!1}}}}get _lang(){return m(this.hass)}updated(e){e.has("hass")&&this.hass&&!this._localeReady&&(this._localeReady=!0,b(this._lang).then(()=>this.requestUpdate()))}async open(){this._open=!0,this._loading=!0,this._error="",this._sensors=[],this._selected=new Set,this._objectNames={},this._responsible="",this._forMinutes="0";try{this._userService?this._userService.updateHass(this.hass):this._userService=new f(this.hass);let[e,o,t]=await Promise.all([this.hass.connection.sendMessagePromise({type:"maintenance_supporter/problem_sensors/discover"}),this._userService.getUsers().catch(()=>[]),this.hass.connection.sendMessagePromise({type:"maintenance_supporter/objects"}).catch(()=>({objects:[]}))]);this._objects=(t.objects||[]).filter(l=>!l.object.archived_at).map(l=>({entry_id:l.entry_id,name:l.object.name})),this._sensors=e.sensors||[],this._selected=new Set(this._sensors.map(l=>l.entity_id)),this._users=o}catch(e){this._error=p(e,this._lang)}finally{this._loading=!1}}_effectiveName(e){return(this._objectNames[e.entity_id]??"").trim()||e.suggested_object_name}_existingEntryFor(e){let o=this._effectiveName(e);if(o===e.suggested_object_name&&e.suggested_entry_id)return e.suggested_entry_id;let t=this._objects.find(l=>l.name.trim().toLowerCase()===o.toLowerCase());return t?t.entry_id:null}_close(){this._open=!1}render(){if(!this._open)return i``;let e=this._lang,o=this._sensors.length>0&&this._selected.size===this._sensors.length;return i`
|
||||
<div class="overlay" @click=${this._close}>
|
||||
<div class="card" @click=${t=>t.stopPropagation()}>
|
||||
<div class="title">${s("adopt_problem_title",e)}</div>
|
||||
<div class="hint">${s("adopt_problem_hint",e)}</div>
|
||||
${this._error?i`<div class="error">${this._error}</div>`:c}
|
||||
|
||||
${this._loading?i`<div class="loading">…</div>`:this._sensors.length===0?i`<div class="empty">${s("adopt_problem_none",e)}</div>`:i`
|
||||
<label class="select-all">
|
||||
<input
|
||||
type="checkbox"
|
||||
.checked=${o}
|
||||
@change=${this._toggleAll}
|
||||
/>
|
||||
<span>${s("selected",e)}: ${this._selected.size} / ${this._sensors.length}</span>
|
||||
</label>
|
||||
<div class="row-sub adopt-object-hint">${s("adopt_object_hint",e)}</div>
|
||||
<datalist id="adopt-object-names">
|
||||
${this._objects.map(t=>i`<option value=${t.name}></option>`)}
|
||||
</datalist>
|
||||
<div class="list">
|
||||
${this._sensors.map(t=>{let l=this._selected.has(t.entity_id),_=t.state==="on",h=[t.device_name,t.area_name].filter(Boolean).join(" \xB7 ");return i`
|
||||
<label class="row">
|
||||
<input
|
||||
type="checkbox"
|
||||
.checked=${l}
|
||||
@change=${()=>this._toggle(t.entity_id)}
|
||||
/>
|
||||
<div class="row-main">
|
||||
<div class="row-top">
|
||||
<span class="row-name">${t.name}</span>
|
||||
<span class="chip ${_?"chip-active":"chip-ok"}">
|
||||
${_?s("adopt_problem_active",e):s("adopt_problem_ok",e)}
|
||||
</span>
|
||||
</div>
|
||||
${h?i`<div class="row-sub">${h}</div>`:c}
|
||||
${l?i`<div class="row-object" @click=${d=>d.stopPropagation()}>
|
||||
<input
|
||||
class="adopt-object"
|
||||
list="adopt-object-names"
|
||||
aria-label=${s("object",e)}
|
||||
placeholder=${t.suggested_object_name}
|
||||
.value=${this._objectNames[t.entity_id]??t.suggested_object_name}
|
||||
@input=${d=>{this._objectNames={...this._objectNames,[t.entity_id]:d.target.value}}}
|
||||
/>
|
||||
</div>`:c}
|
||||
<div class="row-target">
|
||||
→ ${this._effectiveName(t)}${this._existingEntryFor(t)?c:i` <span class="new-tag">${s("adopt_problem_new_object",e)}</span>`}
|
||||
</div>
|
||||
${t.suggested_part_name?i`<div class="row-part">
|
||||
<ha-icon icon="mdi:package-variant-closed"></ha-icon>
|
||||
${s("adopt_problem_part",e).replace("{name}",t.suggested_part_name)}
|
||||
</div>`:c}
|
||||
</div>
|
||||
</label>
|
||||
`})}
|
||||
</div>
|
||||
`}
|
||||
|
||||
${!this._loading&&this._sensors.length>0?i`
|
||||
<label class="responsible">
|
||||
<span>${s("for_at_least_minutes",e)}</span>
|
||||
<input
|
||||
class="for-input"
|
||||
type="number"
|
||||
min="0"
|
||||
max="1440"
|
||||
.value=${this._forMinutes}
|
||||
@input=${t=>this._forMinutes=t.target.value}
|
||||
/>
|
||||
</label>
|
||||
<div class="for-hint">${s("adopt_for_minutes_hint",e)}</div>
|
||||
`:c}
|
||||
|
||||
${!this._loading&&this._sensors.length>0&&this._users.length>0?i`
|
||||
<label class="responsible">
|
||||
<span>${s("adopt_problem_responsible",e)}</span>
|
||||
<select
|
||||
.value=${this._responsible}
|
||||
@change=${t=>{this._responsible=t.target.value}}
|
||||
>
|
||||
<option value="" ?selected=${!this._responsible}>${s("no_user_assigned",e)}</option>
|
||||
${this._users.map(t=>i`<option value=${t.id} ?selected=${t.id===this._responsible}>${t.name}</option>`)}
|
||||
</select>
|
||||
</label>
|
||||
`:c}
|
||||
|
||||
<div class="actions">
|
||||
<ha-button appearance="plain" @click=${this._close}>
|
||||
${s("cancel",e)}
|
||||
</ha-button>
|
||||
<ha-button
|
||||
@click=${this._adopt}
|
||||
.disabled=${this._selected.size===0||this._adopting}
|
||||
>
|
||||
${s("adopt_problem_adopt",e)}
|
||||
</ha-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`}};r.styles=g`
|
||||
.overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-background-color, #fff);
|
||||
color: var(--primary-text-color);
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-width: min(360px, calc(100vw - 24px));
|
||||
max-width: 560px;
|
||||
width: 90vw;
|
||||
max-height: 80vh;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.title {
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.hint {
|
||||
color: var(--secondary-text-color);
|
||||
font-size: 13px;
|
||||
}
|
||||
.error {
|
||||
color: var(--error-color, #f44336);
|
||||
font-size: 13px;
|
||||
}
|
||||
.loading,
|
||||
.empty {
|
||||
color: var(--secondary-text-color);
|
||||
font-size: 14px;
|
||||
padding: 12px 0;
|
||||
}
|
||||
.select-all {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
color: var(--secondary-text-color);
|
||||
cursor: pointer;
|
||||
}
|
||||
.select-all input {
|
||||
cursor: pointer;
|
||||
}
|
||||
.list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
overflow-y: auto;
|
||||
max-height: 50vh;
|
||||
}
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--divider-color);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.row input {
|
||||
margin-top: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.row-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
.row-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.row-name {
|
||||
font-weight: 500;
|
||||
font-size: 13px;
|
||||
}
|
||||
.row-sub {
|
||||
color: var(--secondary-text-color);
|
||||
font-size: 12px;
|
||||
}
|
||||
.row-object { margin-top: 6px; }
|
||||
.row-object input {
|
||||
width: 100%; box-sizing: border-box; padding: 6px 8px; font: inherit;
|
||||
border: 1px solid var(--divider-color); border-radius: 6px;
|
||||
background: var(--card-background-color); color: var(--primary-text-color);
|
||||
}
|
||||
.adopt-object-hint { margin: 0 0 8px; }
|
||||
.row-target {
|
||||
color: var(--secondary-text-color);
|
||||
font-size: 12px;
|
||||
}
|
||||
.row-part {
|
||||
color: var(--secondary-text-color);
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
.row-part ha-icon {
|
||||
--mdc-icon-size: 14px;
|
||||
}
|
||||
.new-tag {
|
||||
font-style: italic;
|
||||
}
|
||||
.chip {
|
||||
font-size: 11px;
|
||||
padding: 1px 8px;
|
||||
border-radius: 10px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.chip-active {
|
||||
background: var(--error-color, #f44336);
|
||||
color: #fff;
|
||||
}
|
||||
.chip-ok {
|
||||
background: var(--divider-color);
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
.responsible {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
color: var(--secondary-text-color);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.for-input {
|
||||
width: 70px;
|
||||
background: var(--card-background-color);
|
||||
color: var(--primary-text-color);
|
||||
border: 1px solid var(--divider-color);
|
||||
border-radius: 4px;
|
||||
padding: 4px 6px;
|
||||
}
|
||||
.for-hint {
|
||||
font-size: 11px;
|
||||
color: var(--secondary-text-color);
|
||||
margin: -4px 0 2px;
|
||||
}
|
||||
.responsible select {
|
||||
flex: 1;
|
||||
min-width: 140px;
|
||||
padding: 4px 6px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid var(--divider-color);
|
||||
background: var(--card-background-color, #fff);
|
||||
color: var(--primary-text-color);
|
||||
font-size: 13px;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding-top: 8px;
|
||||
}
|
||||
`,a([v({attribute:!1})],r.prototype,"hass",2),a([n()],r.prototype,"_open",2),a([n()],r.prototype,"_loading",2),a([n()],r.prototype,"_adopting",2),a([n()],r.prototype,"_error",2),a([n()],r.prototype,"_sensors",2),a([n()],r.prototype,"_selected",2),a([n()],r.prototype,"_objectNames",2),a([n()],r.prototype,"_objects",2),a([n()],r.prototype,"_users",2),a([n()],r.prototype,"_responsible",2),a([n()],r.prototype,"_forMinutes",2);customElements.get("maintenance-adopt-problem-sensors-dialog")||customElements.define("maintenance-adopt-problem-sensors-dialog",r);export{r as MaintenanceAdoptProblemSensorsDialog};
|
||||
@@ -0,0 +1,153 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{a as u}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-WQXORDNI.js";import{a as r,b as _,c as l,f as o,h,l as d,m as s,q as i,s as p}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";var a=class extends h{constructor(){super(...arguments);this.objects=[];this._open=!1;this._loading=!1;this._error="";this._name="";this._manufacturer="";this._model="";this._serialNumber="";this._areaId="";this._installationDate="";this._warrantyExpiry="";this._documentationUrl="";this._notes="";this._haDeviceId="";this._parentEntryId="";this._entryId=null}get _lang(){return p(this.hass)}openCreate(){this._entryId=null,this._name="",this._manufacturer="",this._model="",this._serialNumber="",this._areaId="",this._installationDate="",this._warrantyExpiry="",this._documentationUrl="",this._notes="",this._haDeviceId="",this._parentEntryId="",this._error="",this._open=!0}openEdit(e,n){this._entryId=e,this._name=n.name||"",this._manufacturer=n.manufacturer||"",this._model=n.model||"",this._serialNumber=n.serial_number||"",this._areaId=n.area_id||"",this._installationDate=n.installation_date||"",this._warrantyExpiry=n.warranty_expiry||"",this._documentationUrl=n.documentation_url||"",this._notes=n.notes||"",this._haDeviceId=n.ha_device_id||"",this._parentEntryId=n.parent_entry_id||"",this._error="",this._open=!0}async _save(){if(!this._loading&&this._name.trim()){this._loading=!0,this._error="";try{this._entryId?await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object/update",entry_id:this._entryId,name:this._name,manufacturer:this._manufacturer||null,model:this._model||null,serial_number:this._serialNumber||null,area_id:this._areaId||null,installation_date:this._installationDate||null,warranty_expiry:this._warrantyExpiry||null,documentation_url:this._documentationUrl.trim()||null,notes:this._notes.trim()||null,ha_device_id:this._haDeviceId||null,parent_entry_id:this._parentEntryId||null}):await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object/create",name:this._name,manufacturer:this._manufacturer||null,model:this._model||null,serial_number:this._serialNumber||null,area_id:this._areaId||null,installation_date:this._installationDate||null,warranty_expiry:this._warrantyExpiry||null,documentation_url:this._documentationUrl.trim()||null,notes:this._notes.trim()||null,ha_device_id:this._haDeviceId||null,parent_entry_id:this._parentEntryId||null}),this._open=!1,this.dispatchEvent(new CustomEvent("object-saved"))}catch(e){this._error=u(e,this._lang,i("save_error",this._lang))}finally{this._loading=!1}}}_parentChoices(){return(this.objects||[]).filter(e=>e.entry_id!==this._entryId)}_close(){this._open=!1}render(){if(!this._open)return l``;let e=this._lang,n=this._entryId?i("edit_object",e):i("new_object",e);return l`
|
||||
<ha-dialog open @closed=${this._close}>
|
||||
<div class="dialog-title">${n}</div>
|
||||
<div class="content">
|
||||
${this._error?l`<div class="error">${this._error}</div>`:o}
|
||||
<ms-textfield
|
||||
label="${i("name",e)}"
|
||||
required
|
||||
.value=${this._name}
|
||||
@input=${t=>this._name=t.target.value}
|
||||
></ms-textfield>
|
||||
<ms-textfield
|
||||
label="${i("manufacturer_optional",e)}"
|
||||
.value=${this._manufacturer}
|
||||
@input=${t=>this._manufacturer=t.target.value}
|
||||
></ms-textfield>
|
||||
<ms-textfield
|
||||
label="${i("model_optional",e)}"
|
||||
.value=${this._model}
|
||||
@input=${t=>this._model=t.target.value}
|
||||
></ms-textfield>
|
||||
<ms-textfield
|
||||
label="${i("serial_number_optional",e)}"
|
||||
.value=${this._serialNumber}
|
||||
@input=${t=>this._serialNumber=t.target.value}
|
||||
></ms-textfield>
|
||||
<ms-textfield
|
||||
label="${i("documentation_url_optional",e)}"
|
||||
type="url"
|
||||
.value=${this._documentationUrl}
|
||||
@input=${t=>this._documentationUrl=t.target.value}
|
||||
></ms-textfield>
|
||||
<ha-area-picker
|
||||
.hass=${this.hass}
|
||||
label="${i("area_id_optional",e)}"
|
||||
.value=${this._areaId}
|
||||
@value-changed=${t=>this._areaId=t.detail.value||""}
|
||||
></ha-area-picker>
|
||||
<ms-date-field
|
||||
kind="date"
|
||||
clearable
|
||||
.hass=${this.hass}
|
||||
.lang=${e}
|
||||
label="${i("installation_date_optional",e)}"
|
||||
.value=${this._installationDate}
|
||||
@value-changed=${t=>this._installationDate=t.detail.value}
|
||||
></ms-date-field>
|
||||
<ms-date-field
|
||||
kind="date"
|
||||
clearable
|
||||
.hass=${this.hass}
|
||||
.lang=${e}
|
||||
label="${i("warranty_expiry_optional",e)}"
|
||||
.value=${this._warrantyExpiry}
|
||||
@value-changed=${t=>this._warrantyExpiry=t.detail.value}
|
||||
></ms-date-field>
|
||||
<ha-form
|
||||
.hass=${this.hass}
|
||||
.data=${{device:this._haDeviceId||void 0}}
|
||||
.schema=${[{name:"device",selector:{device:{}}}]}
|
||||
.computeLabel=${()=>i("link_device_optional",e)}
|
||||
@value-changed=${t=>this._haDeviceId=t.detail.value?.device||""}
|
||||
></ha-form>
|
||||
${this._parentChoices().length?l`<label class="textarea-field">
|
||||
<span class="textarea-label">${i("parent_object_optional",e)}</span>
|
||||
<select
|
||||
class="parent-select"
|
||||
.value=${this._parentEntryId}
|
||||
@change=${t=>this._parentEntryId=t.target.value}
|
||||
>
|
||||
<option value="" ?selected=${!this._parentEntryId}>
|
||||
${i("parent_none",e)}
|
||||
</option>
|
||||
${this._parentChoices().map(t=>l`<option
|
||||
value=${t.entry_id}
|
||||
?selected=${this._parentEntryId===t.entry_id}
|
||||
>${t.object.name}</option>`)}
|
||||
</select>
|
||||
</label>`:o}
|
||||
<label class="textarea-field">
|
||||
<span class="textarea-label">${i("object_notes_optional",e)}</span>
|
||||
<textarea
|
||||
rows="3"
|
||||
.value=${this._notes}
|
||||
@input=${t=>this._notes=t.target.value}
|
||||
></textarea>
|
||||
<span class="md-hint">${i("notes_markdown_hint",e)}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="dialog-actions">
|
||||
<ha-button appearance="plain" @click=${this._close}>
|
||||
${i("cancel",this._lang)}
|
||||
</ha-button>
|
||||
<ha-button
|
||||
@click=${this._save}
|
||||
.disabled=${this._loading||!this._name.trim()}
|
||||
>
|
||||
${this._loading?i("saving",this._lang):i("save",this._lang)}
|
||||
</ha-button>
|
||||
</div>
|
||||
</ha-dialog>
|
||||
`}};a.styles=_`
|
||||
.dialog-title {
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-width: 300px;
|
||||
}
|
||||
.dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding-top: 16px;
|
||||
}
|
||||
ms-textfield {
|
||||
display: block;
|
||||
}
|
||||
.textarea-field {
|
||||
display: flex; flex-direction: column; gap: 4px;
|
||||
}
|
||||
.textarea-label {
|
||||
font-size: 12px; color: var(--secondary-text-color, #888); font-weight: 500;
|
||||
}
|
||||
.textarea-field textarea {
|
||||
padding: 8px 10px; font-size: 14px; font-family: inherit;
|
||||
background: var(--secondary-background-color, rgba(0,0,0,0.06));
|
||||
color: var(--primary-text-color);
|
||||
border: 1px solid var(--divider-color); border-radius: 6px;
|
||||
resize: vertical;
|
||||
}
|
||||
.textarea-field textarea:focus {
|
||||
outline: none; border-color: var(--primary-color);
|
||||
}
|
||||
.md-hint {
|
||||
font-size: 11px; color: var(--secondary-text-color); font-style: italic;
|
||||
}
|
||||
.parent-select {
|
||||
padding: 8px 10px; font-size: 14px; font-family: inherit;
|
||||
background: var(--secondary-background-color, rgba(0,0,0,0.06));
|
||||
color: var(--primary-text-color);
|
||||
border: 1px solid var(--divider-color); border-radius: 6px;
|
||||
}
|
||||
.error {
|
||||
color: var(--error-color, #f44336);
|
||||
font-size: 13px;
|
||||
}
|
||||
`,r([d({attribute:!1})],a.prototype,"hass",2),r([d({attribute:!1})],a.prototype,"objects",2),r([s()],a.prototype,"_open",2),r([s()],a.prototype,"_loading",2),r([s()],a.prototype,"_error",2),r([s()],a.prototype,"_name",2),r([s()],a.prototype,"_manufacturer",2),r([s()],a.prototype,"_model",2),r([s()],a.prototype,"_serialNumber",2),r([s()],a.prototype,"_areaId",2),r([s()],a.prototype,"_installationDate",2),r([s()],a.prototype,"_warrantyExpiry",2),r([s()],a.prototype,"_documentationUrl",2),r([s()],a.prototype,"_notes",2),r([s()],a.prototype,"_haDeviceId",2),r([s()],a.prototype,"_parentEntryId",2),r([s()],a.prototype,"_entryId",2);customElements.get("maintenance-object-dialog")||customElements.define("maintenance-object-dialog",a);export{a};
|
||||
@@ -0,0 +1,88 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{A as m,a,b as y,c as s,f as l,h as g,l as o,m as f,q as d}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";function $(n){let t=m("2001-02-03",n).match(/\d+/g)||[],e=v=>t.findIndex(_=>Number(_)===v),h=e(2001),c=e(2),u=e(3);return h===0?"YMD":c>=0&&u>=0&&c<u?"MDY":"DMY"}function p(n,i,t){if(n<1e3||n>9999||i<1||i>12||t<1||t>31)return null;let e=new Date(n,i-1,t);return e.getFullYear()!==n||e.getMonth()!==i-1||e.getDate()!==t?null:`${n}-${String(i).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function b(n,i){let t=n.trim(),e;if(e=t.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/))return p(+e[1],+e[2],+e[3]);if(e=t.match(/^(\d{4})$/))return p(+e[1],1,1);if(e=t.match(/^(\d{1,2})[./](\d{4})$/))return p(+e[2],+e[1],1);if(e=t.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/))return p(+e[3],+e[2],+e[1]);if(e=t.match(/^(\d{1,2})[/-](\d{1,2})[/-](\d{4})$/)){let h=+e[1],c=+e[2],u=+e[3];return $(i)==="MDY"?p(u,h,c):p(u,c,h)}return null}function x(n,i){if(i)switch(n){case"date":return i.split("T")[0];case"time":return i.length===5?`${i}:00`:i;case"datetime":{let[t,e="00:00:00"]=i.split("T");return`${t} ${e.length===5?`${e}:00`:e}`}}}function k(n,i){if(typeof i!="string"||!i)return"";switch(n){case"date":return i.slice(0,10);case"time":return i.slice(0,5);case"datetime":{let[t,e="00:00:00"]=i.split(" ");return`${t}T${e.length===5?`${e}:00`:e}`}}}var r=class extends g{constructor(){super(...arguments);this.kind="date";this.label="";this.value="";this.clearable=!1;this.disabled=!1;this.required=!1;this.lang="en";this._typing=!1;this._typed="";this._typedInvalid=!1}_startTyping(){this._typed=this.value,this._typedInvalid=!1,this._typing=!0,this.updateComplete.then(()=>this.shadowRoot?.querySelector("input.typed")?.focus())}_commitTyped(){if(!this._typed.trim()){this._typing=!1;return}let t=b(this._typed,this.lang);if(!t){this._typedInvalid=!0;return}this._typing=!1,this._typedInvalid=!1,this._emit(t)}_onTypedKey(t){t.key==="Enter"?(t.preventDefault(),this._commitTyped()):t.key==="Escape"&&(t.preventDefault(),this._typing=!1,this._typedInvalid=!1)}_selector(){switch(this.kind){case"date":return{date:{}};case"time":return{time:{no_second:!0}};case"datetime":return{datetime:{}}}}_onSelectorChange(t){t.stopPropagation(),this._emit(k(this.kind,t.detail?.value))}_clear(){this._emit("")}_emit(t){t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("value-changed",{bubbles:!0,composed:!0,detail:{value:t}})))}render(){return s`
|
||||
<div class="field">
|
||||
${this.label?s`<span class="label">${this.label}${this.required?s`<span class="req">*</span>`:l}</span>`:l}
|
||||
<div class="row">
|
||||
${this._typing?s`<input class="typed" type="text" inputmode="numeric" autocomplete="off"
|
||||
.value=${this._typed}
|
||||
placeholder=${m("1978-03-15",this.lang)}
|
||||
aria-invalid=${this._typedInvalid?"true":"false"}
|
||||
@input=${t=>{this._typed=t.target.value,this._typedInvalid=!1}}
|
||||
@keydown=${this._onTypedKey}
|
||||
@blur=${this._commitTyped} />`:s`<ha-selector
|
||||
.hass=${this.hass}
|
||||
.selector=${this._selector()}
|
||||
.value=${x(this.kind,this.value)}
|
||||
.required=${this.required}
|
||||
.disabled=${this.disabled}
|
||||
@value-changed=${this._onSelectorChange}
|
||||
></ha-selector>`}
|
||||
${this.kind==="date"&&!this.disabled&&!this._typing?s`<button type="button" class="type-toggle" title=${d("date_type_toggle",this.lang)} aria-label=${d("date_type_toggle",this.lang)} @click=${this._startTyping}>
|
||||
<ha-icon icon="mdi:keyboard-outline"></ha-icon>
|
||||
</button>`:l}
|
||||
${this.clearable&&this.value&&!this.disabled&&!this._typing?s`<button type="button" class="clear" title=${d("clear",this.lang)} aria-label=${d("clear",this.lang)} @click=${this._clear}>
|
||||
<ha-icon icon="mdi:close"></ha-icon>
|
||||
</button>`:l}
|
||||
</div>
|
||||
${this._typedInvalid?s`<span class="helper invalid">${d("date_type_invalid",this.lang)}</span>`:this.helper?s`<span class="helper">${this.helper}</span>`:l}
|
||||
</div>
|
||||
`}};r.styles=y`
|
||||
:host { display: block; }
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
.label {
|
||||
font-size: 12px;
|
||||
color: var(--secondary-text-color, #888);
|
||||
font-weight: 500;
|
||||
}
|
||||
.req { color: var(--error-color, #f44336); margin-left: 2px; }
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
ha-selector {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.clear, .type-toggle {
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
color: var(--secondary-text-color);
|
||||
cursor: pointer;
|
||||
--mdc-icon-size: 20px;
|
||||
}
|
||||
.clear:hover, .type-toggle:hover { background: rgba(var(--rgb-primary-text-color, 0, 0, 0), 0.08); }
|
||||
.clear:focus-visible, .type-toggle:focus-visible { outline: 2px solid var(--primary-color); }
|
||||
.helper {
|
||||
font-size: 11px;
|
||||
color: var(--secondary-text-color);
|
||||
font-style: italic;
|
||||
}
|
||||
.helper.invalid { color: var(--error-color, #f44336); font-style: normal; }
|
||||
input.typed {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 40px;
|
||||
box-sizing: border-box;
|
||||
padding: 0 12px;
|
||||
border: 1px solid var(--divider-color, #ccc);
|
||||
border-radius: 4px;
|
||||
background: var(--card-background-color, #fff);
|
||||
color: var(--primary-text-color);
|
||||
font: inherit;
|
||||
}
|
||||
input.typed[aria-invalid="true"] { border-color: var(--error-color, #f44336); }
|
||||
input.typed:focus { outline: 2px solid var(--primary-color); outline-offset: -1px; }
|
||||
`,a([o({attribute:!1})],r.prototype,"hass",2),a([o()],r.prototype,"kind",2),a([o()],r.prototype,"label",2),a([o()],r.prototype,"value",2),a([o()],r.prototype,"helper",2),a([o({type:Boolean})],r.prototype,"clearable",2),a([o({type:Boolean})],r.prototype,"disabled",2),a([o({type:Boolean})],r.prototype,"required",2),a([o()],r.prototype,"lang",2),a([f()],r.prototype,"_typing",2),a([f()],r.prototype,"_typed",2),a([f()],r.prototype,"_typedInvalid",2);customElements.get("ms-date-field")||customElements.define("ms-date-field",r);
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{q as p}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";function f(r){return`${r.entry_id??""}\0${r.part_id}`}function g(r,n,i,o){let t=!!r.entry_id&&r.entry_id!==n,e=t?r.entry_id:n,s=i.find(l=>l.entry_id===e),a=(s?.parts||[]).find(l=>l.id===r.part_id)||null,u=t&&s?.object?.name||"",d=a?.name||p("shared_part_unknown",o);return{part:a,foreign:t,ownerName:u,label:u?`${d} (${u})`:d}}function _(r,n,i,o){let{part:t,label:e}=g(r,n,i,o),s=t&&t.stock!==null&&t.stock!==void 0?` (${t.stock}${t.unit?" "+t.unit:""})`:"",a=t?.storage_location?` \u2014 ${t.storage_location}`:"";return`${r.quantity}\xD7 ${e}${s}${a}`}function R(r,n,i,o){let e=(i.find(a=>a.entry_id===n)?.parts||[]).map(a=>({...a})),s=new Set(e.map(a=>f({part_id:a.id})));for(let a of r?.consumes_parts||[]){if(!a.entry_id||a.entry_id===n)continue;let u=f(a);if(s.has(u))continue;s.add(u);let{part:d,ownerName:l}=g(a,n,i,o);e.push({id:a.part_id,name:d?.name||p("shared_part_unknown",o),unit:d?.unit,stock:d?.stock??null,storage_location:d?.storage_location,entry_id:a.entry_id,owner_name:l})}return e}function w(){let r=new Uint8Array(4);return(globalThis.crypto??{getRandomValues:n=>n.map(()=>Math.floor(Math.random()*256))}).getRandomValues(r),Array.from(r,n=>n.toString(16).padStart(2,"0")).join("")}function c(r){let n=r?.reading_values;if(!Array.isArray(n))return[];let i=[],o=new Set;for(let t of n){if(!t||typeof t!="object")continue;let e=t;typeof e.id!="string"||!e.id||o.has(e.id)||typeof e.value!="number"||!Number.isFinite(e.value)||(o.add(e.id),i.push({id:e.id,name:typeof e.name=="string"?e.name:e.id,unit:typeof e.unit=="string"?e.unit:null,value:e.value}))}return i}function y(r){return r.filter(n=>n.type==="completed"&&(n.reading_value!=null||c(n).length>0)).sort((n,i)=>n.timestamp.localeCompare(i.timestamp))}function S(r){return y(r??[]).map(n=>({timestamp:n.timestamp,values:c(n)})).filter(n=>n.values.length>0)}function P(r,n,i){let o;for(let t of r){if(i!==void 0){let s=new Date(t.timestamp).getTime();if(!isNaN(s)&&s>=i)break}let e=t.values.find(s=>s.id===n);e&&(o=e)}return o}function b(r,n,i){let o=c(n).find(e=>e.id===i);if(!o)return null;let t=null;for(let e of y(r)){if(e.timestamp>=n.timestamp)break;let s=c(e).find(a=>a.id===i);s&&(t=s.value)}return t==null?null:o.value-t}function E(r){let n=new Set,i=new Set;for(let o of r){let t=(o.name||"").trim().toLowerCase();t&&(n.has(t)?i.add(o.id):n.add(t))}return i}function v(r){let n=[],i=new Set,o=new Set;for(let t of r){let e=(t.name||"").trim();if(!(!e||i.has(t.id)||o.has(e.toLowerCase()))&&(i.add(t.id),o.add(e.toLowerCase()),n.push({id:t.id,name:e,unit:(t.unit||"").trim()||null}),n.length>=20))break}return n}var x=["notes","cost","duration","photo","user"],h={notes:"notes_label",cost:"cost",duration:"duration",photo:"photo_label",user:"user_label"};export{f as a,_ as b,R as c,w as d,c as e,S as f,P as g,b as h,E as i,v as j,x as k,h as l};
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{c as r,f as i}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";var a=["#c62828","#ad1457","#6a1b9a","#4527a0","#283593","#1565c0","#00838f","#2e7d32","#558b2f","#ef6c00","#6d4c41","#546e7a"];function u(e){let s=(e||"").split(/\s+/).filter(Boolean);return s.length===0?"?":s.length===1?s[0][0].toUpperCase():(s[0][0]+s[s.length-1][0]).toUpperCase()}function c(e){let s=0;for(let n of e)s=s*31+n.charCodeAt(0)>>>0;return a[s%a.length]}function o(e){return e?{id:e.id,name:e.name,initials:e.initials||u(e.name),color:e.color||c(e.id)}:null}function h(e){return e?r`<span class="person-avatar" style="--person-color: ${e.color}" title=${e.name}>${e.initials}</span>`:i}function m(e,s=""){return e?r`<span class="person-chip ${s}" title=${e.name}>${h(e)}<span class="person-name">${e.name}</span></span>`:i}var l=class{constructor(s){this.usersCache=null;this.cacheTimestamp=0;this.CACHE_TTL_MS=6e4;this.hass=s}updateHass(s){this.hass=s}async getUsers(s=!1){let n=Date.now();if(!s&&this.usersCache&&n-this.cacheTimestamp<this.CACHE_TTL_MS)return this.usersCache;try{let t=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/users/list"});return this.usersCache=t.users,this.cacheTimestamp=n,this.usersCache}catch(t){return console.error("Failed to fetch users:",t),this.usersCache||[]}}async assignUser(s,n,t){await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/assign_user",entry_id:s,task_id:n,user_id:t})}async getTasksByUser(s){return(await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/tasks/by_user",user_id:s})).tasks}getUserName(s){return!s||!this.usersCache?null:this.usersCache.find(t=>t.id===s)?.name||null}getPerson(s){return o(this.getUser(s))}getUser(s){return!s||!this.usersCache?null:this.usersCache.find(n=>n.id===s)||null}getCurrentUserId(){return this.hass.user?.id||null}isCurrentUser(s){return s?s===this.getCurrentUserId():!1}clearCache(){this.usersCache=null,this.cacheTimestamp=0}};export{a,o as b,h as c,m as d,l as e};
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{b as S}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-XB4BHMUS.js";async function x(n,t,s=300){return(await n.connection.sendMessagePromise({type:"auth/sign_path",path:t,expires:s})).path}async function C(n,t,s=300){return x(n,`/api/maintenance_supporter/document/${t}`,s)}async function N(n,t,s=""){let e=window.open("about:blank","_blank");try{let o=await C(n,t);e&&(e.location.href=new URL(o+s,window.location.origin).href)}catch(o){throw e&&e.close(),o}}async function B(n,t,s){S(await C(n,t,30),s)}function O(n){let t=URL.createObjectURL(new Blob([n],{type:"text/html"}));window.open(t,"_blank"),setTimeout(()=>URL.revokeObjectURL(t),6e4)}var E={days:1,weeks:7,months:30.4368,years:365.25};function b(n,t){return!n||n<=0?0:n*(E[t||"days"]??1)}function L(n,t,s){let e=b(n,s);if(e<=0||t==null)return{pct:0,overflow:!1};let o=(e-t)/e*100;return{pct:Math.max(0,Math.min(100,o)),overflow:o>100}}var D=5;function h(n){let t=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),e=String(n.getDate()).padStart(2,"0");return`${t}-${s}-${e}`}function P(n,t){let s=[];for(let e=0;e<t;e++){let o=new Date(n);o.setDate(o.getDate()+e),o.setHours(0,0,0,0),s.push(h(o))}return s}function y(n,t){let[s,e,o]=n.split("-").map(Number),g=new Date(s,e-1,o);return g.setDate(g.getDate()+t),h(g)}function R(n){if(!n||n.length===0)return null;let t=n.map(s=>s.cost).filter(s=>typeof s=="number");return t.length===0?null:t.reduce((s,e)=>s+e,0)/t.length}function T(n){let{windowStart:t,windowEnd:s,task:e,entryId:o,objectName:g}=n,u=[],d=(a,c)=>({date:a,entry_id:o,task_id:e.id,task_name:e.name,object_name:g,status:c&&(e.status==="overdue"||e.status==="triggered")?"ok":e.status,days_until_due:c?null:e.days_until_due??null,projected:c,schedule_type:e.schedule_type,interval_days:e.interval_days??null,interval_unit:e.interval_unit??null,responsible_user_id:e.responsible_user_id??null,avg_cost:R(e.history),adaptive_enabled:!!e.adaptive_config?.enabled,prediction_confidence:e.threshold_prediction_confidence??null}),p=Math.max(1,Math.round(b(e.interval_days,e.interval_unit)));if(e.status==="overdue"||e.status==="triggered"){if(u.push(d(t,!1)),e.schedule_type==="time_based"&&e.interval_days&&e.interval_days>0){let a=y(t,p),c=1;for(;a<=s&&c<D;)u.push(d(a,!0)),c++,a=y(a,p)}return u}let r=e.next_due;if(typeof r!="string"||!r)return u;let i=r.slice(0,10);if(i>=t&&i<=s)u.push(d(i,!1));else if(i>s)return u;if(e.schedule_type==="time_based"&&e.interval_days&&e.interval_days>0){let a=y(i,p),c=u.length;for(;a<=s&&c<D;)a>=t&&(u.push(d(a,!0)),c++),a=y(a,p)}return u}var j={overdue:0,triggered:1,due_soon:2,ok:3};function Y(n,t,s,e=null){let o=P(t,s),g=o[0],u=o[o.length-1],d=[];for(let r of n){let i=r.object?.name||"",a=r.entry_id,c=r.tasks||[];for(let l of c){if(e&&l.responsible_user_id!==e||l.enabled===!1)continue;let _=T({windowStart:g,windowEnd:u,task:l,entryId:a,objectName:i});d.push(..._)}}let p=new Map;for(let r of o)p.set(r,[]);for(let r of d){let i=p.get(r.date);i&&i.push(r)}for(let[,r]of p)r.sort((i,a)=>{let c=j[i.status]??99,l=j[a.status]??99;if(c!==l)return c-l;if(i.projected!==a.projected)return i.projected?1:-1;let _=i.object_name.localeCompare(a.object_name);return _!==0?_:i.task_name.localeCompare(a.task_name)});return o.map(r=>({date:r,events:p.get(r)??[]}))}var H={completed:"ok",reset:"ok",skipped:"due_soon",missed:"overdue",triggered:"triggered",trigger_replaced:"triggered",trigger_removed:"ok"};function M(n,t){let s=[];for(let e=t-1;e>=0;e--){let o=new Date(n);o.setDate(o.getDate()-e),o.setHours(0,0,0,0),s.push(h(o))}return s}function $(n,t,s,e=null){let o=M(t,s),g=o[0],u=o[o.length-1],d=new Map;for(let r of o)d.set(r,[]);for(let r of n){let i=r.object?.name||"",a=r.entry_id,c=r.tasks||[];for(let l of c){if(e&&l.responsible_user_id!==e)continue;let _=l.history||[];for(let m of _){if(typeof m?.timestamp!="string")continue;let f=m.timestamp.slice(0,10);if(f<g||f>u)continue;let w=d.get(f);if(!w)continue;let k=m.type??"completed";w.push({date:f,entry_id:a,task_id:l.id,task_name:l.name,object_name:i,status:H[k]??"ok",days_until_due:null,projected:!1,schedule_type:l.schedule_type,interval_days:l.interval_days??null,responsible_user_id:l.responsible_user_id??null,avg_cost:typeof m.cost=="number"?m.cost:null,adaptive_enabled:!!l.adaptive_config?.enabled,prediction_confidence:null,history_timestamp:m.timestamp,history_type:k,history_cost:typeof m.cost=="number"?m.cost:null,history_notes:typeof m.notes=="string"?m.notes:null,history_duration:typeof m.duration=="number"?m.duration:null})}}}let p={completed:0,reset:1,skipped:2,triggered:3,trigger_replaced:4};for(let[,r]of d)r.sort((i,a)=>{let c=p[i.history_type??""]??99,l=p[a.history_type??""]??99;if(c!==l)return c-l;let _=i.object_name.localeCompare(a.object_name);return _!==0?_:i.task_name.localeCompare(a.task_name)});return o.map(r=>({date:r,events:d.get(r)??[]}))}var v={features:{adaptive:!1,predictions:!1,seasonal:!1,environmental:!1,budget:!1,groups:!1,checklists:!1,schedule_time:!1,complLine truncated
|
||||
@@ -0,0 +1,79 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{a as r,b as l,c as i,f as o,h as n,l as t}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";var e=class extends n{constructor(){super(...arguments);this.label="";this.value="";this.placeholder="";this.type="text";this.required=!1;this.disabled=!1;this.multiline=!1;this.rows=3}_onInput(s){let a=s.target.value;this.value=a,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{value:a}}))}render(){return i`
|
||||
<label class="field">
|
||||
${this.label?i`<span class="label">${this.label}${this.required?i`<span class="req">*</span>`:o}</span>`:o}
|
||||
${this.multiline?i`
|
||||
<textarea
|
||||
.value=${this.value??""}
|
||||
rows=${this.rows}
|
||||
?required=${this.required}
|
||||
?disabled=${this.disabled}
|
||||
placeholder=${this.placeholder}
|
||||
@input=${this._onInput}
|
||||
@change=${this._onInput}
|
||||
></textarea>`:i`
|
||||
<input
|
||||
.value=${this.value??""}
|
||||
.type=${this.type}
|
||||
?required=${this.required}
|
||||
?disabled=${this.disabled}
|
||||
placeholder=${this.placeholder}
|
||||
step=${this.step??o}
|
||||
min=${this.min??o}
|
||||
max=${this.max??o}
|
||||
pattern=${this.pattern??o}
|
||||
@input=${this._onInput}
|
||||
@change=${this._onInput}
|
||||
/>`}
|
||||
${this.helper?i`<span class="helper">${this.helper}</span>`:o}
|
||||
</label>
|
||||
`}};e.styles=l`
|
||||
:host { display: block; }
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
.label {
|
||||
font-size: 12px;
|
||||
color: var(--secondary-text-color, #888);
|
||||
font-weight: 500;
|
||||
}
|
||||
.req { color: var(--error-color, #f44336); margin-left: 2px; }
|
||||
input {
|
||||
padding: 8px 10px;
|
||||
font-size: 14px;
|
||||
background: var(--secondary-background-color, rgba(0,0,0,0.06));
|
||||
color: var(--primary-text-color);
|
||||
border: 1px solid var(--divider-color, rgba(255,255,255,0.12));
|
||||
border-radius: 6px;
|
||||
font-family: inherit;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
outline: none;
|
||||
}
|
||||
input:focus {
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
input:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
textarea {
|
||||
padding: 8px 10px;
|
||||
font-size: 14px;
|
||||
background: var(--secondary-background-color, rgba(0,0,0,0.06));
|
||||
color: var(--primary-text-color);
|
||||
border: 1px solid var(--divider-color, rgba(255,255,255,0.12));
|
||||
border-radius: 6px;
|
||||
font-family: inherit;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
outline: none;
|
||||
resize: vertical;
|
||||
}
|
||||
textarea:focus { border-color: var(--primary-color); }
|
||||
textarea:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
.helper {
|
||||
font-size: 11px;
|
||||
color: var(--secondary-text-color);
|
||||
font-style: italic;
|
||||
}
|
||||
`,r([t()],e.prototype,"label",2),r([t()],e.prototype,"value",2),r([t()],e.prototype,"placeholder",2),r([t()],e.prototype,"type",2),r([t({type:Boolean})],e.prototype,"required",2),r([t({type:Boolean})],e.prototype,"disabled",2),r([t()],e.prototype,"step",2),r([t()],e.prototype,"min",2),r([t()],e.prototype,"max",2),r([t()],e.prototype,"pattern",2),r([t()],e.prototype,"helper",2),r([t({type:Boolean})],e.prototype,"multiline",2),r([t({type:Number})],e.prototype,"rows",2);customElements.get("ms-textfield")||customElements.define("ms-textfield",e);
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
var l=[{key:"name",labelKey:"name",required:!0},{key:"ref_no",labelKey:"ref_number"},{key:"manufacturer",labelKey:"manufacturer"},{key:"model",labelKey:"model"},{key:"serial_number",labelKey:"serial_number_label"},{key:"installation_date",labelKey:"installed"},{key:"warranty_expiry",labelKey:"warranty"},{key:"area_id",labelKey:"area"},{key:"documentation_url",labelKey:"documentation_url_label"},{key:"notes",labelKey:"object_notes_label"},{key:"task_count",labelKey:"tasks"},{key:"actions",labelKey:"actions"}],i=l.map(a=>a.key),r=["name","manufacturer","model","serial_number","installation_date","warranty_expiry","area_id","task_count","actions"];function o(a){if(!Array.isArray(a))return[...r];let t=new Set,e=[];for(let n of a)typeof n=="string"&&i.includes(n)&&!t.has(n)&&(t.add(n),e.push(n));return e.length?(e.includes("name")||e.unshift("name"),e):[...r]}export{l as a,r as b,o as c};
|
||||
@@ -0,0 +1,213 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{a as x}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-XB4BHMUS.js";import{a,b as v,c as n,f as p,h as b,l as h,m as c,q as t}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";function d(l){return l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function f(l){return!l.startsWith("data:image/svg+xml,")&&!l.startsWith("data:image/png;base64,")?"":d(l)}function q(l){return l.replace(/[/\\:*?"<>|#%]+/g,"").replace(/\s+/g,"-").toLowerCase().substring(0,100)}var o=class extends b{constructor(){super(...arguments);this.lang="en";this._open=!1;this._loading=!1;this._error="";this._viewResult=null;this._completeResult=null;this._urlMode="companion";this._entryId="";this._taskId=null;this._objectName="";this._taskName="";this._generateSeq=0}openForObject(e,i){this._entryId=e,this._taskId=null,this._objectName=i,this._taskName="",this._urlMode="companion",this._error="",this._viewResult=null,this._completeResult=null,this._open=!0,this._generate()}openForTask(e,i,r,s){this._entryId=e,this._taskId=i,this._objectName=r,this._taskName=s,this._urlMode="companion",this._error="",this._viewResult=null,this._completeResult=null,this._open=!0,this._generate()}async _generate(){let e=++this._generateSeq;this._loading=!0,this._error="",this._viewResult=null,this._completeResult=null;try{let i={type:"maintenance_supporter/qr/generate",entry_id:this._entryId,url_mode:this._urlMode};this._taskId&&(i.task_id=this._taskId);let r=[this.hass.connection.sendMessagePromise({...i,action:"view"})];this._taskId&&r.push(this.hass.connection.sendMessagePromise({...i,action:"complete"}));let s=await Promise.all(r);if(e!==this._generateSeq)return;this._viewResult=s[0],s.length>1&&(this._completeResult=s[1])}catch(i){if(e!==this._generateSeq)return;let r=i?.code,s=i?.message;this._error=r==="no_url"||typeof s=="string"&&s.includes("No Home Assistant URL")?t("qr_error_no_url",this.lang):t("qr_error",this.lang)}finally{e===this._generateSeq&&(this._loading=!1)}}_setUrlMode(e){this._urlMode!==e&&(this._urlMode=e,this._generate())}_print(){if(!this._viewResult)return;let e=this._viewResult,i=e.label.task_name?`${e.label.object_name} \u2014 ${e.label.task_name}`:e.label.object_name,r=[e.label.manufacturer,e.label.model].filter(Boolean).join(" "),s=window.open("","_blank","width=600,height=500");if(!s)return;let g=this.lang||"en",u=d(i),m=d(r),_=!!this._completeResult,w=d(t("qr_action_view",g)),$=d(t("qr_action_complete",g));s.document.write(`<!DOCTYPE html><html><head><meta charset="utf-8">
|
||||
<meta name="color-scheme" content="light">
|
||||
<title>${u}</title>
|
||||
<style>
|
||||
/* Printable sheet \u2014 must not inherit the phone's dark theme. The QR images
|
||||
carry their own white quiet zone and stay scannable either way, but the
|
||||
labels below are explicit dark greys and would vanish on a WebView's dark
|
||||
canvas. Same reasoning as helpers/report.ts. */
|
||||
:root{color-scheme:light}
|
||||
body{font-family:sans-serif;text-align:center;padding:20px;background:#fff;color:#1a1a1a}
|
||||
h2{margin:0 0 4px}
|
||||
.sub{color:#666;font-size:14px;margin-bottom:16px}
|
||||
.qr-row{display:flex;justify-content:center;gap:24px;margin:12px 0}
|
||||
.qr-col{display:flex;flex-direction:column;align-items:center;gap:6px}
|
||||
.qr-col img{width:${_?"200px":"280px"}}
|
||||
.qr-label{font-size:13px;font-weight:500;color:#333}
|
||||
.url{font-size:10px;color:#999;word-break:break-all;margin-top:8px;max-width:480px}
|
||||
</style></head><body>
|
||||
<h2>${u}</h2>
|
||||
${m?`<div class="sub">${m}</div>`:""}
|
||||
<div class="qr-row">
|
||||
<div class="qr-col">
|
||||
<img src="${f(this._viewResult.svg_data_uri)}" alt="QR Info" />
|
||||
<div class="qr-label">${w}</div>
|
||||
</div>
|
||||
${_?`<div class="qr-col">
|
||||
<img src="${f(this._completeResult.svg_data_uri)}" alt="QR Complete" />
|
||||
<div class="qr-label">${$}</div>
|
||||
</div>`:""}
|
||||
</div>
|
||||
<div class="url">${d(this._viewResult.url)}</div>
|
||||
<script>setTimeout(()=>window.print(),300)<\/script>
|
||||
</body></html>`),s.document.close()}_downloadSvg(e,i){let r=decodeURIComponent(e.svg_data_uri.replace("data:image/svg+xml,","")),s=this._taskName?`${this._objectName}-${this._taskName}`:this._objectName;x(r,`qr-${q(s)}-${i}.svg`,"image/svg+xml")}_close(){this._open=!1,this._viewResult=null,this._completeResult=null,this._error="",this._loading=!1}render(){if(!this._open)return n``;let e=this.lang||this.hass?.language||"en",i=this._taskName?`${t("qr_code",e)}: ${this._objectName} \u2014 ${this._taskName}`:`${t("qr_code",e)}: ${this._objectName}`,r=!!this._viewResult;return n`
|
||||
<ha-dialog open @closed=${this._close}>
|
||||
<div class="dialog-title">${i}</div>
|
||||
<div class="content">
|
||||
${this._loading?n`<div class="loading">${t("qr_generating",e)}</div>`:this._error?n`<div class="error">${this._error}</div>`:r?n`
|
||||
<div class="qr-pair">
|
||||
<div class="qr-item">
|
||||
<img
|
||||
class="qr-image ${this._completeResult?"small":""}"
|
||||
src="${this._viewResult.svg_data_uri}"
|
||||
alt="QR Info"
|
||||
/>
|
||||
<div class="qr-item-label">${t("qr_action_view",e)}</div>
|
||||
<button class="dl-btn"
|
||||
@click=${()=>this._downloadSvg(this._viewResult,"info")}>
|
||||
<ha-icon icon="mdi:download"></ha-icon>
|
||||
${t("qr_download",e)}
|
||||
</button>
|
||||
</div>
|
||||
${this._completeResult?n`
|
||||
<div class="qr-item">
|
||||
<img
|
||||
class="qr-image small"
|
||||
src="${this._completeResult.svg_data_uri}"
|
||||
alt="QR Complete"
|
||||
/>
|
||||
<div class="qr-item-label">${t("qr_action_complete",e)}</div>
|
||||
<button class="dl-btn"
|
||||
@click=${()=>this._downloadSvg(this._completeResult,"complete")}>
|
||||
<ha-icon icon="mdi:download"></ha-icon>
|
||||
${t("qr_download",e)}
|
||||
</button>
|
||||
</div>
|
||||
`:p}
|
||||
</div>
|
||||
<div class="url-display">${this._viewResult.url}</div>
|
||||
`:p}
|
||||
<div class="action-row">
|
||||
<label>${t("qr_url_mode",e)}</label>
|
||||
<div class="action-toggle">
|
||||
<button class="toggle-btn ${this._urlMode==="companion"?"active":""}"
|
||||
@click=${()=>this._setUrlMode("companion")}>${t("qr_mode_companion",e)}</button>
|
||||
<button class="toggle-btn ${this._urlMode==="local"?"active":""}"
|
||||
@click=${()=>this._setUrlMode("local")}>${t("qr_mode_local",e)}</button>
|
||||
<button class="toggle-btn ${this._urlMode==="server"?"active":""}"
|
||||
@click=${()=>this._setUrlMode("server")}>${t("qr_mode_server",e)}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dialog-actions">
|
||||
<ha-button appearance="plain" @click=${this._close}>
|
||||
${t("cancel",e)}
|
||||
</ha-button>
|
||||
<ha-button
|
||||
@click=${this._print}
|
||||
.disabled=${!r}
|
||||
>
|
||||
${t("qr_print",e)}
|
||||
</ha-button>
|
||||
</div>
|
||||
</ha-dialog>
|
||||
`}};o.styles=v`
|
||||
.dialog-title {
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
min-width: 300px;
|
||||
}
|
||||
.dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding-top: 16px;
|
||||
}
|
||||
.qr-pair {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
.qr-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.qr-image {
|
||||
width: 240px;
|
||||
height: 240px;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
.qr-image.small {
|
||||
width: 180px;
|
||||
height: 180px;
|
||||
}
|
||||
.qr-item-label {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--secondary-text-color);
|
||||
text-align: center;
|
||||
}
|
||||
.dl-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
background: none;
|
||||
border: 1px solid var(--divider-color, #e0e0e0);
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
color: var(--primary-text-color);
|
||||
padding: 6px 14px;
|
||||
border-radius: 18px;
|
||||
transition: background 0.2s, border-color 0.2s;
|
||||
}
|
||||
.dl-btn:hover {
|
||||
background: var(--secondary-background-color, #f5f5f5);
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
.dl-btn ha-icon {
|
||||
--mdc-icon-size: 18px;
|
||||
}
|
||||
.url-display {
|
||||
font-size: 11px;
|
||||
color: var(--secondary-text-color);
|
||||
word-break: break-all;
|
||||
text-align: center;
|
||||
max-width: 400px;
|
||||
}
|
||||
.loading {
|
||||
padding: 40px 0;
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
.error {
|
||||
padding: 20px 0;
|
||||
color: var(--error-color, #f44336);
|
||||
}
|
||||
.action-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
}
|
||||
.action-row label {
|
||||
font-size: 13px;
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
.action-toggle {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
background: var(--divider-color, #e0e0e0);
|
||||
border-radius: 6px;
|
||||
padding: 3px;
|
||||
}
|
||||
.toggle-btn {
|
||||
flex: 1;
|
||||
padding: 8px 12px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--primary-text-color);
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
transition: all 0.2s;
|
||||
line-height: 1.3;
|
||||
}
|
||||
.toggle-btn:hover {
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
.toggle-btn.active {
|
||||
background: var(--primary-color);
|
||||
color: var(--text-primary-color, #fff);
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
`,a([h({attribute:!1})],o.prototype,"hass",2),a([h()],o.prototype,"lang",2),a([c()],o.prototype,"_open",2),a([c()],o.prototype,"_loading",2),a([c()],o.prototype,"_error",2),a([c()],o.prototype,"_viewResult",2),a([c()],o.prototype,"_completeResult",2),a([c()],o.prototype,"_urlMode",2);customElements.get("maintenance-qr-dialog")||customElements.define("maintenance-qr-dialog",o);export{o as a};
|
||||
@@ -0,0 +1,452 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{a as x,g as q,l as L}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-5XRT3AM7.js";import{a as O}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-WQXORDNI.js";import{M as P,a as o,b as y,c,f as p,h as k,l,m as u,q as a,x as T,y as A}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";function V(m){if(!m)return[];let n=[],t=m.photo_doc_id;typeof t=="string"&&n.push(t);let e=m.photo_doc_ids;Array.isArray(e)&&n.push(...e);let i=[];for(let s of n){if(typeof s!="string")continue;let r=s.trim();if(!(!r||i.includes(r))&&(i.push(r),i.length>=10))break}return i}async function j(m,n,t,e){let i=new FormData;i.append("entry_id",n);for(let f of e)i.append("tags",f);i.append("file",t,t.name);let s=await fetch("/api/maintenance_supporter/document/upload",{method:"POST",headers:{Authorization:`Bearer ${m.auth?.data?.access_token??""}`},body:i});if(s.status===413)throw new Error("doc_too_large");if(!s.ok)throw new Error("doc_upload_failed");let r=await s.json();if(!r.id)throw new Error("doc_upload_failed");return{id:r.id,deduped:!!r.deduped,duplicate_in_object:r.duplicate_in_object??null}}async function H(m,n,t){return(await j(m,n,t,["photo"])).id}async function S(m,n){await Promise.all(n.map(t=>m.connection.sendMessagePromise({type:"maintenance_supporter/documents/delete",doc_id:t}).catch(()=>{})))}var w=class{constructor(n,t){this.host=n;this.opts=t;this.photos=[];this.uploadedIds=[];this.uploading=!1;this.errorKey="";this.max=t.max??10,n.addController(this)}hostConnected(){}get ids(){return this.photos.map(n=>n.id)}get remaining(){return Math.max(this.max-this.photos.length,0)}get full(){return this.remaining===0}errorText(n){return this.errorKey?a(this.errorKey,n).replace("{max}",String(this.max)):""}clearError(){this.errorKey=""}reset(n=[]){this._revokeAll(),this.photos=n.map(t=>({id:t,preview:""})),this.uploadedIds=[],this.uploading=!1,this.errorKey="",this.host.requestUpdate()}async addFiles(n){if(n.length===0)return;let t=n.slice(0,this.remaining);this.uploading=!0,this.errorKey="",this.host.requestUpdate();try{for(let e of t){let i=await H(this.opts.hass(),this.opts.entryId(),e);this.uploadedIds=[...this.uploadedIds,i],this.photos=[...this.photos,{id:i,preview:URL.createObjectURL(e)}],this.host.requestUpdate()}n.length>t.length&&(this.errorKey="photos_limit")}catch(e){this.errorKey=e instanceof Error&&e.message==="doc_too_large"?"doc_too_large":"doc_upload_failed"}finally{this.uploading=!1,this.host.requestUpdate()}}remove(n){let t=this.photos.find(e=>e.id===n);t?.preview&&URL.revokeObjectURL(t.preview),this.photos=this.photos.filter(e=>e.id!==n),this.uploadedIds.includes(n)&&(this.uploadedIds=this.uploadedIds.filter(e=>e!==n),S(this.opts.hass(),[n])),this.host.requestUpdate()}discardOrphans(){if(this.uploadedIds.length===0)return;let n=this.uploadedIds;this.uploadedIds=[],S(this.opts.hass(),n)}markAttached(){this.uploadedIds=[]}_revokeAll(){for(let n of this.photos)n.preview&&URL.revokeObjectURL(n.preview)}};function $(){if(window.externalApp!==void 0)return!0;let n=typeof navigator<"u"&&navigator.userAgent||"";return/Home Assistant\//.test(n)&&/Android/.test(n)}var I={objectSections:"msp-object-sections",printOptions:"msp-print-options",batteryRosterOpen:"msp-bf-roster-open",docSort:"msp-doc-sort",cameraDevice:"msp-camera-device",overviewTab:"msp-overview-tab",collapsedSections:"msp-collapsed-sections",chartRange:"msp-chart-range",chartHideOutliers:"msp-chart-hide-outliers",taskSort:"maintenance_supporter_sort",objectSort:"maintenance_supporter_object_sort",groupBy:"maintenance_supporter_groupby",objectView:"maintenance_supporter_object_view",objectsCache:"msp-objects-cache",gettingStartedDismissed:"msp-gs-dismissed",batteryRosterSort:"ms_bf_roster_sort"};function R(m){try{return localStorage.getItem(m)}catch{return null}}function N(m,n){try{localStorage.setItem(m,n)}catch{}}function U(){if(!$())return!1;let m=typeof navigator<"u"?navigator.mediaDevices:void 0;return!!m&&typeof m.getUserMedia=="function"}var C=1920,B=.88,b=class extends k{constructor(){super(...arguments);this.lang="en";this._open=!1;this._busy=!1;this._devices=[];this._deviceIndex=-1;this._switchFailed=!1;this._facing="environment";this._stream=null}async open(){if(this._open)return;let t=typeof navigator<"u"?navigator.mediaDevices:void 0;if(!t||typeof t.getUserMedia!="function"){this._unavailable("no_media_devices");return}let e=R(I.cameraDevice),i=!1;if(e)try{this._stream=await t.getUserMedia({video:{deviceId:{exact:e}},audio:!1}),i=!0}catch{}if(!i){try{this._stream=await t.getUserMedia({video:{facingMode:{ideal:"environment"},zoom:1,advanced:[{zoom:1}]},audio:!1})}catch(r){this._unavailable(r instanceof Error?r.name||r.message:String(r));return}await this._preferMainBackCamera(t)}await this._applyZoomOne(),await this._listDevices(t),this._deviceIndex=this._indexOfCurrent(e&&i?e:null),this._switchFailed=!1,this._facing=this._stream?.getVideoTracks()[0]?.getSettings().facingMode??"environment",this._Line truncated
|
||||
<div class="overlay" role="dialog" aria-modal="true" aria-label=${a("doc_camera",t)}>
|
||||
<video autoplay playsinline muted></video>
|
||||
${this._switchFailed?c`<div class="switch-note" role="status">${a("camera_switch_failed",t)}</div>`:p}
|
||||
<div class="bar">
|
||||
<button type="button" class="cancel" @click=${this.close}>${a("cancel",t)}</button>
|
||||
${this._devices.length>1?c`<button type="button" class="switch" ?disabled=${this._busy} title=${a("camera_switch_lens",t)} aria-label=${a("camera_switch_lens",t)} @click=${this._switchCamera}>
|
||||
<ha-icon icon="mdi:camera-flip-outline"></ha-icon>
|
||||
<span class="switch-pos">${this._deviceIndex>=0?`${this._deviceIndex+1}/${this._devices.length}`:`?/${this._devices.length}`}</span>
|
||||
</button>`:p}
|
||||
<button type="button" class="shoot" ?disabled=${this._busy} @click=${this._shoot}>
|
||||
<ha-icon icon="mdi:camera"></ha-icon><span>${a("camera_capture_shoot",t)}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`}};b.styles=y`
|
||||
:host { display: contents; }
|
||||
.overlay {
|
||||
position: fixed; inset: 0; z-index: 10000;
|
||||
background: #000; color: #fff;
|
||||
display: flex; flex-direction: column;
|
||||
}
|
||||
video { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #000; }
|
||||
.bar {
|
||||
display: flex; justify-content: space-between; align-items: center; gap: 16px;
|
||||
padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
button {
|
||||
font: inherit; border-radius: 24px; padding: 10px 18px; cursor: pointer;
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
}
|
||||
.cancel { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.6); }
|
||||
.switch { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.6); padding: 10px 12px; }
|
||||
.switch ha-icon { --mdc-icon-size: 22px; }
|
||||
.switch-pos { font-size: 12px; opacity: 0.85; }
|
||||
.switch-note { position: absolute; left: 12px; right: 12px; bottom: 84px; text-align: center; color: #fff; font-size: 13px; text-shadow: 0 1px 2px #000; }
|
||||
.shoot { background: var(--primary-color, #03a9f4); color: #fff; border: none; font-weight: 600; }
|
||||
.shoot[disabled] { opacity: 0.6; cursor: default; }
|
||||
.shoot ha-icon { --mdc-icon-size: 22px; }
|
||||
`,o([l({type:String})],b.prototype,"lang",2),o([u()],b.prototype,"_open",2),o([u()],b.prototype,"_busy",2),o([u()],b.prototype,"_devices",2),o([u()],b.prototype,"_deviceIndex",2),o([u()],b.prototype,"_switchFailed",2);customElements.get("ms-camera-capture")||customElements.define("ms-camera-capture",b);var z=y`
|
||||
ms-photo-picker { display: contents; }
|
||||
.photo-pickers {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
.photo-pick {
|
||||
display: inline-flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border: 1px dashed var(--divider-color);
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
color: var(--secondary-text-color);
|
||||
width: fit-content;
|
||||
}
|
||||
.photo-pick:hover { border-color: var(--primary-color); }
|
||||
.photo-pick:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
|
||||
.photo-pick.disabled { opacity: 0.6; cursor: default; }
|
||||
.photo-pick input[type="file"] { display: none; }
|
||||
.photo-android-hint {
|
||||
font-size: 12px;
|
||||
color: var(--secondary-text-color);
|
||||
margin-top: 4px;
|
||||
}
|
||||
`,v=class extends k{constructor(){super(...arguments);this.lang="en";this.disabled=!1;this.busy=!1;this.accept="image/*";this.showCamera=!0;this.showGallery=!0;this.compact=!1;this.remaining=1/0;this._singlePick=$();this._inAppCamera=U()}createRenderRoot(){return this}get _locked(){return this.disabled||this.busy}_emit(t){t.length!==0&&this.dispatchEvent(new CustomEvent("files-picked",{detail:{files:t},bubbles:!0,composed:!0}))}_onInput(t){let e=t.target,i=Array.from(e.files??[]);e.value="",this._emit(i)}_onCameraClick(t){!this._inAppCamera||this._locked||(t.preventDefault(),this.querySelector("ms-camera-capture")?.open())}_onCameraUnavailable(){this._inAppCamera=!1,this.querySelector(".photo-pick-camera input")?.click()}_onKeydown(t){t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),!this._locked&&t.currentTarget.click())}render(){if(this.remaining<=0||!this.showCamera&&!this.showGallery)return p;let t=this.lang,e=this._locked?"disabled":"",i=this.busy?a("uploading",t):a("doc_camera",t),s=a(this._singlePick?"choose_photo":"choose_photos",t);return c`
|
||||
<div class="photo-pickers">
|
||||
${this.showCamera?c`<label class="photo-pick photo-pick-camera ${e}" role="button" tabindex="0"
|
||||
aria-label=${i} title=${this.compact?i:p}
|
||||
@click=${this._onCameraClick} @keydown=${this._onKeydown}>
|
||||
<ha-icon icon="mdi:camera"></ha-icon>
|
||||
${this.compact?p:c`<span>${i}</span>`}
|
||||
<input type="file" accept=${this.accept} capture="environment"
|
||||
?disabled=${this._locked} @change=${this._onInput} />
|
||||
</label>`:p}
|
||||
${this.showGallery?c`<label class="photo-pick photo-pick-gallery ${e}" role="button" tabindex="0"
|
||||
aria-label=${s} title=${this.compact?s:p}
|
||||
@keydown=${this._onKeydown}>
|
||||
<ha-icon icon="mdi:image-multiple"></ha-icon>
|
||||
${this.compact?p:c`<span>${s}</span>`}
|
||||
<input type="file" accept=${this.accept} ?multiple=${!this._singlePick}
|
||||
?disabled=${this._locked} @change=${this._onInput} />
|
||||
</label>`:p}
|
||||
</div>
|
||||
${this.showGallery&&this._singlePick?c`<div class="photo-android-hint">${a("photos_android_hint",t)}</div>`:p}
|
||||
${this.showCamera&&this._inAppCamera?c`<ms-camera-capture .lang=${t}
|
||||
@photo-captured=${r=>this._emit([r.detail.file])}
|
||||
@capture-unavailable=${this._onCameraUnavailable}></ms-camera-capture>`:p}
|
||||
`}};o([l({type:String})],v.prototype,"lang",2),o([l({type:Boolean})],v.prototype,"disabled",2),o([l({type:Boolean})],v.prototype,"busy",2),o([l({type:String})],v.prototype,"accept",2),o([l({type:Boolean})],v.prototype,"showCamera",2),o([l({type:Boolean})],v.prototype,"showGallery",2),o([l({type:Boolean})],v.prototype,"compact",2),o([l({type:Number})],v.prototype,"remaining",2),o([u()],v.prototype,"_inAppCamera",2);customElements.get("ms-photo-picker")||customElements.define("ms-photo-picker",v);var d=class extends k{constructor(){super(...arguments);this.entryId="";this.taskId="";this.taskName="";this.lang="en";this.checklist=[];this.adaptiveEnabled=!1;this.taskType="";this.readingUnit="";this.readings=[];this.readingHistory=[];this.restockDefault=null;this.restockUnitCost=null;this.currencySymbol="";this.parts=[];this.consumesParts=[];this.consumesInfo=[];this.requiredFields=[];this.phaseLabel="";this.requireTagScan=!1;this.viaTagScan=!1;this._open=!1;this._notes="";this._cost="";this._duration="";this._loading=!1;this._error="";this._checklistState={};this._feedback="needed";this._photos=new w(this,{entryId:()=>this.entryId,hass:()=>this.hass});this._readingValue="";this._readingValues={};this._restockQty="";this._completedAt="";this._usedParts={};this.checklistPrefill={}}open(t={}){this._open||(this._open=!0,this.viaTagScan=!!t.viaTagScan,this._notes="",this._cost="",this._duration="",this._error="",this._checklistState=Object.fromEntries(this.checklist.map((e,i)=>[String(i),!!this.checklistPrefill[e]]).filter(([,e])=>e)),this._feedback="needed",this._photos.reset(),this._readingValue="",this._readingValues={},this._restockQty=this.restockDefault!==null?String(this.restockDefault):"",this._completedAt="",this._usedParts=Object.fromEntries(this.consumesParts.map(e=>[x(e),{...e}])))}_toggleCheck(t){let e=String(t);this._checklistState={...this._checklistState,[e]:!this._checklistState[e]}}_setFeedback(t){this._feedback=t}async _complete(){this._loading=!0,this._error="",this._photos.clearError();try{let t={type:"maintenance_supporter/task/complete",entry_id:this.entryId,task_id:this.taskId};if(this._notes&&(t.notes=this._notes),this._cost){let e=parseFloat(this._cost);!isNaN(e)&&e>=0&&(t.cost=e)}if(this._duration){let e=parseInt(this._duration,10);!isNaN(e)&&e>=0&&(t.duration=e)}if(this.checklist.length>0&&(t.checklist_state=this._checklistState),this.adaptiveEnabled&&(t.feedback=this._feedback),this._photos.photos.length>0&&(t.photo_doc_ids=this._photos.ids),this.viaTagScan&&(t.via_tag_scan=!0),this._completedAt){if(new Date(this._completedAt).getTime()>Date.now()){this._error=a("completed_at_future_error",this.lang),this._loading=!1;return}t.completed_at=this._completedAt.length===16?`${this._completedAt}:00`:this._completedAt}if(this.readings.length>0){let e={};for(let i of this.readings){let s=(this._readingValues[i.id]??"").trim();if(s==="")continue;let r=parseFloat(s.replace(",","."));isNaN(r)||(e[i.id]=r)}Object.keys(e).length>0&&(t.reading_values=e)}else if(this._readingValue!==""){let e=parseFloat(this._readingValue);isNaN(e)||(t.reading_value=e)}if(this.restockDefault!==null&&this._restockQty!==""){let e=parseFloat(this._restockQty);!isNaN(e)&&e>=1&&(t.restock_quantity=e)}this.parts.length>0&&(t.used_parts=Object.values(this._usedParts).filter(e=>Number.isFinite(e.quantity)&&e.quantity>0).map(e=>e.entry_id?{part_id:e.part_id,quantity:e.quantity,entry_id:e.entry_id}:{part_id:e.part_id,quantity:e.quantity})),await this.hass.connection.sendMessagePromise(t),this._photos.markAttached(),this._open=!1,this.dispatchEvent(new CustomEvent("task-completed"))}catch(t){this._error=O(t,this.lang,a("save_error",this.lang))}finally{this._loading=!1}}_renderReadingField(t,e){let i=this._completedAt?new Date(this._completedAt).getTime():NaN,s=q(this.readingHistory,t.id,isNaN(i)?void 0:i),r=t.unit||this.readingUnit,f=(this._readingValues[t.id]??"").trim(),h=f===""?NaN:parseFloat(f.replace(",",".")),_=s!==void 0&&!isNaN(h)&&h<s.value,g=s!==void 0?T(s.value,e,{maximumFractionDigits:3}):"";return c`
|
||||
<label class="field reading-field">
|
||||
<span class="field-label">${t.name}${r?` (${r})`:""}</span>
|
||||
<input type="text" inputmode="decimal" class="field-input"
|
||||
placeholder=${s!==void 0?a("reading_last",e).replace("{value}",g):""}
|
||||
.value=${this._readingValues[t.id]??""}
|
||||
@input=${E=>{this._readingValues={...this._readingValues,[t.id]:E.target.value}}} />
|
||||
${_?c`<span class="reading-warn">${a("reading_below_last",e).replace("{value}",g)}</span>`:p}
|
||||
</label>`}get _missingRequired(){let t={notes:this._notes.trim()!=="",cost:this._cost.trim()!=="",duration:this._duration.trim()!=="",photo:this._photos.photos.length>0,user:!!this.hass?.user};return this.requiredFields.filter(e=>!t[e])}_req(t){return this.requiredFields.includes(t)?c`<span class="req-mark" aria-hidden="true">*</span>`:p}_partsCostSuggestion(){if(this.restockDefault!==null){let i=parseFloat(this._restockQty);return this.restockUnitCost==null||!Number.isFinite(i)||i<=0?null:Math.round(this.restockUnitCost*i*100)/100}if(!this.parts.length)return null;let t=0,e=!1;for(let i of Object.values(this._usedParts)){let s=this.parts.find(r=>x({part_id:r.id,entry_id:r.entry_id})===x(i));s?.cost!=null&&(t+=s.cost*(i.quantity||1),e=!0)}return e?Math.round(t*100)/100:null}_renderCostSuggestion(t){if(this._cost.trim()!=="")return p;let e=this._partsCostSuggestion();if(e==null||e<=0)return p;let i=A(e,this.currencySymbol,t);return c`<button
|
||||
type="button"
|
||||
class="cost-suggestion"
|
||||
@click=${()=>this._cost=String(Math.round(e*100)/100)}
|
||||
>${a("cost_from_parts",t).replace("{amount}",i)}</button>`}_close(){this._open=!1,this._photos.discardOrphans()}_pickCompletedAt(){let t=new Date,e=i=>String(i).padStart(2,"0");this._completedAt=`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}T${e(t.getHours())}:${e(t.getMinutes())}:00`}render(){if(!this._open)return c``;let t=this.lang||this.hass?.language||"en",e=this._error||this._photos.errorText(t);return c`
|
||||
<ha-dialog open @closed=${this._close}>
|
||||
<div class="dialog-title">${a("complete_title",t)}${this.taskName}</div>
|
||||
${this.phaseLabel?c`<div class="phase-line">${a("phase_current",t)}: ${this.phaseLabel}</div>`:p}
|
||||
${this.requireTagScan&&!this.viaTagScan?c`<div class="scan-required-note">${a("require_tag_scan_hint",t)}</div>`:p}
|
||||
<div class="content">
|
||||
${e?c`<div class="error">${e}</div>`:p}
|
||||
${this.checklist.length>0?c`
|
||||
<div class="checklist-section">
|
||||
<label class="checklist-label">${a("checklist",t)}</label>
|
||||
${this.checklist.map((i,s)=>c`
|
||||
<label class="checklist-item" @click=${()=>this._toggleCheck(s)}>
|
||||
<input type="checkbox" .checked=${!!this._checklistState[String(s)]} />
|
||||
<span>${i}</span>
|
||||
</label>
|
||||
`)}
|
||||
</div>
|
||||
`:p}
|
||||
${this.readings.length>0?c`<div class="readings-block">
|
||||
<span class="field-label">${a("readings_section",t)}</span>
|
||||
${this.readings.map(i=>this._renderReadingField(i,t))}
|
||||
</div>`:this.taskType==="reading"?c`
|
||||
<label class="field">
|
||||
<span class="field-label">${a("reading_value_label",t)}${this.readingUnit?` (${this.readingUnit})`:""}</span>
|
||||
<input type="number" step="any" class="field-input"
|
||||
.value=${this._readingValue}
|
||||
@input=${i=>this._readingValue=i.target.value} />
|
||||
</label>`:p}
|
||||
${this.parts.length?c`<div class="used-parts">
|
||||
<span class="field-label">${a("complete_parts_used",t)}</span>
|
||||
${this.parts.map(i=>{let s=x({part_id:i.id,entry_id:i.entry_id}),r=this._usedParts[s],f=r!==void 0,h=i.entry_id?{part_id:i.id,quantity:1,entry_id:i.entry_id}:{part_id:i.id,quantity:1};return c`<div class="used-part-row">
|
||||
<label class="used-part-check">
|
||||
<input type="checkbox" .checked=${f}
|
||||
@change=${_=>{let g={...this._usedParts};_.target.checked?g[s]=g[s]||h:delete g[s],this._usedParts=g}} />
|
||||
<span
|
||||
>${i.name}${i.owner_name?c`<span class="used-part-owner"> (${i.owner_name})</span>`:p}${i.stock!==null&&i.stock!==void 0?` (${i.stock}${i.unit?" "+i.unit:""})`:""}</span
|
||||
>
|
||||
</label>
|
||||
${f?c`<input class="used-part-qty" type="number" min="0.01" max="999" step="0.01"
|
||||
.value=${String(r.quantity)}
|
||||
@input=${_=>{let g=parseFloat(_.target.value);this._usedParts={...this._usedParts,[s]:{...h,quantity:Number.isFinite(g)&&g>=.01?g:1}}}} />`:p}
|
||||
</div>`})}
|
||||
</div>`:this.consumesInfo.length?c`<div class="consumes-hint">
|
||||
${this.consumesInfo.map(i=>c`<div>${i}</div>`)}
|
||||
</div>`:p}
|
||||
${this.restockDefault!==null?c`
|
||||
<label class="field">
|
||||
<span class="field-label">${a("restock_quantity_label",t)}</span>
|
||||
<input type="number" step="0.01" min="0.01" class="field-input"
|
||||
.value=${this._restockQty}
|
||||
@input=${i=>this._restockQty=i.target.value} />
|
||||
</label>`:p}
|
||||
<!-- Native <input>s rather than <ha-textfield>: when this dialog
|
||||
is opened from a Lovelace card via dialog-mount, ha-textfield
|
||||
isn't yet registered (HA loads it lazily when its own panels
|
||||
need it) so the elements render with zero height and the user
|
||||
only sees the title + Cancel/Complete buttons — the original
|
||||
bug report. Native inputs always render. -->
|
||||
<label class="field">
|
||||
<span class="field-label">${a("notes_optional",t)}${this._req("notes")}</span>
|
||||
<input type="text" class="field-input"
|
||||
.value=${this._notes}
|
||||
@input=${i=>this._notes=i.target.value} />
|
||||
</label>
|
||||
<label class="field">
|
||||
<span class="field-label">${a("cost_optional",t)}${this._req("cost")}</span>
|
||||
<input type="number" step="0.01" min="0" class="field-input"
|
||||
.value=${this._cost}
|
||||
@input=${i=>this._cost=i.target.value} />
|
||||
${this._renderCostSuggestion(t)}
|
||||
</label>
|
||||
<label class="field">
|
||||
<span class="field-label">${a("duration_minutes",t)}${this._req("duration")}</span>
|
||||
<input type="number" step="0.01" min="0" class="field-input"
|
||||
.value=${this._duration}
|
||||
@input=${i=>this._duration=i.target.value} />
|
||||
</label>
|
||||
<div class="field">
|
||||
<span class="field-label">${a("completed_at_optional",t)}</span>
|
||||
${this._completedAt?c`<ms-date-field
|
||||
kind="datetime"
|
||||
clearable
|
||||
.hass=${this.hass}
|
||||
.lang=${t}
|
||||
.value=${this._completedAt}
|
||||
@value-changed=${i=>this._completedAt=i.detail.value}
|
||||
></ms-date-field>`:c`<button type="button" class="backdate-pick" @click=${this._pickCompletedAt}>
|
||||
<ha-icon icon="mdi:calendar-clock"></ha-icon>${a("completed_at_pick",t)}
|
||||
</button>`}
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="field-label">${a("completion_photos_optional",t)}${this._req("photo")}</span>
|
||||
${this._photos.photos.length>0?c`<div class="photo-strip">
|
||||
${this._photos.photos.map(i=>c`
|
||||
<div class="photo-preview">
|
||||
<img src=${i.preview} alt="" />
|
||||
<button type="button" class="photo-remove" @click=${()=>this._photos.remove(i.id)}
|
||||
title="${a("remove",t)}">✕</button>
|
||||
</div>`)}
|
||||
</div>`:p}
|
||||
${this._photos.full?c`<div class="photo-limit">${a("photos_limit",t).replace("{max}",String(this._photos.max))}</div>`:c`<ms-photo-picker .lang=${t} .busy=${this._photos.uploading} .remaining=${this._photos.remaining}
|
||||
@files-picked=${i=>this._photos.addFiles(i.detail.files)}
|
||||
></ms-photo-picker>`}
|
||||
</div>
|
||||
${this.adaptiveEnabled?c`
|
||||
<div class="feedback-section">
|
||||
<label class="feedback-label">${a("was_maintenance_needed",t)}</label>
|
||||
<div class="feedback-buttons">
|
||||
<button
|
||||
class="feedback-btn ${this._feedback==="needed"?"selected":""}"
|
||||
@click=${()=>this._setFeedback("needed")}
|
||||
>${a("feedback_needed",t)}</button>
|
||||
<button
|
||||
class="feedback-btn ${this._feedback==="not_needed"?"selected":""}"
|
||||
@click=${()=>this._setFeedback("not_needed")}
|
||||
>${a("feedback_not_needed",t)}</button>
|
||||
<button
|
||||
class="feedback-btn ${this._feedback==="not_sure"?"selected":""}"
|
||||
@click=${()=>this._setFeedback("not_sure")}
|
||||
>${a("feedback_not_sure",t)}</button>
|
||||
</div>
|
||||
</div>
|
||||
`:p}
|
||||
</div>
|
||||
<div class="dialog-actions">
|
||||
<ha-button appearance="plain" @click=${this._close}>
|
||||
${a("cancel",t)}
|
||||
</ha-button>
|
||||
<ha-button
|
||||
@click=${this._complete}
|
||||
.disabled=${this._loading||this._missingRequired.length>0}
|
||||
title=${this._missingRequired.length?this._missingRequired.map(i=>a("err_required",t).replace("{field}",a(L[i]??i,t))).join(" \xB7 "):""}
|
||||
>
|
||||
${this._loading?a("completing",t):a("complete",t)}
|
||||
</ha-button>
|
||||
</div>
|
||||
</ha-dialog>
|
||||
`}};d.styles=[P,z,y`
|
||||
.req-mark {
|
||||
color: var(--error-color, #f44336);
|
||||
margin-left: 2px;
|
||||
font-weight: 600;
|
||||
}
|
||||
/* #104: one-click cost suggestion from parts — quiet link-style chip. */
|
||||
.cost-suggestion {
|
||||
align-self: flex-start;
|
||||
margin-top: 4px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--primary-color);
|
||||
font-size: 12.5px;
|
||||
cursor: pointer;
|
||||
text-decoration: underline dotted;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
.dialog-title {
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
.scan-required-note {
|
||||
margin: -4px 0 12px;
|
||||
padding: 8px 10px;
|
||||
border-radius: 6px;
|
||||
background: rgba(255, 152, 0, 0.12);
|
||||
color: var(--primary-text-color);
|
||||
font-size: 13px;
|
||||
}
|
||||
.phase-line {
|
||||
margin-top: -8px;
|
||||
padding-bottom: 12px;
|
||||
font-size: 13px;
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-width: 300px;
|
||||
}
|
||||
.dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding-top: 16px;
|
||||
}
|
||||
.consumes-hint {
|
||||
font-size: 13px;
|
||||
color: var(--secondary-text-color);
|
||||
border-left: 3px solid var(--primary-color);
|
||||
padding: 4px 8px;
|
||||
margin: 4px 0 8px;
|
||||
}
|
||||
/* #99: editable per-completion parts selection */
|
||||
.used-parts { margin: 4px 0 8px; display: flex; flex-direction: column; gap: 4px; }
|
||||
.used-part-row { display: flex; align-items: center; gap: 8px; }
|
||||
.used-part-check {
|
||||
display: flex; align-items: center; gap: 6px; flex: 1;
|
||||
font-size: 13px; cursor: pointer;
|
||||
}
|
||||
.used-part-check input { cursor: pointer; }
|
||||
/* #111: whose stock this row draws on. Muted but never omitted — an
|
||||
unlabelled foreign pool is indistinguishable from an own part. */
|
||||
.used-part-owner { color: var(--secondary-text-color); }
|
||||
.used-part-qty {
|
||||
width: 76px; padding: 4px 6px; border-radius: 4px; font: inherit; font-size: 13px;
|
||||
border: 1px solid var(--divider-color);
|
||||
background: var(--card-background-color);
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
.error {
|
||||
color: var(--error-color, #f44336);
|
||||
font-size: 13px;
|
||||
}
|
||||
/* .field/.field-label/.field-input come from nativeFieldStyles */
|
||||
/* #161 phase 2: the per-slot reading fields */
|
||||
.readings-block { display: flex; flex-direction: column; gap: 8px; }
|
||||
.readings-block > .field-label { margin-bottom: -4px; }
|
||||
.reading-warn {
|
||||
font-size: 12px;
|
||||
color: var(--warning-color, #ff9800);
|
||||
}
|
||||
/* .photo-pick / .photo-pickers / .photo-android-hint come from photoPickerStyles */
|
||||
/* #163: the backdate moment starts EMPTY (= now); the button seeds the
|
||||
HA date+time picker with the current minute instead of the picker's
|
||||
own 00:00 default, so a backdated completion never lands at midnight
|
||||
by accident. */
|
||||
.backdate-pick {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border: 1px dashed var(--divider-color);
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
color: var(--secondary-text-color);
|
||||
width: fit-content;
|
||||
--mdc-icon-size: 18px;
|
||||
}
|
||||
.backdate-pick:hover { border-color: var(--primary-color); }
|
||||
/* #161: several photos per completion — tiles wrap into a strip,
|
||||
the two pickers (camera / gallery) sit underneath while there is
|
||||
room left under the cap. */
|
||||
.photo-strip {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin: 8px 0; /* room for the remove badges above the tiles */
|
||||
}
|
||||
.photo-limit {
|
||||
font-size: 12px;
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
.photo-preview {
|
||||
position: relative;
|
||||
width: fit-content;
|
||||
}
|
||||
/* Uniform tiles: a tiny or portrait shot must not collapse the strip. */
|
||||
.photo-preview img {
|
||||
width: 96px;
|
||||
height: 96px;
|
||||
object-fit: cover;
|
||||
border-radius: 8px;
|
||||
display: block;
|
||||
background: var(--secondary-background-color, rgba(0,0,0,0.06));
|
||||
}
|
||||
.photo-remove {
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
right: -8px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: var(--error-color, #db4437);
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
}
|
||||
.checklist-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid var(--divider-color);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.checklist-label {
|
||||
font-weight: 500;
|
||||
font-size: 13px;
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
.checklist-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
padding: 4px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
.checklist-item input[type="checkbox"] {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.feedback-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 8px 0;
|
||||
border-top: 1px solid var(--divider-color);
|
||||
}
|
||||
.feedback-label {
|
||||
font-weight: 500;
|
||||
font-size: 13px;
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
.feedback-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.feedback-btn {
|
||||
flex: 1;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid var(--divider-color);
|
||||
border-radius: 8px;
|
||||
background: var(--card-background-color, #fff);
|
||||
color: var(--primary-text-color);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.feedback-btn:hover {
|
||||
background: var(--secondary-background-color, #f5f5f5);
|
||||
}
|
||||
.feedback-btn.selected {
|
||||
background: var(--primary-color);
|
||||
color: var(--text-primary-color, #fff);
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
`],o([l({attribute:!1})],d.prototype,"hass",2),o([l()],d.prototype,"entryId",2),o([l()],d.prototype,"taskId",2),o([l()],d.prototype,"taskName",2),o([l()],d.prototype,"lang",2),o([l({type:Array})],d.prototype,"checklist",2),o([l({type:Boolean})],d.prototype,"adaptiveEnabled",2),o([l()],d.prototype,"taskType",2),o([l()],d.prototype,"readingUnit",2),o([l({attribute:!1})],d.prototype,"readings",2),o([l({attribute:!1})],d.prototype,"readingHistory",2),o([l({attribute:!1})],d.prototype,"restockDefault",2),o([l({attribute:!1})],d.prototype,"restockUnitCost",2),o([l()],d.prototype,"currencySymbol",2),o([l({attribute:!1})],d.prototype,"parts",2),o([l({attribute:!1})],d.prototype,"consumesParts",2),o([l({type:Array})],d.prototype,"consumesInfo",2),o([l({type:Array})],d.prototype,"requiredFields",2),o([l()],d.prototype,"phaseLabel",2),o([l({type:Boolean})],d.prototype,"requireTagScan",2),o([l({type:Boolean})],d.prototype,"viaTagScan",2),o([u()],d.prototype,"_open",2),o([u()],d.prototype,"_notes",2),o([u()],d.prototype,"_cost",2),o([u()],d.prototype,"_duration",2),o([u()],d.prototype,"_loading",2),o([u()],d.prototype,"_error",2),o([u()],d.prototype,"_checklistState",2),o([u()],d.prototype,"_feedback",2),o([u()],d.prototype,"_readingValue",2),o([u()],d.prototype,"_readingValues",2),o([u()],d.prototype,"_restockQty",2),o([u()],d.prototype,"_completedAt",2),o([u()],d.prototype,"_usedParts",2),o([l({attribute:!1})],d.prototype,"checklistPrefill",2);customElements.get("maintenance-complete-dialog")||customElements.define("maintenance-complete-dialog",d);export{I as a,R as b,N as c,$ as d,V as e,j as f,z as g,w as h,d as i};
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{a as i}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-WQXORDNI.js";import{q as s,s as o}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";async function f(e,a,n={}){n.busy?.(!0);try{return await e.hass.connection.sendMessagePromise(a)}catch(t){let r=o(e.hass);n.onError?.(i(t,r,n.fallbackKey?s(n.fallbackKey,r):void 0));return}finally{n.busy?.(!1)}}export{f as a};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{q as o}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";var v={already_archived:"ws_err_already_archived",already_paused:"ws_err_already_paused",archived:"ws_err_archived",create_failed:"ws_err_create_failed",duplicate_failed:"ws_err_duplicate_failed",empty:"ws_err_empty",empty_csv:"ws_err_empty_csv",invalid_cursor:"ws_err_invalid_cursor",invalid_date:"ws_err_invalid_date",invalid_device:"ws_err_invalid_device",invalid_entity_slug:"ws_err_invalid_entity_slug",invalid_format:"ws_err_invalid_format",invalid_input:"ws_err_invalid_input",invalid_mirror_todo:"ws_err_invalid_mirror_todo",invalid_parent:"ws_err_invalid_parent",invalid_icon:"ws_err_invalid_icon",invalid_range:"ws_err_invalid_range",invalid_search_template:"ws_err_invalid_search_template",invalid_target:"ws_err_invalid_target",invalid_trigger_config:"ws_err_invalid_trigger_config",invalid_url:"ws_err_invalid_url",invalid_user:"ws_err_invalid_user",invalid_view:"ws_err_invalid_view",limit_reached:"ws_err_limit_reached",no_defaults:"ws_err_no_defaults",no_phases:"ws_err_no_phases",no_url:"ws_err_no_url",not_archived:"ws_err_not_archived",not_available:"ws_err_not_available",not_configured:"ws_err_not_configured",not_found:"ws_err_not_found",not_loaded:"ws_err_not_loaded",not_paused:"ws_err_not_paused",replace_failed:"ws_err_replace_failed",self_link_device:"ws_err_self_link_device",storage_unavailable:"ws_err_storage_unavailable",too_early:"ws_err_too_early",too_large:"ws_err_too_large",too_many:"ws_err_too_many",too_many_views:"ws_err_too_many_views",unauthorized:"ws_err_unauthorized",unavailable:"ws_err_unavailable"},p={entry_id:"object",name:"name",task_type:"maintenance_type",schedule_type:"schedule_type",interval_days:"interval_days",interval_anchor:"interval_anchor",warning_days:"warning_days",last_performed:"last_performed_optional",notes:"notes_optional",documentation_url:"documentation_url_optional",custom_icon:"custom_icon_optional",nfc_tag_id:"nfc_tag_id_optional",responsible_user_id:"responsible_user",entity_slug:"entity_slug",entity_id:"entity_id",area_id:"area_id_optional",manufacturer:"manufacturer_optional",model:"model_optional",serial_number:"serial_number_optional",installation_date:"installation_date_optional",warranty_expiry:"warranty_expiry_optional",checklist:"checklist_steps_optional",reason:"reason",feedback:"feedback",cost:"cost",duration:"duration",description:"description_optional",environmental_entity:"environmental_entity_optional",environmental_attribute:"environmental_attribute_optional",trigger_above:"trigger_above",trigger_below:"trigger_below",trigger_equals:"trigger_equals",trigger_not_equals:"trigger_not_equals",trigger_for_minutes:"trigger_for_minutes"};function g(e){let _=e.replace(/_ids?$/,"").split("_").filter(Boolean);if(_.length===0)return e;let r=_.join(" ");return r.charAt(0).toUpperCase()+r.slice(1)}function w(e,_){let r=p[e];if(r){let t=o(r,_);if(t&&t!==r)return t}return g(e)}function f(e){let _=[...e.matchAll(/\['([^']+)'\]/g)].map(i=>i[1]),r=_.length?_[_.length-1]:void 0,t;return(t=e.match(/length of value must be at most (\d+)/))?{field:r,rule:"too_long",param:t[1]}:(t=e.match(/length of value must be at least (\d+)/))?{field:r,rule:"too_short",param:t[1]}:(t=e.match(/value must be at most (\S+)/))?{field:r,rule:"value_too_high",param:t[1]}:(t=e.match(/value must be at least (\S+)/))?{field:r,rule:"value_too_low",param:t[1]}:/required key not provided/.test(e)?{field:r,rule:"required"}:(t=e.match(/expected (\w+)/))?{field:r,rule:"wrong_type",param:t[1]}:/value must be one of/.test(e)?{field:r,rule:"invalid_choice"}:/not a valid value/.test(e)?{field:r,rule:"invalid_value"}:{field:r,rule:"unknown"}}var u=e=>e.toLowerCase().split(/[^a-z0-9]+/).filter(_=>_.length>1);function m(e,_){let r=new Set(u(_));return u(e).every(t=>r.has(t))}function y(e,_,r){if(r=r??o("action_error",_),typeof e=="string")return e;if(typeof e!="object"||e===null)return r;let t=e,i=t.message||t.error?.message||"",s=t.code||t.error?.code||"",d=s?v[s]:void 0;if(!i&&!d)return r;let a=f(i),c=a.field?w(a.field,_):"",n=l=>o(l,_).replace("{field}",c).replace("{n}",a.param??"");switch(a.rule){case"too_long":return n("err_too_long");case"too_short":return n("err_too_short");case"value_too_high":return n("err_value_too_high");case"value_too_low":return n("err_value_too_low");case"required":return n("err_required");case"wrong_type":return n("err_wrong_type").replace("{type}",a.param??"");case"invalid_choice":return n("err_invalid_choice");case"invalid_value":return n("err_invalid_value");default:if(d){let l=o(d,_);return i&&!m(i,s)?`${l} (${i})`:l}return i||r}}export{y as a};
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
function c(o,t,e){let l=new Blob([o],{type:e}),d=URL.createObjectURL(l),n=document.createElement("a");n.href=d,n.download=t,n.target="_blank",n.rel="noopener",n.style.display="none",document.body.appendChild(n),n.dispatchEvent(new MouseEvent("click")),document.body.removeChild(n),setTimeout(()=>URL.revokeObjectURL(d),6e4)}function r(o,t){let e=document.createElement("a");e.href=o,e.download=t,e.target="_blank",e.rel="noopener",e.style.display="none",document.body.appendChild(e),e.dispatchEvent(new MouseEvent("click")),document.body.removeChild(e)}export{c as a,r as b};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,937 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{b as ft,g as $t,j as Y,k as wt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-C7OGYVZI.js";import{e as Z,g as xt,h as kt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-PDDZINC4.js";import{b as gt,c as yt,e as G,f as vt,h as bt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-5XRT3AM7.js";import{a as $}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-WQXORDNI.js";import{A as z,B as pt,D as ut,E as B,J as X,K as ht,L as _t,O as mt,a as h,b as M,c as l,d as C,f as d,h as D,l as L,m as _,n as W,o as st,p as j,q as s,s as T,t as at,u as ot,v as lt,w as dt,x as y,y as U,z as ct}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";var P=class extends D{constructor(){super(...arguments);this.docId="";this._url="";this._failed=!1;this._signedFor=""}updated(){this.hass&&this.docId&&this._signedFor!==this.docId&&(this._signedFor=this.docId,this._url="",this._failed=!1,this._sign())}async _sign(){try{this._url=await ft(this.hass,this.docId)}catch{this._failed=!0}}render(){return this._failed||!this.docId?d:this._url?l`
|
||||
<a href=${this._url} target="_blank" rel="noopener" class="wrap">
|
||||
<img src=${this._url} alt="" loading="lazy"
|
||||
@error=${()=>this._failed=!0} />
|
||||
</a>`:l`<div class="ph"></div>`}};P.styles=M`
|
||||
.wrap { display: inline-block; margin-top: 4px; }
|
||||
/* #161: uniform 96px tiles — several photos sit in a strip, so a
|
||||
tiny or portrait shot must not collapse its slot. */
|
||||
img {
|
||||
width: 96px;
|
||||
height: 96px;
|
||||
object-fit: cover;
|
||||
border-radius: 6px;
|
||||
display: block;
|
||||
border: 1px solid var(--divider-color);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.ph {
|
||||
width: 96px;
|
||||
height: 96px;
|
||||
border-radius: 6px;
|
||||
background: var(--secondary-background-color, rgba(0,0,0,0.06));
|
||||
margin-top: 4px;
|
||||
}
|
||||
`,h([L({attribute:!1})],P.prototype,"hass",2),h([L()],P.prototype,"docId",2),h([_()],P.prototype,"_url",2),h([_()],P.prototype,"_failed",2);customElements.get("maintenance-history-photo")||customElements.define("maintenance-history-photo",P);var v=class extends D{constructor(){super(...arguments);this._open=!1;this._saving=!1;this._error="";this._draft=null;this._originalSnapshot=null;this._partOptions=null;this._partQty={};this._partQtyOriginal="";this._photos=new kt(this,{entryId:()=>this._draft?.entry_id??"",hass:()=>this.hass});this._photosOriginal="";this._readingRows=[];this._readingText={};this._readingsOriginal=""}get _lang(){return T(this.hass)}openEdit(t){this._draft={...t},this._originalSnapshot={...t},this._error="",this._open=!0,this._partOptions=null,this._partQty={},this._partQtyOriginal="",this._photos.reset(t.photo_doc_ids??[]),this._photosOriginal=JSON.stringify(this._photos.ids),this._seedReadings(t),this._loadPartOptions()}_seedReadings(t){let n=[],r=new Set;for(let o of t.readings??[])r.has(o.id)||(r.add(o.id),n.push({id:o.id,name:o.name,unit:o.unit??null}));for(let o of t.reading_values??[])r.has(o.id)||(r.add(o.id),n.push({id:o.id,name:o.name,unit:o.unit??null}));this._readingRows=n;let a={};for(let o of t.reading_values??[])a[o.id]=String(o.value);this._readingText=a,this._readingsOriginal=JSON.stringify(this._readingNumbers())}_readingNumbers(){let t={};for(let n of this._readingRows){let r=(this._readingText[n.id]??"").trim();if(r==="")continue;let a=parseFloat(r.replace(",","."));isNaN(a)||(t[n.id]=a)}return t}async _loadPartOptions(){let t=this._draft;if(t)try{let n=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/parts/overview"}),r=[];for(let o of n.parts||[]){let c=o.entry_id===t.entry_id,u=o.consumers.some(p=>p.entry_id===t.entry_id&&p.task_id===t.task_id);!c&&!u||r.push({part_id:o.part_id,name:o.name,entry_id:o.entry_id,foreign:!c,object_name:o.object_name})}for(let o of t.used_parts||[]){let c=o.entry_id||t.entry_id;r.some(u=>u.part_id===o.part_id&&u.entry_id===c)||r.push({part_id:o.part_id,name:o.name||o.part_id,entry_id:c,foreign:c!==t.entry_id,object_name:null})}let a={};for(let o of t.used_parts||[])a[`${o.entry_id||t.entry_id}:${o.part_id}`]=o.quantity??1;this._partOptions=r,this._partQty=a,this._partQtyOriginal=this._partSelectionKey()}catch{this._partOptions=[]}}_partSelectionKey(){return JSON.stringify(Object.entries(this._partQty).filter(([,t])=>t>0).sort(([t],[n])=>t.localeCompare(n)))}close(){this._open=!1,this._error="",this._draft=null,this._originalSnapshot=null,this._photos.discardOrphans()}_set(t,n){this._draft&&(this._draft={...this._draft,[t]:n})}async _delete(){if(!this._draft||!this._originalSnapshot)return;let t=this._lang;if(window.confirm(s("history_delete_confirm",t))){this._saving=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/history/delete",entry_id:this._draft.entry_id,task_id:this._draft.task_id,timestamp:this._originalSnapshot.original_timestamp}),this.dispatchEvent(new CustomEvent("history-entry-saved",{detail:{entry_id:this._draft.entry_id,task_id:this._draft.task_id,deleted:!0},bubbles:!0,composed:!0})),this.close()}catch(n){this._error=$(n,t)}finally{this._saving=!1}}}async _save(){if(!(!this._draft||!this._originalSnapshot)){this._saving=!0,this._error="",this._photos.clearError();try{let t={type:"maintenance_supporter/task/history/update",entry_id:this._draft.entry_id,task_id:this._draft.task_id,original_timestamp:this._originalSnapshot.original_timestamp};if(this._draft.timestamp!==this._originalSnapshot.timestamp&&(t.timestamp=this._draft.timestamp),this._draft.notes!==this._originalSnapshot.notes&&(t.notes=this._draft.notes),this._draft.cost!==this._originalSnapshot.cost&&(t.cost=this._draft.cost),this._draft.duration!==this._originalSnapshot.duration&&(t.duration=this._draft.duration),this._draft.completed_by!==this._originalSnapshot.completed_by&&(t.completed_by=this._draft.completed_by),this._partOptions!==null&&this._partSelectionKey()!==this._partQtyOriginal&&(t.used_parts=(this._partOptions||[]).filter(r=>(this._partQty[`${r.entry_id}:${r.part_id}`]||0)>0).map(r=>({part_id:r.part_id,quantity:this._partQty[`${r.entry_id}:${r.part_id}`],...r.foreign?{entry_id:r.entry_id}:{}}))),this._draft.reading_value!==this._originalSnapshot.reading_value&&(t.reading_value=this._draft.reading_value??null),this._readingRows.length>0&&JSON.stringify(this._readingNumbers())!==this._readingsOriginal){let r=this._readingNumbers(),a={};for(let o of this._readingRows)a[o.id]=r[o.id]??null;t.reading_values=a}if(JSON.stringify(this._photos.ids)!==this._photosOriginal&&(t.photo_doc_ids=this._photos.ids),Object.keys(t).filter(r=>!["type","entry_id","task_id","original_timestamp"].includes(r)).length===0){this.close();return}await this.hass.connection.sendMessagePromise(t),this._photos.markAttached(),this.dispatchEvent(new CustomEvent("history-entry-saved",{detail:{entry_id:
Line truncated
|
||||
<div class="backdrop" @click=${this.close}></div>
|
||||
<div class="dialog" role="dialog" aria-modal="true">
|
||||
<h2>${s("history_edit_title",t)}</h2>
|
||||
<div class="entry-type">
|
||||
<ha-icon icon="mdi:tag-outline"></ha-icon>
|
||||
<span>${s(n.type,t)||n.type}</span>
|
||||
</div>
|
||||
<ms-date-field
|
||||
kind="datetime"
|
||||
required
|
||||
.hass=${this.hass}
|
||||
.lang=${t}
|
||||
.label=${s("history_edit_timestamp",t)}
|
||||
.value=${n.timestamp.slice(0,19)}
|
||||
@value-changed=${a=>{let o=a.detail.value;o&&this._set("timestamp",o)}}
|
||||
></ms-date-field>
|
||||
<label>
|
||||
<span>${s("notes_label",t)}</span>
|
||||
<textarea
|
||||
rows="3"
|
||||
@input=${a=>{let o=a.target.value;this._set("notes",o||null)}}
|
||||
.value=${n.notes??""}></textarea>
|
||||
</label>
|
||||
<div class="row">
|
||||
<label>
|
||||
<span>${s("cost",t)}</span>
|
||||
<input type="number" min="0" step="0.01"
|
||||
.value=${n.cost!=null?String(n.cost):""}
|
||||
@input=${a=>{let o=a.target.value;this._set("cost",o?Number(o):null)}} />
|
||||
</label>
|
||||
<label>
|
||||
<span>${s("duration",t)}</span>
|
||||
<input type="number" min="0"
|
||||
.value=${n.duration!=null?String(n.duration):""}
|
||||
@input=${a=>{let o=a.target.value;this._set("duration",o?Number(o):null)}} />
|
||||
</label>
|
||||
</div>
|
||||
${this._renderReadings(n,t)}
|
||||
${this._partOptions&&this._partOptions.length>0?l`
|
||||
<div class="parts-block">
|
||||
<span class="parts-title">${s("complete_parts_used",t)}</span>
|
||||
${this._partOptions.map(a=>{let o=`${a.entry_id}:${a.part_id}`,c=this._partQty[o]||0;return l`
|
||||
<label class="part-row-edit">
|
||||
<input type="checkbox" .checked=${c>0}
|
||||
@change=${u=>{let p=u.target.checked;this._partQty={...this._partQty,[o]:p?1:0}}} />
|
||||
<span class="part-label">${a.name}${a.foreign&&a.object_name?` (${a.object_name})`:""}</span>
|
||||
${c>0?l`
|
||||
<input class="part-qty" type="number" min="0.01" max="999" step="0.01"
|
||||
.value=${String(c)}
|
||||
@input=${u=>{let p=parseFloat(u.target.value);!isNaN(p)&&p>0&&(this._partQty={...this._partQty,[o]:p})}} />
|
||||
`:d}
|
||||
</label>
|
||||
`})}
|
||||
</div>
|
||||
`:d}
|
||||
<div class="photos-block">
|
||||
<span class="parts-title">${s("completion_photos",t)}</span>
|
||||
${this._photos.photos.length>0?l`
|
||||
<div class="photo-strip">
|
||||
${this._photos.photos.map(a=>l`
|
||||
<div class="photo-tile">
|
||||
<maintenance-history-photo .hass=${this.hass} .docId=${a.id}></maintenance-history-photo>
|
||||
<button type="button" class="photo-remove" title=${s("remove",t)}
|
||||
@click=${()=>this._photos.remove(a.id)}>✕</button>
|
||||
</div>`)}
|
||||
</div>`:d}
|
||||
${this._photos.full?l`<span class="photos-hint">${s("photos_limit",t).replace("{max}",String(this._photos.max))}</span>`:l`<ms-photo-picker .lang=${t} .busy=${this._photos.uploading} .remaining=${this._photos.remaining}
|
||||
@files-picked=${a=>this._photos.addFiles(a.detail.files)}
|
||||
></ms-photo-picker>`}
|
||||
<span class="photos-hint">${s("history_edit_photos_hint",t)}</span>
|
||||
</div>
|
||||
${r?l`<div class="error">${r}</div>`:d}
|
||||
<div class="actions">
|
||||
<button class="delete-entry" @click=${this._delete} ?disabled=${this._saving} title=${s("history_delete_entry",t)}>
|
||||
<ha-icon icon="mdi:delete-outline"></ha-icon> ${s("history_delete_entry",t)}
|
||||
</button>
|
||||
<button class="cancel" @click=${this.close} ?disabled=${this._saving}>
|
||||
${s("cancel",t)}
|
||||
</button>
|
||||
<button class="save" @click=${this._save} ?disabled=${this._saving}>
|
||||
${this._saving?s("saving",t):s("save",t)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`}_renderReadings(t,n){return this._readingRows.length>0?l`
|
||||
<div class="readings-block">
|
||||
<span class="parts-title">${s("readings_section",n)}</span>
|
||||
${this._readingRows.map(r=>l`
|
||||
<label class="reading-row-edit">
|
||||
<span class="reading-row-name">${r.name}${r.unit?` (${r.unit})`:""}</span>
|
||||
<input type="text" inputmode="decimal" class="reading-row-input"
|
||||
.value=${this._readingText[r.id]??""}
|
||||
@input=${a=>{this._readingText={...this._readingText,[r.id]:a.target.value}}} />
|
||||
</label>
|
||||
`)}
|
||||
</div>`:t.reading_value==null&&t.task_type!=="reading"?d:l`
|
||||
<label>
|
||||
<span>${s("reading_value_label",n)}${t.reading_unit?` (${t.reading_unit})`:""}</span>
|
||||
<input type="number" step="any"
|
||||
.value=${t.reading_value!=null?String(t.reading_value):""}
|
||||
@input=${r=>{let a=r.target.value,o=a===""?NaN:Number(a);this._set("reading_value",isNaN(o)?null:o)}} />
|
||||
</label>`}};v.styles=[xt,M`
|
||||
:host { display: contents; }
|
||||
.backdrop {
|
||||
position: fixed; inset: 0;
|
||||
background: rgba(0,0,0,0.5);
|
||||
z-index: 100;
|
||||
}
|
||||
.dialog {
|
||||
position: fixed; left: 50%; top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 95vw; max-width: 480px;
|
||||
background: var(--card-background-color, var(--ha-card-background, #1c1c1c));
|
||||
color: var(--primary-text-color);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.4);
|
||||
padding: 20px;
|
||||
display: flex; flex-direction: column; gap: 12px;
|
||||
z-index: 101;
|
||||
max-height: 90vh; overflow: auto;
|
||||
}
|
||||
h2 { margin: 0; font-size: 18px; }
|
||||
.entry-type {
|
||||
display: flex; align-items: center; gap: 6px;
|
||||
color: var(--secondary-text-color); font-size: 13px;
|
||||
}
|
||||
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
|
||||
label span { color: var(--secondary-text-color); }
|
||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
|
||||
input, textarea {
|
||||
padding: 8px; font-size: 14px;
|
||||
background: var(--secondary-background-color, #2c2c2c);
|
||||
color: var(--primary-text-color);
|
||||
border: 1px solid var(--divider-color, #444);
|
||||
border-radius: 6px;
|
||||
width: 100%; box-sizing: border-box;
|
||||
font-family: inherit;
|
||||
}
|
||||
.delete-entry { margin-right: auto; color: var(--error-color, #d32f2f); background: transparent; border: 1px solid var(--error-color, #d32f2f); border-radius: 6px; padding: 6px 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
|
||||
.delete-entry ha-icon { --mdc-icon-size: 18px; }
|
||||
.actions {
|
||||
display: flex; gap: 8px; justify-content: flex-end;
|
||||
margin-top: 8px;
|
||||
}
|
||||
button {
|
||||
padding: 8px 16px; font-size: 14px;
|
||||
border-radius: 6px; cursor: pointer;
|
||||
border: none; font-weight: 500;
|
||||
}
|
||||
button.cancel {
|
||||
background: transparent;
|
||||
color: var(--primary-text-color);
|
||||
border: 1px solid var(--divider-color);
|
||||
}
|
||||
button.save {
|
||||
background: var(--primary-color);
|
||||
color: var(--text-primary-color, white);
|
||||
}
|
||||
button[disabled] { opacity: 0.5; cursor: wait; }
|
||||
.error {
|
||||
color: var(--error-color, #d32f2f);
|
||||
font-size: 13px; padding: 8px;
|
||||
background: rgba(211,47,47,0.1);
|
||||
border-radius: 6px;
|
||||
}
|
||||
/* #130: parts on the entry */
|
||||
.parts-block {
|
||||
display: flex; flex-direction: column; gap: 6px;
|
||||
border: 1px solid var(--divider-color, #444);
|
||||
border-radius: 6px; padding: 8px;
|
||||
}
|
||||
.parts-title { color: var(--secondary-text-color); font-size: 13px; }
|
||||
.part-row-edit {
|
||||
display: flex; flex-direction: row; align-items: center; gap: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.part-row-edit input[type="checkbox"] { width: auto; }
|
||||
.part-label { flex: 1; color: var(--primary-text-color); }
|
||||
.part-qty { width: 76px; }
|
||||
/* #161 phase 2: readings on the entry */
|
||||
.readings-block {
|
||||
display: flex; flex-direction: column; gap: 6px;
|
||||
border: 1px solid var(--divider-color, #444);
|
||||
border-radius: 6px; padding: 8px;
|
||||
}
|
||||
.reading-row-edit {
|
||||
display: flex; flex-direction: row; align-items: center; gap: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.reading-row-name { flex: 1; color: var(--primary-text-color); min-width: 0; }
|
||||
.reading-row-input { width: 140px; font-variant-numeric: tabular-nums; }
|
||||
/* #161: photos on the entry */
|
||||
.photos-block {
|
||||
display: flex; flex-direction: column; gap: 6px;
|
||||
border: 1px solid var(--divider-color, #444);
|
||||
border-radius: 6px; padding: 8px;
|
||||
}
|
||||
.photo-strip { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
|
||||
.photo-tile { position: relative; width: fit-content; }
|
||||
.photo-remove {
|
||||
position: absolute; top: -4px; right: -8px;
|
||||
width: 22px; height: 22px; border-radius: 50%; border: none;
|
||||
background: var(--error-color, #db4437); color: #fff;
|
||||
cursor: pointer; font-size: 11px; line-height: 1; padding: 0;
|
||||
}
|
||||
/* the camera / gallery pickers come from photoPickerStyles (ms-photo-picker) */
|
||||
.photos-hint { font-size: 12px; color: var(--secondary-text-color); }
|
||||
`],h([L({attribute:!1})],v.prototype,"hass",2),h([_()],v.prototype,"_open",2),h([_()],v.prototype,"_saving",2),h([_()],v.prototype,"_error",2),h([_()],v.prototype,"_draft",2),h([_()],v.prototype,"_partOptions",2),h([_()],v.prototype,"_partQty",2),h([_()],v.prototype,"_readingRows",2),h([_()],v.prototype,"_readingText",2);customElements.get("maintenance-history-edit-dialog")||customElements.define("maintenance-history-edit-dialog",v);function Qt(e,i){if(i<=0)return 0;let t=typeof e=="number"&&Number.isFinite(e)?Math.trunc(e):0;return t<0?0:t%i}function Xt(e){return!!(e?.phases&&e.phase_sequence&&e.phase_sequence.length>0)}function tt(e){if(!e||!Xt(e))return null;let i=e.phase_sequence,t=Qt(e.phase_cursor,i.length),n=i[t],r=e.phases?.[n];return r?{id:n,name:r.name,index:t,count:i.length,notes:r.notes,checklist:r.checklist!==void 0?r.checklist:e.checklist??[],consumesParts:r.consumes_parts!==void 0?r.consumes_parts:e.consumes_parts??[],requiredFields:r.required_completion_fields!==void 0?r.required_completion_fields:e.required_completion_fields??[]}:null}function N(e){let i=tt(e);return i?`${i.index+1}/${i.count} \xB7 ${i.name}`:""}function At(e){let i=e.task??null,t=i?tt(i):null,n=t?t.consumesParts:i?.consumes_parts||[],r=!!i?.part_ref,a=e.objects.find(u=>u.entry_id===e.entryId)?.parts||[],o=r?a.find(u=>u.id===i.part_ref.part_id):void 0,c=e.checklistsEnabled??!0;return{entry_id:e.entryId,task_id:e.taskId,task_name:e.taskName,checklist:t?c?t.checklist:[]:e.checklist??[],adaptive_enabled:!!e.adaptiveEnabled,required_completion_fields:t?t.requiredFields:i?.required_completion_fields||[],task_type:i?.type||"",reading_unit:i?.reading_unit||"",readings:i?.readings||[],reading_history:vt(i?.history),parts:r?[]:yt({consumes_parts:n},e.entryId,e.objects,e.lang),consumes_parts:r?[]:n,phase_label:t?N(i):"",require_tag_scan:!!i?.require_tag_scan,restock_default:r?o?.restock_quantity??1:null,restock_unit_cost:r?o?.cost??null:null,currency_symbol:j({currency_symbol:e.currencySymbol}),consumes_info:n.map(u=>gt(u,e.entryId,e.objects,e.lang)),checklist_prefill:i?.checklist_progress||{},via_tag_scan:!!e.viaTagScan}}function Et(e,i,t){e.entryId=i.entry_id,e.taskId=i.task_id,e.taskName=i.task_name,e.lang=t,e.checklist=i.checklist??[],e.adaptiveEnabled=!!i.adaptive_enabled,e.requiredFields=i.required_completion_fields??[],e.taskType=i.task_type??"",e.readingUnit=i.reading_unit??"",e.readings=i.readings??[],e.readingHistory=i.reading_history??[],e.parts=i.parts??[],e.consumesParts=i.consumes_parts??[],e.phaseLabel=i.phase_label??"",e.requireTagScan=!!i.require_tag_scan,e.restockDefault=i.restock_default??null,e.restockUnitCost=i.restock_unit_cost??null,e.currencySymbol=j(i),e.consumesInfo=i.consumes_info??[],e.checklistPrefill=i.checklist_prefill??{},e.viaTagScan=!!i.via_tag_scan,e.open({viaTagScan:!!i.via_tag_scan})}function et(e,i,t,n){let r=t,a=u=>typeof u=="string"?u:null,o=u=>typeof u=="number"?u:null,c=a(r.timestamp)??"";return{entry_id:e,task_id:i,original_timestamp:c,type:a(r.type)||"completed",timestamp:c,notes:a(r.notes),cost:o(r.cost),duration:o(r.duration),completed_by:a(r.completed_by),used_parts:Array.isArray(r.used_parts)?r.used_parts:null,photo_doc_ids:Z(r),reading_value:o(r.reading_value),reading_values:G(r),readings:n?.readings??[],task_type:n?.type??null,reading_unit:n?.reading_unit??null}}async function Je(e,i,t,n){let a=(await e.connection.sendMessagePromise({type:"maintenance_supporter/object",entry_id:i})).tasks?.find(c=>c.id===t),o=a?.history?.find(c=>c.timestamp===n);return!a||!o?null:et(i,t,o,a)}var Lt=e=>typeof e=="number"&&Number.isInteger(e)&&e>0;function te(e){return e&&Lt(e.ref_no)?String(e.ref_no):null}function Tt(e,i){let t=te(e);return t&&i&&Lt(i.ref_no)?`${t}.${i.ref_no}`:null}function ti(e){let i=/^(\d+)(?:\.(\d+)(?:-(\d+))?)?$/.exec(e.trim());return i?{object:Number(i[1]),task:i[2]?Number(i[2]):null,entry:i[3]?Number(i[3]):null}:null}function Ht(e,i){return e?l`<span class="ref-chip" title=${i??""}>#${e}</span>`:d}var ee={\u00DF:"s","\u1E9E":"s",\u00E6:"a",\u0153:"o",\u00F8:"o",\u0111:"d",\u00F0:"d",\u00FE:"t",\u0142:"l",\u0131:"i"},Dt=10,ie=7,it=4,It=2,ne=5,Pt=3,re=/[a-z0-9]+/g;function K(e){let i="";for(let t of e.toLowerCase()){if(t.charCodeAt(0)<128&&t.length===1){i+=t;continue}let n=ee[t];if(n){i+=n;continue}let r=t.normalize("NFKD")[0]||t;i+=r.charCodeAt(0)<128?r:t}return i}function St(e){return K(e).match(re)||[]}function se(e){return K(e).replace(/[^a-z0-9]+/g,"")}function ae(e){return e.replace(/ue/g,"u").replace(/oe/g,"o").replace(/ae/g,"a").replace(/ss/g,"s")}function oe(e){let i=[];for(let t of St(e)){let n=[t],r=ae(t);r&&r!==t&&n.push(r),i.push(n)}return i}function Mt(e,i){if(e===i)return!0;let t=e.length,n=i.length;if(Math.abs(t-n)>1)return!1;if(t===n){let p=[];for(let f=0;f<t;f++)e[f]!==i[f]&&p.push(f);if(p.length===1)return!0;if(p.length===2&&p[1]===p[0]+1){let f=p[0];return e[f]===i[f+1]&&e[f+1]===i[f]}return!1}let[r,a]=t>n?[e,i]:[i,e],o=0,c=0,u=!1;for(;o<r.length&&c<a.lengtLine truncated
|
||||
<div class="history-filters-new">
|
||||
<div class="filter-chips">
|
||||
${ue.map(n=>{let r=e.history.filter(a=>a.type===n).length;return r===0?d:l`
|
||||
<span class="filter-chip ${i.filter===n?"active":""}"
|
||||
@click=${()=>i.setFilter(i.filter===n?null:n)}>
|
||||
${s(n,t)} (${r})
|
||||
</span>
|
||||
`})}
|
||||
${i.filter?l`<span class="filter-chip clear" @click=${()=>i.setFilter(null)}>${s("show_all",t)}</span>`:d}
|
||||
</div>
|
||||
<div class="filter-controls">
|
||||
<input type="text" class="search-input" placeholder="${s("search_notes",t)}..." .value=${i.search} @input=${n=>i.setSearch(n.target.value)} />
|
||||
</div>
|
||||
</div>
|
||||
`}function pi(e,i){let t=i.lang,n=i.filter?e.history.filter(r=>r.type===i.filter):e.history;if(i.search){let r=i.search.toLowerCase();n=n.filter(a=>Rt(a.notes,i.search)||(Ct(i,a)??"").toLowerCase().endsWith(r))}return n.length===0?l`<p class="empty">${s("no_history",t)}</p>`:l`
|
||||
<div class="history-timeline">
|
||||
${[...n].reverse().map(r=>nt(r,i))}
|
||||
</div>
|
||||
`}function Ct(e,i){return e.taskRef&&i.ref_no?`${e.taskRef}-${i.ref_no}`:null}function he(e,i){let t=Z(i);return t.length>0?l`<div class="history-photos">
|
||||
${t.map(n=>l`<maintenance-history-photo .hass=${e} .docId=${n}></maintenance-history-photo>`)}
|
||||
</div>`:d}function _e(e,i){let t=i.lang,n=o=>y(o,t,{maximumFractionDigits:3}),r=o=>o==null?"":` (${o>=0?"+":""}${n(o)})`,a=G(e);return a.length>0?l`<div class="history-readings">
|
||||
${a.map(o=>l`<span class="history-reading">
|
||||
<span class="history-reading-name">${o.name}</span>
|
||||
<span class="history-reading-value">${n(o.value)}${o.unit?` ${o.unit}`:""}${r(i.readingSlotDelta?.(e,o.id))}</span>
|
||||
</span>`)}
|
||||
</div>`:e.reading_value!=null?l`<div class="history-readings"><span class="history-reading">
|
||||
<span class="history-reading-name">${s("reading_label",t)}</span>
|
||||
<span class="history-reading-value">${n(e.reading_value)}${i.readingUnit?` ${i.readingUnit}`:""}${r(i.readingDelta?.(e))}</span>
|
||||
</span></div>`:d}function nt(e,i,t={}){let n=i.lang,{compact:r=!1,showRef:a=!0,showBadges:o=!0,showEdit:c=!0}=t,u=c&&pe.includes(e.type);return l`
|
||||
<div class="history-entry${r?" compact":""}">
|
||||
${r?d:l`<div class="history-icon ${e.type}">
|
||||
<ha-icon .icon=${st[e.type]||"mdi:circle"}></ha-icon>
|
||||
</div>`}
|
||||
<div class="history-content">
|
||||
<div class="history-row">
|
||||
<strong>${s(e.type,n)}</strong>
|
||||
${a?Ht(Ct(i,e),s("ref_number",n)):d}
|
||||
${o&&e.phase_id?l`<span class="history-phase-badge">${i.phaseNames?.[e.phase_id]||e.phase_id}</span>`:d}
|
||||
${o&&e.auto?l`<span class="history-auto-badge">${s("history_auto",n)}</span>`:d}
|
||||
${u?l`<button class="history-edit-btn"
|
||||
title=${s("history_edit_button",n)}
|
||||
@click=${()=>i.openEdit(e)}>
|
||||
<ha-icon icon="mdi:pencil"></ha-icon>
|
||||
</button>`:d}
|
||||
</div>
|
||||
<div class="history-date">${pt(e.timestamp,n)}</div>
|
||||
${e.notes?l`<div>${e.notes}</div>`:d}
|
||||
${he(i.hass,e)}
|
||||
${_e(e,i)}
|
||||
${e.cost!=null||e.duration!=null||e.trigger_value!=null?l`<div class="history-details">
|
||||
${e.cost!=null?l`<span>${s("cost",n)}: ${U(e.cost,i.currencySymbol,n)}</span>`:d}
|
||||
${e.duration!=null?l`<span>${s("duration",n)}: ${B(e.duration,n)}</span>`:d}
|
||||
${e.trigger_value!=null?l`<span>${s("trigger_val",n)}: ${e.trigger_value}</span>`:d}
|
||||
</div>`:d}
|
||||
</div>
|
||||
</div>
|
||||
`}function m(e){return e.toFixed(1)}function _i(e,i,t=4){if(!isFinite(e)||!isFinite(i))return{ticks:[],niceMin:0,niceMax:1};if(e===i){let p=Math.abs(e)*.1||1;e-=p,i+=p}let n=i-e,r=Math.pow(10,Math.floor(Math.log10(n/Math.max(1,t)))),a=r;for(let p of[1,2,5,10])if(a=r*p,n/a<=t+.5)break;let o=Math.floor(e/a)*a,c=Math.ceil(i/a)*a,u=[];for(let p=o;p<=c+a*1e-6;p+=a)u.push(Math.abs(p)<a*1e-9?0:p);return{ticks:u,niceMin:o,niceMax:c}}function mi(e,i){let t=Math.abs(e),n=r=>({maximumFractionDigits:r});return t>=1e6?y(e/1e6,i,n(t>=1e7?0:1))+"M":t>=1e4?y(e/1e3,i,n(0))+"k":t>=1e3?y(e/1e3,i,n(1))+"k":t>=100?y(e,i,n(0)):t>=1?y(e,i,n(1)):t===0?"0":y(e,i,n(2))}function fi(e,i,t){let n=y(e,t,{maximumFractionDigits:Math.abs(e)>=100?0:1});return i?`${n} ${i}`:n}function gi(e,i,t){return X(new Date(e),i,t)}function yi(e,i){let t=new Date(e);return`${X(t,i)}, ${ct(t,i)}`}function vi(e,i){return new Date(e).getFullYear()!==new Date(i).getFullYear()}function bi(e,i,t){if(t<2||i<=e)return[e,i];let n=[];for(let r=0;r<t;r++)n.push(e+(i-e)*r/(t-1));return n}function Ot(e,i){let t=e.interval_analysis,n=t?.weibull_beta,r=t?.weibull_eta;if(n==null||r==null||r<=0)return d;let a=e.interval_days??0,o=e.suggested_interval??a;return l`
|
||||
<div class="weibull-section">
|
||||
<div class="weibull-title">
|
||||
<ha-svg-icon aria-hidden="true" path="M3,14L3.5,14.07L8.07,9.5C7.89,8.85 8.06,8.11 8.59,7.59C9.37,6.8 10.63,6.8 11.41,7.59C11.94,8.11 12.11,8.85 11.93,9.5L14.5,12.07L15,12C15.18,12 15.35,12 15.5,12.07L19.07,8.5C19,8.35 19,8.18 19,8A2,2 0 0,1 21,6A2,2 0 0,1 23,8A2,2 0 0,1 21,10C20.82,10 20.65,10 20.5,9.93L16.93,13.5C17,13.65 17,13.82 17,14A2,2 0 0,1 15,16A2,2 0 0,1 13,14L13.07,13.5L10.5,10.93C10.18,11 9.82,11 9.5,10.93L4.93,15.5L5,16A2,2 0 0,1 3,18A2,2 0 0,1 1,16A2,2 0 0,1 3,14Z"></ha-svg-icon>
|
||||
${s("weibull_reliability_curve",i)}
|
||||
${me(n,i)}
|
||||
</div>
|
||||
${fe(n,r,a,o,i)}
|
||||
${ge(t,i)}
|
||||
${t?.confidence_interval_low!=null?ye(t,e,i):d}
|
||||
</div>
|
||||
`}function me(e,i){let t,n,r;return e<.8?(t="early_failures",n="M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z",r="beta_early_failures"):e<=1.2?(t="random_failures",n="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M13,17H11V15H13V17M13,13H11V7H13V13Z",r="beta_random_failures"):e<=3.5?(t="wear_out",n="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4M12,6A6,6 0 0,1 18,12H12V6Z",r="beta_wear_out"):(t="highly_predictable",n="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M11,16.5L18,9.5L16.59,8.09L11,13.67L7.91,10.59L6.5,12L11,16.5Z",r="beta_highly_predictable"),l`
|
||||
<span class="beta-badge ${t}">
|
||||
<ha-svg-icon path="${n}"></ha-svg-icon>
|
||||
${s(r,i)} (\u03B2=${y(e,i,2)})
|
||||
</span>
|
||||
`}function fe(e,i,t,n,r){let b=Math.max(t,n,i,1)*1.3,A=50,E=[];for(let x=0;x<=A;x++){let k=x/A*b,Yt=1-Math.exp(-Math.pow(k/i,e)),Kt=32+k/b*260,Jt=136-Yt*128;E.push([Kt,Jt])}let q=E.map(([x,k])=>`${m(x)},${m(k)}`).join(" "),Q="M32,136 "+E.map(([x,k])=>`L${m(x)},${m(k)}`).join(" ")+` L${m(E[A][0])},136 Z`,R=32+t/b*260,F=1-Math.exp(-Math.pow(t/i,e)),V=136-F*128,Gt=y((1-F)*100,r,0),rt=32+n/b*260,Zt=[0,.25,.5,.75,1];return l`
|
||||
<div class="weibull-chart">
|
||||
<svg viewBox="0 0 ${300} ${160}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="${s("chart_weibull",r)}">
|
||||
${Zt.map(x=>{let k=136-x*128;return C`
|
||||
<line x1="${32}" y1="${m(k)}" x2="${292}" y2="${m(k)}"
|
||||
stroke="var(--divider-color)" stroke-width="0.5" stroke-dasharray="${x===.5?"4,3":d}" />
|
||||
<text x="${28}" y="${m(k+3)}" fill="var(--secondary-text-color)"
|
||||
font-size="8" text-anchor="end">${y(x*100,r,0)}%</text>
|
||||
`})}
|
||||
|
||||
<text x="${32}" y="${156}" fill="var(--secondary-text-color)" font-size="8" text-anchor="middle">0</text>
|
||||
<text x="${324/2}" y="${156}" fill="var(--secondary-text-color)" font-size="8" text-anchor="middle">${Math.round(b/2)}</text>
|
||||
<text x="${292}" y="${156}" fill="var(--secondary-text-color)" font-size="8" text-anchor="middle">${Math.round(b)}</text>
|
||||
|
||||
<path d="${Q}" fill="var(--primary-color, #03a9f4)" opacity="0.08" />
|
||||
<polyline points="${q}" fill="none"
|
||||
stroke="var(--primary-color, #03a9f4)" stroke-width="2" />
|
||||
|
||||
${t>0?C`
|
||||
<line x1="${m(R)}" y1="${8}" x2="${m(R)}" y2="${m(136)}"
|
||||
stroke="var(--primary-color, #03a9f4)" stroke-width="1.5" stroke-dasharray="4,3" />
|
||||
<circle cx="${m(R)}" cy="${m(V)}" r="3"
|
||||
fill="var(--primary-color, #03a9f4)" />
|
||||
<text x="${m(R+4)}" y="${m(V-6)}" fill="var(--primary-color, #03a9f4)"
|
||||
font-size="9" font-weight="600">R=${Gt}%</text>
|
||||
`:d}
|
||||
|
||||
${n>0&&n!==t?C`
|
||||
<line x1="${m(rt)}" y1="${8}" x2="${m(rt)}" y2="${m(136)}"
|
||||
stroke="var(--success-color, #4caf50)" stroke-width="1.5" stroke-dasharray="4,3" />
|
||||
`:d}
|
||||
|
||||
<line x1="${32}" y1="${8}" x2="${32}" y2="${136}"
|
||||
stroke="var(--secondary-text-color)" stroke-width="1" />
|
||||
<line x1="${32}" y1="${136}" x2="${292}" y2="${136}"
|
||||
stroke="var(--secondary-text-color)" stroke-width="1" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="chart-legend">
|
||||
<span class="legend-item"><span class="legend-swatch" style="background:var(--primary-color, #03a9f4)"></span> ${s("weibull_failure_probability",r)}</span>
|
||||
${t>0?l`<span class="legend-item"><span class="legend-swatch" style="background:var(--primary-color, #03a9f4); opacity:0.5"></span> ${s("current_interval_marker",r)}</span>`:d}
|
||||
${n>0&&n!==t?l`<span class="legend-item"><span class="legend-swatch" style="background:var(--success-color, #4caf50)"></span> ${s("recommended_marker",r)}</span>`:d}
|
||||
</div>
|
||||
`}function ge(e,i){return l`
|
||||
<div class="weibull-info-row">
|
||||
<div class="weibull-info-item">
|
||||
<span>${s("characteristic_life",i)}</span>
|
||||
<span class="weibull-info-value">${Math.round(e.weibull_eta)} ${s("days",i)}</span>
|
||||
</div>
|
||||
${e.weibull_r_squared!=null?l`
|
||||
<div class="weibull-info-item">
|
||||
<span>${s("weibull_r_squared",i)}</span>
|
||||
<span class="weibull-info-value">${y(e.weibull_r_squared,i,3)}</span>
|
||||
</div>
|
||||
`:d}
|
||||
</div>
|
||||
`}function ye(e,i,t){let n=e.confidence_interval_low,r=e.confidence_interval_high,a=i.suggested_interval??i.interval_days??0,o=i.interval_days??0,c=Math.max(0,n-5),p=r+5-c,f=(n-c)/p*100,S=(r-n)/p*100,O=(a-c)/p*100,b=o>0?(o-c)/p*100:-1;return l`
|
||||
<div class="confidence-range">
|
||||
<div class="confidence-range-title">
|
||||
${s("confidence_interval",t)}: ${a} ${s("days",t)} (${n}\u2013${r})
|
||||
</div>
|
||||
<div class="confidence-bar">
|
||||
<div class="confidence-fill" style="left:${m(f)}%;width:${m(S)}%"></div>
|
||||
${b>=0?l`<div class="confidence-marker current" style="left:${m(b)}%"></div>`:d}
|
||||
<div class="confidence-marker recommended" style="left:${m(O)}%"></div>
|
||||
</div>
|
||||
<div class="confidence-labels">
|
||||
<span class="confidence-text low">${s("confidence_conservative",t)} (${n}${s("days",t).charAt(0)})</span>
|
||||
<span class="confidence-text high">${s("confidence_aggressive",t)} (${r}${s("days",t).charAt(0)})</span>
|
||||
</div>
|
||||
</div>
|
||||
`}function jt(e,i,t){let n=e.degradation_trend!=null&&e.degradation_trend!=="insufficient_data",r=e.days_until_threshold!=null,a=e.environmental_factor!=null&&e.environmental_factor!==1;if(!n&&!r&&!a)return d;let o=e.degradation_trend==="rising"?"M16,6L18.29,8.29L13.41,13.17L9.41,9.17L2,16.59L3.41,18L9.41,12L13.41,16L19.71,9.71L22,12V6H16Z":e.degradation_trend==="falling"?"M16,18L18.29,15.71L13.41,10.83L9.41,14.83L2,7.41L3.41,6L9.41,12L13.41,8L19.71,14.29L22,12V18H16Z":"M22,12L18,8V11H3V13H18V16L22,12Z";return l`
|
||||
<div class="prediction-section">
|
||||
${e.sensor_prediction_urgency?l`
|
||||
<div class="prediction-urgency-banner">
|
||||
<ha-svg-icon path="M1,21H23L12,2L1,21M12,18A1,1 0 0,1 11,17A1,1 0 0,1 12,16A1,1 0 0,1 13,17A1,1 0 0,1 12,18M13,15H11V10H13V15Z"></ha-svg-icon>
|
||||
${s("sensor_prediction_urgency",i).replace("{days}",String(Math.round(e.days_until_threshold||0)))}
|
||||
</div>
|
||||
`:d}
|
||||
<div class="prediction-title">
|
||||
<ha-svg-icon path="M2,2V4H7V2H2M22,2V4H13V2H22M7,7V9H2V7H7M22,7V9H13V7H22M7,12V14H2V12H7M22,12V14H13V12H22M7,17V19H2V17H7M22,17V19H13V17H22M9,2V19L12,22L15,19V2H9M11,4H13V17.17L12,18.17L11,17.17V4Z"></ha-svg-icon>
|
||||
${s("sensor_prediction",i)}
|
||||
</div>
|
||||
<div class="prediction-grid">
|
||||
${n?l`
|
||||
<div class="prediction-item">
|
||||
<ha-svg-icon path="${o}"></ha-svg-icon>
|
||||
<span class="prediction-label">${s("degradation_trend",i)}</span>
|
||||
<span class="prediction-value ${e.degradation_trend}">${s("trend_"+e.degradation_trend,i)}</span>
|
||||
${e.degradation_rate!=null?l`<span class="prediction-rate">${e.degradation_rate>0?"+":""}${y(e.degradation_rate,i,Math.abs(e.degradation_rate)>=10?0:1)} ${e.trigger_entity_info?.unit_of_measurement||""}/${s("day_short",i)}</span>`:d}
|
||||
</div>
|
||||
`:d}
|
||||
${r?l`
|
||||
<div class="prediction-item">
|
||||
<ha-svg-icon path="M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22A9,9 0 0,0 21,13A9,9 0 0,0 12,4M12.5,8H11V14L15.75,16.85L16.5,15.62L12.5,13.25V8M7.88,3.39L6.6,1.86L2,5.71L3.29,7.24L7.88,3.39M22,5.72L17.4,1.86L16.11,3.39L20.71,7.25L22,5.72Z"></ha-svg-icon>
|
||||
<span class="prediction-label">${s("days_until_threshold",i)}</span>
|
||||
<span class="prediction-value prediction-days${e.days_until_threshold===0?" exceeded":e.sensor_prediction_urgency?" urgent":""}">${e.days_until_threshold===0?s("threshold_exceeded",i):"~"+Math.round(e.days_until_threshold)+" "+s("days",i)}</span>
|
||||
${e.threshold_prediction_date?l`<span class="prediction-date">${z(e.threshold_prediction_date,i)}</span>`:d}
|
||||
${e.threshold_prediction_confidence?l`<span class="confidence-dot ${e.threshold_prediction_confidence}"></span>`:d}
|
||||
${(e.prediction_cycles??0)>0?l`<span class="prediction-cycles">${s("prediction_cycles",i)}: ${e.prediction_cycles}</span>`:d}
|
||||
</div>
|
||||
`:d}
|
||||
${a&&t.environmental?l`
|
||||
<div class="prediction-item">
|
||||
<ha-svg-icon path="M15,13V5A3,3 0 0,0 12,2A3,3 0 0,0 9,5V13A5,5 0 0,0 7,17A5,5 0 0,0 12,22A5,5 0 0,0 17,17A5,5 0 0,0 15,13M12,4A1,1 0 0,1 13,5V8H11V5A1,1 0 0,1 12,4Z"></ha-svg-icon>
|
||||
<span class="prediction-label">${s("environmental_adjustment",i)}</span>
|
||||
<span class="prediction-value">${y(e.environmental_factor,i,2)}x</span>
|
||||
${e.environmental_entity?l`<span class="prediction-entity entity-link" @click=${c=>_t(c,e.environmental_entity)}>${e.environmental_entity}</span>`:d}
|
||||
</div>
|
||||
`:d}
|
||||
</div>
|
||||
</div>
|
||||
`}function zt(e,i,t,n){let r=Math.max(e||1,i);return l`
|
||||
<div class="interval-comparison">
|
||||
<div class="interval-bar">
|
||||
<div class="interval-label">
|
||||
${s("current",n)}: ${e??"\u2014"} ${e!=null?s("days",n):""}
|
||||
</div>
|
||||
<div class="interval-visual current"
|
||||
style="width: ${e!=null?Math.min(e/r*100,100):0}%"></div>
|
||||
</div>
|
||||
<div class="interval-bar">
|
||||
<div class="interval-label">
|
||||
${s("recommended",n)}: ${i} ${s("days",n)}
|
||||
<span class="confidence-badge ${t}">${s(`confidence_${t}`,n)}</span>
|
||||
</div>
|
||||
<div class="interval-visual suggested"
|
||||
style="width: ${Math.min(i/r*100,100)}%"></div>
|
||||
</div>
|
||||
</div>
|
||||
`}var Nt=["month_jan","month_feb","month_mar","month_apr","month_may","month_jun","month_jul","month_aug","month_sep","month_oct","month_nov","month_dec"];function qt(e,i,t){if(!t.seasonal||!e.seasonal_factor||e.seasonal_factor===1)return d;let n=Nt.map(c=>s(c,i)),r=new Date().getMonth(),a=e.seasonal_factors||e.interval_analysis?.seasonal_factors||null,o=a&&a.length===12?a:n.map((c,u)=>{let p=e.seasonal_factor||1,f=Math.sin((u-6)*Math.PI/6)*.3;return Math.max(.7,Math.min(1.3,p+f))});return l`
|
||||
<div class="seasonal-card-compact">
|
||||
<h4>${s("seasonal_awareness",i)}</h4>
|
||||
<div class="seasonal-mini-chart">
|
||||
${o.map((c,u)=>{let p=c*40,f=c<.9?"low":c>1.1?"high":"normal";return l`
|
||||
<div class="seasonal-bar ${f} ${u===r?"current":""}"
|
||||
style="height: ${p}px"
|
||||
title="${n[u]}: ${y(c,i,2)}x">
|
||||
</div>
|
||||
`})}
|
||||
</div>
|
||||
<div class="seasonal-legend">
|
||||
<span class="legend-item"><span class="dot low"></span> ${s("shorter",i)}</span>
|
||||
<span class="legend-item"><span class="dot normal"></span> ${s("normal",i)}</span>
|
||||
<span class="legend-item"><span class="dot high"></span> ${s("longer",i)}</span>
|
||||
</div>
|
||||
</div>
|
||||
`}function Ft(e,i){return ve(e,i)}function ve(e,i){let t=e.seasonal_factors??e.interval_analysis?.seasonal_factors;if(!t||t.length!==12)return d;let n=e.interval_analysis?.seasonal_reason,r=new Date().getMonth(),a=300,o=100,c=8,p=o-c-4,f=Math.max(...t,1.5),S=a/12,O=S*.65,b=c+p-1/f*p;return l`
|
||||
<div class="seasonal-chart">
|
||||
<div class="seasonal-chart-title">
|
||||
<ha-svg-icon aria-hidden="true" path="M17.75 4.09L15.22 6.03L16.13 9.09L13.5 7.28L10.87 9.09L11.78 6.03L9.25 4.09L12.44 4L13.5 1L14.56 4L17.75 4.09M21.25 11L19.61 12.25L20.2 14.23L18.5 13.06L16.8 14.23L17.39 12.25L15.75 11L17.81 10.95L18.5 9L19.19 10.95L21.25 11M18.97 15.95C19.8 15.87 20.69 17.05 20.16 17.8C19.84 18.25 19.5 18.67 19.08 19.07C15.17 23 8.84 23 4.94 19.07C1.03 15.17 1.03 8.83 4.94 4.93C5.34 4.53 5.76 4.17 6.21 3.85C6.96 3.32 8.14 4.21 8.06 5.04C7.79 7.9 8.75 10.87 10.95 13.06C13.14 15.26 16.1 16.22 18.97 15.95Z"></ha-svg-icon>
|
||||
${s("seasonal_chart_title",i)}
|
||||
${n?l`<span class="source-tag">${n==="learned"?s("seasonal_learned",i):s("seasonal_manual",i)}</span>`:d}
|
||||
</div>
|
||||
<svg viewBox="0 0 ${a} ${o}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="${s("chart_seasonal",i)}">
|
||||
<line x1="0" y1="${m(b)}" x2="${a}" y2="${m(b)}"
|
||||
stroke="var(--divider-color)" stroke-width="1" stroke-dasharray="4,3" />
|
||||
${t.map((A,E)=>{let q=A/f*p,Q=E*S+(S-O)/2,R=c+p-q,F=E===r,V=A<1?"var(--success-color, #4caf50)":A>1?"var(--warning-color, #ff9800)":"var(--secondary-text-color)";return C`
|
||||
<rect x="${m(Q)}" y="${m(R)}"
|
||||
width="${m(O)}" height="${m(q)}"
|
||||
fill="${V}" opacity="${F?1:.5}" rx="2" />
|
||||
`})}
|
||||
</svg>
|
||||
<div class="seasonal-labels">
|
||||
${Nt.map((A,E)=>l`<span class="seasonal-label ${E===r?"active-month":""}">${s(A,i)}</span>`)}
|
||||
</div>
|
||||
</div>
|
||||
`}var g=class extends D{constructor(){super(...arguments);this._open=!1;this._entryId=null;this._taskId=null;this._task=null;this._objectName="";this._taskRef=null;this._busy=!1;this._error="";this._showSkip=!1;this._showReset=!1;this._showDetails=!1;this._showAdaptive=!1;this._skipReason="";this._resetDate="";this._features={adaptive:!1,predictions:!1,seasonal:!1,environmental:!1,budget:!1,groups:!1,checklists:!1,schedule_time:!1,completion_actions:!1};this._toast="";this._featuresLoaded=!1;this._currencySymbol=""}get _lang(){return T(this.hass)}async openFor(t,n){this._entryId=t,this._taskId=n,this._error="",this._showSkip=!1,this._showReset=!1,this._showAdaptive=!1,this._skipReason="",this._resetDate=$t(new Date),this._open=!0,await Promise.all([this._loadTask(),this._loadFeatures()])}async _loadFeatures(){if(!this._featuresLoaded)try{let t=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/settings"});t?.features&&(this._features={...this._features,...t.features}),this._currencySymbol=j(t?.budget),lt(t?.budget),this._featuresLoaded=!0}catch{}}close(){this._open=!1,this._task=null,this._error=""}async _loadTask(){if(!(!this._entryId||!this._taskId))try{let t=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object",entry_id:this._entryId});this._objectName=t.object?.name||"";let n=(t.tasks||[]).find(r=>r.id===this._taskId);this._task=n??null,this._taskRef=Tt(t.object,n)}catch(t){this._error=$(t,this._lang)}}async _runWs(t){this._busy=!0,this._error="";try{return await this.hass.connection.sendMessagePromise(t),this._busy=!1,!0}catch(n){return this._error=$(n,this._lang),this._busy=!1,!1}}_notifyChanged(t){this.dispatchEvent(new CustomEvent("task-action-fired",{detail:{entry_id:this._entryId,task_id:this._taskId,action:t},bubbles:!0,composed:!0}))}_onComplete(){!this._entryId||!this._taskId||!this._task||import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-UGGXUPH3.js").then(async({openCompleteDialog:t})=>{let n=this._task,r=[];try{r=(await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/objects",compact:!0})).objects||[]}catch{}t(At({entryId:this._entryId,taskId:this._taskId,taskName:n.name,task:n,objects:r,lang:this._lang,checklist:n.checklist||[],adaptiveEnabled:!!n.adaptive_config?.enabled,currencySymbol:this._currencySymbol}))&&(this._notifyChanged("complete"),this.close())})}async _onSkipConfirm(){if(!this._entryId||!this._taskId)return;await this._runWs({type:"maintenance_supporter/task/skip",entry_id:this._entryId,task_id:this._taskId,reason:this._skipReason.trim()||null})&&(this._notifyChanged("skip"),this.close())}async _onResetConfirm(){if(!this._entryId||!this._taskId)return;await this._runWs({type:"maintenance_supporter/task/reset",entry_id:this._entryId,task_id:this._taskId,date:this._resetDate||void 0})&&(this._notifyChanged("reset"),this.close())}_onEdit(){!this._entryId||!this._taskId||import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-UGGXUPH3.js").then(({openEditTaskDialog:t})=>{t(this._entryId,this._taskId),this.close()})}_onQr(){!this._entryId||!this._taskId||!this._task||import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-UGGXUPH3.js").then(({openQrDialog:t})=>{t({entry_id:this._entryId,task_id:this._taskId,task_name:this._task.name,object_name:this._objectName}),this.close()})}async _onDelete(){if(!this._entryId||!this._taskId)return;let t=s("delete_task_confirm",this._lang)||`Delete "${this._task?.name}"?`;if(!window.confirm(t))return;await this._runWs({type:"maintenance_supporter/task/delete",entry_id:this._entryId,task_id:this._taskId})&&(this._notifyChanged("delete"),this.close())}async _onArchive(){if(!this._entryId||!this._taskId)return;await this._runWs({type:"maintenance_supporter/task/archive",entry_id:this._entryId,task_id:this._taskId})&&(this._notifyChanged("archive"),this.close())}async _onUnarchive(){if(!this._entryId||!this._taskId)return;await this._runWs({type:"maintenance_supporter/task/unarchive",entry_id:this._entryId,task_id:this._taskId})&&(this._notifyChanged("unarchive"),this.close())}_onOpenInPanel(){if(!this._entryId||!this._taskId)return;let t=`/maintenance-supporter?entry_id=${encodeURIComponent(this._entryId)}&task_id=${encodeURIComponent(this._taskId)}`;history.pushState(null,"",t),window.dispatchEvent(new CustomEvent("location-changed")),this.close()}async _applySuggestion(){if(!this._entryId||!this._taskId||!this._task?.suggested_interval)return;await this._runWs({type:"maintenance_supporter/task/apply_suggestion",entry_id:this._entryId,task_id:this._taskId,interval:this._task.suggested_interval})&&(this._toast=s("suggestion_applied",this._lang),this._notifyChanged("apply_suggestion"),await this._loadTask(),setTimeout(()=>{this._toast=""},2500))}async _reanalyzeInterval(){if(!(!this._entryId||!this._taskId)){this._busy=!0,this._error="";try{let t=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/analyze
Line truncated
|
||||
<div class="recommendation-card">
|
||||
<h4>${s("suggested_interval",n)}</h4>
|
||||
${zt(t.interval_days,t.suggested_interval,t.interval_confidence||"medium",n)}
|
||||
<div class="recommendation-actions">
|
||||
<button class="btn primary"
|
||||
@click=${this._applySuggestion} ?disabled=${this._busy}>
|
||||
<ha-icon icon="mdi:check"></ha-icon>
|
||||
${s("apply_suggestion",n)}
|
||||
</button>
|
||||
<button class="btn"
|
||||
@click=${this._reanalyzeInterval} ?disabled=${this._busy}>
|
||||
<ha-icon icon="mdi:refresh"></ha-icon>
|
||||
${s("reanalyze",n)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`}_renderAdaptive(t){let n=this._lang,r=this._features.adaptive&&t.suggested_interval&&t.suggested_interval!==t.interval_days,a=t.degradation_trend!=null&&t.degradation_trend!=="insufficient_data"||t.days_until_threshold!=null||t.environmental_factor!=null&&t.environmental_factor!==1,o=this._features.adaptive&&t.interval_analysis?.weibull_beta!=null&&t.interval_analysis?.weibull_eta!=null,c=this._features.seasonal&&t.seasonal_factor&&t.seasonal_factor!==1;return!r&&!a&&!o&&!c?l`<div class="adaptive-empty">
|
||||
${s("adaptive_no_data",n)}
|
||||
</div>`:l`
|
||||
<div class="adaptive-stack">
|
||||
${this._toast?l`<div class="toast">${this._toast}</div>`:d}
|
||||
${r?this._renderRecommendation(t):d}
|
||||
${a?jt(t,n,this._features):d}
|
||||
${o?Ot(t,n):d}
|
||||
${c?l`
|
||||
${qt(t,n,this._features)}
|
||||
${t.seasonal_factors?.length===12||t.interval_analysis?.seasonal_factors?.length===12?Ft(t,n):d}
|
||||
`:d}
|
||||
</div>
|
||||
`}_renderDetails(t){let n=this._lang,r=t.history||[],a=r.filter(u=>u.type==="completed"),o=a.reduce((u,p)=>u+(typeof p.cost=="number"?p.cost:0),0),c=(()=>{let u=a.map(p=>typeof p.duration=="number"?p.duration:null).filter(p=>p!=null);return u.length?Math.round(u.reduce((p,f)=>p+f,0)/u.length):null})();return l`
|
||||
<div class="details">
|
||||
<div class="stats-grid">
|
||||
<div class="stat">
|
||||
<span class="stat-label">${s("times_performed",n)}</span>
|
||||
<span class="stat-value">${a.length}</span>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat-label">${s("total_cost",n)}</span>
|
||||
<span class="stat-value">${U(o,this._currencySymbol,n)}</span>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat-label">${s("avg_duration",n)}</span>
|
||||
<span class="stat-value">${B(c,n)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="history-header">
|
||||
<strong>${s("history",n)}</strong>
|
||||
<span class="history-count">${r.length}</span>
|
||||
</div>
|
||||
${r.length===0?l`<div class="history-empty">${s("history_empty",n)}</div>`:l`
|
||||
<div class="history-list">
|
||||
${[...r].reverse().slice(0,20).map(u=>nt(u,{lang:n,hass:this.hass,currencySymbol:this._currencySymbol,openEdit:p=>this._onEditHistoryEntry(p),readingUnit:t.reading_unit,readingSlotDelta:(p,f)=>bt(r,p,f),taskRef:this._taskRef},{compact:!0}))}
|
||||
${r.length>20?l`<div class="history-more">… +${r.length-20} ${s("older_entries",n)}</div>`:d}
|
||||
</div>
|
||||
`}
|
||||
</div>
|
||||
`}render(){if(!this._open)return d;let t=this._lang,n=this._task,r=this.hass?.user?.is_admin??!0;return l`
|
||||
<div class="backdrop" @click=${this.close}></div>
|
||||
<div class="dialog" role="dialog" aria-modal="true">
|
||||
${n?l`
|
||||
<div class="header">
|
||||
<div class="title">
|
||||
<span class="status-dot" style="background: ${W[n.status]||"#ccc"}"></span>
|
||||
<span class="task-name">${n.name}</span>
|
||||
</div>
|
||||
<div class="object">
|
||||
<button class="link-inline" @click=${()=>{this._entryId&&import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-UGGXUPH3.js").then(({openObjectQuickActions:a})=>{a(this._entryId),this.close()})}}>${this._objectName}</button>
|
||||
</div>
|
||||
<div class="quick-info">
|
||||
${n.next_due?l`<span><strong>${s("next_due",t)}:</strong> ${z(n.next_due,t)}</span>`:d}
|
||||
${n.last_performed?l`<span><strong>${s("last_performed",t)}:</strong> ${z(n.last_performed,t)}</span>`:d}
|
||||
${n.schedule?.kind&&!["manual","one_time"].includes(n.schedule.kind)||n.interval_days!=null?l`<span><strong>${s("interval",t)}:</strong> ${ht(n,t)}</span>`:d}
|
||||
${N(n)?l`<span><strong>${s("phase_current",t)}:</strong> ${N(n)}</span>`:d}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
${this._error?l`<div class="error">${this._error}</div>`:d}
|
||||
|
||||
${this._showSkip?l`
|
||||
<div class="inline-form">
|
||||
<label>${s("skip_reason",t)}</label>
|
||||
<input type="text" .value=${this._skipReason}
|
||||
@input=${a=>{this._skipReason=a.target.value}} />
|
||||
<div class="inline-actions">
|
||||
<button class="btn cancel" @click=${()=>{this._showSkip=!1}} ?disabled=${this._busy}>
|
||||
${s("cancel",t)}
|
||||
</button>
|
||||
<button class="btn primary" @click=${this._onSkipConfirm} ?disabled=${this._busy}>
|
||||
${s("skip",t)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`:this._showReset?l`
|
||||
<div class="inline-form">
|
||||
<label>${s("reset_to_date",t)}</label>
|
||||
<ms-date-field
|
||||
kind="date"
|
||||
.hass=${this.hass}
|
||||
.lang=${t}
|
||||
.value=${this._resetDate}
|
||||
@value-changed=${a=>{this._resetDate=a.detail.value}}
|
||||
></ms-date-field>
|
||||
<div class="inline-actions">
|
||||
<button class="btn cancel" @click=${()=>{this._showReset=!1}} ?disabled=${this._busy}>
|
||||
${s("cancel",t)}
|
||||
</button>
|
||||
<button class="btn primary" @click=${this._onResetConfirm} ?disabled=${this._busy}>
|
||||
${s("reset",t)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`:l`
|
||||
<div class="actions primary-row">
|
||||
<ha-button appearance="accent" variant="success" @click=${this._onComplete} .disabled=${this._busy}>
|
||||
<ha-icon slot="start" icon="mdi:check"></ha-icon>
|
||||
${s("complete",t)}
|
||||
</ha-button>
|
||||
${n.allow_skip!==!1?l`
|
||||
<ha-button appearance="outlined" variant="warning" @click=${()=>{this._showSkip=!0}} .disabled=${this._busy}>
|
||||
<ha-icon slot="start" icon="mdi:skip-next"></ha-icon>
|
||||
${s("skip",t)}
|
||||
</ha-button>
|
||||
`:d}
|
||||
<ha-button appearance="outlined" variant="neutral" @click=${()=>{this._showReset=!0}} .disabled=${this._busy}>
|
||||
<ha-icon slot="start" icon="mdi:restart"></ha-icon>
|
||||
${s("reset",t)}
|
||||
</ha-button>
|
||||
</div>
|
||||
${r?l`
|
||||
<div class="actions secondary-row">
|
||||
<ha-button size="small" appearance="outlined" variant="neutral" @click=${this._onEdit} .disabled=${this._busy}>
|
||||
<ha-icon slot="start" icon="mdi:pencil"></ha-icon>
|
||||
${s("edit",t)}
|
||||
</ha-button>
|
||||
<ha-button size="small" appearance="outlined" variant="neutral" @click=${this._onQr} .disabled=${this._busy}>
|
||||
<ha-icon slot="start" icon="mdi:qrcode"></ha-icon>
|
||||
${s("qr_code",t)}
|
||||
</ha-button>
|
||||
<ha-button size="small" appearance="outlined" variant="neutral"
|
||||
@click=${n.archived?this._onUnarchive:this._onArchive}
|
||||
.disabled=${this._busy}>
|
||||
<ha-icon slot="start" icon="${n.archived?"mdi:archive-arrow-up-outline":"mdi:archive-outline"}"></ha-icon>
|
||||
${n.archived?s("unarchive",t):s("archive",t)}
|
||||
</ha-button>
|
||||
<ha-button size="small" appearance="outlined" variant="danger" class="danger" @click=${this._onDelete} .disabled=${this._busy}>
|
||||
<ha-icon slot="start" icon="mdi:delete"></ha-icon>
|
||||
${s("delete",t)}
|
||||
</ha-button>
|
||||
</div>
|
||||
`:d}
|
||||
<div class="details-toggle">
|
||||
<button class="link" @click=${()=>{this._showDetails=!this._showDetails}}>
|
||||
<ha-icon icon="${this._showDetails?"mdi:chevron-up":"mdi:chevron-down"}"></ha-icon>
|
||||
${this._showDetails?s("hide_details",t):s("show_details",t)}
|
||||
</button>
|
||||
${this._features.adaptive||this._features.seasonal||this._features.environmental?l`<button class="link" @click=${()=>{this._showAdaptive=!this._showAdaptive}}>
|
||||
<ha-icon icon="${this._showAdaptive?"mdi:chart-line":"mdi:chart-line-variant"}"></ha-icon>
|
||||
${this._showAdaptive?s("hide_stats",t):s("show_stats",t)}
|
||||
</button>`:d}
|
||||
</div>
|
||||
${this._showDetails?this._renderDetails(n):d}
|
||||
${this._showAdaptive?this._renderAdaptive(n):d}
|
||||
<div class="footer">
|
||||
<button class="link" @click=${this._onOpenInPanel}>
|
||||
<ha-icon icon="mdi:open-in-new"></ha-icon>
|
||||
${s("open_in_panel",t)}
|
||||
</button>
|
||||
</div>
|
||||
`}
|
||||
`:l`<div class="loading">${s("loading",t)}</div>`}
|
||||
</div>
|
||||
`}};g.styles=[mt,M`
|
||||
:host { display: contents; }
|
||||
.backdrop {
|
||||
position: fixed; inset: 0; z-index: 100;
|
||||
background: rgba(0,0,0,0.5);
|
||||
}
|
||||
.dialog {
|
||||
position: fixed; left: 50%; top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 95vw; max-width: 460px;
|
||||
max-height: 92vh; overflow: auto;
|
||||
background: var(--card-background-color, var(--ha-card-background, #1c1c1c));
|
||||
color: var(--primary-text-color);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.4);
|
||||
padding: 20px;
|
||||
display: flex; flex-direction: column; gap: 14px;
|
||||
z-index: 101;
|
||||
}
|
||||
.header { display: flex; flex-direction: column; gap: 6px; }
|
||||
.title { display: flex; align-items: center; gap: 10px; }
|
||||
.status-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
|
||||
.task-name { font-size: 18px; font-weight: 600; }
|
||||
.object { font-size: 13px; color: var(--secondary-text-color); }
|
||||
.link-inline {
|
||||
background: transparent; border: none; padding: 0; cursor: pointer;
|
||||
color: var(--primary-color); font-size: inherit; font-family: inherit;
|
||||
}
|
||||
.link-inline:hover { text-decoration: underline; }
|
||||
.quick-info {
|
||||
display: flex; flex-wrap: wrap; gap: 12px;
|
||||
font-size: 12px; color: var(--secondary-text-color);
|
||||
padding-top: 4px; border-top: 1px solid var(--divider-color);
|
||||
}
|
||||
.quick-info strong { color: var(--primary-text-color); font-weight: 500; }
|
||||
.actions { display: flex; gap: 8px; }
|
||||
.actions.primary-row { gap: 6px; }
|
||||
.actions.primary-row .btn { flex: 1; }
|
||||
.actions.primary-row ha-button { flex: 1; }
|
||||
/* Edit + QR are admin-tools — left-align as a group; Delete is destructive
|
||||
so it gets pushed to the far right with margin-left:auto for visual
|
||||
separation. Earlier this row was flex-end which left a strange empty
|
||||
gap on the left (user feedback). */
|
||||
.actions.secondary-row {
|
||||
padding-top: 8px; border-top: 1px solid var(--divider-color);
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.actions.secondary-row .btn.danger,
|
||||
.actions.secondary-row ha-button.danger {
|
||||
margin-left: auto;
|
||||
}
|
||||
.actions.secondary-row ha-button { --ha-button-font-size: 13px; }
|
||||
.btn {
|
||||
padding: 8px 12px; font-size: 14px;
|
||||
border-radius: 6px; cursor: pointer;
|
||||
border: 1px solid var(--divider-color);
|
||||
background: var(--secondary-background-color, transparent);
|
||||
color: var(--primary-text-color);
|
||||
font-weight: 500;
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
transition: background 0.12s;
|
||||
}
|
||||
.btn:hover { background: var(--state-icon-color, rgba(255,255,255,0.06)); }
|
||||
.btn[disabled] { opacity: 0.5; cursor: wait; }
|
||||
.btn.primary {
|
||||
background: var(--primary-color);
|
||||
color: var(--text-primary-color, white);
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
.btn.cancel { background: transparent; }
|
||||
.btn.ghost { padding: 6px 10px; font-size: 13px; }
|
||||
.btn.danger { color: var(--error-color); }
|
||||
.btn ha-icon { --mdc-icon-size: 18px; }
|
||||
.inline-form { display: flex; flex-direction: column; gap: 8px; }
|
||||
.inline-form label { font-size: 13px; color: var(--secondary-text-color); }
|
||||
.inline-form input {
|
||||
padding: 8px; font-size: 14px;
|
||||
background: var(--secondary-background-color, #2c2c2c);
|
||||
color: var(--primary-text-color);
|
||||
border: 1px solid var(--divider-color, #444);
|
||||
border-radius: 6px;
|
||||
}
|
||||
.inline-actions { display: flex; gap: 8px; justify-content: flex-end; }
|
||||
.footer { display: flex; justify-content: center; padding-top: 4px; }
|
||||
.link {
|
||||
background: transparent; border: none; cursor: pointer;
|
||||
color: var(--primary-color); font-size: 13px;
|
||||
display: inline-flex; align-items: center; gap: 4px;
|
||||
}
|
||||
.link:hover { text-decoration: underline; }
|
||||
.link ha-icon { --mdc-icon-size: 14px; }
|
||||
.loading { padding: 24px; text-align: center; color: var(--secondary-text-color); }
|
||||
.error {
|
||||
padding: 8px; border-radius: 6px;
|
||||
background: rgba(211,47,47,0.1);
|
||||
color: var(--error-color, #d32f2f); font-size: 13px;
|
||||
}
|
||||
|
||||
/* Details (expandable Show details section) */
|
||||
.details-toggle { display: flex; justify-content: center; margin-top: 4px; }
|
||||
.details {
|
||||
display: flex; flex-direction: column; gap: 12px;
|
||||
border-top: 1px solid var(--divider-color);
|
||||
padding-top: 12px;
|
||||
}
|
||||
.stats-grid {
|
||||
display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
|
||||
}
|
||||
.stat {
|
||||
display: flex; flex-direction: column; gap: 2px;
|
||||
background: var(--secondary-background-color, rgba(255,255,255,0.04));
|
||||
padding: 8px; border-radius: 6px;
|
||||
align-items: center;
|
||||
}
|
||||
.stat-label { font-size: 11px; color: var(--secondary-text-color); text-transform: uppercase; letter-spacing: 0.5px; }
|
||||
.stat-value { font-size: 16px; font-weight: 600; }
|
||||
.history-header {
|
||||
display: flex; align-items: baseline; gap: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.history-count {
|
||||
font-size: 12px; color: var(--secondary-text-color);
|
||||
background: var(--secondary-background-color); padding: 2px 8px; border-radius: 999px;
|
||||
}
|
||||
.history-empty { color: var(--secondary-text-color); font-style: italic; font-size: 13px; }
|
||||
/* The rows themselves are the shared renderer's (.history-entry.compact
|
||||
+ the history-* classes from sharedStyles); only the list chrome is
|
||||
local. */
|
||||
.history-list { display: flex; flex-direction: column; max-height: 280px; overflow: auto; }
|
||||
.history-list .history-entry {
|
||||
padding: 6px 8px; border-radius: 6px; border-bottom: none; margin-bottom: 6px;
|
||||
background: var(--secondary-background-color, rgba(255,255,255,0.03));
|
||||
}
|
||||
.history-list .history-date { font-size: 11px; }
|
||||
.history-list .history-details { font-size: 11px; }
|
||||
.history-more { padding: 8px; text-align: center; font-size: 12px; color: var(--secondary-text-color); font-style: italic; }
|
||||
|
||||
/* Adaptive section — wraps the panel renderers (which assume sharedStyles
|
||||
are present) and adds dialog-specific layout. */
|
||||
.adaptive-stack {
|
||||
display: flex; flex-direction: column; gap: 12px;
|
||||
border-top: 1px solid var(--divider-color);
|
||||
padding-top: 12px;
|
||||
}
|
||||
.adaptive-empty {
|
||||
padding: 16px; text-align: center;
|
||||
color: var(--secondary-text-color);
|
||||
font-style: italic; font-size: 13px;
|
||||
border-top: 1px solid var(--divider-color);
|
||||
}
|
||||
.toast {
|
||||
padding: 8px 12px; border-radius: 6px;
|
||||
background: rgba(76, 175, 80, 0.15);
|
||||
color: #4caf50; font-size: 13px; font-weight: 500;
|
||||
}
|
||||
/* The panel's recommendation-card uses ha-button. We use plain <button>
|
||||
in this dialog's button styles. Re-style the action row to match. */
|
||||
.recommendation-actions {
|
||||
display: flex; gap: 8px; margin-top: 8px;
|
||||
}
|
||||
/* Constrain SVG charts so they fit the dialog width even on mobile. */
|
||||
.weibull-section, .seasonal-card-compact { max-width: 100%; }
|
||||
.weibull-chart svg { max-width: 100%; height: auto; }
|
||||
.details-toggle { gap: 12px; flex-wrap: wrap; }
|
||||
`],h([L({attribute:!1})],g.prototype,"hass",2),h([_()],g.prototype,"_open",2),h([_()],g.prototype,"_entryId",2),h([_()],g.prototype,"_taskId",2),h([_()],g.prototype,"_task",2),h([_()],g.prototype,"_objectName",2),h([_()],g.prototype,"_taskRef",2),h([_()],g.prototype,"_busy",2),h([_()],g.prototype,"_error",2),h([_()],g.prototype,"_showSkip",2),h([_()],g.prototype,"_showReset",2),h([_()],g.prototype,"_showDetails",2),h([_()],g.prototype,"_showAdaptive",2),h([_()],g.prototype,"_skipReason",2),h([_()],g.prototype,"_resetDate",2),h([_()],g.prototype,"_features",2),h([_()],g.prototype,"_toast",2);customElements.get("maintenance-task-quick-actions-dialog")||customElements.define("maintenance-task-quick-actions-dialog",g);function Vt(e){return!!e&&/^https?:\/\//i.test(e)}function Wt(e){return e?customElements.get("ha-markdown")?l`<ha-markdown class="notes-md" .content=${e} breaks></ha-markdown>`:l`${e}`:d}var w=class extends D{constructor(){super(...arguments);this._open=!1;this._entryId=null;this._data=null;this._busy=!1;this._error=""}get _lang(){return T(this.hass)}async openFor(t){this._entryId=t,this._error="",this._open=!0,await this._load()}close(){this._open=!1,this._data=null,this._error=""}async _load(){if(this._entryId)try{let t=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object",entry_id:this._entryId});this._data=t}catch(t){this._error=$(t,this._lang)}}_onEditObject(){!this._entryId||!this._data||import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-UGGXUPH3.js").then(({openEditObjectDialog:t})=>{t(this._entryId,this._data.object),this.close()})}_onAddTask(){this._entryId&&import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-UGGXUPH3.js").then(({openCreateTaskDialog:t})=>{t(this._entryId),this.close()})}async _onDelete(){if(!this._entryId||!this._data)return;let t=s("delete_object_confirm",this._lang)||`Delete "${this._data.object.name}" and all its tasks?`;if(window.confirm(t)){this._busy=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object/delete",entry_id:this._entryId}),this.dispatchEvent(new CustomEvent("object-deleted",{detail:{entry_id:this._entryId},bubbles:!0,composed:!0})),this.close()}catch(n){this._error=$(n,this._lang)}finally{this._busy=!1}}}async _onArchiveObject(){if(!this._entryId||!this._data)return;let t=!!this._data.object.archived;if(!t){let n=s("confirm_archive_object",this._lang);if(!window.confirm(n))return}this._busy=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:t?"maintenance_supporter/object/unarchive":"maintenance_supporter/object/archive",entry_id:this._entryId}),this.dispatchEvent(new CustomEvent("object-changed",{detail:{entry_id:this._entryId},bubbles:!0,composed:!0})),this.close()}catch(n){this._error=$(n,this._lang)}finally{this._busy=!1}}_onTaskClick(t){this._entryId&&import("/maintenance_supporter_panelfiles/panel-chunks/dialog-mount-UGGXUPH3.js").then(({openTaskQuickActions:n})=>{n(this._entryId,t)})}render(){if(!this._open)return d;let t=this._lang,n=this._data,r=n?.object,a=n?.tasks||[],o=this.hass?.user?.is_admin??!0;return l`
|
||||
<div class="backdrop" @click=${this.close}></div>
|
||||
<div class="dialog" role="dialog" aria-modal="true">
|
||||
${n&&r?l`
|
||||
<div class="header">
|
||||
<div class="title">${r.name}</div>
|
||||
${this._renderMetaRow(r)}
|
||||
</div>
|
||||
|
||||
${this._error?l`<div class="error">${this._error}</div>`:d}
|
||||
|
||||
<div class="tasks-section">
|
||||
<div class="section-header">
|
||||
<strong>${s("tasks",t)}</strong>
|
||||
<span class="count">${a.length}</span>
|
||||
</div>
|
||||
${a.length===0?l`<div class="empty">${s("no_tasks",t)}</div>`:l`
|
||||
<div class="task-list">
|
||||
${a.map(c=>l`
|
||||
<div class="task-row" @click=${()=>this._onTaskClick(c.id)}>
|
||||
<span class="status-dot" style="background: ${W[c.status]||"#ccc"}"></span>
|
||||
<span class="task-name">${c.name}</span>
|
||||
<span class="task-status">${s(c.status||"ok",t)}</span>
|
||||
</div>
|
||||
`)}
|
||||
</div>
|
||||
`}
|
||||
</div>
|
||||
|
||||
${r.notes?l`
|
||||
<div class="notes-section">
|
||||
<strong>${s("object_notes_label",t)}</strong>
|
||||
<div class="notes-body">${Wt(r.notes)}</div>
|
||||
</div>
|
||||
`:d}
|
||||
|
||||
${o?l`
|
||||
<div class="actions">
|
||||
<button class="btn primary" @click=${this._onAddTask} ?disabled=${this._busy}>
|
||||
<ha-icon icon="mdi:plus"></ha-icon>
|
||||
${s("add_task",t)}
|
||||
</button>
|
||||
<button class="btn" @click=${this._onEditObject} ?disabled=${this._busy}>
|
||||
<ha-icon icon="mdi:pencil"></ha-icon>
|
||||
${s("edit",t)}
|
||||
</button>
|
||||
<button class="btn" @click=${this._onArchiveObject} ?disabled=${this._busy}>
|
||||
<ha-icon icon="${r.archived?"mdi:archive-arrow-up-outline":"mdi:archive-outline"}"></ha-icon>
|
||||
${r.archived?s("unarchive_object",t):s("archive_object",t)}
|
||||
</button>
|
||||
<button class="btn danger" @click=${this._onDelete} ?disabled=${this._busy}>
|
||||
<ha-icon icon="mdi:delete"></ha-icon>
|
||||
${s("delete",t)}
|
||||
</button>
|
||||
</div>
|
||||
`:d}
|
||||
`:l`<div class="loading">${s("loading",t)}</div>`}
|
||||
</div>
|
||||
`}_renderMetaRow(t){let n=this._lang,r=[];return t.area_id&&r.push([s("area",n),t.area_id]),t.manufacturer&&r.push([s("manufacturer",n),t.manufacturer]),t.model&&r.push([s("model",n),t.model]),t.serial_number&&r.push([s("serial_number_label",n),t.serial_number]),t.installation_date&&r.push([s("installed",n),t.installation_date]),t.warranty_expiry&&r.push([s("warranty",n),t.warranty_expiry]),t.documentation_url&&r.push([s("documentation_url_label",n),t.documentation_url]),r.length===0?d:l`
|
||||
<div class="meta">
|
||||
${r.map(([a,o])=>l`
|
||||
<div class="meta-item">
|
||||
<span class="meta-label">${a}</span>
|
||||
<span class="meta-value">${Vt(o)?l`<a href="${o}" target="_blank" rel="noopener noreferrer">${o}</a>`:o}</span>
|
||||
</div>
|
||||
`)}
|
||||
</div>
|
||||
`}};w.styles=M`
|
||||
:host { display: contents; }
|
||||
.backdrop {
|
||||
position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.5);
|
||||
}
|
||||
.dialog {
|
||||
position: fixed; left: 50%; top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 95vw; max-width: 480px;
|
||||
max-height: 92vh; overflow: auto;
|
||||
background: var(--card-background-color, var(--ha-card-background, #1c1c1c));
|
||||
color: var(--primary-text-color);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.4);
|
||||
padding: 20px; z-index: 101;
|
||||
display: flex; flex-direction: column; gap: 14px;
|
||||
}
|
||||
.header { display: flex; flex-direction: column; gap: 6px; }
|
||||
.title { font-size: 20px; font-weight: 600; }
|
||||
.meta { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; border-top: 1px solid var(--divider-color); }
|
||||
.meta-item { display: flex; gap: 8px; font-size: 12px; }
|
||||
.meta-label { color: var(--secondary-text-color); min-width: 100px; }
|
||||
.meta-value { color: var(--primary-text-color); flex: 1; word-break: break-word; }
|
||||
.meta-value a { color: var(--primary-color); }
|
||||
.tasks-section, .notes-section { display: flex; flex-direction: column; gap: 6px; }
|
||||
.section-header { display: flex; align-items: baseline; gap: 8px; }
|
||||
.count {
|
||||
font-size: 11px; color: var(--secondary-text-color);
|
||||
background: var(--secondary-background-color); padding: 2px 8px; border-radius: 999px;
|
||||
}
|
||||
.empty { color: var(--secondary-text-color); font-style: italic; font-size: 13px; padding: 8px 0; }
|
||||
.task-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow: auto; }
|
||||
.task-row {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
padding: 8px; border-radius: 6px; cursor: pointer;
|
||||
background: var(--secondary-background-color, rgba(255,255,255,0.03));
|
||||
transition: background 0.12s;
|
||||
}
|
||||
.task-row:hover { background: var(--state-icon-color, rgba(255,255,255,0.06)); }
|
||||
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
|
||||
.task-name { flex: 1; font-size: 14px; }
|
||||
.task-status { font-size: 11px; color: var(--secondary-text-color); text-transform: uppercase; }
|
||||
.notes-body { white-space: pre-wrap; font-size: 13px; padding: 8px; background: var(--secondary-background-color); border-radius: 6px; }
|
||||
.notes-body ha-markdown { white-space: normal; }
|
||||
.actions { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--divider-color); }
|
||||
.actions .btn { flex: 1; }
|
||||
.btn {
|
||||
padding: 8px; font-size: 13px; border-radius: 6px; cursor: pointer;
|
||||
border: 1px solid var(--divider-color);
|
||||
background: var(--secondary-background-color, transparent);
|
||||
color: var(--primary-text-color); font-weight: 500;
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: 6px;
|
||||
}
|
||||
.btn:hover { background: var(--state-icon-color, rgba(255,255,255,0.06)); }
|
||||
.btn[disabled] { opacity: 0.5; cursor: wait; }
|
||||
.btn.primary { background: var(--primary-color); color: var(--text-primary-color, white); border-color: var(--primary-color); }
|
||||
.btn.danger { color: var(--error-color); }
|
||||
.btn ha-icon { --mdc-icon-size: 16px; }
|
||||
.loading { padding: 24px; text-align: center; color: var(--secondary-text-color); }
|
||||
.error { padding: 8px; border-radius: 6px; background: rgba(211,47,47,0.1); color: var(--error-color); font-size: 13px; }
|
||||
`,h([L({attribute:!1})],w.prototype,"hass",2),h([_()],w.prototype,"_open",2),h([_()],w.prototype,"_entryId",2),h([_()],w.prototype,"_data",2),h([_()],w.prototype,"_busy",2),h([_()],w.prototype,"_error",2);customElements.get("maintenance-object-quick-actions-dialog")||customElements.define("maintenance-object-quick-actions-dialog",w);var Ut="maintenance-object-dialog",Bt="maintenance-task-dialog",be="maintenance-history-edit-dialog",xe="maintenance-complete-dialog",$e="maintenance-qr-dialog",ke="maintenance-task-quick-actions-dialog",we="maintenance-object-quick-actions-dialog";function J(){return document.querySelector("home-assistant")?.hass}function Ae(){return document.querySelector("home-assistant")?.shadowRoot??document.body}function H(e){let i=Ae(),t=i.querySelector(e)??document.body.querySelector(e);return t?t.parentNode!==i&&i.appendChild(t):(t=document.createElement(e),i.appendChild(t)),t}function I(e){let i=J();if(!i)return!1;e.hass=i;let t=T(i);return at(t)||ot(t).then(()=>{e.requestUpdate?.()}),dt(i.locale,i.config?.country),!0}function $n(e){return Y(e).then(i=>i.rowActionStyle)}function kn(){wt()}function wn(){let e=H(Ut);return I(e)?(e.openCreate(),!0):!1}function An(e,i){let t=H(Ut);return I(t)?(t.openEdit(e,i),!0):!1}function En(e="",i){let t=H(Bt);if(!I(t))return!1;let n=J();return n?((async()=>{let r=await Y(n),a=t;a.checklistsEnabled=r.features.checklists,a.scheduleTimeEnabled=r.features.schedule_time,a.completionActionsEnabled=r.features.completion_actions,a.defaultWarningDays=r.defaultWarningDays,a.openCreate(e,i)})(),!0):!1}function Ln(e,i){let t=H(Bt);if(!I(t))return!1;let n=J();return n?((async()=>{try{let[r,a]=await Promise.all([n.connection.sendMessagePromise({type:"maintenance_supporter/object",entry_id:e}),Y(n)]),o=(r.tasks||[]).find(u=>u.id===i);if(!o){console.warn(`openEditTaskDialog: task ${i} not found in entry ${e}`);return}let c=t;c.checklistsEnabled=a.features.checklists,c.scheduleTimeEnabled=a.features.schedule_time,c.completionActionsEnabled=a.features.completion_actions,c.defaultWarningDays=a.defaultWarningDays,await c.openEdit(e,o)}catch(r){console.warn("openEditTaskDialog: failed to load task/features",r)}})(),!0):!1}function Tn(e){let i=H(be);return I(i)?(i.openEdit(e),!0):!1}function Hn(e){let i=H(xe);return I(i)?(Et(i,e,T(J())),!0):!1}function In(e){let i=H($e);return I(i)?(i.openForTask(e.entry_id,e.task_id,e.object_name,e.task_name),!0):!1}function Mn(e,i){let t=H(ke);return I(t)?(t.openFor(e,i),!0):!1}function Dn(e){let i=H(we);return I(i)?(i.openFor(e),!0):!1}export{Vt as a,oe as b,ce as c,te as d,Tt as e,ti as f,Ht as g,Wt as h,Qt as i,Xt as j,tt as k,At as l,Et as m,m as n,_i as o,mi as p,fi as q,gi as r,yi as s,vi as t,bi as u,et as v,Je as w,ci as x,pi as y,nt as z,Ot as A,jt as B,zt as C,qt as D,Ft as E,$n as F,kn as G,wn as H,An as I,En as J,Ln as K,Tn as L,Hn as M,In as N,Mn as O,Dn as P};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{i as a}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-PDDZINC4.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-5XRT3AM7.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-2PKU3QXM.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-WQXORDNI.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";export{a as MaintenanceCompleteDialog};
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{F as a,G as b,H as c,I as d,J as e,K as f,L as g,M as h,N as i,O as j,P as k}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-ZMV2VB57.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-C7OGYVZI.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-2IGVBRZV.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-ZJPHP3YU.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-QOKIQTSS.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-EH52ZZY4.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-PDDZINC4.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-5XRT3AM7.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-2PKU3QXM.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-FLCA3VKG.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-XB4BHMUS.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-73EHFI76.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-WQXORDNI.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";export{b as __resetSettingsCacheForTests,a as getRowActionStyle,h as openCompleteDialog,c as openCreateObjectDialog,e as openCreateTaskDialog,d as openEditObjectDialog,f as openEditTaskDialog,g as openHistoryEditDialog,k as openObjectQuickActions,i as openQrDialog,j as openTaskQuickActions};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{a}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-2IGVBRZV.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-EH52ZZY4.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-2PKU3QXM.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-WQXORDNI.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";export{a as MaintenanceObjectDialog};
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{a}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-FLCA3VKG.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-XB4BHMUS.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";export{a as MaintenanceQrDialog};
|
||||
+1371
File diff suppressed because it is too large.
Load diff
+146
@@ -0,0 +1,146 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{a as g}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-WQXORDNI.js";import{a as l,b as m,c as i,f as h,h as v,l as u,m as d,q as p,s as f,u as x}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";var a=class extends v{constructor(){super(...arguments);this._open=!1;this._loading=!1;this._adopting=!1;this._error="";this._setups=[];this._selected=new Set;this._baselines=new Map;this._targets=new Map;this._objects=[];this._localeReady=!1;this._toggle=t=>{let e=new Set(this._selected);e.has(t)?e.delete(t):e.add(t),this._selected=e};this._adopt=async()=>{if(!(this._selected.size===0||this._adopting)){this._adopting=!0,this._error="";try{let t=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/integration_setups/adopt",selections:[...this._selected].map(e=>{let r={device_id:e},c=this._targets.get(e);c&&(r.entry_id=c);let s=this._setups.find(n=>n.device_id===e);for(let n of s?.tasks??[]){let o=this._baselines.get(`${e} ${n.task_name}`),_=o?parseFloat(o):NaN;!isNaN(_)&&_>=0&&((r.baselines??={})[n.task_name]=_)}return r})});this.dispatchEvent(new CustomEvent("integration-setups-adopted",{bubbles:!0,composed:!0,detail:t})),this._open=!1}catch(t){this._error=g(t,this._lang)}finally{this._adopting=!1}}}}get _lang(){return f(this.hass)}updated(t){t.has("hass")&&this.hass&&!this._localeReady&&(this._localeReady=!0,x(this._lang).then(()=>this.requestUpdate()))}async open(){this._open=!0,this._loading=!0,this._error="",this._setups=[],this._selected=new Set;try{let t=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/integration_setups/discover"});this._setups=t.setups||[],this._selected=new Set(this._setups.map(e=>e.device_id)),this._baselines=new Map,this._targets=new Map;try{let e=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/objects"});this._objects=(e.objects||[]).map(r=>({entry_id:r.entry_id,name:r.object?.name||r.entry_id})).sort((r,c)=>r.name.localeCompare(c.name))}catch{this._objects=[]}}catch(t){this._error=g(t,this._lang)}finally{this._loading=!1}}_close(){this._open=!1}render(){if(!this._open)return i``;let t=this._lang;return i`
|
||||
<div class="overlay" @click=${this._close}>
|
||||
<div class="card" @click=${e=>e.stopPropagation()}>
|
||||
<div class="title">${p("setups_title",t)}</div>
|
||||
<div class="hint">${p("setups_hint",t)}</div>
|
||||
${this._error?i`<div class="error">${this._error}</div>`:h}
|
||||
|
||||
${this._loading?i`<div class="loading">…</div>`:this._setups.length===0?i`<div class="empty">${p("setups_none",t)}</div>`:i`
|
||||
<div class="list">
|
||||
${this._setups.map(e=>{let r=this._selected.has(e.device_id),c=[e.integration_name,e.area_name].filter(Boolean).join(" \xB7 ");return i`
|
||||
<label class="row">
|
||||
<input
|
||||
type="checkbox"
|
||||
.checked=${r}
|
||||
@change=${()=>this._toggle(e.device_id)}
|
||||
/>
|
||||
<div class="row-main">
|
||||
<div class="row-top">
|
||||
<span class="row-name">${e.device_name}</span>
|
||||
</div>
|
||||
<div class="row-sub">${c}</div>
|
||||
<div class="row-target" @click=${s=>s.preventDefault()}>
|
||||
→
|
||||
${r&&this._objects.length>0?i`
|
||||
<select
|
||||
class="target-select"
|
||||
@change=${s=>{let n=new Map(this._targets),o=s.target.value;o?n.set(e.device_id,o):n.delete(e.device_id),this._targets=n}}
|
||||
>
|
||||
<option value="" ?selected=${!this._targets.get(e.device_id)}>
|
||||
${e.suggested_entry_id?e.suggested_object_name:p("setups_target_new",t).replace("{name}",e.suggested_object_name)}
|
||||
</option>
|
||||
${this._objects.filter(s=>s.entry_id!==e.suggested_entry_id).map(s=>i`<option
|
||||
value=${s.entry_id}
|
||||
?selected=${this._targets.get(e.device_id)===s.entry_id}
|
||||
>
|
||||
${s.name}
|
||||
</option>`)}
|
||||
</select>
|
||||
`:i`${e.suggested_object_name}${e.suggested_entry_id?h:i` <span class="new-tag">${p("adopt_problem_new_object",t)}</span>`}`}
|
||||
</div>
|
||||
<div class="row-tasks">
|
||||
${e.tasks.map(s=>i`<span class="chip" title=${s.entity_ids.join(", ")}>
|
||||
<ha-icon icon="mdi:link-variant"></ha-icon>${s.task_name_localized||s.task_name}
|
||||
</span>`)}
|
||||
</div>
|
||||
${r?e.tasks.filter(s=>s.direction==="usage_delta").map(s=>{let n=`${e.device_id} ${s.task_name}`;return i`
|
||||
<div class="baseline-field" @click=${o=>o.preventDefault()}>
|
||||
<span class="baseline-label"
|
||||
>${s.task_name_localized||s.task_name} —
|
||||
${p("setups_baseline_hint",t)}</span
|
||||
>
|
||||
<input
|
||||
type="number"
|
||||
step="any"
|
||||
min="0"
|
||||
.value=${this._baselines.get(n)??""}
|
||||
@click=${o=>o.preventDefault()}
|
||||
@input=${o=>{let _=new Map(this._baselines);_.set(n,o.target.value),this._baselines=_}}
|
||||
/>
|
||||
</div>
|
||||
`}):h}
|
||||
</div>
|
||||
</label>
|
||||
`})}
|
||||
</div>
|
||||
`}
|
||||
|
||||
<div class="actions">
|
||||
<ha-button appearance="plain" @click=${this._close}>
|
||||
${p("cancel",t)}
|
||||
</ha-button>
|
||||
<ha-button
|
||||
@click=${this._adopt}
|
||||
.disabled=${this._selected.size===0||this._adopting}
|
||||
>
|
||||
${p("setups_adopt",t)}
|
||||
</ha-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`}};a.styles=m`
|
||||
.overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-background-color, #fff);
|
||||
color: var(--primary-text-color);
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-width: min(360px, calc(100vw - 24px));
|
||||
max-width: 560px;
|
||||
width: 90vw;
|
||||
max-height: 80vh;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.title { font-size: 18px; font-weight: 500; }
|
||||
.hint { color: var(--secondary-text-color); font-size: 13px; }
|
||||
.error { color: var(--error-color, #f44336); font-size: 13px; }
|
||||
.loading, .empty { color: var(--secondary-text-color); font-size: 14px; padding: 12px 0; }
|
||||
.list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 50vh; }
|
||||
.row {
|
||||
display: flex; align-items: flex-start; gap: 10px; padding: 8px;
|
||||
border: 1px solid var(--divider-color); border-radius: 6px; cursor: pointer;
|
||||
}
|
||||
.row input { margin-top: 2px; cursor: pointer; }
|
||||
.row-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
|
||||
.row-name { font-weight: 500; font-size: 13px; }
|
||||
.row-sub, .row-target { color: var(--secondary-text-color); font-size: 12px; }
|
||||
.new-tag { font-style: italic; }
|
||||
.row-tasks { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
|
||||
.chip {
|
||||
display: inline-flex; align-items: center; gap: 4px;
|
||||
font-size: 11px; padding: 2px 8px; border-radius: 10px;
|
||||
background: var(--secondary-background-color, rgba(0, 0, 0, 0.06));
|
||||
color: var(--primary-text-color); white-space: nowrap;
|
||||
}
|
||||
.chip ha-icon { --mdc-icon-size: 12px; color: var(--primary-color); }
|
||||
.target-select {
|
||||
font-size: 12px; padding: 2px 4px; max-width: 100%;
|
||||
border: 1px solid var(--divider-color); border-radius: 4px;
|
||||
background: var(--card-background-color, #fff);
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
.baseline-field {
|
||||
display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
|
||||
margin-top: 4px; font-size: 12px; color: var(--secondary-text-color);
|
||||
}
|
||||
.baseline-field input {
|
||||
width: 110px; padding: 3px 6px; font-size: 12px;
|
||||
border: 1px solid var(--divider-color); border-radius: 4px;
|
||||
background: var(--card-background-color, #fff);
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
.actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }
|
||||
`,l([u({attribute:!1})],a.prototype,"hass",2),l([d()],a.prototype,"_open",2),l([d()],a.prototype,"_loading",2),l([d()],a.prototype,"_adopting",2),l([d()],a.prototype,"_error",2),l([d()],a.prototype,"_setups",2),l([d()],a.prototype,"_selected",2),l([d()],a.prototype,"_baselines",2),l([d()],a.prototype,"_targets",2),l([d()],a.prototype,"_objects",2);customElements.get("maintenance-suggested-setups-dialog")||customElements.define("maintenance-suggested-setups-dialog",a);export{a as MaintenanceSuggestedSetupsDialog};
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! maintenance_supporter frontend 2.90.0 */
|
||||
import{a}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-ZJPHP3YU.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-QOKIQTSS.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-EH52ZZY4.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-5XRT3AM7.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-2PKU3QXM.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-73EHFI76.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-WQXORDNI.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-RAW6RFRE.js";export{a as MaintenanceTaskDialog};
|
||||
Reference in new issue
Block a user