extracting out local db action to its own utility class

This commit is contained in:
Ro 2018-12-02 19:47:28 -05:00
parent ec5a58c49d
commit 22af04f59a
6 changed files with 464 additions and 42 deletions

View file

@ -17,6 +17,7 @@ export const POST_ADDED = 'postAdded';
export const POST_UPDATED = 'postUpdated'; export const POST_UPDATED = 'postUpdated';
export const POST_DELETED = 'postImageAdded'; export const POST_DELETED = 'postImageAdded';
export const POSTS_SYNCED = 'postsSynced'; export const POSTS_SYNCED = 'postsSynced';
export const LOCAL_DB_READY = 'localDBReady';
class DataEvent class DataEvent
{ {

View file

@ -0,0 +1,52 @@
"use strict";
import DataUtils from '../../../themes/default/src/com/tools/utilities/DataUtils';
import Dexie from 'dexie';
import * as DataEvent from '../events/DataEvent';
export default class DBUtils
{
//--------------------------
// constructor
//--------------------------
constructor()
{
this.dataUtils = new DataUtils();
this.db = new Dexie("fipamo_posts");
this.db.version(1).stores(
{
postList: 'id,post'
});
}
//--------------------------
// methods
//--------------------------
resetLocal(array)
{
let self = this;
return new Promise(function(resolve, reject)
{
self.db.postList.clear().then(result =>
{
self.db.postList.bulkAdd(array).then(key =>
{
self.db.postList.toArray(array =>
{
let event = DataEvent.LOCAL_DB_READY
resolve(
{
event
})
})
}).catch(Dexie.BulkError, e =>
{
reject(
{
e
})
})
})
})
}
//--------------------------
// event handlers
//--------------------------
}

View file

@ -197,7 +197,7 @@ exports.default = _default;
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.default = exports.POSTS_SYNCED = exports.POST_DELETED = exports.POST_UPDATED = exports.POST_ADDED = exports.POST_ERROR = exports.FEATURE_IMAGE_ADDED = exports.POST_IMAGE_ADDED = exports.PROJECTS_SORTED = exports.PROJECT_ADDED = exports.PROJECT_UPDATED = exports.ARCHIVES_ENTRY_LOADED = exports.ARCHIVES_PAGE_LOADED = exports.ARCHIVES_JSON_LOADED = exports.HTML_LOADED = exports.SETTINGS_LOADED = exports.IMG_REQUEST_LAME = exports.IMG_REQUEST_GOOD = exports.REQUEST_LAME = exports.REQUEST_GOOD = void 0; exports.default = exports.LOCAL_DB_READY = exports.POSTS_SYNCED = exports.POST_DELETED = exports.POST_UPDATED = exports.POST_ADDED = exports.POST_ERROR = exports.FEATURE_IMAGE_ADDED = exports.POST_IMAGE_ADDED = exports.PROJECTS_SORTED = exports.PROJECT_ADDED = exports.PROJECT_UPDATED = exports.ARCHIVES_ENTRY_LOADED = exports.ARCHIVES_PAGE_LOADED = exports.ARCHIVES_JSON_LOADED = exports.HTML_LOADED = exports.SETTINGS_LOADED = exports.IMG_REQUEST_LAME = exports.IMG_REQUEST_GOOD = exports.REQUEST_LAME = exports.REQUEST_GOOD = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@ -239,6 +239,8 @@ var POST_DELETED = 'postImageAdded';
exports.POST_DELETED = POST_DELETED; exports.POST_DELETED = POST_DELETED;
var POSTS_SYNCED = 'postsSynced'; var POSTS_SYNCED = 'postsSynced';
exports.POSTS_SYNCED = POSTS_SYNCED; exports.POSTS_SYNCED = POSTS_SYNCED;
var LOCAL_DB_READY = 'localDBReady';
exports.LOCAL_DB_READY = LOCAL_DB_READY;
var DataEvent = function DataEvent() { var DataEvent = function DataEvent() {
_classCallCheck(this, DataEvent); _classCallCheck(this, DataEvent);
@ -37547,7 +37549,396 @@ function () {
}(); }();
exports.default = DashManager; exports.default = DashManager;
},{"./PostEditor":"controllers/PostEditor.js","../../../../../brain/tools/effects/Animate":"../../../../brain/tools/effects/Animate.js","./PostIndex":"controllers/PostIndex.js"}],"Base.js":[function(require,module,exports) { },{"./PostEditor":"controllers/PostEditor.js","../../../../../brain/tools/effects/Animate":"../../../../brain/tools/effects/Animate.js","./PostIndex":"controllers/PostIndex.js"}],"../../../default/src/com/tools/events/EventEmitter.jsx":[function(require,module,exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var EventEmitter =
/*#__PURE__*/
function () {
//--------------------------
// constructor
//--------------------------
function EventEmitter() {
_classCallCheck(this, EventEmitter);
this.listeners = new Map();
} //--------------------------
// methods
//--------------------------
_createClass(EventEmitter, [{
key: "addListener",
value: function addListener(label, callback) {
this.listeners.has(label) || this.listeners.set(label, []);
this.listeners.get(label).push(callback);
}
}, {
key: "removeListener",
value: function removeListener(label, callback) {
var isFunction = function isFunction(obj) {
return typeof obj == 'function' || false;
};
var listeners = this.listeners.get(label),
index;
if (listeners && listeners.length) {
index = listeners.reduce(function (i, listener, index) {
return isFunction(listener) && listener === callback ? i = index : i;
}, -1);
if (index > -1) {
listeners.splice(index, 1);
this.listeners.set(label, listeners);
return true;
}
}
return false;
}
}, {
key: "emitEvent",
value: function emitEvent(label) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var listeners = this.listeners.get(label);
if (listeners && listeners.length) {
listeners.forEach(function (listener) {
listener.apply(void 0, args);
});
return true;
}
return false;
} //--------------------------
// event handlers
//--------------------------
}]);
return EventEmitter;
}();
var _default = EventEmitter;
exports.default = _default;
},{}],"../../../default/src/com/tools/events/DataEvent.jsx":[function(require,module,exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.PROJECTS_SORTED = exports.PROJECT_ADDED = exports.PROJECT_UPDATED = exports.ARCHIVES_ENTRY_LOADED = exports.ARCHIVES_PAGE_LOADED = exports.ARCHIVES_JSON_LOADED = exports.HTML_LOADED = exports.SETTINGS_LOADED = exports.IMG_REQUEST_LAME = exports.IMG_REQUEST_GOOD = exports.REQUEST_LAME = exports.REQUEST_GOOD = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var REQUEST_GOOD = 'requestGood';
exports.REQUEST_GOOD = REQUEST_GOOD;
var REQUEST_LAME = 'requestLame';
exports.REQUEST_LAME = REQUEST_LAME;
var IMG_REQUEST_GOOD = 'imgRequestGood';
exports.IMG_REQUEST_GOOD = IMG_REQUEST_GOOD;
var IMG_REQUEST_LAME = 'imgRequestLame';
exports.IMG_REQUEST_LAME = IMG_REQUEST_LAME;
var SETTINGS_LOADED = 'dataLoaded';
exports.SETTINGS_LOADED = SETTINGS_LOADED;
var HTML_LOADED = 'htmlLoaded';
exports.HTML_LOADED = HTML_LOADED;
var ARCHIVES_JSON_LOADED = 'archivesJSONLoaded';
exports.ARCHIVES_JSON_LOADED = ARCHIVES_JSON_LOADED;
var ARCHIVES_PAGE_LOADED = 'archivesPAGELoaded';
exports.ARCHIVES_PAGE_LOADED = ARCHIVES_PAGE_LOADED;
var ARCHIVES_ENTRY_LOADED = 'archivesEntryLoaded';
exports.ARCHIVES_ENTRY_LOADED = ARCHIVES_ENTRY_LOADED;
var PROJECT_UPDATED = 'projectUpdated';
exports.PROJECT_UPDATED = PROJECT_UPDATED;
var PROJECT_ADDED = 'projectAdded';
exports.PROJECT_ADDED = PROJECT_ADDED;
var PROJECTS_SORTED = 'projectsSorted';
exports.PROJECTS_SORTED = PROJECTS_SORTED;
var DataEvent = function DataEvent() {
_classCallCheck(this, DataEvent);
};
var _default = new DataEvent();
exports.default = _default;
},{}],"../../../default/src/com/tools/utilities/DataUtils.jsx":[function(require,module,exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.CONTENT_TYPE_FORM = exports.CONTENT_TYPE_JSON = exports.REQUEST_TYPE_DELETE = exports.REQUEST_TYPE_PUT = exports.REQUEST_TYPE_GET = exports.REQUEST_TYPE_POST = void 0;
var _EventEmitter2 = _interopRequireDefault(require("../events/EventEmitter.jsx"));
var DataEvent = _interopRequireWildcard(require("../events/DataEvent.jsx"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
var REQUEST_TYPE_POST = "POST";
exports.REQUEST_TYPE_POST = REQUEST_TYPE_POST;
var REQUEST_TYPE_GET = "GET";
exports.REQUEST_TYPE_GET = REQUEST_TYPE_GET;
var REQUEST_TYPE_PUT = "PUT";
exports.REQUEST_TYPE_PUT = REQUEST_TYPE_PUT;
var REQUEST_TYPE_DELETE = "DELETE";
exports.REQUEST_TYPE_DELETE = REQUEST_TYPE_DELETE;
var CONTENT_TYPE_JSON = 'json';
exports.CONTENT_TYPE_JSON = CONTENT_TYPE_JSON;
var CONTENT_TYPE_FORM = 'x-www-form-urlencoded';
exports.CONTENT_TYPE_FORM = CONTENT_TYPE_FORM;
var DataUtils =
/*#__PURE__*/
function (_EventEmitter) {
_inherits(DataUtils, _EventEmitter);
//--------------------------
// constructor
//--------------------------
function DataUtils() {
var _this;
_classCallCheck(this, DataUtils);
_this = _possibleConstructorReturn(this, _getPrototypeOf(DataUtils).call(this));
var self = _assertThisInitialized(_assertThisInitialized(_this));
return _this;
} //--------------------------
// methods
//--------------------------
_createClass(DataUtils, [{
key: "request",
value: function request(requestURL, eventType) {
var requestType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : REQUEST_TYPE_GET;
var contentType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : CONTENT_TYPE_JSON;
var requestData = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var self = this;
return new Promise(function (resolve, reject) {
var request = new XMLHttpRequest();
request.upload.onprogress = self.handleLoadProgress;
request.open(requestType, requestURL, true);
request.onload = function (e) {
if (request.status == 200) {
resolve({
request: request,
eventType: eventType
});
} else {
reject({
request: request,
eventType: eventType
});
}
;
};
if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {
switch (contentType) {
case CONTENT_TYPE_JSON:
request.setRequestHeader("Content-type", "application/" + contentType);
request.send(JSON.stringify(requestData));
break;
case CONTENT_TYPE_FORM:
request.send(requestData);
break;
}
} else {
request.send();
}
});
}
}, {
key: "imgLoad",
value: function imgLoad(url) {
'use strict'; // Create new promise with the Promise() constructor;
// This has as its argument a function with two parameters, resolve and reject
return new Promise(function (resolve, reject) {
// Standard XHR to load an image
var request = new XMLHttpRequest();
request.open('GET', url);
request.responseType = 'blob'; // When the request loads, check whether it was successful
request.onload = function () {
if (request.status === 200) {
// If successful, resolve the promise by passing back the request response
resolve(request.response);
} else {
// If it fails, reject the promise with a error message
reject(new Error('Image didn\'t load successfully; error code:' + request.statusText));
}
};
request.onerror = function () {
// Also deal with the case when the entire request fails to begin with
// This is probably a network error, so reject the promise with an appropriate message
reject(new Error('There was a network error.'));
}; // Send the request
request.send();
});
}
}, {
key: "loadImage",
value: function loadImage(src) {
'use strict';
var self = this;
return new Promise(function (resolve, reject) {
// Get a reference to the body element, and create a new image object
var body = document.querySelector('body'),
myImage = new Image();
myImage.crossOrigin = ""; // or "anonymous"
// Call the function with the URL we want to load, but then chain the
// promise then() method on to the end of it. This contains two callbacks
self.imgLoad(src).then(function (response) {
// The first runs when the promise resolves, with the request.reponse specified within the resolve() method.
var imageURL = window.URL.createObjectURL(response);
resolve(imageURL); //$('background-content').setStyle('background-image', 'url('+imageURL+')') //myImage.src = imageURL;
//console.log(imageURL);
//body.appendChild(myImage);
// The second runs when the promise is rejected, and logs the Error specified with the reject() method.
}, function (Error) {
reject(Error);
});
});
} //--------------------------
// event handlers
//--------------------------
}, {
key: "handleLoadProgress",
value: function handleLoadProgress(e) {
var percentComplete = Math.ceil(e.loaded / e.total * 100); //console.log(percentComplete);
}
}]);
return DataUtils;
}(_EventEmitter2.default);
var _default = DataUtils;
exports.default = _default;
},{"../events/EventEmitter.jsx":"../../../default/src/com/tools/events/EventEmitter.jsx","../events/DataEvent.jsx":"../../../default/src/com/tools/events/DataEvent.jsx"}],"../../../../brain/tools/utilities/DBUtils.js":[function(require,module,exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _DataUtils = _interopRequireDefault(require("../../../themes/default/src/com/tools/utilities/DataUtils"));
var _dexie = _interopRequireDefault(require("dexie"));
var DataEvent = _interopRequireWildcard(require("../events/DataEvent"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var DBUtils =
/*#__PURE__*/
function () {
//--------------------------
// constructor
//--------------------------
function DBUtils() {
_classCallCheck(this, DBUtils);
this.dataUtils = new _DataUtils.default();
this.db = new _dexie.default("fipamo_posts");
this.db.version(1).stores({
postList: 'id,post'
});
} //--------------------------
// methods
//--------------------------
_createClass(DBUtils, [{
key: "resetLocal",
value: function resetLocal(array) {
var self = this;
return new Promise(function (resolve, reject) {
self.db.postList.clear().then(function (result) {
self.db.postList.bulkAdd(array).then(function (key) {
self.db.postList.toArray(function (array) {
var event = DataEvent.LOCAL_DB_READY;
resolve({
event: event
});
});
}).catch(_dexie.default.BulkError, function (e) {
reject({
e: e
});
});
});
});
} //--------------------------
// event handlers
//--------------------------
}]);
return DBUtils;
}();
exports.default = DBUtils;
},{"../../../themes/default/src/com/tools/utilities/DataUtils":"../../../default/src/com/tools/utilities/DataUtils.jsx","dexie":"../../../../node_modules/dexie/dist/dexie.es.js","../events/DataEvent":"../../../../brain/tools/events/DataEvent.js"}],"Base.js":[function(require,module,exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
@ -37561,7 +37952,7 @@ var DataEvent = _interopRequireWildcard(require("../../../../brain/tools/events/
var _DashManager = _interopRequireDefault(require("./controllers/DashManager")); var _DashManager = _interopRequireDefault(require("./controllers/DashManager"));
var _dexie = _interopRequireDefault(require("dexie")); var _DBUtils = _interopRequireDefault(require("../../../../brain/tools/utilities/DBUtils"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@ -37579,13 +37970,13 @@ function () {
//-------------------------- //--------------------------
// constructor // constructor
//-------------------------- //--------------------------
//TODO: Flip to unified structure defined in BMG, brah
function Base() { function Base() {
_classCallCheck(this, Base); _classCallCheck(this, Base);
var self = this; var self = this;
this.dashManager = []; this.dashManager = [];
this.dataUtils = new _DataUtils.default(); this.dataUtils = new _DataUtils.default();
this.dbUtils = new _DBUtils.default();
this.settings = []; this.settings = [];
this.cacheAssets(); this.cacheAssets();
this.storeLocalData(); this.storeLocalData();
@ -37614,18 +38005,10 @@ function () {
}); });
} }
var fipamoPosts = new _dexie.default("fipamo_posts"); self.dbUtils.resetLocal(list).then(function (r) {
fipamoPosts.version(1).stores({
postList: 'id, post'
});
fipamoPosts.postList.clear().then(function (result) {
fipamoPosts.postList.bulkAdd(list).then(function (key) {
self.start(); self.start();
fipamoPosts.postList.toArray(function (array) {//console.log(array[21].post.title); }).catch(function (err) {
}); console.log(err);
}).catch(_dexie.default.BulkError, function (e) {
console.log(e);
});
}); });
}).catch(function (err) { }).catch(function (err) {
console.log(err); console.log(err);
@ -37652,7 +38035,7 @@ function () {
}(); }();
exports.default = Base; exports.default = Base;
},{"../../../../brain/tools/utilities/DataUtils":"../../../../brain/tools/utilities/DataUtils.js","../../../../brain/tools/events/DataEvent":"../../../../brain/tools/events/DataEvent.js","./controllers/DashManager":"controllers/DashManager.js","dexie":"../../../../node_modules/dexie/dist/dexie.es.js"}],"Start.js":[function(require,module,exports) { },{"../../../../brain/tools/utilities/DataUtils":"../../../../brain/tools/utilities/DataUtils.js","../../../../brain/tools/events/DataEvent":"../../../../brain/tools/events/DataEvent.js","./controllers/DashManager":"controllers/DashManager.js","../../../../brain/tools/utilities/DBUtils":"../../../../brain/tools/utilities/DBUtils.js"}],"Start.js":[function(require,module,exports) {
"use strict"; "use strict";
var _Base = _interopRequireDefault(require("./Base")); var _Base = _interopRequireDefault(require("./Base"));

File diff suppressed because one or more lines are too long

View file

@ -1,8 +1,4 @@
#dash-menu #dash-menu
a#settings(href="/@/dashboard/settings")
svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-cog')
label Settings
a#entries(href="/@/dashboard/posts") a#entries(href="/@/dashboard/posts")
svg(viewBox="0 0 20 20" class="icons") svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-book') use(xlink:href='/dash/assets/images/sprite.svg#entypo-book')
@ -15,6 +11,10 @@
svg(viewBox="0 0 20 20" class="icons") svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-suitcase') use(xlink:href='/dash/assets/images/sprite.svg#entypo-suitcase')
label Folio label Folio
a#settings(href="/@/dashboard/settings")
svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-cog')
label Settings
a#menu(href="") a#menu(href="")
svg(viewBox="0 0 20 20" class="icons") svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-list') use(xlink:href='/dash/assets/images/sprite.svg#entypo-list')

View file

@ -10,18 +10,18 @@ import DataUtils,
from '../../../../brain/tools/utilities/DataUtils'; from '../../../../brain/tools/utilities/DataUtils';
import * as DataEvent from '../../../../brain/tools/events/DataEvent'; import * as DataEvent from '../../../../brain/tools/events/DataEvent';
import DashManager from './controllers/DashManager'; import DashManager from './controllers/DashManager';
import Dexie from 'dexie'; import DBUtils from '../../../../brain/tools/utilities/DBUtils';
export default class Base export default class Base
{ {
//-------------------------- //--------------------------
// constructor // constructor
//-------------------------- //--------------------------
//TODO: Flip to unified structure defined in BMG, brah
constructor() constructor()
{ {
var self = this; var self = this;
this.dashManager = []; this.dashManager = [];
this.dataUtils = new DataUtils(); this.dataUtils = new DataUtils();
this.dbUtils = new DBUtils();
this.settings = []; this.settings = [];
this.cacheAssets(); this.cacheAssets();
this.storeLocalData(); this.storeLocalData();
@ -44,25 +44,11 @@ export default class Base
for (let index = 0; index < posts.length; index++) { for (let index = 0; index < posts.length; index++) {
list.push({id:posts[index].id ,post:posts[index].post}); list.push({id:posts[index].id ,post:posts[index].post});
} }
var fipamoPosts = new Dexie("fipamo_posts"); self.dbUtils.resetLocal(list).then(r=>{
fipamoPosts.version(1).stores(
{
postList: 'id, post'
});
fipamoPosts.postList.clear().then(result =>
{
fipamoPosts.postList.bulkAdd(list).then(key =>
{
self.start(); self.start();
fipamoPosts.postList.toArray(array => }).catch(err=>{
{ console.log(err);
//console.log(array[21].post.title); });
})
}).catch(Dexie.BulkError, e =>
{
console.log(e);
})
})
}).catch((err) => }).catch((err) =>
{ {
console.log(err); console.log(err);