summaryrefslogtreecommitdiffstats
path: root/webapp/src/main.js
diff options
context:
space:
mode:
authorUdo Walter2019-02-22 03:44:24 +0100
committerUdo Walter2019-02-22 03:44:24 +0100
commit3a95b5e8a9a030b318199838ac05a0692e5473a8 (patch)
tree97d1e67585b86dd205b86f853eeca8465ba43899 /webapp/src/main.js
parent[router] All modules have the new api style, deleted old unnecessary code (diff)
downloadbas-3a95b5e8a9a030b318199838ac05a0692e5473a8.tar.gz
bas-3a95b5e8a9a030b318199838ac05a0692e5473a8.tar.xz
bas-3a95b5e8a9a030b318199838ac05a0692e5473a8.zip
[webapp] implement time slicing loop and use it to search in the datatable
This improves UI responsiveness a lot while searching.
Diffstat (limited to 'webapp/src/main.js')
-rw-r--r--webapp/src/main.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/webapp/src/main.js b/webapp/src/main.js
index 4eb4636..a87aae8 100644
--- a/webapp/src/main.js
+++ b/webapp/src/main.js
@@ -88,10 +88,28 @@ Vue.prototype.$alert = function (data, emit = true) {
if (emit) socket.emit('notifications newAlert', data)
store.commit('notifications/newAlert', data)
}
+
Vue.prototype.$snackbar = function (data) {
store.commit('notifications/newSnackbar', data)
}
+// Loop that processes work in chunks to allow the UI to refresh inbetween and prevents freezing.
+Vue.prototype.$loop = function (count, chunksize, callback, breakLoop = () => false, finished = () => {}) {
+ var i = 0;
+ (function chunk () {
+ var end = Math.min(i + chunksize, count)
+ for (; i < end; ++i) {
+ callback(i)
+ }
+ let bl = breakLoop()
+ if (i < count && !bl) {
+ setTimeout(chunk, 0)
+ } else if (!bl) {
+ finished()
+ }
+ })()
+}
+
new Vue({
store,
router,