Skip to content

Commit

Permalink
https://github.com/berlotti/bimvie.ws/issues/2
Browse files Browse the repository at this point in the history
  • Loading branch information
rubendel committed Sep 4, 2013
1 parent 8158a3c commit 507ea2e
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 109 deletions.
143 changes: 74 additions & 69 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
], function(){});

LazyLoad.js([
baseJsDir + "jquery-2.0.2.min.js",
baseJsDir + "jquery-2.0.3.min.js",
baseJsDir + "main.js",
baseJsDir + "jquery.history.js",
baseJsDir + "jquery.cookie.js",
Expand Down Expand Up @@ -95,18 +95,82 @@

pushInitialState();

othis.loadBimServerApiFromAddress = function(address, successFunction, errorFunction){
loadBimServerApi(address, Global.notifier, function(serverInfo){
if (serverInfo.serverState == "NOT_SETUP") {
$(".indexcontainer").load(Global.baseDir + "setup.html", function(){
new Setup(address);
});
} else if (serverInfo.serverState == "UNDEFINED") {
} else if (serverInfo.serverState == "MIGRATION_REQUIRED") {
} else if (serverInfo.serverState == "MIGRATION_IMPOSSIBLE") {
} else if (serverInfo.serverState == "FATAL_ERROR") {
} else if (serverInfo.serverState == "RUNNING") {
successFunction();
}
}, function(){
errorFunction();
});
};

function load() {
var history = History.getState().data;
if (history.page == "Login") {
tryAutoLogin();
} else if (history.page == "SelectServer") {
$(".indexcontainer").load(Global.baseDir + "selectserver.html", function(){
othis.current = new SelectServer(null);
var notLoggedInFunction = function(){
var history = History.getState().data;
if (history.page == "Login") {
$(".indexcontainer").load(Global.baseDir + "login.html", function(){
othis.current = new Login(null);
});
} else if (history.page == "SelectServer") {
$(".indexcontainer").load(Global.baseDir + "selectserver.html", function(){
othis.current = new SelectServer(null);
});
} else if (history.page == "Register") {
$(".indexcontainer").load(Global.baseDir + "register.html", function(){
othis.current = new Register($(this));
});
} else if (history.page == "ResetPassword") {
$(".indexcontainer").load(Global.baseDir + "resetpassword.html", function(){
othis.current = new ResetPassword($(this), null);
});
} else {
$(".indexcontainer").load(Global.baseDir + "login.html", function(){
othis.current = new Login(null);
});
}
};

var successFunction = function(){
// We do have an API
if ($.cookie("autologin") != null) {
Global.bimServerApi.token = $.cookie("autologin");
Global.bimServerApi.call("AuthInterface", "getLoggedInUser", {}, function(data){
$(".indexcontainer").load(Global.baseDir + "main.html", function(){
$(".indexStatus").hide();
othis.current = new Main(Global.bimServerApi.baseUrl, data.name).show(false);
});
}, function(){
$.removeCookie("autologin");
notLoggedInFunction();
});
} else {
notLoggedInFunction();
}
};

var errorFunction = function(){

};

if ($.cookie("address") != null) {
othis.loadBimServerApiFromAddress($.cookie("address"), successFunction, errorFunction);
} else if (!Settings.allowBimServerAddress()) {
Settings.getStaticServerAddress(function(address){
othis.loadBimServerApiFromAddress(address, successFunction, errorFunction);
});
} else if (history.page == "ResetPassword") {
showResetPassword();
} else {
tryAutoLogin();
$(".indexcontainer").load(Global.baseDir + "selectserver.html", function(){
new SelectServer();
});
}
}

Expand Down Expand Up @@ -203,65 +267,6 @@
});
}

this.showResetPassword = function() {
$(".indexcontainer").load(Global.baseDir + "resetpassword.html", function(){
new ResetPassword($(this), null);
});
};

this.loadBimServerApiFromAddress = function(address){
loadBimServerApi(address, Global.notifier, function(serverInfo){
if (serverInfo.serverState == "NOT_SETUP") {
$(".indexcontainer").load(Global.baseDir + "setup.html", function(){
new Setup(address);
});
} else if (serverInfo.serverState == "UNDEFINED") {
} else if (serverInfo.serverState == "MIGRATION_REQUIRED") {
} else if (serverInfo.serverState == "MIGRATION_IMPOSSIBLE") {
} else if (serverInfo.serverState == "FATAL_ERROR") {
} else if (serverInfo.serverState == "RUNNING") {
if ($.cookie("autologin") != null) {
Global.bimServerApi.token = $.cookie("autologin");
Global.bimServerApi.call("AuthInterface", "getLoggedInUser", {}, function(data){
$(".indexcontainer").load(Global.baseDir + "main.html", function(){
$(".indexStatus").hide();
othis.current = new Main(Global.bimServerApi.baseUrl, data.name).show(false);
});
}, function(){
$.removeCookie("autologin");
$(".indexcontainer").load(Global.baseDir + "login.html", function(){
othis.current = new Login(address);
});
});
} else {
$(".indexcontainer").load(Global.baseDir + "login.html", function(){
othis.current = new Login(address);
});
}
}
}, function(){
$(".indexcontainer").load(Global.baseDir + "selectserver.html", function(){
othis.current = new SelectServer(address);
});
});
};

this.tryAutoLogin = function(){
$(function(){
if ($.cookie("address") != null) {
othis.loadBimServerApiFromAddress($.cookie("address"));
} else if (!Settings.allowBimServerAddress()) {
Settings.getStaticServerAddress(function(address){
othis.loadBimServerApiFromAddress(address);
});
} else {
$(".indexcontainer").load(Global.baseDir + "selectserver.html", function(){
new SelectServer();
});
}
});
};

setInterval(function() {
var now = new Date().getTime();
$(".timespan").each(function() {
Expand Down
6 changes: 0 additions & 6 deletions js/jquery-2.0.2.min.js

This file was deleted.

6 changes: 6 additions & 0 deletions js/jquery-2.0.3.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/jquery-2.0.3.min.map

Large diffs are not rendered by default.

22 changes: 5 additions & 17 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,9 @@
othis.login($("#inputServer").val());
});

this.resetPassword = function(address){
loadBimServerApi(address, Global.notifier, function(serverInfo){
if (serverInfo.serverState == "NOT_SETUP") {
$(".indexcontainer").load(Global.baseDir + "setup.html", function(){
new Setup(address);
});
} else if (serverInfo.serverState == "UNDEFINED") {
} else if (serverInfo.serverState == "MIGRATION_REQUIRED") {
} else if (serverInfo.serverState == "MIGRATION_IMPOSSIBLE") {
} else if (serverInfo.serverState == "FATAL_ERROR") {
} else if (serverInfo.serverState == "RUNNING") {
Global.bimServerApi.callWithFullIndication("AuthInterface", "requestPasswordChange", {username: $(".username").val(), resetUrl: Global.baseDir + "?page=ResetPassword"}, function(){

});
}
this.resetPassword = function(){
Global.bimServerApi.callWithFullIndication("AuthInterface", "requestPasswordChange", {username: $(".username").val(), resetUrl: Global.baseDir + "?page=ResetPassword"}, function(){

});
};

Expand All @@ -111,15 +99,15 @@
};

this.registerClick = function(){
$(".form").load("register.html", function(){
$(".indexcontainer").load(Global.baseDir + "register.html", function(){
new Register($(this));
});
};

$(".registerButton").click(othis.registerClick);;

$(".resetPasswordButton").click(function(){
othis.resetPassword("http://" + $(".serverAddress").html());
othis.resetPassword();
});

Global.bimServerApi.call("SettingsInterface", "isAllowSelfRegistration", {}, function(enabled){
Expand Down
40 changes: 23 additions & 17 deletions register.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
<div class="register">
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputUsername">Username</label>
<div class="controls">
<input type="text" id="inputUsername" class="inputUsername" placeholder="Email address">
<div class="register container">
<div class="span7">
<div class="header"></div>
<form class="form-horizontal">
<legend>Register</legend>
<div class="control-group">
<label class="control-label" for="inputUsername">Username</label>
<div class="controls">
<input type="text" id="inputUsername" class="inputUsername" placeholder="Email address">
</div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputName">Name</label>
<div class="controls">
<input type="text" id="inputName" class="inputName" placeholder="Full name">
<div class="control-group">
<label class="control-label" for="inputName">Name</label>
<div class="controls">
<input type="text" id="inputName" class="inputName" placeholder="Full name">
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn registerButton">Register</button>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn registerButton">Register</button>
</div>
</div>
</div>
</form>
</form>
</div>
</div>
<script>
function Register(containerDiv) {
Expand All @@ -35,6 +39,8 @@

});
};

$(".header").load(Global.baseDir + "header.html");

pushHistory({page: "Register"}, "Register");

Expand Down
24 changes: 24 additions & 0 deletions testing.html
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,30 @@
});
});

this.addTest("Test 10", "Checkin from URL and load", function(doneCallback){
Global.bimServerApi.call("Bimsie1ServiceInterface", "addProject", {projectName: "Test 10 - " + Math.random()}, function(project){
Global.bimServerApi.call("Bimsie1ServiceInterface", "getSuggestedDeserializerForExtension", {extension: "ifc"}, function(deserializer){
Global.bimServerApi.call("ServiceInterface", "checkinFromUrl", {
poid: project.oid,
comment: "New revision from url",
deserializerOid: deserializer.oid,
fileName: "AC11-Institute-Var-2-IFC.ifc",
url: "http://archive.opensourcebim.org/BIMserver/IFC-example-files/AC11-Institute-Var-2-IFC.ifc",
merge: false,
sync: true
}, function(checkinId){
Global.bimServerApi.call("Bimsie1ServiceInterface", "getProjectByPoid", {poid: project.oid}, function(project){
Global.bimServerApi.getModel(project.oid, project.lastRevisionId, false, function(model){
model.load(false, function(){
doneCallback("SUCCESS");
});
});
});
});
});
});
});

$(".lazyProjectStructure").click(function(){
Global.bimServerApi.call("Bimsie1ServiceInterface", "addProject", {projectName: "Gebouw"}, function(building){
Global.bimServerApi.call("Bimsie1ServiceInterface", "addProjectAsSubProject", {projectName: "Architekt", parentPoid: building.oid}, function(architekt){
Expand Down

0 comments on commit 507ea2e

Please sign in to comment.