Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change seesionStorage with localStorage #443

Merged
merged 1 commit into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function AlgorithmOptions({


function openTrueOrFalse_algorithm_popup(){
if (sessionStorage.getItem("algorithm-popup") == "true"){
if (localStorage.getItem("algorithm-popup") == "true"){

// if (document.getElementById("aiTooglePopup")!==null){
// document.getElementById("aiTooglePopup").style.cssText = "display: block !important";
Expand Down Expand Up @@ -135,9 +135,9 @@ function AlgorithmOptions({

document.getElementById("algorithm-popup").style.cssText += ';display:none !important;';

sessionStorage.setItem("algorithm-popup", "true");
localStorage.setItem("algorithm-popup", "true");
// show the local storage on the console
console.log("algorithm-popup", sessionStorage.getItem("algorithm-popup"));
console.log("algorithm-popup", localStorage.getItem("algorithm-popup"));


// get class name content under id aiTooglePopup
Expand Down
13 changes: 7 additions & 6 deletions lab/webapp/src/components/Builder/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Builder extends Component {

function openTrueOrFalse_submit_experiment_popup()
{
if (sessionStorage.getItem("submit-experiment-popup") == "true"){
if (localStorage.getItem("submit-experiment-popup") == "true"){
return false;
}
else{
Expand Down Expand Up @@ -152,11 +152,12 @@ class Builder extends Component {
disabled={isSubmitting}
// onClick={this.handleSubmitExperiment}
onClick={() => {
sessionStorage.setItem("algorithm-popup", "true");
localStorage.setItem("algorithm-popup", "true");

// param-popup
sessionStorage.setItem("param-popup", "true");
localStorage.setItem("param-popup", "true");

sessionStorage.setItem("submit-experiment-popup", "true");
localStorage.setItem("submit-experiment-popup", "true");

this.handleSubmitExperiment();

Expand Down Expand Up @@ -187,9 +188,9 @@ class Builder extends Component {

document.getElementById("submit-experiment-popup").style.cssText += ';display:none !important;';

sessionStorage.setItem("submit-experiment-popup", "true");
localStorage.setItem("submit-experiment-popup", "true");
// show the local storage on the console
console.log("submit-experiment-popup", sessionStorage.getItem("submit-experiment-popup"));
console.log("submit-experiment-popup", localStorage.getItem("submit-experiment-popup"));

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ const AddNewDatasetCard = () => {
// console.log("Link", Link);

// var icon_type = "question circle";
// console.log("sessionStorage.getItem(addNewPopup)",sessionStorage.getItem("addNewPopup"))
// console.log("localStorage.getItem(addNewPopup)",localStorage.getItem("addNewPopup"))

function openTrueOrFalse_addNewPopup(){
if (sessionStorage.getItem("addNewPopup") == "true"){
if (localStorage.getItem("addNewPopup") == "true"){

// if (document.getElementById("aiTooglePopup")!==null){
// document.getElementById("aiTooglePopup").style.cssText = "display: block !important";
Expand Down Expand Up @@ -80,7 +80,7 @@ const AddNewDatasetCard = () => {
}

return (
// if sessionStorage does not have addNewPopup
// if localStorage does not have addNewPopup


<Grid.Column className="dataset-card" id= "gridAddNewdataCard" >
Expand Down Expand Up @@ -169,7 +169,7 @@ const AddNewDatasetCard = () => {
content="Add New Dataset"
onClick={() => {

sessionStorage.setItem("addNewPopup", "true")
localStorage.setItem("addNewPopup", "true")
}

}
Expand Down Expand Up @@ -207,9 +207,9 @@ const AddNewDatasetCard = () => {
// save flag to local storage to avoid showing the popup again
// use session storage to avoid showing the popup again

sessionStorage.setItem("addNewPopup", "true");
localStorage.setItem("addNewPopup", "true");
// show the local storage on the console
console.log("addNewPopup", sessionStorage.getItem("addNewPopup"));
console.log("addNewPopup", localStorage.getItem("addNewPopup"));


// add below to App.css in javascript
Expand Down
2 changes: 1 addition & 1 deletion lab/webapp/src/components/DonutChart/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ look here - https://github.com/c3js/c3/issues/493#issuecomment-456686654


// get class_and_file from session storage
const class_and_file = sessionStorage.getItem('class_and_file')
const class_and_file = localStorage.getItem('class_and_file')

// split class_and_file with *
const class_and_file_split_star = class_and_file.split('*')
Expand Down
66 changes: 33 additions & 33 deletions lab/webapp/src/components/FileUpload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,9 +1072,9 @@ handleclassUserTextOnChange(e) {



// console.log("sessionStorage.getItem('class')) ",sessionStorage.getItem('class'))
// console.log("localStorage.getItem('class')) ",localStorage.getItem('class'))
// // if "class" is not in the session storage
// if(!sessionStorage.getItem('class')) {
// if(!localStorage.getItem('class')) {

// this.showErrorModal("Error with class name", "Please write a class name for your dataset");

Expand All @@ -1090,8 +1090,8 @@ handleclassUserTextOnChange(e) {


var class_name_log = true
if (sessionStorage.getItem('class')===null) {
console.log("sessionStorage.getItem('class')",sessionStorage.getItem('class'))
if (localStorage.getItem('class')===null) {
console.log("localStorage.getItem('class')",localStorage.getItem('class'))
class_name_log = false
}

Expand Down Expand Up @@ -1119,13 +1119,13 @@ handleclassUserTextOnChange(e) {
console.log("resp",resp)
console.log("errorRespObj",errorRespObj)

console.log("sessionStorage.getItem('class')",sessionStorage.getItem('class'))
console.log("localStorage.getItem('class')",localStorage.getItem('class'))
console.log("uploadButtonDisabled",this.state.uploadButtonDisabled)


// var class_name_log = true
// if (sessionStorage.getItem('class')===null) {
// console.log("sessionStorage.getItem('class')",sessionStorage.getItem('class'))
// if (localStorage.getItem('class')===null) {
// console.log("localStorage.getItem('class')",localStorage.getItem('class'))
// class_name_log = false
// }

Expand All @@ -1151,11 +1151,11 @@ handleclassUserTextOnChange(e) {
this.setState({uploadButtonDisabled:false});


sessionStorage.removeItem("selectedFile_name");
sessionStorage.setItem("selectedFile_name", this.state.selectedFile.name);
localStorage.removeItem("selectedFile_name");
localStorage.setItem("selectedFile_name", this.state.selectedFile.name);

// get class from selectedFile_name
let class_string = sessionStorage.getItem("class");
let class_string = localStorage.getItem("class");



Expand All @@ -1164,38 +1164,38 @@ handleclassUserTextOnChange(e) {

let class_and_file = class_string + "&" + this.state.selectedFile.name;

// if "class_and_file" is in sessionStorage, get the value
if (sessionStorage.getItem("class_and_file")) {
console.log("class_and_file is in sessionStorage");
let value = sessionStorage.getItem("class_and_file");
// if "class_and_file" is in localStorage, get the value
if (localStorage.getItem("class_and_file")) {
console.log("class_and_file is in localStorage");
let value = localStorage.getItem("class_and_file");
value = value +"*"+class_and_file
sessionStorage.setItem("class_and_file", value);
localStorage.setItem("class_and_file", value);

// remove "class" from sessionStorage
sessionStorage.removeItem("class");
// remove "class" from localStorage
localStorage.removeItem("class");

} else {
// store class_and_file in sessionStorage
sessionStorage.setItem("class_and_file", class_and_file);
sessionStorage.removeItem("class");
// store class_and_file in localStorage
localStorage.setItem("class_and_file", class_and_file);
localStorage.removeItem("class");
}




}
// else if (!sessionStorage.getItem('class')) {
// else if (!localStorage.getItem('class')) {

// this.showErrorModal("Error with class name", "Please write a class name for your dataset");

// this.setState({uploadButtonDisabled:false});
// }

// if there is no 'class' in sessionStorage,
// if there is no 'class' in localStorage,
// make the Upload dataset button disabled
// console.log(sessionStorage.getItem('class'));
// console.log(localStorage.getItem('class'));
// else if (true) {
// console.log("sessionStorage.getItem('class')",sessionStorage.getItem('class'))
// console.log("localStorage.getItem('class')",localStorage.getItem('class'))
// console.log("uploadButtonDisabled",this.state.uploadButtonDisabled)
// this.setState({uploadButtonDisabled:true});
// }
Expand Down Expand Up @@ -1670,21 +1670,21 @@ handleclassUserTextOnChange(e) {
// return {success: true, message: ""}
// console.log(string)
// save experiment.data._id and string to the session stroage
// sessionStorage.setItem("data_id", this.experiment.data._id);
// localStorage.setItem("data_id", this.experiment.data._id);
// this.state.selectedFile.name
// check if selectedFile_name is in the session storage
// if yes, then update the string
// if no, then create a new key-value pair

// remove selectedFile_name from session storage
// sessionStorage.removeItem("selectedFile_name");
// localStorage.removeItem("selectedFile_name");

// sessionStorage.setItem("selectedFile_name", this.state.selectedFile.name);
sessionStorage.setItem("class", string);
// localStorage.setItem("selectedFile_name", this.state.selectedFile.name);
localStorage.setItem("class", string);
console.log("success to store data_id and class in session storage")
// current data name
// experiment.data._id
// sessionStorage.setItem("class", string);
// localStorage.setItem("class", string);
return {success: true, message: string}
}

Expand Down Expand Up @@ -3345,7 +3345,7 @@ handleclassUserTextOnChange(e) {


function openTrueOrFalse_file_upload_popup(){
if (sessionStorage.getItem("file_upload_popup") == "true"){
if (localStorage.getItem("file_upload_popup") == "true"){

// if (document.getElementById("aiTooglePopup")!==null){
// document.getElementById("aiTooglePopup").style.cssText = "display: block !important";
Expand Down Expand Up @@ -3433,7 +3433,7 @@ handleclassUserTextOnChange(e) {
<Button
// onClick={() => this.resetState()}
// when click on cancel button, this.resetState() will be called and "class" in session storage will be removed if the "class" exists in the session storage.
onClick={() => {this.resetState(); sessionStorage.removeItem("class");}}
onClick={() => {this.resetState(); localStorage.removeItem("class");}}

inverted
className="file-upload-button"
Expand Down Expand Up @@ -3480,9 +3480,9 @@ handleclassUserTextOnChange(e) {

this.state.file_upload_popup = "none";

sessionStorage.setItem("file_upload_popup", "true");
localStorage.setItem("file_upload_popup", "true");
// show the local storage on the console
console.log("file_upload_popup", sessionStorage.getItem("file_upload_popup"));
console.log("file_upload_popup", localStorage.getItem("file_upload_popup"));

}
}
Expand Down
2 changes: 1 addition & 1 deletion lab/webapp/src/components/ScatterPlot/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ look here - https://github.com/c3js/c3/issues/493#issuecomment-456686654

// another
// get class_and_file from session storage
var class_and_file = sessionStorage.getItem('class_and_file');
var class_and_file = localStorage.getItem('class_and_file');

// console.log("class_and_file in scatter plot: ", class_and_file);

Expand Down