Add task capture, work reports, daily digests and private contacts
Build and publish container images / images (push) Successful in 16m37s
Build and publish container images / images (push) Successful in 16m37s
This commit is contained in:
1 parent
50b8b0323f
commit
b4792bb175
50 files changed
+2678
-17
No files matched your search
@@ -0,0 +1,6 @@
|
||||
(()=>{'use strict';const app=document.getElementById('tasks-app');if(!app)return;const ja=document.documentElement.lang.startsWith('ja'),t=(a,b)=>ja?b:a,api='/_/api/v1/extension/organizer.tasks/',bar=document.createElement('section'),label=document.createElement('a'),clock=document.createElement('span'),stop=document.createElement('button'),status=document.createElement('span');bar.className='task-work-bar';bar.hidden=true;bar.style.cssText='display:none;grid-column:1/-1;gap:.6rem;align-items:center;flex-wrap:wrap;padding:.5rem 0';stop.type='button';stop.textContent=t('■ Stop recording','■ 作業記録を終了');status.role='status';bar.append(label,clock,stop,status);app.prepend(bar);let current=null,busy=false;
|
||||
async function request(path,options={}){const r=await fetch(api+path,{credentials:'same-origin',signal:AbortSignal.timeout(15000),...options,headers:{'Content-Type':'application/json'}});const d=await r.json().catch(()=>({}));if(!r.ok||r.redirected)throw Error(t('Recording failed. Check the active timer and reload; no duplicate timer is started.','記録できません。実行中の記録と権限を確認し再読込してください。タイマーは重複開始しません。'));return d;}
|
||||
function tick(){clock.textContent=current?.uuid?Math.floor(Math.max(0,Date.now()-current.start_ms)/60000)+' min':'';}
|
||||
async function load(){if(busy||document.hidden)return;try{const d=await request('work');current=d.item;bar.hidden=!current?.uuid;bar.style.display=bar.hidden?'none':'flex';if(current?.uuid){label.href='/v/plan/task/'+current.task_uuid;const task=await request('items/'+current.task_uuid);label.textContent=t('Recording: ','作業記録:')+task.item.title;}tick();}catch(e){status.textContent=e.message;}}
|
||||
app.addEventListener('task-work',async e=>{if(busy)return;busy=true;try{await request('work',{method:'POST',body:JSON.stringify({action:'start',uuid:crypto.randomUUID(),task_uuid:e.detail.uuid})});status.textContent='';}catch(err){bar.hidden=false;bar.style.display='flex';status.textContent=err.message;const feedback=document.getElementById('tasks-status');if(feedback)feedback.textContent=err.message;}finally{busy=false;await load();}});
|
||||
stop.onclick=async()=>{if(busy||!current?.uuid)return;busy=true;stop.disabled=true;try{await request('work',{method:'POST',body:JSON.stringify({...current,action:'stop'})});status.textContent='';}catch(e){status.textContent=e.message;}finally{busy=false;stop.disabled=false;await load();}};setInterval(()=>{if(!document.hidden)tick();},10000);setInterval(load,60000);document.addEventListener('visibilitychange',load);load();})();
|
||||
Reference in new issue
Block a user