-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e69dbcd
commit bd2c520
Showing
11 changed files
with
579 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,22 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
export function showInputBox(prompt: string, placeHolder: string, validator: any) { | ||
const options: vscode.InputBoxOptions = { | ||
prompt: prompt, | ||
placeHolder: placeHolder, | ||
validateInput: validator, | ||
ignoreFocusOut: true | ||
}; | ||
return vscode.window.showInputBox(options); | ||
} | ||
|
||
export function showInputBoxPassword(prompt: string, placeHolder: string, validator: any) { | ||
const options: vscode.InputBoxOptions = { | ||
prompt: prompt, | ||
ignoreFocusOut: true, | ||
placeHolder: placeHolder, | ||
validateInput: validator, | ||
password: true | ||
}; | ||
return vscode.window.showInputBox(options); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,18 +1,71 @@ | ||
const core = require('totalcross-core-dev'); | ||
|
||
import {showInputBox, showInputBoxPassword} from './components/components'; | ||
import {validateLogin, validatePassword} from './validators/login'; | ||
import {Response} from './model/response'; | ||
import * as vscode from 'vscode'; | ||
export class LoginHandler { | ||
/** | ||
* Check if token is valid | ||
* return promise with true, if token is valid | ||
* Show login an then password | ||
* return true if some error happen | ||
*/ | ||
async verifyToken() { | ||
async showLoginPanel() : Promise<Response>{ | ||
return new Promise(async function(resolve, reject) { | ||
let login = await showInputBox( | ||
'Login', | ||
'[email protected]', | ||
validateLogin | ||
); | ||
if(!login) { | ||
return reject({ | ||
error: true, | ||
message: 'Empty login!' | ||
}); | ||
} | ||
let password = await showInputBoxPassword( | ||
'Password', | ||
'password', | ||
validateLogin | ||
); | ||
|
||
if(!password) { | ||
return reject({ | ||
error: true, | ||
message: 'Empty password!' | ||
}); | ||
} | ||
|
||
let myStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100); | ||
myStatusBarItem.text = `$(sync~spin) TotalCross Login Request...`; | ||
myStatusBarItem.show(); | ||
return core.login({ | ||
email: login, | ||
password: password | ||
}) | ||
.then((response: any) => { | ||
vscode.window.showInformationMessage("TotalCross: you have successfully logged in."); | ||
return { | ||
error: false, | ||
message: response | ||
}; | ||
}) | ||
.catch((error: any) => { | ||
vscode.window | ||
.showErrorMessage("TotalCross: something got wrong, verify your credentials and try again"); | ||
return { | ||
error: true, | ||
message: error | ||
}; | ||
}) | ||
.then(() => myStatusBarItem.hide()); | ||
}); | ||
|
||
} | ||
|
||
/** | ||
* Show login an then password | ||
*/ | ||
async showLoginPanel() { | ||
|
||
|
||
} | ||
} | ||
|
||
export function login() { | ||
let loginHandler = new LoginHandler(); | ||
loginHandler.showLoginPanel(); | ||
} |
This file contains 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,4 @@ | ||
export interface Response { | ||
error: boolean; | ||
message: any; | ||
} |
File renamed without changes.
Oops, something went wrong.