From b6425e2c0727dd13e93d028c8f653ef7e03544dc Mon Sep 17 00:00:00 2001 From: ro Date: Tue, 7 May 2024 14:17:18 -0600 Subject: [PATCH] quick clean up changes to front end scripting has rendered some files obsolete so they have been removed. removed some todo notes that have already been implemented --- app/Services/MaintenanceService.php | 1 - public/assets/scripts/dash/app/Base.js | 211 ------------------ public/assets/scripts/dash/app/Start.js | 9 - .../dash/app/controllers/InitController.js | 1 - .../dash/app/controllers/PageEditor.js | 1 - 5 files changed, 223 deletions(-) delete mode 100644 public/assets/scripts/dash/app/Base.js delete mode 100644 public/assets/scripts/dash/app/Start.js diff --git a/app/Services/MaintenanceService.php b/app/Services/MaintenanceService.php index 0a93145..9534b16 100644 --- a/app/Services/MaintenanceService.php +++ b/app/Services/MaintenanceService.php @@ -51,7 +51,6 @@ class MaintenanceService $zip->addGlob($months . '/*.md', GLOB_BRACE, $options); } } - //TODO: add collectors for docs and vids //gather paths for blog images $blogImages = []; $dir = new \RecursiveDirectoryIterator('../public/assets/images/blog'); diff --git a/public/assets/scripts/dash/app/Base.js b/public/assets/scripts/dash/app/Base.js deleted file mode 100644 index b247389..0000000 --- a/public/assets/scripts/dash/app/Base.js +++ /dev/null @@ -1,211 +0,0 @@ -import FipamoAdminAPI from '../libraries/FipamoAdminAPI'; -import Maintenance from './controllers/MaintenanceManager'; -import DataUitls from './utils/DataUtils'; -import * as DataEvent from './events/DataEvent'; -import DashManager from './controllers/DashManager'; -import Notfications from './ui/Notifications'; -const data = new DataUitls(); -const notify = new Notfications(); - -export default class Base { - //-------------------------- - // constructor - //-------------------------- - constructor() { - this.processing = false; - this.start(); - } - - //-------------------------- - // methods - //-------------------------- - - //TODO: Move init functions and set up to their own class - start() { - if ( - document.getElementById('login') || - document.querySelector('[role="site-restore"]') - ) { - var options = document.getElementsByClassName('init-option'); - for (let index = 0; index < options.length; index++) { - options[index].addEventListener('click', e => this.handleOptions(e)); - } - if (document.getElementById('login')) { - document - .getElementById('login-btn') - .addEventListener('click', e => this.handleLogin(e)); - } else { - document - .getElementById('init-blog') - .addEventListener('click', e => this.handleSetup(e)); - document - .getElementById('blog-restore') - .addEventListener('click', e => this.handleRestore(e)); - } - } else if (document.getElementById('dash-reset')) { - document - .getElementById('get-secret-btn') - .addEventListener('click', e => this.handleReset(e)); - - document - .getElementById('reset-btn') - .addEventListener('click', e => this.handleReset(e)); - } else { - new DashManager(); - } - } - //-------------------------- - // event handlers - //-------------------------- - handleLogin(e) { - if (this.processing) return; - let self = this; - e.preventDefault(); - let authForm = data.formDataToJSON(document.getElementById('login')); - //notify.alert('Looking, hold up', null); - let api = new FipamoAdminAPI(); - this.processing = true; - api.login(authForm) - .then(response => { - self.processing = false; - if (response.type === DataEvent.REQUEST_LAME) { - e.target.innerHTML = response.message; - } else { - e.target.innerHTML = response.message; - setTimeout(() => { - window.location = '/dashboard'; - }, 500); - } - }) - .catch(err => { - self.processing = false; - }); - } - - handleSetup(e) { - if (this.processing) return; - let self = this; - e.stopPropagation(); - e.preventDefault(); - let setUpForm = data.formDataToJSON(document.getElementById('init-form')); - let mm = new Maintenance(); - this.processing = true; - mm.create(setUpForm) - .then(response => { - if (response.type === DataEvent.API_INIT_LAME) { - self.processing = false; - e.target.innerHTML = response.message; - } else { - self.processing = false; - e.target.innerHTML = response.message; - setTimeout(() => { - window.location = '/dashboard'; - }, 700); - } - }) - .catch(err => { - self.processing = false; - //notify.alert(err, false); - }); - } - - handleRestore(e) { - if (this.processing) return; - let self = this; - e.stopPropagation(); - e.preventDefault(); - let mm = new Maintenance(); - var form = document.getElementById('init-restore'); - this.processing = true; - mm.restore(form) - .then(response => { - if (response.type === DataEvent.REQUEST_LAME) { - self.processing = false; - e.target.innerHTML = response.message; - } else { - self.processing = false; - e.target.innerHTML = response.message; - setTimeout(() => { - window.location = '/dashboard'; - }, 1500); - } - }) - .catch(err => { - self.processing = false; - e.target.innerHTML = err; - }); - } - - handleReset(e) { - e.stopPropagation(); - e.preventDefault(); - let self = this; - let mm = new Maintenance(); - if (e.target.id == 'get-secret-btn') { - let data = { - email: document.getElementById('email').value, - task: 'retrieveSecret' - }; - this.processing = true; - mm.secret(data) - .then(response => { - self.processing = false; - if (response.secret) { - document.getElementById('secret').value = response.secret; - notify.alert(response.message, true); - } else { - if (response.type == 'mailSent') { - notify.alert(response.message, true); - } else { - notify.alert(response.message, false); - } - } - }) - .catch(err => { - self.processing = false; - notify.alert(err, false); - }); - } else { - let data = { - newPass: document.getElementById('new_password').value, - newPassConfirm: document.getElementById('new_password2').value, - secret: document.getElementById('secret').value - }; - mm.newPass(data) - .then(response => { - self.processing = false; - if (response.type == 'passNotCreated') { - notify.alert(response.message, false); - } else { - notify.alert(response.message, true); - setTimeout(() => { - window.location = '/dashboard'; - }, 1000); - } - }) - .catch(err => { - self.processing = false; - notify.alert(err, false); - }); - } - } - handleOptions(e) { - e.stopPropagation(); - e.preventDefault(); - let init = document.querySelector('[role="restore-fresh"]'); - let restore = document.querySelector('[role="restore-backup"]'); - if (e.target.id === 'init-switch-restore') { - init.style.display = 'none'; - init.style.visibility = 'hidden'; - - restore.style.display = 'grid'; - restore.style.visibility = 'visible'; - } else { - init.style.display = 'grid'; - init.style.visibility = 'visible'; - - restore.style.display = 'none'; - restore.style.visibility = 'hidden'; - } - } -} diff --git a/public/assets/scripts/dash/app/Start.js b/public/assets/scripts/dash/app/Start.js deleted file mode 100644 index b843adb..0000000 --- a/public/assets/scripts/dash/app/Start.js +++ /dev/null @@ -1,9 +0,0 @@ -import Base from './Base'; - -document.addEventListener( - 'DOMContentLoaded', - function () { - new Base(); - }, - false -); diff --git a/public/assets/scripts/dash/app/controllers/InitController.js b/public/assets/scripts/dash/app/controllers/InitController.js index 898fb63..e8b1256 100644 --- a/public/assets/scripts/dash/app/controllers/InitController.js +++ b/public/assets/scripts/dash/app/controllers/InitController.js @@ -19,7 +19,6 @@ export default class InitController { // methods //-------------------------- - //TODO: Move init functions and set up to their own class start() { if (document.getElementById('login') || document.querySelector('.site-restore')) { var options = document.getElementsByClassName('init-option'); diff --git a/public/assets/scripts/dash/app/controllers/PageEditor.js b/public/assets/scripts/dash/app/controllers/PageEditor.js index a90736a..52e26d3 100644 --- a/public/assets/scripts/dash/app/controllers/PageEditor.js +++ b/public/assets/scripts/dash/app/controllers/PageEditor.js @@ -8,7 +8,6 @@ import Maintenance from './MaintenanceManager.js'; import * as DataEvent from '../events/DataEvent.js'; import PageActions from '../actions/PageActions.js'; import * as EditorEvent from '../events/EditorEvent.js'; -//import TinyDatePicker from 'tiny-date-picker'; TODO: Reactivate for scheduled publishing import TextEditor from '../ui/TextEditor.js'; import Notfications from '../ui/Notifications.js'; import FileManager from '../ui/FileManager.js';