Skip to content

Commit

Permalink
Fix url parse for csv upload (#180)
Browse files Browse the repository at this point in the history
* Postioning all levels of cell types linearly

* Removing commented code

* new column names added

* CSV file can be uploaded in playground component

* Code smells

* Code smells

* suggested changes

* Code smells and minor changes

* minor changes

* minor changes

* minor changes

* Play ground code refactored for CSV and csv support for compare component

* Minor issues and code smells

* Label syncs and Drop down menu in organ selection can support for csv

* Minor issues

* Regex error solved

* Merge confilcts resolved

Co-authored-by: Vutukuri Sai Ajay <vutukurisaiajay@Vutukuris-MacBook-Pro.local>
  • Loading branch information
vutukuriajay2241 and Vutukuri Sai Ajay authored Jul 2, 2021
1 parent 62f1281 commit e075c2f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
23 changes: 11 additions & 12 deletions projects/v2/src/app/components/compare/compare.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,21 @@ export class CompareComponent implements OnInit {
}

checkLinkFormat(url: string) {
const matches = /\/([\w-_]{15,})\/(.*?gid=(\d+))?|\w*csv$/.exec(url);
if (matches) {
if (matches[0] === 'csv') {
if (url.startsWith('https://docs.google.com/spreadsheets/d/')) {
const splitUrl = url.split('/');
if (splitUrl.length === 7) {
return {
sheetID: '0',
gid: '0',
csvUrl: url
};
}
else {
return {
sheetID: matches[1],
gid: matches[3],
sheetID: splitUrl[5],
gid: splitUrl[6].split('=')[1],
csvUrl: ''
};
}
} else {
return {
sheetID: '0',
gid: '0',
csvUrl: url
};
}
}

Expand Down
23 changes: 11 additions & 12 deletions projects/v2/src/app/modules/playground/playground.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,22 +282,21 @@ export class PlaygroundComponent implements OnInit, AfterViewInit {
* Link validation function
*/
checkLinkFormat(url: string) {
const matches = /\/([\w-_]{15,})\/(.*?gid=(\d+))?|\w*csv$/.exec(url);
if (matches) {
if (matches[0] === 'csv') {
if (url.startsWith('https://docs.google.com/spreadsheets/d/')) {
const splitUrl = url.split('/');
if (splitUrl.length === 7) {
return {
sheetID: '0',
gid: '0',
csvUrl: url
};
}
else {
return {
sheetID: matches[1],
gid: matches[3],
sheetID: splitUrl[5],
gid: splitUrl[6].split('=')[1],
csvUrl: ''
};
}
} else {
return {
sheetID: '0',
gid: '0',
csvUrl: url
};
}
}
}

0 comments on commit e075c2f

Please sign in to comment.