1
0
Fork 0

Ask for confirmation before removing something

This commit is contained in:
Frédéric Guillot 2017-11-21 14:44:47 -08:00
parent 25a5250eb9
commit 5983db1a77
15 changed files with 165 additions and 40 deletions

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2017-11-20 18:31:16.993089344 -0800 PST m=+0.032236726
// 2017-11-21 14:38:46.654499991 -0800 PST m=+0.006321563
package locale
@ -131,12 +131,18 @@ var Translations = map[string]string{
"Unable to parse Atom feed: %v.": "Impossible de lire ce flux Atom: %v.",
"Unable to parse JSON feed: %v.": "Impossible de lire ce flux JSON: %v.",
"Unable to parse RDF feed: %v.": "Impossible de lire ce flux RDF: %v.",
"Unable to normalize encoding: %v.": "Impossible de normaliser l'encodage : %v."
"Unable to normalize encoding: %v.": "Impossible de normaliser l'encodage : %v.",
"Unable to create this category.": "Impossible de créer cette catégorie.",
"yes": "oui",
"no": "non",
"Are you sure?": "Êtes-vous sûr ?",
"Work in progress...": "Travail en cours...",
"This user already exists.": "Cet utilisateur existe déjà."
}
`,
}
var TranslationsChecksums = map[string]string{
"en_US": "6fe95384260941e8a5a3c695a655a932e0a8a6a572c1e45cb2b1ae8baa01b897",
"fr_FR": "946d1c30bcb862ef35741786cdb5768900ad0d704e802472e481540f9b6542e5",
"fr_FR": "bfa4a8bb15bd6016da8b9b5f851121a4ae278e2a195cd2edc4737ff075d28f02",
}

View file

@ -115,5 +115,11 @@
"Unable to parse Atom feed: %v.": "Impossible de lire ce flux Atom: %v.",
"Unable to parse JSON feed: %v.": "Impossible de lire ce flux JSON: %v.",
"Unable to parse RDF feed: %v.": "Impossible de lire ce flux RDF: %v.",
"Unable to normalize encoding: %v.": "Impossible de normaliser l'encodage : %v."
"Unable to normalize encoding: %v.": "Impossible de normaliser l'encodage : %v.",
"Unable to create this category.": "Impossible de créer cette catégorie.",
"yes": "oui",
"no": "non",
"Are you sure?": "Êtes-vous sûr ?",
"Work in progress...": "Travail en cours...",
"This user already exists.": "Cet utilisateur existe déjà."
}

View file

@ -74,7 +74,7 @@ func getRoutes(store *storage.Storage, feedHandler *feed.Handler) *mux.Router {
router.Handle("/feed/{feedID}/refresh", uiHandler.Use(uiController.RefreshFeed)).Name("refreshFeed").Methods("GET")
router.Handle("/feed/{feedID}/edit", uiHandler.Use(uiController.EditFeed)).Name("editFeed").Methods("GET")
router.Handle("/feed/{feedID}/remove", uiHandler.Use(uiController.RemoveFeed)).Name("removeFeed").Methods("GET")
router.Handle("/feed/{feedID}/remove", uiHandler.Use(uiController.RemoveFeed)).Name("removeFeed").Methods("POST")
router.Handle("/feed/{feedID}/update", uiHandler.Use(uiController.UpdateFeed)).Name("updateFeed").Methods("POST")
router.Handle("/feed/{feedID}/entries", uiHandler.Use(uiController.ShowFeedEntries)).Name("feedEntries").Methods("GET")
router.Handle("/feeds", uiHandler.Use(uiController.ShowFeedsPage)).Name("feeds").Methods("GET")
@ -92,7 +92,7 @@ func getRoutes(store *storage.Storage, feedHandler *feed.Handler) *mux.Router {
router.Handle("/category/{categoryID}/entries", uiHandler.Use(uiController.ShowCategoryEntries)).Name("categoryEntries").Methods("GET")
router.Handle("/category/{categoryID}/edit", uiHandler.Use(uiController.EditCategory)).Name("editCategory").Methods("GET")
router.Handle("/category/{categoryID}/update", uiHandler.Use(uiController.UpdateCategory)).Name("updateCategory").Methods("POST")
router.Handle("/category/{categoryID}/remove", uiHandler.Use(uiController.RemoveCategory)).Name("removeCategory").Methods("GET")
router.Handle("/category/{categoryID}/remove", uiHandler.Use(uiController.RemoveCategory)).Name("removeCategory").Methods("POST")
router.Handle("/icon/{iconID}", uiHandler.Use(uiController.ShowIcon)).Name("icon").Methods("GET")
router.Handle("/proxy/{encodedURL}", uiHandler.Use(uiController.ImageProxy)).Name("proxy").Methods("GET")
@ -102,7 +102,7 @@ func getRoutes(store *storage.Storage, feedHandler *feed.Handler) *mux.Router {
router.Handle("/user/save", uiHandler.Use(uiController.SaveUser)).Name("saveUser").Methods("POST")
router.Handle("/users/{userID}/edit", uiHandler.Use(uiController.EditUser)).Name("editUser").Methods("GET")
router.Handle("/users/{userID}/update", uiHandler.Use(uiController.UpdateUser)).Name("updateUser").Methods("POST")
router.Handle("/users/{userID}/remove", uiHandler.Use(uiController.RemoveUser)).Name("removeUser").Methods("GET")
router.Handle("/users/{userID}/remove", uiHandler.Use(uiController.RemoveUser)).Name("removeUser").Methods("POST")
router.Handle("/about", uiHandler.Use(uiController.AboutPage)).Name("about").Methods("GET")
@ -110,7 +110,7 @@ func getRoutes(store *storage.Storage, feedHandler *feed.Handler) *mux.Router {
router.Handle("/settings", uiHandler.Use(uiController.UpdateSettings)).Name("updateSettings").Methods("POST")
router.Handle("/sessions", uiHandler.Use(uiController.ShowSessions)).Name("sessions").Methods("GET")
router.Handle("/sessions/{sessionID}/remove", uiHandler.Use(uiController.RemoveSession)).Name("removeSession").Methods("GET")
router.Handle("/sessions/{sessionID}/remove", uiHandler.Use(uiController.RemoveSession)).Name("removeSession").Methods("POST")
router.Handle("/export", uiHandler.Use(uiController.Export)).Name("export").Methods("GET")
router.Handle("/import", uiHandler.Use(uiController.Import)).Name("import").Methods("GET")

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2017-11-20 18:31:16.964945842 -0800 PST m=+0.004093224
// 2017-11-21 14:38:46.651098874 -0800 PST m=+0.002920446
package static

File diff suppressed because one or more lines are too long

View file

@ -167,13 +167,6 @@ th {
background: #fcfcfc;
}
.table-overflow td {
max-width: 0;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
tr:hover {
background-color: #f9f9f9;
}
@ -213,7 +206,7 @@ input[type="password"],
input[type="text"] {
border: 1px solid #ccc;
padding: 3px;
line-height: 15px;
line-height: 20px;
width: 250px;
font-size: 99%;
margin-bottom: 10px;
@ -652,3 +645,17 @@ a.button {
.enclosure-image img {
max-width: 100%;
}
/* Confirmation */
.confirm {
font-weight: 500;
color: #ed2d04;
}
.confirm a {
color: #ed2d04;
}
.loading {
font-style: italic;
}

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2017-11-20 18:31:16.972315949 -0800 PST m=+0.011463331
// 2017-11-21 14:38:46.652422004 -0800 PST m=+0.004243576
package static
@ -15,7 +15,9 @@ getKey(event){const mapping={'Esc':'Escape','Up':'ArrowUp','Down':'ArrowDown','L
return event.key;}}
class FormHandler{static handleSubmitButtons(){let elements=document.querySelectorAll("form");elements.forEach(function(element){element.onsubmit=function(){let button=document.querySelector("button");if(button){button.innerHTML=button.dataset.labelLoading;button.disabled=true;}};});}}
class MouseHandler{onClick(selector,callback){let elements=document.querySelectorAll(selector);elements.forEach((element)=>{element.onclick=(event)=>{event.preventDefault();callback(event);};});}}
class App{run(){FormHandler.handleSubmitButtons();let keyboardHandler=new KeyboardHandler();keyboardHandler.on("g u",()=>this.goToPage("unread"));keyboardHandler.on("g h",()=>this.goToPage("history"));keyboardHandler.on("g f",()=>this.goToPage("feeds"));keyboardHandler.on("g c",()=>this.goToPage("categories"));keyboardHandler.on("g s",()=>this.goToPage("settings"));keyboardHandler.on("ArrowLeft",()=>this.goToPrevious());keyboardHandler.on("ArrowRight",()=>this.goToNext());keyboardHandler.on("j",()=>this.goToPrevious());keyboardHandler.on("p",()=>this.goToPrevious());keyboardHandler.on("k",()=>this.goToNext());keyboardHandler.on("n",()=>this.goToNext());keyboardHandler.on("h",()=>this.goToPage("previous"));keyboardHandler.on("l",()=>this.goToPage("next"));keyboardHandler.on("o",()=>this.openSelectedItem());keyboardHandler.on("v",()=>this.openOriginalLink());keyboardHandler.on("m",()=>this.toggleEntryStatus());keyboardHandler.on("A",()=>this.markPageAsRead());keyboardHandler.listen();let mouseHandler=new MouseHandler();mouseHandler.onClick("a[data-on-click=markPageAsRead]",()=>this.markPageAsRead());if(document.documentElement.clientWidth<600){mouseHandler.onClick(".logo",()=>this.toggleMainMenu());mouseHandler.onClick(".header nav li",(event)=>this.clickMenuListItem(event));}}
class App{run(){FormHandler.handleSubmitButtons();let keyboardHandler=new KeyboardHandler();keyboardHandler.on("g u",()=>this.goToPage("unread"));keyboardHandler.on("g h",()=>this.goToPage("history"));keyboardHandler.on("g f",()=>this.goToPage("feeds"));keyboardHandler.on("g c",()=>this.goToPage("categories"));keyboardHandler.on("g s",()=>this.goToPage("settings"));keyboardHandler.on("ArrowLeft",()=>this.goToPrevious());keyboardHandler.on("ArrowRight",()=>this.goToNext());keyboardHandler.on("j",()=>this.goToPrevious());keyboardHandler.on("p",()=>this.goToPrevious());keyboardHandler.on("k",()=>this.goToNext());keyboardHandler.on("n",()=>this.goToNext());keyboardHandler.on("h",()=>this.goToPage("previous"));keyboardHandler.on("l",()=>this.goToPage("next"));keyboardHandler.on("o",()=>this.openSelectedItem());keyboardHandler.on("v",()=>this.openOriginalLink());keyboardHandler.on("m",()=>this.toggleEntryStatus());keyboardHandler.on("A",()=>this.markPageAsRead());keyboardHandler.listen();let mouseHandler=new MouseHandler();mouseHandler.onClick("a[data-on-click=markPageAsRead]",()=>this.markPageAsRead());mouseHandler.onClick("a[data-confirm]",(event)=>this.confirm(event));if(document.documentElement.clientWidth<600){mouseHandler.onClick(".logo",()=>this.toggleMainMenu());mouseHandler.onClick(".header nav li",(event)=>this.clickMenuListItem(event));}}
remove(url){let request=new Request(url,{method:"POST",cache:"no-cache",credentials:"include",headers:new Headers({"X-Csrf-Token":this.getCsrfToken()})});fetch(request).then(()=>{window.location.reload();});}
confirm(event){let questionElement=document.createElement("span");let linkElement=event.target;let containerElement=linkElement.parentNode;linkElement.style.display="none";let yesElement=document.createElement("a");yesElement.href="#";yesElement.appendChild(document.createTextNode(linkElement.dataset.labelYes));yesElement.onclick=(event)=>{event.preventDefault();let loadingElement=document.createElement("span");loadingElement.className="loading";loadingElement.appendChild(document.createTextNode(linkElement.dataset.labelLoading));questionElement.remove();containerElement.appendChild(loadingElement);this.remove(linkElement.dataset.url);};let noElement=document.createElement("a");noElement.href="#";noElement.appendChild(document.createTextNode(linkElement.dataset.labelNo));noElement.onclick=(event)=>{event.preventDefault();linkElement.style.display="inline";questionElement.remove();};questionElement.className="confirm";questionElement.appendChild(document.createTextNode(linkElement.dataset.labelQuestion+" "));questionElement.appendChild(yesElement);questionElement.appendChild(document.createTextNode(", "));questionElement.appendChild(noElement);containerElement.appendChild(questionElement);}
clickMenuListItem(event){let element=event.target;console.log(element);if(element.tagName==="A"){window.location.href=element.getAttribute("href");}else{window.location.href=element.querySelector("a").getAttribute("href");}}
toggleMainMenu(){let menu=document.querySelector(".header nav ul");if(this.isVisible(menu)){menu.style.display="none";}else{menu.style.display="block";}}
updateEntriesStatus(entryIDs,status){let url=document.body.dataset.entriesStatusUrl;let request=new Request(url,{method:"POST",cache:"no-cache",credentials:"include",body:JSON.stringify({entry_ids:entryIDs,status:status}),headers:new Headers({"Content-Type":"application/json","X-Csrf-Token":this.getCsrfToken()})});fetch(request);}
@ -48,5 +50,5 @@ document.addEventListener("DOMContentLoaded",function(){(new App()).run();});})(
}
var JavascriptChecksums = map[string]string{
"app": "e250c2af19dea14fd75681a81080cf183919a7a589b0886a093586ee894c8282",
"app": "cc5edd35e9e10e45cd84487bd11bed357f4e759917da1c83137f3c37006edd6f",
}

View file

@ -120,6 +120,7 @@ class App {
let mouseHandler = new MouseHandler();
mouseHandler.onClick("a[data-on-click=markPageAsRead]", () => this.markPageAsRead());
mouseHandler.onClick("a[data-confirm]", (event) => this.confirm(event));
if (document.documentElement.clientWidth < 600) {
mouseHandler.onClick(".logo", () => this.toggleMainMenu());
@ -127,6 +128,61 @@ class App {
}
}
remove(url) {
let request = new Request(url, {
method: "POST",
cache: "no-cache",
credentials: "include",
headers: new Headers({
"X-Csrf-Token": this.getCsrfToken()
})
});
fetch(request).then(() => {
window.location.reload();
});
}
confirm(event) {
let questionElement = document.createElement("span");
let linkElement = event.target;
let containerElement = linkElement.parentNode;
linkElement.style.display = "none";
let yesElement = document.createElement("a");
yesElement.href = "#";
yesElement.appendChild(document.createTextNode(linkElement.dataset.labelYes));
yesElement.onclick = (event) => {
event.preventDefault();
let loadingElement = document.createElement("span");
loadingElement.className = "loading";
loadingElement.appendChild(document.createTextNode(linkElement.dataset.labelLoading));
questionElement.remove();
containerElement.appendChild(loadingElement);
this.remove(linkElement.dataset.url);
};
let noElement = document.createElement("a");
noElement.href = "#";
noElement.appendChild(document.createTextNode(linkElement.dataset.labelNo));
noElement.onclick = (event) => {
event.preventDefault();
linkElement.style.display = "inline";
questionElement.remove();
};
questionElement.className = "confirm";
questionElement.appendChild(document.createTextNode(linkElement.dataset.labelQuestion + " "));
questionElement.appendChild(yesElement);
questionElement.appendChild(document.createTextNode(", "));
questionElement.appendChild(noElement);
containerElement.appendChild(questionElement);
}
clickMenuListItem(event) {
let element = event.target;console.log(element);

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2017-11-20 18:31:16.991583598 -0800 PST m=+0.030730980
// 2017-11-21 14:38:46.654164863 -0800 PST m=+0.005986435
package template

View file

@ -37,7 +37,13 @@
</li>
{{ if eq .FeedCount 0 }}
<li>
<a href="{{ route "removeCategory" "categoryID" .ID }}">{{ t "Remove" }}</a>
<a href="#"
data-confirm="true"
data-label-question="{{ t "Are you sure?" }}"
data-label-yes="{{ t "yes" }}"
data-label-no="{{ t "no" }}"
data-label-loading="{{ t "Work in progress..." }}"
data-url="{{ route "removeCategory" "categoryID" .ID }}">{{ t "Remove" }}</a>
</li>
{{ end }}
</ul>

View file

@ -53,7 +53,13 @@
<a href="{{ route "editFeed" "feedID" .ID }}">{{ t "Edit" }}</a>
</li>
<li>
<a href="{{ route "removeFeed" "feedID" .ID }}">{{ t "Remove" }}</a>
<a href="#"
data-confirm="true"
data-label-question="{{ t "Are you sure?" }}"
data-label-yes="{{ t "yes" }}"
data-label-no="{{ t "no" }}"
data-label-loading="{{ t "Work in progress..." }}"
data-url="{{ route "removeFeed" "feedID" .ID }}">{{ t "Remove" }}</a>
</li>
</ul>
</div>

View file

@ -16,7 +16,7 @@
</ul>
</section>
<table class="table-overflow">
<table>
<tr>
<th>{{ t "Date" }}</th>
<th>{{ t "IP Address" }}</th>
@ -32,7 +32,13 @@
{{ if eq .Token $.currentSessionToken }}
{{ t "Current session" }}
{{ else }}
<a href="{{ route "removeSession" "sessionID" .ID }}">{{ t "Remove" }}</a>
<a href="#"
data-confirm="true"
data-label-question="{{ t "Are you sure?" }}"
data-label-yes="{{ t "yes" }}"
data-label-no="{{ t "no" }}"
data-label-loading="{{ t "Work in progress..." }}"
data-url="{{ route "removeSession" "sessionID" .ID }}">{{ t "Remove" }}</a>
{{ end }}
</td>
</tr>

View file

@ -40,7 +40,13 @@
</td>
<td>
<a href="{{ route "editUser" "userID" .ID }}">{{ t "Edit" }}</a>,
<a href="{{ route "removeUser" "userID" .ID }}">{{ t "Remove" }}</a>
<a href="#"
data-confirm="true"
data-label-question="{{ t "Are you sure?" }}"
data-label-yes="{{ t "yes" }}"
data-label-no="{{ t "no" }}"
data-label-loading="{{ t "Work in progress..." }}"
data-url="{{ route "removeUser" "userID" .ID }}">{{ t "Remove" }}</a>
</td>
</tr>
{{ end }}

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2017-11-20 18:31:16.974386894 -0800 PST m=+0.013534276
// 2017-11-21 14:38:46.652925155 -0800 PST m=+0.004746727
package template
@ -127,7 +127,13 @@ var templateViewsMap = map[string]string{
</li>
{{ if eq .FeedCount 0 }}
<li>
<a href="{{ route "removeCategory" "categoryID" .ID }}">{{ t "Remove" }}</a>
<a href="#"
data-confirm="true"
data-label-question="{{ t "Are you sure?" }}"
data-label-yes="{{ t "yes" }}"
data-label-no="{{ t "no" }}"
data-label-loading="{{ t "Work in progress..." }}"
data-url="{{ route "removeCategory" "categoryID" .ID }}">{{ t "Remove" }}</a>
</li>
{{ end }}
</ul>
@ -621,7 +627,13 @@ var templateViewsMap = map[string]string{
<a href="{{ route "editFeed" "feedID" .ID }}">{{ t "Edit" }}</a>
</li>
<li>
<a href="{{ route "removeFeed" "feedID" .ID }}">{{ t "Remove" }}</a>
<a href="#"
data-confirm="true"
data-label-question="{{ t "Are you sure?" }}"
data-label-yes="{{ t "yes" }}"
data-label-no="{{ t "no" }}"
data-label-loading="{{ t "Work in progress..." }}"
data-url="{{ route "removeFeed" "feedID" .ID }}">{{ t "Remove" }}</a>
</li>
</ul>
</div>
@ -752,7 +764,7 @@ var templateViewsMap = map[string]string{
</ul>
</section>
<table class="table-overflow">
<table>
<tr>
<th>{{ t "Date" }}</th>
<th>{{ t "IP Address" }}</th>
@ -768,7 +780,13 @@ var templateViewsMap = map[string]string{
{{ if eq .Token $.currentSessionToken }}
{{ t "Current session" }}
{{ else }}
<a href="{{ route "removeSession" "sessionID" .ID }}">{{ t "Remove" }}</a>
<a href="#"
data-confirm="true"
data-label-question="{{ t "Are you sure?" }}"
data-label-yes="{{ t "yes" }}"
data-label-no="{{ t "no" }}"
data-label-loading="{{ t "Work in progress..." }}"
data-url="{{ route "removeSession" "sessionID" .ID }}">{{ t "Remove" }}</a>
{{ end }}
</td>
</tr>
@ -930,7 +948,13 @@ var templateViewsMap = map[string]string{
</td>
<td>
<a href="{{ route "editUser" "userID" .ID }}">{{ t "Edit" }}</a>,
<a href="{{ route "removeUser" "userID" .ID }}">{{ t "Remove" }}</a>
<a href="#"
data-confirm="true"
data-label-question="{{ t "Are you sure?" }}"
data-label-yes="{{ t "yes" }}"
data-label-no="{{ t "no" }}"
data-label-loading="{{ t "Work in progress..." }}"
data-url="{{ route "removeUser" "userID" .ID }}">{{ t "Remove" }}</a>
</td>
</tr>
{{ end }}
@ -945,7 +969,7 @@ var templateViewsMap = map[string]string{
var templateViewsMapChecksums = map[string]string{
"about": "56f1d45d8b9944306c66be0712320527e739a0ce4fccbd97a4c414c8f9cfab04",
"add_subscription": "098ea9e492e18242bd414b22c4d8638006d113f728e5ae78c9186663f60ae3f1",
"categories": "721b6bae6aa6461f4e020d667707fabe53c94b399f7d74febef2de5eb9f15071",
"categories": "ca1280cd157bb527d4fc907da67b05a8347378f6dce965b9389d4bcdf3600a11",
"category_entries": "0bdcf28ef29b976b78d1add431896a8c56791476abd7a4240998d52c3efe1f35",
"choose_subscription": "d37682743d8bbd84738a964e238103db2651f95fa340c6e285ffe2e12548d673",
"create_category": "2b82af5d2dcd67898dc5daa57a6461e6ff8121a6089b2a2a1be909f35e4a2275",
@ -955,12 +979,12 @@ var templateViewsMapChecksums = map[string]string{
"edit_user": "f0f79704983de3ca7858bd8cda7a372c3999f5e4e0cf951fba5fa2c1752f9111",
"entry": "32e605edd6d43773ac31329d247ebd81d38d974cd43689d91de79fffec7fe04b",
"feed_entries": "9aff923b6c7452dec1514feada7e0d2bbc1ec21c6f5e9f48b2de41d1b731ffe4",
"feeds": "ddcf12a47c850e6a1f3b85c9ab6566b4e45adfcd7a3546381a0c3a7a54f2b7d4",
"feeds": "94e43404a4044490c065c888a49bebd3ff51b588b9fb47d03c2598003aa40dca",
"history": "439000d0be8fd716f3b89860af4d721e05baef0c2ccd2325ba020c940d6aa847",
"import": "73b5112e20bfd232bf73334544186ea419505936bc237d481517a8622901878f",
"login": "568f2f69f248048f3e55e9bbc719077a74ae23fe18f237aa40e3de37e97b7a41",
"sessions": "7fcd3bb794d4ad01eb9fa515660f04c8e79e1568970fd541cc7b2de8a76e1542",
"sessions": "5ac3793f0ee74d0807bab6a173a1aa6508e98add5c022fa54c8fdf5c6b4a0e75",
"settings": "9c89bfd70ff288b4256e5205be78a7645450b364db1df51d10fee3cb915b2c6b",
"unread": "b6f9be1a72188947c75a6fdcac6ff7878db7745f9efa46318e0433102892a722",
"users": "5bd535de3e46d9b14667d8159a5ec1478d6e028a77bf306c89d7b55813eeb625",
"users": "c6b1fa81cf229dde88e69c353114b542c67794a2cd513eddaf600828ab14aa18",
}

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2017-11-20 18:31:16.963285699 -0800 PST m=+0.002433081
// 2017-11-21 14:38:46.650534269 -0800 PST m=+0.002355841
package sql