Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Dec 7, 2023
1 parent 2c413ed commit d105bf5
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 57 deletions.
58 changes: 30 additions & 28 deletions web/sub-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,38 @@
</button>
<span class="ml-2">Subscription Details</span>
</div>
<form class="space-y-2 max-w-[1024px]">
<div class="flex">
<label for="id">Id</label>
<input type="text" readonly="readonly" id="id" class="ml-2">
</div>
<div class="flex">
<label for="description" style="padding-top: 0.125rem">Description</label>
<input type="text" id="description" class="ml-2">
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<div id="sub_cond_editor"></div>
<div class="flex justify-center">
<form class="space-y-2 max-w-[800px] grow">
<div class="flex">
<label for="id">Id</label>
<input type="text" readonly="readonly" id="id" class="ml-2">
</div>
<div class="flex">
<label for="description" style="padding-top: 0.125rem">Description</label>
<input type="text" id="description" class="ml-2">
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<div id="sub_cond_editor"></div>
</div>
</div>
</div>
</div>
<script src="sub-details.js"></script>
<div class="flex items-center justify-center space-x-2">
<button type="button" class="flex delete justify-center text-center" onclick="deleteSubscription()">
<svg fill="currentColor" width="21px" height="21px" viewBox="-3.5 0 19 19" xmlns="http://www.w3.org/2000/svg" class="cf-icon-svg"><path d="M11.383 13.644A1.03 1.03 0 0 1 9.928 15.1L6 11.172 2.072 15.1a1.03 1.03 0 1 1-1.455-1.456l3.928-3.928L.617 5.79a1.03 1.03 0 1 1 1.455-1.456L6 8.261l3.928-3.928a1.03 1.03 0 0 1 1.455 1.456L7.455 9.716z"/></svg>
<span class="mt-1">Unsubscribe</span>
</button>
<button id="button-submit" type="button" class="flex submit justify-center text-center" onclick="updateSubscription()">
<svg width="21px" height="21px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.6097 5.20743C21.0475 5.54416 21.1294 6.17201 20.7926 6.60976L10.7926 19.6098C10.6172 19.8378 10.352 19.9793 10.0648 19.9979C9.77765 20.0166 9.49637 19.9106 9.29289 19.7072L4.29289 14.7072C3.90237 14.3166 3.90237 13.6835 4.29289 13.2929C4.68342 12.9024 5.31658 12.9024 5.70711 13.2929L9.90178 17.4876L19.2074 5.39034C19.5441 4.95258 20.172 4.87069 20.6097 5.20743Z" fill="currentColor"/>
</svg>
<span class="mt-1">Save Changes</span>
</button>
</div>
</form>
<script src="sub-details.js"></script>
<div class="flex items-center justify-center space-x-2">
<button type="button" class="flex delete justify-center text-center" onclick="deleteSubscription()">
<svg fill="currentColor" width="21px" height="21px" viewBox="-3.5 0 19 19" xmlns="http://www.w3.org/2000/svg" class="cf-icon-svg"><path d="M11.383 13.644A1.03 1.03 0 0 1 9.928 15.1L6 11.172 2.072 15.1a1.03 1.03 0 1 1-1.455-1.456l3.928-3.928L.617 5.79a1.03 1.03 0 1 1 1.455-1.456L6 8.261l3.928-3.928a1.03 1.03 0 0 1 1.455 1.456L7.455 9.716z"/></svg>
<span class="mt-1">Unsubscribe</span>
</button>
<button id="button-submit" type="button" class="flex submit justify-center text-center" onclick="updateSubscription()">
<svg width="21px" height="21px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.6097 5.20743C21.0475 5.54416 21.1294 6.17201 20.7926 6.60976L10.7926 19.6098C10.6172 19.8378 10.352 19.9793 10.0648 19.9979C9.77765 20.0166 9.49637 19.9106 9.29289 19.7072L4.29289 14.7072C3.90237 14.3166 3.90237 13.6835 4.29289 13.2929C4.68342 12.9024 5.31658 12.9024 5.70711 13.2929L9.90178 17.4876L19.2074 5.39034C19.5441 4.95258 20.172 4.87069 20.6097 5.20743Z" fill="currentColor"/>
</svg>
<span class="mt-1">Save Changes</span>
</button>
</div>
</form>
</div>
</div>

</body>
Expand Down
58 changes: 29 additions & 29 deletions web/sub-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,36 @@ function loadSubscription() {
const id = urlParams.get("id");
document.getElementById("id").value = id;
//
// const data = {"description":"Exoplanets","enabled":true,"cond":{"gc":{"logic":"Or","group":[{"tc":{"id":"txt_651f009c25fef58d2c176c06","term":"exoplanet экзопланета экзопланет экзопланеты экзопланету"}},{"gc":{"group":[{"tc":{"id":"txt_651f009c25fef58d2c176c13","term":"planet"}},{"tc":{"id":"txt_651f009c25fef58d2c176c27","term":"extrasolar"}}]}}]}},"expires":"0001-01-01T00:00:00Z"};
// editor.setValue(data.cond);
const data = {"description":"Exoplanets","enabled":true,"cond":{"gc":{"logic":"Or","group":[{"tc":{"id":"txt_651f009c25fef58d2c176c06","term":"exoplanet экзопланета экзопланет экзопланеты экзопланету"}},{"gc":{"group":[{"tc":{"id":"txt_651f009c25fef58d2c176c13","term":"planet"}},{"tc":{"id":"txt_651f009c25fef58d2c176c27","term":"extrasolar"}}]}}]}},"expires":"0001-01-01T00:00:00Z"};
editor.setValue(data.cond);
//
let authToken = sessionStorage.getItem("authToken");
let userId = sessionStorage.getItem("userId");
let optsReq = {
method: "GET",
headers: {
"Authorization": `Bearer ${authToken}`,
"X-Awakari-Group-Id": defaultGroupId,
"X-Awakari-User-Id": userId,
},
cache: "default",
}
fetch(`/v1/sub/${id}`, optsReq)
.then(resp => {
if (!resp.ok) {
throw new Error(`Request failed with status: ${resp.status}`);
}
return resp.json();
})
.then(data => {
if (data != null) {
document.getElementById("description").value = data.description;
editor.setValue(data.cond);
}
})
.catch(err => {
alert(err);
});
// let authToken = sessionStorage.getItem("authToken");
// let userId = sessionStorage.getItem("userId");
// let optsReq = {
// method: "GET",
// headers: {
// "Authorization": `Bearer ${authToken}`,
// "X-Awakari-Group-Id": defaultGroupId,
// "X-Awakari-User-Id": userId,
// },
// cache: "default",
// }
// fetch(`/v1/sub/${id}`, optsReq)
// .then(resp => {
// if (!resp.ok) {
// throw new Error(`Request failed with status: ${resp.status}`);
// }
// return resp.json();
// })
// .then(data => {
// if (data != null) {
// document.getElementById("description").value = data.description;
// editor.setValue(data.cond);
// }
// })
// .catch(err => {
// alert(err);
// });
}

function updateSubscription() {
Expand Down

0 comments on commit d105bf5

Please sign in to comment.