@@ -35,6 +35,16 @@
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
v-on:keyup.enter="insertTodo"/>
+
+
+
+
+
+
+
+
+
+
diff --git a/src/globalroutines/index.js b/src/globalroutines/index.js
new file mode 100644
index 0000000..bcde872
--- /dev/null
+++ b/src/globalroutines/index.js
@@ -0,0 +1,7 @@
+import indexdb from './indexdb'
+
+export default async (context, cmd, table, data = null, id = '') => {
+ const descr = data !== null ? data.descr : ''
+ // console.log('globalroutines', cmd, table, descr, id)
+ return await indexdb(context, cmd, table, data, id)
+}
diff --git a/src/globalroutines/indexdb.js b/src/globalroutines/indexdb.js
new file mode 100644
index 0000000..00e7d3b
--- /dev/null
+++ b/src/globalroutines/indexdb.js
@@ -0,0 +1,79 @@
+import store from '../store'
+import _ from 'lodash'
+import { UserStore, Todos } from '@store'
+import { i18n } from '../plugins/i18n'
+
+import {idbKeyval as storage} from '../js/storage.js';
+
+function saveConfigIndexDb(context) {
+
+ let data = []
+ data['_id'] = 1
+ data['lang'] = UserStore.state.lang
+ data['token'] = UserStore.state.idToken
+ data['userId'] = UserStore.state.userId
+
+ writeConfigIndexDb('config', data)
+}
+
+function writeConfigIndexDb(context, data) {
+ // console.log('writeConfigIndexDb', data)
+
+ storage.setdata('config', data)
+ .then(ris => {
+ return true
+ })
+
+}
+
+async function readfromIndexDbToStateTodos(context, table) {
+ // console.log('*** read from IndexDb to state.todos')
+
+ return await storage.getalldata(table)
+ .then(records => {
+ // console.log('&&&&&&& readfromIndexDbToStateTodos OK: Num RECORD: ', records.length)
+ if (table === 'todos') {
+ Todos.state.todos = [...records]
+ Todos.mutations.setTodos_changed()
+ // console.log('Todos.state.todos_changed:', Todos.state.todos_changed)
+ // setTimeout(testfunc2, 3000)
+ }
+ }).catch((error) => {
+ console.log('err: ', error)
+ })
+
+}
+
+function consolelogpao(str, str2 = '', str3 = '') {
+ console.log(str, str2, str3)
+ // Todos.mutations.setTestpao(str + str2 + str3)
+}
+
+function testfunc2 () {
+ consolelogpao('testfunc2')
+ Todos.mutations.setTodos_changed()
+
+ consolelogpao('testfunc2: Todos.state.todos_changed:', Todos.state.todos_changed)
+}
+
+export default async (context, cmd, table, datakey = null, id = '') => {
+ if (cmd === 'loadapp') {
+ // ****** LOAD APP AL CARICAMENTO ! *******
+ return saveConfigIndexDb(context, datakey)
+
+ } else if (cmd === 'write') {
+ return await storage.setdata(table, datakey)
+ } else if (cmd === 'updateinMemory') {
+ return await readfromIndexDbToStateTodos(context, table)
+ } else if (cmd === 'readall') {
+ return await storage.getalldata(table)
+ } else if (cmd === 'count') {
+ return await storage.count(table)
+ } else if (cmd === 'read') {
+ return await storage.getdata(table, id)
+ } else if (cmd === 'delete') {
+ return await storage.deletedata(table, id)
+ } else if (cmd === 'log') {
+ consolelogpao(table)
+ }
+}
diff --git a/src/globalroutines/util.js b/src/globalroutines/util.js
new file mode 100644
index 0000000..ffb4043
--- /dev/null
+++ b/src/globalroutines/util.js
@@ -0,0 +1,18 @@
+import { UserStore } from "../store/Modules";
+import messages from "../statics/i18n";
+
+function translate(params) {
+ let msg = params.split('.')
+ let lang = UserStore.state.lang
+
+ let stringa = messages[lang]
+
+ let ris = stringa
+ msg.forEach(param => {
+ ris = ris[param]
+ })
+
+ return ris
+}
+
+export default translate
diff --git a/src/index.template.html b/src/index.template.html
index 4e2e4de..aa2c291 100644
--- a/src/index.template.html
+++ b/src/index.template.html
@@ -10,15 +10,25 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
diff --git a/src/js/fetch.js b/src/js/fetch.js
index 6bac6b3..30ea634 100644
--- a/src/js/fetch.js
+++ b/src/js/fetch.js
@@ -295,7 +295,7 @@
}
// HTTP methods whose capitalization should be normalized
- var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']
+ var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT', 'PATCH']
function normalizeMethod(method) {
var upcased = method.toUpperCase()
diff --git a/src/js/idb.js b/src/js/idb.js
deleted file mode 100644
index 9835513..0000000
--- a/src/js/idb.js
+++ /dev/null
@@ -1,311 +0,0 @@
-'use strict';
-
-(function() {
- function toArray(arr) {
- return Array.prototype.slice.call(arr);
- }
-
- function promisifyRequest(request) {
- return new Promise(function(resolve, reject) {
- request.onsuccess = function() {
- resolve(request.result);
- };
-
- request.onerror = function() {
- reject(request.error);
- };
- });
- }
-
- function promisifyRequestCall(obj, method, args) {
- var request;
- var p = new Promise(function(resolve, reject) {
- request = obj[method].apply(obj, args);
- promisifyRequest(request).then(resolve, reject);
- });
-
- p.request = request;
- return p;
- }
-
- function promisifyCursorRequestCall(obj, method, args) {
- var p = promisifyRequestCall(obj, method, args);
- return p.then(function(value) {
- if (!value) return;
- return new Cursor(value, p.request);
- });
- }
-
- function proxyProperties(ProxyClass, targetProp, properties) {
- properties.forEach(function(prop) {
- Object.defineProperty(ProxyClass.prototype, prop, {
- get: function() {
- return this[targetProp][prop];
- },
- set: function(val) {
- this[targetProp][prop] = val;
- }
- });
- });
- }
-
- function proxyRequestMethods(ProxyClass, targetProp, Constructor, properties) {
- properties.forEach(function(prop) {
- if (!(prop in Constructor.prototype)) return;
- ProxyClass.prototype[prop] = function() {
- return promisifyRequestCall(this[targetProp], prop, arguments);
- };
- });
- }
-
- function proxyMethods(ProxyClass, targetProp, Constructor, properties) {
- properties.forEach(function(prop) {
- if (!(prop in Constructor.prototype)) return;
- ProxyClass.prototype[prop] = function() {
- return this[targetProp][prop].apply(this[targetProp], arguments);
- };
- });
- }
-
- function proxyCursorRequestMethods(ProxyClass, targetProp, Constructor, properties) {
- properties.forEach(function(prop) {
- if (!(prop in Constructor.prototype)) return;
- ProxyClass.prototype[prop] = function() {
- return promisifyCursorRequestCall(this[targetProp], prop, arguments);
- };
- });
- }
-
- function Index(index) {
- this._index = index;
- }
-
- proxyProperties(Index, '_index', [
- 'name',
- 'keyPath',
- 'multiEntry',
- 'unique'
- ]);
-
- proxyRequestMethods(Index, '_index', IDBIndex, [
- 'get',
- 'getKey',
- 'getAll',
- 'getAllKeys',
- 'count'
- ]);
-
- proxyCursorRequestMethods(Index, '_index', IDBIndex, [
- 'openCursor',
- 'openKeyCursor'
- ]);
-
- function Cursor(cursor, request) {
- this._cursor = cursor;
- this._request = request;
- }
-
- proxyProperties(Cursor, '_cursor', [
- 'direction',
- 'key',
- 'primaryKey',
- 'value'
- ]);
-
- proxyRequestMethods(Cursor, '_cursor', IDBCursor, [
- 'update',
- 'delete'
- ]);
-
- // proxy 'next' methods
- ['advance', 'continue', 'continuePrimaryKey'].forEach(function(methodName) {
- if (!(methodName in IDBCursor.prototype)) return;
- Cursor.prototype[methodName] = function() {
- var cursor = this;
- var args = arguments;
- return Promise.resolve().then(function() {
- cursor._cursor[methodName].apply(cursor._cursor, args);
- return promisifyRequest(cursor._request).then(function(value) {
- if (!value) return;
- return new Cursor(value, cursor._request);
- });
- });
- };
- });
-
- function ObjectStore(store) {
- this._store = store;
- }
-
- ObjectStore.prototype.createIndex = function() {
- return new Index(this._store.createIndex.apply(this._store, arguments));
- };
-
- ObjectStore.prototype.index = function() {
- return new Index(this._store.index.apply(this._store, arguments));
- };
-
- proxyProperties(ObjectStore, '_store', [
- 'name',
- 'keyPath',
- 'indexNames',
- 'autoIncrement'
- ]);
-
- proxyRequestMethods(ObjectStore, '_store', IDBObjectStore, [
- 'put',
- 'add',
- 'delete',
- 'clear',
- 'get',
- 'getAll',
- 'getKey',
- 'getAllKeys',
- 'count'
- ]);
-
- proxyCursorRequestMethods(ObjectStore, '_store', IDBObjectStore, [
- 'openCursor',
- 'openKeyCursor'
- ]);
-
- proxyMethods(ObjectStore, '_store', IDBObjectStore, [
- 'deleteIndex'
- ]);
-
- function Transaction(idbTransaction) {
- this._tx = idbTransaction;
- this.complete = new Promise(function(resolve, reject) {
- idbTransaction.oncomplete = function() {
- resolve();
- };
- idbTransaction.onerror = function() {
- reject(idbTransaction.error);
- };
- idbTransaction.onabort = function() {
- reject(idbTransaction.error);
- };
- });
- }
-
- Transaction.prototype.objectStore = function() {
- return new ObjectStore(this._tx.objectStore.apply(this._tx, arguments));
- };
-
- proxyProperties(Transaction, '_tx', [
- 'objectStoreNames',
- 'mode'
- ]);
-
- proxyMethods(Transaction, '_tx', IDBTransaction, [
- 'abort'
- ]);
-
- function UpgradeDB(db, oldVersion, transaction) {
- this._db = db;
- this.oldVersion = oldVersion;
- this.transaction = new Transaction(transaction);
- }
-
- UpgradeDB.prototype.createObjectStore = function() {
- return new ObjectStore(this._db.createObjectStore.apply(this._db, arguments));
- };
-
- proxyProperties(UpgradeDB, '_db', [
- 'name',
- 'version',
- 'objectStoreNames'
- ]);
-
- proxyMethods(UpgradeDB, '_db', IDBDatabase, [
- 'deleteObjectStore',
- 'close'
- ]);
-
- function DB(db) {
- this._db = db;
- }
-
- DB.prototype.transaction = function() {
- return new Transaction(this._db.transaction.apply(this._db, arguments));
- };
-
- proxyProperties(DB, '_db', [
- 'name',
- 'version',
- 'objectStoreNames'
- ]);
-
- proxyMethods(DB, '_db', IDBDatabase, [
- 'close'
- ]);
-
- // Add cursor iterators
- // TODO: remove this once browsers do the right thing with promises
- ['openCursor', 'openKeyCursor'].forEach(function(funcName) {
- [ObjectStore, Index].forEach(function(Constructor) {
- Constructor.prototype[funcName.replace('open', 'iterate')] = function() {
- var args = toArray(arguments);
- var callback = args[args.length - 1];
- var nativeObject = this._store || this._index;
- var request = nativeObject[funcName].apply(nativeObject, args.slice(0, -1));
- request.onsuccess = function() {
- callback(request.result);
- };
- };
- });
- });
-
- // polyfill getAll
- [Index, ObjectStore].forEach(function(Constructor) {
- if (Constructor.prototype.getAll) return;
- Constructor.prototype.getAll = function(query, count) {
- var instance = this;
- var items = [];
-
- return new Promise(function(resolve) {
- instance.iterateCursor(query, function(cursor) {
- if (!cursor) {
- resolve(items);
- return;
- }
- items.push(cursor.value);
-
- if (count !== undefined && items.length == count) {
- resolve(items);
- return;
- }
- cursor.continue();
- });
- });
- };
- });
-
- var exp = {
- open: function(name, version, upgradeCallback) {
- var p = promisifyRequestCall(indexedDB, 'open', [name, version]);
- var request = p.request;
-
- request.onupgradeneeded = function(event) {
- if (upgradeCallback) {
- upgradeCallback(new UpgradeDB(request.result, event.oldVersion, request.transaction));
- }
- };
-
- return p.then(function(db) {
- return new DB(db);
- });
- },
- delete: function(name) {
- return promisifyRequestCall(indexedDB, 'deleteDatabase', [name]);
- }
- };
-
- if (typeof module !== 'undefined') {
- module.exports = exp;
- module.exports.default = module.exports;
- }
- else {
- self.idb = exp;
- }
-}());
diff --git a/src/js/immortal-db.min.js b/src/js/immortal-db.min.js
new file mode 100644
index 0000000..7735d36
--- /dev/null
+++ b/src/js/immortal-db.min.js
@@ -0,0 +1,8 @@
+var ImmortalDB=function(t){var r={};function n(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)n.d(e,o,function(r){return t[r]}.bind(null,o));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s=68)}([function(t,r,n){var e=n(39)("wks"),o=n(19),i=n(1).Symbol,u="function"==typeof i;(t.exports=function(t){return e[t]||(e[t]=u&&i[t]||(u?i:o)("Symbol."+t))}).store=e},function(t,r){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(t,r){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,r,n){var e=n(1),o=n(13),i=n(10),u=n(12),c=n(7),a=function(t,r,n){var s,f,l,p,h=t&a.F,v=t&a.G,y=t&a.S,d=t&a.P,m=t&a.B,g=v?e:y?e[r]||(e[r]={}):(e[r]||{}).prototype,w=v?o:o[r]||(o[r]={}),x=w.prototype||(w.prototype={});for(s in v&&(n=r),n)l=((f=!h&&g&&void 0!==g[s])?g:n)[s],p=m&&f?c(l,e):d&&"function"==typeof l?c(Function.call,l):l,g&&u(g,s,l,t&a.U),w[s]!=l&&i(w,s,p),d&&x[s]!=l&&(x[s]=l)};e.core=o,a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,t.exports=a},function(t,r,n){var e=n(6),o=n(67),i=n(43),u=Object.defineProperty;r.f=n(5)?Object.defineProperty:function(t,r,n){if(e(t),r=i(r,!0),e(n),o)try{return u(t,r,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[r]=n.value),t}},function(t,r,n){t.exports=!n(9)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,r,n){var e=n(2);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,r,n){var e=n(18);t.exports=function(t,r,n){if(e(t),void 0===r)return t;switch(n){case 1:return function(n){return t.call(r,n)};case 2:return function(n,e){return t.call(r,n,e)};case 3:return function(n,e,o){return t.call(r,n,e,o)}}return function(){return t.apply(r,arguments)}}},function(t,r){var n={}.hasOwnProperty;t.exports=function(t,r){return n.call(t,r)}},function(t,r){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,r,n){var e=n(4),o=n(20);t.exports=n(5)?function(t,r,n){return e.f(t,r,o(1,n))}:function(t,r,n){return t[r]=n,t}},function(t,r,n){var e=n(61),o=n(41);t.exports=function(t){return e(o(t))}},function(t,r,n){var e=n(1),o=n(10),i=n(8),u=n(19)("src"),c=Function.toString,a=(""+c).split("toString");n(13).inspectSource=function(t){return c.call(t)},(t.exports=function(t,r,n,c){var s="function"==typeof n;s&&(i(n,"name")||o(n,"name",r)),t[r]!==n&&(s&&(i(n,u)||o(n,u,t[r]?""+t[r]:a.join(String(r)))),t===e?t[r]=n:c?t[r]?t[r]=n:o(t,r,n):(delete t[r],o(t,r,n)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[u]||c.call(this)})},function(t,r){var n=t.exports={version:"2.6.1"};"number"==typeof __e&&(__e=n)},function(t,r,n){var e=n(4).f,o=n(8),i=n(0)("toStringTag");t.exports=function(t,r,n){t&&!o(t=n?t:t.prototype,i)&&e(t,i,{configurable:!0,value:r})}},function(t,r){t.exports=!1},function(t,r){t.exports={}},function(t,r){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,r){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,r){var n=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+e).toString(36))}},function(t,r){t.exports=function(t,r){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:r}}},function(t,r,n){var e=n(6),o=n(83),i=n(31),u=n(32)("IE_PROTO"),c=function(){},a=function(){var t,r=n(44)("iframe"),e=i.length;for(r.style.display="none",n(59).appendChild(r),r.src="javascript:",(t=r.contentWindow.document).open(),t.write("