Skip to content

Commit

Permalink
Merge pull request #185 from ncsa/184-import-is-not-working-properly
Browse files Browse the repository at this point in the history
184 import is not working properly
  • Loading branch information
longshuicy authored Aug 29, 2024
2 parents 7ab6db9 + 170eef1 commit 5172848
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Import data is not working properly [#184](https://github.com/ncsa/standalone-smm-smile/issues/184)

## [0.4.2] - 2024-07-17
### Added
- Provide google api key to authorize YouTube Data API [#179](https://github.com/ncsa/standalone-smm-smile/issues/179)
Expand Down
2 changes: 1 addition & 1 deletion www/public/bootstrap/js/customized/analyses/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ $.getScript("bootstrap/js/customized/view_helperFunc.js", function(){

// add preview and column
$previewContent.append(arrayToTable(text_data.slice(0, 11), '#selectFileTable'));
$columnContent.append(extractHeader2(text_data));
$columnContent.append(extractHeaderRadio(text_data));
$preview.show();
$column.show();

Expand Down
43 changes: 33 additions & 10 deletions www/public/bootstrap/js/customized/view_helperFunc.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,38 @@ function escapeHtml(str) {
.replace(/'/g, ''');
}

function extractHeader2(array) {

function extractHeaderRadio(array) {
var headerContent = '';
var column_header = array[0];
$.each(column_header, function (i, val) {
// Check the first item
if (i === 0) {
headerContent += `<label class="radio-inline">
<input type="radio" class="customized-radio" name="selectFileColumn" id="` + val
+ `" value="` + val + `" checked>` + val + `</label>`;
} else {
headerContent += `<label class="radio-inline">
<input type="radio" class="customized-radio" name="selectFileColumn" id="` + val
+ `" value="` + val + `">` + val + `</label>`;
}
});
return headerContent;
}

function extractHeaderCheckBox(array) {
var headerContent = '';
column_header = array[0];
var column_header = array[0];
$.each(column_header, function (i, val) {
//check the first item
// Check the first item
if (i === 0) {
headerContent += `<label class=radio-inline>
<input type="radio" class="customized-radio" name="selectFileColumn",id=`
+ val + ` value=` + val + ` checked></div>` + val + ` </label>`;
headerContent += `<label class="checkbox-inline">
<input type="checkbox" class="customized-checkbox" name="selectFileColumn" id="` + val
+ `" value="` + val + `" checked>` + val + `</label>`;
} else {
headerContent += `<label class=radio-inline>
<input type="radio" class="customized-radio" name="selectFileColumn",id=`
+ val + ` value=` + val + `></div>` + val + ` </label>`;
headerContent += `<label class="checkbox-inline">
<input type="checkbox" class="customized-checkbox" name="selectFileColumn" id="` + val
+ `" value="` + val + `">` + val + `</label>`;
}
});
return headerContent;
Expand Down Expand Up @@ -174,6 +193,10 @@ function processData(csv) {
$("#datasrc-criteria-hint").html("<p>Based on the column of your imported file, it is likely that you uploaded a " +
"<u>Reddit Comment</u> dataset.</p>")
}
else if (previewLinesWords[0].indexOf('snippet.title') > 0 || previewLinesWords[0].indexOf('snippet.description') > 0){
$("#datasrc-criteria-hint").html("<p>Based on the column of your imported file, it is likely that you uploaded a " +
"<u>YouTube video/channel/playlist search collection</u> dataset.</p>")
}
else{
$("#datasrc-criteria-hint").html("<p>We cannot detect the file category, make sure you choose <u>Others</u> in the category.</p>")
}
Expand All @@ -183,7 +206,7 @@ function processData(csv) {

// set column headers for userspec-Others-metadata
$("#column-header-selection").empty();
$("#column-header-selection").append(extractHeader1(previewLinesWords));
$("#column-header-selection").append(extractHeaderCheckBox(previewLinesWords));

}

Expand Down
16 changes: 15 additions & 1 deletion www/public/bootstrap/js/customized/view_import.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ $("#datasrc-category").on("change", function(){
$("#datasrc-criteria").html("<p>Make sure your file has column <u>body</u>.</p>")
}
else if (selectedItem === 'youtube-Search-Video' || selectedItem === 'youtube-Search-Channel'|| selectedItem === 'youtube-Search-Playlist') {
$("#datasrc-criteria").html("<p>Make sure your file has column <u>snippet.title</u> or <u>snippet.description</u>.</p>")
$("#datasrc-criteria").html("<p>Make sure your file has column <u>title</u>, <u>description</u>, " +
"<u>snippet.title</u>, or <u>snippet.description</u>.</p>")
}
else if (selectedItem === 'userspec-Others') {
$("#datasrc-criteria").html("<p>You provide the <u>column headers</u> that you would like to analyze, as well as select " +
Expand Down Expand Up @@ -167,6 +168,19 @@ function importFormValidate(){
return false;
}
}
else if (category === 'youtube-Search-Video' || category === 'youtube-Search-Channel'|| category === 'youtube-Search-Playlist') {
if (importedColumnHeaders.indexOf('title') === -1
&& importedColumnHeaders.indexOf('description') === -1
&& importedColumnHeaders.indexOf('snippet.description') === -1
&& importedColumnHeaders.indexOf('snippet.description') === -1
){
$("#modal-message").append("<h4>Your file must have <u>title</u> and/or <u>description</u> " +
"and/or <u>snippet.title</u> and/or <u>snippet.description</u> column to be " +
"categorized as YouTube video/channel/playlist search collection.</h4>");
$("#alert").modal('show');
return false;
}
}

return true;
}
Expand Down

0 comments on commit 5172848

Please sign in to comment.