From ca6e9e488b2bcdbbfe9b311bfed2300d0a13f353 Mon Sep 17 00:00:00 2001 From: Ro Date: Wed, 17 Jun 2020 16:45:55 -0700 Subject: [PATCH] removed uneccessary util files, moved token set up to API util constructor, notifications style tweak --- src/com/controllers/NavIndex.js | 1 - src/com/controllers/PageEditor.js | 2 +- src/com/controllers/SettingsIndex.js | 1 - src/com/utils/APIUtils.js | 8 +- src/com/utils/DBUtils.js | 178 --------------------------- src/com/utils/RightsManager.js | 137 --------------------- src/styles/main/_structure.styl | 2 +- 7 files changed, 5 insertions(+), 324 deletions(-) delete mode 100644 src/com/utils/DBUtils.js delete mode 100644 src/com/utils/RightsManager.js diff --git a/src/com/controllers/NavIndex.js b/src/com/controllers/NavIndex.js index d7f6b45..080fb95 100644 --- a/src/com/controllers/NavIndex.js +++ b/src/com/controllers/NavIndex.js @@ -9,7 +9,6 @@ export default class NavIndex { // constructor //-------------------------- constructor() { - api.authStatus(); this.start(); } //-------------------------- diff --git a/src/com/controllers/PageEditor.js b/src/com/controllers/PageEditor.js index 9418705..de60345 100644 --- a/src/com/controllers/PageEditor.js +++ b/src/com/controllers/PageEditor.js @@ -7,7 +7,7 @@ import ApiUtils, { import * as DataEvent from '../events/DataEvent'; import PageActions from '../actions/PageActions'; import * as EditorEvent from '../events/EditorEvent'; -import TinyDatePicker from 'tiny-date-picker'; +//import TinyDatePicker from 'tiny-date-picker'; import TextEditor from '../ui/TextEditor'; import Notfications from '../ui/Notifications'; const api = new ApiUtils(); diff --git a/src/com/controllers/SettingsIndex.js b/src/com/controllers/SettingsIndex.js index 2e55169..f9a7538 100644 --- a/src/com/controllers/SettingsIndex.js +++ b/src/com/controllers/SettingsIndex.js @@ -15,7 +15,6 @@ export default class SettingsIndex { // constructor //-------------------------- constructor() { - api.authStatus(); this.start(); } //-------------------------- diff --git a/src/com/utils/APIUtils.js b/src/com/utils/APIUtils.js index 6dc74a0..49c8f5e 100644 --- a/src/com/utils/APIUtils.js +++ b/src/com/utils/APIUtils.js @@ -12,11 +12,6 @@ export default class APIUtils { constructor() { this.percentComplete = 0; this.token = null; - } - //-------------------------- - // methods - //-------------------------- - authStatus() { this.request('/api/v1/auth/status').then(r => { let response = JSON.parse(r.request['response']); if (response.type === DataEvent.API_REQUEST_GOOD) { @@ -26,6 +21,9 @@ export default class APIUtils { } }); } + //-------------------------- + // methods + //-------------------------- request( requestURL, eventType, diff --git a/src/com/utils/DBUtils.js b/src/com/utils/DBUtils.js deleted file mode 100644 index ae029c8..0000000 --- a/src/com/utils/DBUtils.js +++ /dev/null @@ -1,178 +0,0 @@ -'use strict'; -import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_JSON } from './DataUtils'; -import Dexie from 'dexie'; -import * as DataEvent from '../events/DataEvent'; -export var COUNT; -export var FINAL_KEY; -export default class DBUtils { - //-------------------------- - // constructor - //-------------------------- - constructor() { - /** - * NOTE: DB ERRORS REPLICATE. - * WHEN FIXING A BUG, FIX DATA WITH JSON BACKUP - */ - this.dataUtils = new DataUtils(); - this.db = new Dexie('fipamo_posts'); - this.db.version(1).stores({ - postList: 'id,post' - }); - this.db.postList.toArray(array => { - COUNT = array.length; - FINAL_KEY = 0; - if (COUNT != 0) FINAL_KEY = array[COUNT - 1].id; - }); - } - //-------------------------- - // methods - //-------------------------- - modify(id, postData) { - let self = this; - let freshID; - return new Promise(function(resolve, reject) { - if (id == null) { - self.db.postList - .put(postData) - .then(fresh => { - freshID = fresh; - }) - .catch(e => { - let err = { - message: 'PUT ERROR', - error: e - }; - - return err; - }); - } else { - //console.log("UPDATED", postData); - self.db.postList - .update(Number(id), { - post: postData - }) - .then(() => {}) - .catch(e => { - let err = { - message: 'UPDATE ERROR', - error: e - }; - return err; - }); - } - self.db.postList.toArray(array => { - self.syncRemote(array, freshID) - .then(response => { - resolve({ - response - }); - }) - .catch(err => { - reject({ - err - }); - }); - }); - }); - } - syncLocal(array) { - let self = this; - return new Promise(function(resolve, reject) { - self.db.postList.clear().then(() => { - self.db.postList - .bulkAdd(array) - .then(() => { - self.db.postList.toArray(() => { - let event = DataEvent.LOCAL_DB_READY; - resolve({ - event - }); - }); - }) - .catch(Dexie.BulkError, e => { - reject({ - e - }); - }); - }); - }); - } - syncRemote(db, newPostId) { - let self = this; - return new Promise(function(resolve, reject) { - self.dataUtils - .request( - '/api/post/sync', - DataEvent.POSTS_SYNCED, - REQUEST_TYPE_POST, - CONTENT_TYPE_JSON, - db - ) - .then(response => { - let bounce = { - message: response, - newPost: newPostId - }; - resolve(bounce); - }) - .catch(err => { - reject(err); - }); - }); - } - getPost(id) { - let self = this; - if (id == null) { - return new Promise(function(resolve, reject) { - self.db.postList - .toArray(array => { - resolve(array); - }) - .catch(err => { - reject(err); - }); - }); - } else { - return new Promise(function(resolve, reject) { - self.db.postList - .get(Number(id)) - .then(obj => { - resolve(obj); - }) - .catch(err => { - reject(err); - }); - }); - } - } - archivePost(id, archive) { - let self = this; - return new Promise(function(resolve, reject) { - self.db.postList - .update(Number(id), { - post: archive - }) - .then(() => { - self.db.postList.toArray(array => { - self.syncRemote(array, null) - .then(response => { - resolve({ - response - }); - }) - .catch(err => { - reject({ - err - }); - }); - }); - }) - .catch(() => { - //console.log('ERROR', e); - }); - }); - } - //-------------------------- - // event handlers - //-------------------------- -} diff --git a/src/com/utils/RightsManager.js b/src/com/utils/RightsManager.js deleted file mode 100644 index 1fd913d..0000000 --- a/src/com/utils/RightsManager.js +++ /dev/null @@ -1,137 +0,0 @@ -export const roles = { - hnic: { - client_admin: { - create: true, - read: true, - update: true, - delete: true - }, - client_user: { - create: true, - read: true, - update: true, - delete: true - }, - client_project: { - create: true, - read: true, - update: true, - delete: true - }, - folio_project: { - create: true, - read: true, - update: true, - delete: true - }, - bookmark: { - create: true, - read: true, - update: true, - delete: true - }, - post: { - create: true, - read: true, - update: true, - delete: true - }, - settings: { - create: true, - read: true, - update: true, - delete: true - } - }, - client: { - client_admin: { - create: false, - read: true, - update: false, - delete: false - }, - client_user: { - create: true, - read: true, - update: true, - delete: true - }, - client_project: { - create: true, - read: true, - update: true, - delete: false - }, - folio_project: { - create: false, - read: false, - update: false, - delete: false - } - }, - user: { - client_admin: { - create: false, - read: false, - update: false, - delete: false - }, - client_user: { - create: false, - read: true, - update: false, - delete: false - }, - client_project: { - create: false, - read: true, - update: true, - delete: false - }, - folio_project: { - create: false, - read: false, - update: false, - delete: false - }, - bookmark: { - create: true, - read: true, - update: true, - delete: true - }, - post: { - create: false, - read: false, - update: false, - delete: false - } - } -}; -export const TASK_CREATE = 'create'; -export const TASK_UPDATE = 'update'; -export const TASK_READ = 'read'; -export const TASK_DELETE = 'delete'; -export const OBJECT_CLIENT_ADMIN = 'client_admin'; -export const OBJECT_CLIENT_USER = 'client_user'; -export const OBJECT_PROJECT_CLIENT = 'client_project'; -export const OBJECT_PROJECT_FOLIO = 'folio_project'; -export const OBJECT_BOOKMARK = 'bookmark'; -export const OBJECT_POST = 'post'; -export const OBJECT_SETTINGS = 'settings'; -export default class RightsManager { - //-------------------------- - // constructor - //-------------------------- - constructor() {} - //-------------------------- - // methods - //-------------------------- - check(role, object, task) { - //console.log(role + " *** " + object + " *** " + task); - return roles[role][object][task]; - } - //-------------------------- - // event handlers - //-------------------------- -} diff --git a/src/styles/main/_structure.styl b/src/styles/main/_structure.styl index 0f85353..71beb7a 100644 --- a/src/styles/main/_structure.styl +++ b/src/styles/main/_structure.styl @@ -21,7 +21,7 @@ svg.icons z-index 2000 height 10% width 100% - display block + display none align-items center justify-content center padding 0