-
Notifications
You must be signed in to change notification settings - Fork 5
Admin #185
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
Open
erenyener
wants to merge
13
commits into
main
Choose a base branch
from
admin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Admin #185
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bb79efc
init admin
c0d6b04
update readme
erenyener 13ae2a1
claspignore added
erenyener da8aa20
Controllers Added
erenyener 736e138
empty modals added
erenyener ddff0c3
typo fix
erenyener 0b168fc
refactor views
erenyener 4ff38fc
add problem view implemented without styles
erenyener 950d687
add new problem
erenyener b16f1d1
format script
erenyener 1bac03d
add UI improvements
erenyener 59e0f8b
create new challange
erenyener d6e8704
fix validation
erenyener File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"scriptId":"1ayOszkKcVSChNjDGnC2V2gx5zOqe7LrC6MdQC6WsR30Vhtv1phLkWpeM","rootDir":"/Users/eren.yener/Desktop/repo/erenyener/codex/admin"} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| **/** | ||
| .git | ||
| .doc | ||
| !src/** | ||
| !appsscript.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Codex Admin Appscripts | ||
|
|
||
|
|
||
| ## Quick Links | ||
| [Panel Link](https://docs.google.com/spreadsheets/d/1TSYzDuSMnv_3uVRcM7o0tNyUdRlKy3C6gFHKMVh5fjc/edit#gid=0) | ||
|
|
||
|
|
||
| ## Install | ||
|
|
||
| First download `clasp`: | ||
|
|
||
| ```sh | ||
| npm install -g @google/clasp | ||
| ``` | ||
|
|
||
| Then enable the Google Apps Script API: https://script.google.com/home/usersettings | ||
|
|
||
|  | ||
|
|
||
|
|
||
| ## Commands | ||
|
|
||
| ```sh | ||
| clasp login (Login with your LDAP) | ||
| clasp pull (Get Latest Code From Google Cloud Scripts) | ||
|
|
||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "timeZone": "Europe/Istanbul", | ||
| "dependencies": { | ||
| }, | ||
| "exceptionLogging": "STACKDRIVER", | ||
| "runtimeVersion": "V8" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| function ChallangeController() { } | ||
|
|
||
| function processAddChallange() { | ||
| const challangeController = new ChallangeController(); | ||
| challangeController.addChallange(); | ||
| return true; | ||
| } | ||
|
|
||
| ChallangeController.prototype.renderAddChallangeModal = function () { | ||
|
|
||
| const scriptProperties = PropertiesService.getScriptProperties(); | ||
| const token = scriptProperties.getProperty("token") | ||
| const data = { token: token }; | ||
|
|
||
| const addProblemModalHtml = HtmlService | ||
| .createTemplateFromFile('src/views/add-new-challange-modal/add-new-challange-modal') | ||
| .evaluate() | ||
| .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL) | ||
| .getContent(); | ||
|
|
||
| const dataScript = "<script>window.stringifiedData = " + JSON.stringify(data) + "</script>"; | ||
| const template = HtmlService.createTemplate(dataScript + addProblemModalHtml) | ||
| .evaluate() | ||
| .setWidth(800) | ||
| .setHeight(350); | ||
|
|
||
| SpreadsheetApp.getUi().showModalDialog(template, 'Add New Challange'); | ||
| } | ||
|
|
||
| ChallangeController.prototype.addChallange = function () { | ||
| return true; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| function ProblemController() { } | ||
|
|
||
| function processAddProblem(problem) { | ||
| const problemController = new ProblemController(); | ||
| problemController.addProblem(); | ||
| return true; | ||
| } | ||
|
|
||
| ProblemController.prototype.renderAddProblemModal = function () { | ||
|
|
||
| const scriptProperties = PropertiesService.getScriptProperties(); | ||
| const token = scriptProperties.getProperty("token") | ||
| const data = { token: token }; | ||
|
|
||
| const addProblemModalHtml = HtmlService | ||
| .createTemplateFromFile('src/views/add-new-problem-modal/add-new-problem-modal') | ||
| .evaluate() | ||
| .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL) | ||
| .getContent(); | ||
|
|
||
| const dataScript = "<script>window.stringifiedData = " + JSON.stringify(data) + "</script>"; | ||
| const template = HtmlService.createTemplate(dataScript + addProblemModalHtml) | ||
| .evaluate() | ||
| .setWidth(1000) | ||
| .setHeight(600); | ||
|
|
||
| SpreadsheetApp.getUi().showModalDialog(template, 'Add New Problem'); | ||
| } | ||
|
|
||
| ProblemController.prototype.addProblem = function () { | ||
| return true; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| function TestController() { } | ||
|
|
||
| function processAddTest() { | ||
| const testController = new TestController(); | ||
| testController.addTest(); | ||
| } | ||
|
|
||
| TestController.prototype.getTestsSelection = function () { | ||
| const testsSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Tests'); | ||
| const activeRange = testsSheet.getActiveRange(); | ||
| const activeValues = activeRange.getValues(); | ||
|
|
||
| let tests = []; | ||
| for(let row of activeValues){ | ||
| tests.push({ | ||
| input: row[0], | ||
| output: row[1], | ||
| isPublic: row[2], | ||
| }) | ||
| } | ||
|
|
||
| return tests; | ||
| } | ||
|
|
||
| TestController.prototype.renderAddTestsModal = function() { | ||
|
|
||
| const addNewTestsHtml = HtmlService | ||
| .createTemplateFromFile('src/views/add-new-tests-modal/add-new-tests-modal') | ||
| .evaluate() | ||
| .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL) | ||
| .getContent(); | ||
|
|
||
| const tests = this.getTestsSelection(); | ||
| const scriptProperties = PropertiesService.getScriptProperties(); | ||
| const token = scriptProperties.getProperty("token") | ||
| const data = { | ||
| token: token, | ||
| tests:tests | ||
| }; | ||
| const dataScript = "<script>window.stringifiedData = " + JSON.stringify(data) + "</script>"; | ||
|
|
||
| const template = HtmlService.createTemplate(dataScript + addNewTestsHtml) | ||
| .evaluate() | ||
| .setWidth(600) | ||
| .setHeight(380); | ||
|
|
||
|
|
||
|
|
||
| SpreadsheetApp.getUi().showModalDialog(template, 'Add New Tests'); | ||
| } | ||
|
|
||
|
|
||
| TestController.prototype.addTest = function () { | ||
| const testsSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Tests'); | ||
| const activeRange = testsSheet.getActiveRange(); | ||
| activeRange.clearContent() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| function onOpen() { | ||
| renderMenu(); | ||
| } | ||
|
|
||
| function renderMenu() { | ||
|
|
||
| const ui = SpreadsheetApp.getUi(); | ||
|
|
||
| ui.createMenu('Codex Admin') | ||
| .addItem('Add Problem', 'addProblem') | ||
| .addItem('Add Challenge', 'addChallange') | ||
| .addItem('Add Tests', 'addTests') | ||
| .addToUi(); | ||
| } | ||
|
|
||
|
|
||
| function addProblem() { | ||
| const problemController = new ProblemController(); | ||
| problemController.renderAddProblemModal(); | ||
| } | ||
|
|
||
| function addChallange() { | ||
| const challangeController = new ChallangeController(); | ||
| challangeController.renderAddChallangeModal(); | ||
| } | ||
|
|
||
| function addTests() { | ||
| const testController = new TestController(); | ||
| testController.renderAddTestsModal(); | ||
| } |
55 changes: 55 additions & 0 deletions
55
admin/src/views/add-new-challange-modal/add-new-challange-modal.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
|
|
||
| <head> | ||
| <base target="_top"> | ||
| <?!= HtmlService.createHtmlOutputFromFile("src/views/add-new-challange-modal/styles-add-new-challange-modal").getContent(); ?> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div class="container"> | ||
| <div id="loader" class="lds-facebook hide"><div></div><div></div><div></div></div> | ||
| <div id="formContainer" class="form-container"> | ||
| <div class="row"> | ||
| <div class="col-6"> | ||
| <div class="form-group"> | ||
| <label for="name">Name</label> | ||
| <input type="text" placeholder="Trendyol Champs" class="text-field" id="name" name="name" /> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label for="description">Description</label> | ||
| <textarea type="text" class="text-area-field description-editor" id="description" name="description" placeholder="### markdown"></textarea> | ||
| </div> | ||
|
|
||
| <div class="form-group"> | ||
| <button id="submitButton" onclick="submit"> Submit </button> | ||
| </div> | ||
| </div> | ||
| <div class="col-6"> | ||
|
|
||
| <div class="form-group"> | ||
| <label for="problem-choice">Select Problem</label> | ||
| <input list="problems" data-selected="" class="text-field" name="problem-choice" id="problemChoice"> | ||
| <datalist id="problems"></datalist> | ||
| </div> | ||
|
|
||
| <div class="form-group"> | ||
| <label for="duration">Duration</label> | ||
| <input type="text" placeholder="10" class="text-field" id="duration" name="duration" /> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label for="teamSize">Team Size</label> | ||
| <input type="text" placeholder="2" class="text-field" id="teamSize" name="teamSize" /> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label for="date">Date</label> | ||
| <input type="text" placeholder="2023-04-07T11:50:06.963Z" class="text-field" id="date" name="date" /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </body> | ||
| <?!= HtmlService.createHtmlOutputFromFile("src/views/add-new-challange-modal/scripts-add-new-challange-modal").getContent(); ?> | ||
|
|
||
| </html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you keep scriptId and rootDir intentionally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
script id can be public, because it is restricted by default via google auth