-
Notifications
You must be signed in to change notification settings - Fork 664
/
Copy pathSettings.vue
205 lines (179 loc) · 5.86 KB
/
Settings.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<template>
<div class="animatable_content_box ">
<div v-if="!is_custom_model_loading">
<h1>Settings</h1>
<br>
<h2>General Settings</h2>
<br>
<div class="setting_box">
<div class="settings_left">
<h3>Notification sound</h3>
<p>To play a notification sound when generation of an image is completed</p>
</div>
<hr>
<div style="float:right;margin-right: 9px;align-self: center;" >
<label class="switch">
<input type="checkbox" v-model="app_state.app_data.settings.notification_sound" checked>
<span class="toggle round"></span>
</label>
</div>
</div>
<div class="setting_box">
<div class="settings_left">
<h3>Live render preview</h3>
<p>To display a preview of the image as it is being rendered, at each step of the generation process</p>
</div>
<hr>
<div style="float:right;margin-right: 9px;align-self: center;" >
<label class="switch">
<input type="checkbox" v-model="app_state.app_data.settings.live_render">
<span class="toggle round"></span>
</label>
</div>
</div>
<hr>
<!--
<div class="setting_box">
<div class="settings_left">
<h2>Allow NSFW Content</h2>
<p>Allows image generation considered NSFW</p>
</div>
<hr>
<div style="float:right;margin-right: 9px;align-self: center;" >
<label class="switch">
<input type="checkbox" v-model="app_state.app_data.settings.nsfw_filter">
<span class="toggle round"></span>
</label>
</div>
</div>
<hr> -->
<div class="l_button button_colored" style="float:right" @click="add_model" >Add New Model</div>
<h2>Custom Models</h2>
<!-- <br> -->
<hr>
<div v-for="model in Object.values(this.app_state.app_data.custom_models)" :key="model.name">
<div class="l_button" @click="delete_model(model.name, model.is_coreml)" style="float:right">Remove</div>
<p> Name : {{model.name}} </p>
<p> Path : {{model.orig_path}} </p>
<span v-if="model.is_coreml" style="color:white;background:#02b3b6;border-radius:10px;padding:2px 5px 2px 5px;font-size:12px;">CoreML Model</span>
<hr>
</div>
</div>
<div v-else>
<LoaderModal :loading_percentage="-1" loading_title="Importing model"></LoaderModal>
</div>
</div>
</template>
<script>
import LoaderModal from '../components_bare/LoaderModal.vue'
import Vue from 'vue'
export default {
name: 'Settings',
props: {
app_state : Object ,
},
components: {LoaderModal},
mounted() {
},
data() {
return {
is_custom_model_loading:false,
};
},
methods: {
delete_model(k, coreml){
let model_path = coreml ? this.app_state.app_data.custom_models[k+" [CoreML ]"].orig_path : this.app_state.app_data.custom_models[k].orig_path;
if (coreml) {
window.ipcRenderer.sendSync('delete_dir', model_path );
Vue.delete( this.app_state.app_data.custom_models , k+" [CoreML ]" );
} else {
window.ipcRenderer.sendSync('delete_file', model_path );
Vue.delete( this.app_state.app_data.custom_models , k );
}
},
add_model(){
let that = this;
let pytorch_model_path = window.ipcRenderer.sendSync('file_dialog', "ckpt_file" );
if(!pytorch_model_path)
return;
if(pytorch_model_path == "NULL")
return;
let model_name = pytorch_model_path.replaceAll("\\" , "/").split("/");
model_name = model_name[model_name.length - 1].split(".")[0]
if(model_name.trim() == ""){
alert("Put non empty model name");
return;
}
if(that.app_state.app_data.custom_models[model_name]){
alert("this model name "+ model_name +" already exists")
return;
}
that.is_custom_model_loading = true
window.ipcRenderer.invoke('add_custom_pytorch_models', pytorch_model_path , model_name ).then((result) => {
that.is_custom_model_loading = false
if(result.success){
Vue.set( that.app_state.app_data.custom_models , model_name , {"name":model_name , "path": result.model_path, "orig_path" : pytorch_model_path } );
} else {
alert("Error " + result.error )
}
})
}
},
}
</script>
<style>
</style>
<style scoped>
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 30px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.toggle {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.toggle:before {
position: absolute;
content: "";
height: 22px;
width: 23px;
left: 5px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .toggle {
background-color: #3E7BFA;
}
input:checked + .toggle:before {
transform: translateX(27px);
}
.toggle.round {
border-radius: 34px;
}
.toggle.round:before {
border-radius: 50%;
}
.setting_box{
display: flex;
flex-direction: row;
}
.settings_left{
flex: 1 1 auto;
}
</style>