Skip to content

Commit

Permalink
Merge pull request #174 from oracle/toxophilist/sprint-12
Browse files Browse the repository at this point in the history
Hide recover menu when auto saving
  • Loading branch information
toxophilist authored Nov 18, 2020
2 parents 5ffd874 + 9cc5517 commit b415ca1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
11 changes: 8 additions & 3 deletions okitweb/static/okit/js/okit.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,15 +695,20 @@ class OkitSettings {

class OkitAutoSave {
key = "okitJson";
constructor() {
constructor(callback, interval = 60000) {
this.autoInterval = undefined;
this.callback = callback;
this.interval = interval
}

startAutoSave(timeout = 30000) {
startAutoSave() {
this.stopAutoSave();
this.autoInterval = setInterval(() => {
localStorage.setItem(this.key, JSON.stringify(okitJsonModel));
}, timeout);
if (this.callback) {
this.callback();
}
}, this.interval);
localStorage.setItem(this.key, JSON.stringify(okitJsonModel));
}

Expand Down
10 changes: 8 additions & 2 deletions okitweb/static/okit/js/okit_designer.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ function handleRecover(evt) {
displayDesignerView();
displayTreeView();
}
hideRecoverMenuItem();
}
function hideRecoverMenuItem() {
$(jqId('file_recover_menu_item_li')).addClass('hidden');
}
/*
Expand All @@ -93,6 +96,7 @@ function handleNew(evt) {
resetDesigner();
newDiagram();
redrawSVGCanvas();
hideRecoverMenuItem();
}
function newDiagram() {
console.log('Creating New Diagram');
Expand Down Expand Up @@ -178,6 +182,7 @@ function loaded(evt) {
displayOkitJson();
displayDesignerView();
displayTreeView();
hideRecoverMenuItem();
}
function errorHandler(evt) {
console.info('Error: ' + evt.target.error.name);
Expand Down Expand Up @@ -207,6 +212,7 @@ function saveJson(text, filename){
let uri = 'data:text/plain;charset=utf-u,'+encodeURIComponent(text);
triggerDownload(uri, filename);
okitAutoSave.removeAutoSave();
hideRecoverMenuItem();
}
/*
** Save Model As Template
Expand Down Expand Up @@ -561,7 +567,7 @@ function selectQueryLastUsedCompartment() {
}
let queryCount = 0;
function showQueryResults() {
console.log('Generating Query Results');
console.info('Generating Query Results');
let regions = $(jqId('query_region_id')).val();
let request = {};
request.compartment_id = $(jqId('query_compartment_id')).val();
Expand Down Expand Up @@ -603,7 +609,7 @@ function showQueryResults() {
console.info('Region Not Selected.');
}
$(jqId('modal_dialog_wrapper')).addClass('hidden');
console.log();
hideRecoverMenuItem();
}
$(document).ajaxStop(function() {
console.info('All Ajax Functions Stopped');
Expand Down
2 changes: 1 addition & 1 deletion okitweb/static/okit/js/okit_designer_ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $(document).ready(function() {
/*
** Configure Auto Save
*/
okitAutoSave = new OkitAutoSave();
okitAutoSave = new OkitAutoSave(hideRecoverMenuItem);
// Test is Auto Save exists
recovered_model = okitAutoSave.getOkitJsonModel();
if (recovered_model) {$(jqId('file_recover_menu_item_li')).removeClass('hidden');}
Expand Down

0 comments on commit b415ca1

Please sign in to comment.