Skip to content

Commit ad351b3

Browse files
authored
Merge pull request #300 from AEtheve/add-clear-history-button
Add clear history button
2 parents 3345351 + cf7af99 commit ad351b3

File tree

3 files changed

+56
-4
lines changed

3 files changed

+56
-4
lines changed

electron_app/src/assets/css/theme.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@
132132
height: 15px;
133133
margin: 10px 0px;
134134
}
135+
.v-toast__item--default {
136+
background-color: #ffffff;
137+
}
138+
.v-toast__item .v-toast__icon {
139+
background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 45.999 45.999'%3e %3cpath fill='%23AAA' d='M39.264 6.736c-8.982-8.981-23.545-8.982-32.528 0-8.982 8.982-8.981 23.545 0 32.528 8.982 8.98 23.545 8.981 32.528 0 8.981-8.983 8.98-23.545 0-32.528zM25.999 33a3 3 0 11-6 0V21a3 3 0 116 0v12zm-3.053-17.128c-1.728 0-2.88-1.224-2.844-2.735-.036-1.584 1.116-2.771 2.879-2.771 1.764 0 2.88 1.188 2.917 2.771-.001 1.511-1.152 2.735-2.952 2.735z'/%3e %3c/svg%3e") no-repeat;
140+
}
135141
}
136142

137143
@media (prefers-color-scheme: dark) {

electron_app/src/components/History.vue

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<div class="animatable_content_box ">
44

55
<b-form-input
6+
@input="currentPage=1"
67
onkeypress="return event.keyCode != 13;"
78
size="sm"
89
placeholder="Search by prompt text"
@@ -16,8 +17,19 @@
1617
<div @click="toggle_order()" style="float:right; margin-bottom: 20px;" class="l_button">
1718
{{this.app_state.show_history_in_oldest_first ? "Oldest": "Newest"}} First
1819
</div>
20+
<div @click="clear_history()" style="float:right; margin-bottom: 20px;" class="l_button">
21+
Clear History
22+
</div>
1923
<div v-if="Object.values(app_state.app_data.history).length > 0">
20-
<div v-for="history_box in get_history()" :key="history_box.key" style="clear: both;">
24+
<div v-if="get_history().length > 30">
25+
<b-pagination
26+
v-model="currentPage"
27+
:total-rows="get_history().length"
28+
:per-page="30"
29+
/>
30+
</div>
31+
<div v-for="history_box in get_history().slice((currentPage - 1) * 30, currentPage * 30)" :key="history_box.key" style="clear: both;">
32+
2133

2234
<div @click="delete_hist(history_box.key)" style="float:right; margin-top: 10px;" class="l_button">Delete</div>
2335
<!-- <div @click="share_on_arthub(history_box)" style="float:right; margin-top: 10px;" class="l_button">Share</div> -->
@@ -65,6 +77,7 @@
6577
</template>
6678
<script>
6779
import ImageItem from '../components/ImageItem.vue'
80+
import {native_confirm} from "../native_functions_vue_bridge.js";
6881
import {share_on_arthub} from '../utils.js'
6982
7083
import Vue from 'vue'
@@ -83,7 +96,8 @@ export default {
8396
},
8497
data() {
8598
return {
86-
searchText: ''
99+
searchText: '',
100+
currentPage: 1,
87101
};
88102
},
89103
methods: {
@@ -95,7 +109,6 @@ export default {
95109
let history = Object.values(this.app_state.app_data.history);
96110
const that = this;
97111
const list = this.app_state.show_history_in_oldest_first ? history : history.reverse();
98-
99112
if (that.searchText.trim() === '') {
100113
return list;
101114
}
@@ -104,7 +117,7 @@ export default {
104117
keys: ['prompt'],
105118
useExtendedSearch: true,
106119
});
107-
120+
108121
return fuse.search(that.searchText).map(r => r.item);
109122
110123
},
@@ -132,6 +145,12 @@ export default {
132145
return r;
133146
},
134147
148+
clear_history(){
149+
if (native_confirm("Are you sure you want to clear history?")){
150+
Vue.set( this.app_state.app_data, "history", {});
151+
}
152+
},
153+
135154
share_on_arthub(box){
136155
this.app_state.global_loader_modal_msg = "Uploading";
137156
let params = this.get_box_params_dict(box);
@@ -147,6 +166,24 @@ export default {
147166
}
148167
</script>
149168
<style>
169+
.page-item .page-link{
170+
outline: none !important;
171+
box-shadow: none;
172+
}
173+
.page-item .page-link{
174+
font-size: 13px;
175+
}
176+
@media (prefers-color-scheme: dark) {
177+
.page-item .page-link, .page-item.disabled .page-link{
178+
background-color:#303030;
179+
border-color: #303030;
180+
color:rgba(255, 255, 255, 0.5);
181+
}
182+
.page-item.active .page-link{
183+
background-color:#606060;
184+
border-color: #606060;
185+
}
186+
}
150187
</style>
151188
<style scoped>
152189
.history_box_info {

electron_app/src/components_bare/SDOptionsDropdown.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,15 @@ export default {
303303
}
304304
</script>
305305
<style scoped>
306+
.b-dropdown ::-webkit-scrollbar {
307+
appearance: none;
308+
width: 7px;
309+
}
310+
.b-dropdown ::-webkit-scrollbar-thumb {
311+
border-radius: 4px;
312+
background-color: rgba(0, 0, 0, .5);
313+
box-shadow: 0 0 1px rgba(255, 255, 255, .5);
314+
}
306315
.options_title {
307316
display: flex;
308317
flex-direction: row;

0 commit comments

Comments
 (0)