Skip to content

Commit

Permalink
WiFi: Put UI behaviours in place
Browse files Browse the repository at this point in the history
Warn that this is not implemented though.
How are we supposed to know what a hidden network's "path" is?
  • Loading branch information
corpuscle committed Jan 29, 2016
1 parent c2a3a92 commit 9b1bc83
Showing 1 changed file with 54 additions and 21 deletions.
75 changes: 54 additions & 21 deletions source/views/WiFi.js
Expand Up @@ -343,6 +343,10 @@ enyo.kind({
content: "Join Other Network",
classes: "content-heading"
},
{
content: "Not Implemented!",
classes: "content-heading"
},
{
kind: "onyx.Groupbox",
components: [
Expand Down Expand Up @@ -406,7 +410,7 @@ enyo.kind({
kind: "onyx.Button",
classes: "onyx-affirmative",
content: "Connect",
ontap: ""
ontap: "onOtherJoinConnectTapped"
},
{
kind: "onyx.Button",
Expand Down Expand Up @@ -735,42 +739,71 @@ enyo.kind({
},
setupKnownNetworkRow: function (inSender, inEvent) {
var ssid = "";
if(enyo.Panels.isScreenNarrow()){
if(this.foundNetworks[inEvent.index].name.length >= 18){ // if the SSID is longer shortten it for the narrow page only
ssid = this.foundNetworks[inEvent.index].name.slice(0,18) + "..";
}else{
ssid = this.foundNetworks[inEvent.index].name;
}
}else{
if(enyo.Panels.isScreenNarrow()){
// if the SSID is longer shorten it for the narrow page only
if(this.foundNetworks[inEvent.index].name.length >= 18){
ssid = this.foundNetworks[inEvent.index].name.slice(0,18) + "..";
}else{
ssid = this.foundNetworks[inEvent.index].name;
}
}else{
ssid = this.foundNetworks[inEvent.index].name;
}
inEvent.item.$.wiFiListItem.$.SSID.setContent( ssid );
inEvent.item.$.wiFiListItem.$.Security.setContent(this.knownNetworks[inEvent.index].security);
inEvent.item.$.wiFiListItem.$.Signal.setShowing(false);
},
onNetworkConnect: function (inSender, inEvent) {
var password = this.$.PasswordInput.getValue();

if (this.validatePassword(password)) {
var password = this.$.PasswordInput.getValue();
var passwordPlausible = this.validatePassword(password);

if (!passwordPlausible) {
this.showError("Entered password is invalid");
} else {
this.connectNetwork(this, {
path: this.currentNetwork.path,
password: password
});
} else {
this.showError("Entered password is invalid");
}

// switch back to network list view
this.showNetworksList();
delete password;
this.$.PasswordInput.setValue("");
// switch back to network list view
this.showNetworksList();
delete password;
this.$.PasswordInput.setValue("");
}
},
onNetworkConnectAborted: function (inSender, inEvent) {
// switch back to network list view
this.showNetworksList(inSender, inEvent);

this.$.PasswordInput.setValue("");
},
onOtherJoinConnectTapped: function() {
if (this.$.ssidInput.getValue() !== "") {
this.currentNetwork = {
ssid: this.$.ssidInput.getValue(),
path: "", // How do we get this from the ssid?
// hidden: true; // In fact, you could type a known ssid.
security: ["none"]
};
var requiredSec = this.$.SecurityTypePicker.getSelected().getContent();
if (requiredSec === "WPA-Personal" ||
requiredSec === "WEP") {
this.currentNetwork.security = ["psk"];
}

if (!this.currentNetwork.security.contains("none")) {
this.log("Connecting to secured network");
this.$.PopupSSID.setContent(this.$.ssidInput.getValue());
this.showNetworkConnect();
} else {
this.log("Connect to open network");
this.connectNetwork(this, {
path: this.currentNetwork.path,
password: ""
});
}
}
},
onOtherJoinCancelled: function (inSender, inEvent) {
// switch back to network list view
this.showNetworksList(inSender, inEvent);
Expand All @@ -784,10 +817,10 @@ enyo.kind({
this.$.WiFiPanels.setIndex(0);
},
showNetworksList: function (inSender, inEvent) {
this.updateSpinnerState("start");
this.updateSpinnerState("start");
return this.$.WiFiPanels.setIndex(1);
},
showNetworkConnect: function (inSender, inEvent) {
showNetworkConnect: function () {
this.$.WiFiPanels.setIndex(2);
this.stopAutoscan();
},
Expand All @@ -803,7 +836,7 @@ enyo.kind({
this.$.WiFiToggle.setValue(value);
},
showError: function (message) {
this.updateSpinnerState();
this.updateSpinnerState();
this.$.ErrorMessage.setContent(message);
this.$.ErrorPopup.show();
},
Expand Down

0 comments on commit 9b1bc83

Please sign in to comment.