File tree Expand file tree Collapse file tree 2 files changed +4
-50
lines changed
src/lib/devices/DeviceCard Expand file tree Collapse file tree 2 files changed +4
-50
lines changed Original file line number Diff line number Diff line change 11<script lang =" ts" >
2- import { deleteDeviceRoute , getDeviceRoutes , modifyDeviceRoutes } from ' ./DeviceRoutesAPI.svelte' ;
2+ import { getDeviceRoutes , modifyDeviceRoutes } from ' ./DeviceRoutesAPI.svelte' ;
33 import { Device , Route } from ' $lib/common/classes' ;
44 import { onMount } from ' svelte' ;
55 import { alertStore } from ' $lib/common/stores' ;
3131 $alertStore = error ;
3232 });
3333 }
34-
35- function deleteDeviceRouteAction() {
36- deleteDeviceRoute (routeID )
37- .then ((response ) => {
38- getDeviceRoutesAction ();
39- })
40- .catch ((error ) => {
41- $alertStore = error ;
42- });
43- }
4434 </script >
4535
4636<th >Device Routes</th >
4737<td
4838 ><ul class =" list-disc list-inside" >
4939 {#each routesList as route , index }
50- <div style =" margin-left: -12px;" >
51- <button
52- on:click |stopPropagation ={() => {
53- routeID = route .id ;
54- deleteDeviceRouteAction ();
55- }}
56- class =" ml-1"
57- ><svg xmlns =" http://www.w3.org/2000/svg" class =" h-5 w-5 inline flex-shrink-0" fill =" none" viewBox =" 0 0 24 24" stroke =" currentColor" stroke-width =" 2" >
58- <path stroke-linecap =" round" stroke-linejoin =" round" d =" M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
59- </svg >
60- </button >
40+ <li >
6141 {route .prefix }
6242 {#if route .enabled }
6343 <button
7454 <button
7555 on:click ={() => {
7656 routesList [index ].enabled = true ;
77- routeID = route .id ;
57+ routeID = route .id
7858 modifyDeviceRoutesAction ();
7959 }}
8060 type =" button"
8161 class =" btn btn-xs tooltip capitalize bg-secondary text-secondary-content mx-1"
8262 data-tip =" press to enable route" >pending</button
8363 >
8464 {/if }
85- </div >
65+ </li >
8666 {/each }
8767 </ul ></td
8868>
Original file line number Diff line number Diff line change 8080 throw error ;
8181 });
8282 }
83-
84- export async function deleteDeviceRoute(routeID : number ): Promise <any > {
85- // variables in local storage
86- let headscaleURL = localStorage .getItem (' headscaleURL' ) || ' ' ;
87- let headscaleAPIKey = localStorage .getItem (' headscaleAPIKey' ) || ' ' ;
88- let endpointURL = ` /api/v1/routes/${routeID } ` ;
89-
90- await fetch (headscaleURL + endpointURL , {
91- method: ' DELETE' ,
92- headers: {
93- Accept: ' application/json' ,
94- Authorization: ` Bearer ${headscaleAPIKey } `
95- }
96- })
97- .then ((response ) => {
98- if (response .ok ) {
99- } else {
100- return response .text ().then ((text ) => {
101- throw JSON .parse (text ).message ;
102- });
103- }
104- })
105- .catch ((error ) => {
106- throw error ;
107- });
108- }
10983 </script >
You can’t perform that action at this time.
0 commit comments