forked from opensourceBIM/bimvie.ws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.html
156 lines (148 loc) · 6.56 KB
/
setup.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<div class="setup container">
<div class="span7 fullwidth">
<img src="img/logo.gif"/>
<h2>Setup BIMserver</h2>
<p>
This BIMserver has not yet been setup. You can setup this BIMserver right now.
</p>
<form class="form-horizontal" style="width: 500px">
<div class="form-group">
<label for="inputSiteAddress">Site address</label>
<div class="input-group">
<span class="siteAddressProtocol input-group-addon">http://</span>
<input type="text" class="siteAddressInput form-control" id="inputSiteAddress"/>
</div>
</div>
<h3>Administrator</h3>
<div class="form-group">
<label for="inputAdminName">Administrator name</label>
<input type="text" class="adminNameInput form-control" id="inputAdminName" value="Administrator">
</div>
<div class="form-group">
<label for="inputAdminUsername">Administrator username</label>
<div class="input-group">
<span class="input-group-addon">@</span>
<input type="text" class="adminUsernameInput form-control" id="inputAdminUsername" placeholder="Username (e-mail address)">
</div>
</div>
<div class="form-group">
<label for="inputAdminPassword">Administrator password</label>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input type="password" class="adminPasswordInput form-control" id="inputAdminPassword">
</div>
</div>
<div class="form-group">
<a class="emailLink">Setup e-mail</a>
</div>
<div class="emailDiv ih">
<h3>E-mail</h3>
<div class="form-group">
<label class="control-label" for="smtpServer"><a rel="tooltip" data-original-title="SMTP server to use for sending emails" data-placement="right">SMTP server</a></label>
<input type="text" class="form-control smtpServer" id="smtpServer" placeholder="Address">
</div>
<div class="form-group">
<label class="control-label" for="smtpUsername"><a rel="tooltip" data-original-title="SMTP username" data-placement="right">SMTP username</a></label>
<input type="text" class="form-control smtpUsername" id="smtpUsername" placeholder="SMTP username">
</div>
<div class="form-group">
<label class="control-label" for="smtpPassword"><a rel="tooltip" data-original-title="SMTP password" data-placement="right">SMTP password</a></label>
<input type="password" class="form-control smtpPassword" id="smtpPassword" placeholder="SMTP password">
</div>
<div class="form-group">
<label class="control-label" for="smtpPort"><a rel="tooltip" data-original-title="SMTP port" data-placement="right">SMTP port</a></label>
<input type="text" class="form-control smtpPort" id="smtpPort" placeholder="SMTP port" value="25">
</div>
<div class="form-group">
<label class="control-label" for="smtpProtocol"><a rel="tooltip" data-original-title="SMTP protocol" data-placement="right">SMTP protocol</a></label>
<select class="form-control smtpProtocol" id="smtpProtocol">
<option value="SMTP">SMTP</option>
<option value="SMTPS">SMTPS</option>
</select>
</div>
<div class="form-group">
<label class="control-label" for="emailSenderAddress"><a rel="tooltip" data-original-title="Email address to send emails from" data-placement="right">E-mail sender address</a></label>
<input type="text" class="form-control emailSenderAddress" id="emailSenderAddress" placeholder="Name">
</div>
<div class="form-group">
<label class="control-label" for="emailSenderName"><a rel="tooltip" data-original-title="Name to use for sending emails" data-placement="right">E-mail sender name</a></label>
<input type="text" class="form-control emailSenderName" id="emailSenderName" placeholder="Name">
</div>
</div>
<div class="form-group">
<div class="controls">
<button type="submit" class="setupButton form-control btn btn-primary">Setup</button>
</div>
</div>
</form>
</div>
</div>
<script>
function Setup(address) {
var othis = this;
if (address.startsWith("http://")) {
address = address.substring(7);
}
if (address.endsWith(":80")) {
address = address.substring(0, address.length - 3);
}
$(".setup .siteAddressInput").val(address);
$(".emailLink").click(function(){
$(this).hide();
$(".emailDiv").show();
});
othis.stage = 0;
this.stage1 = function(next){
Global.bimServerApi.call("AdminInterface", "setup", {
siteAddress: $(".setup .siteAddressProtocol").html() + $(".setup .siteAddressInput").val(),
smtpServer: $(".setup .smtpServer").val() == "" ? "localhost" : $(".setup .smtpServer").val(),
smtpSender: $(".setup .emailSenderAddress").val() == "" ? "[email protected]" : $(".setup .emailSenderAddress").val(),
adminName: $(".setup .adminNameInput").val(),
adminUsername: $(".setup .adminUsernameInput").val(),
adminPassword: $(".setup .adminPasswordInput").val()
}, function(){
othis.stage = 1;
next();
});
};
this.stage2 = function(){
Global.bimServerApi.login($(".setup .adminUsernameInput").val(), $(".setup .adminPasswordInput").val(), function(data){
Global.bimServerApi.call("SettingsInterface", "getServerSettings", {}, function(serverSettings){
serverSettings.smtpServer = $(".setup .smtpServer").val();
serverSettings.smtpProtocol = $(".setup .smtpProtocol").val();
serverSettings.smtpPort = $(".setup .smtpPort").val();
serverSettings.smtpUsername = $(".setup .smtpUsername").val();
serverSettings.smtpPassword = $(".setup .smtpPassword").val();
serverSettings.emailSenderAddress = $(".setup .emailSenderAddress").val();
serverSettings.emailSenderName = $(".setup .emailSenderName").val();
Global.bimServerApi.callWithFullIndication("SettingsInterface", "setServerSettings", {serverSettings: serverSettings}, function(data){
othis.finalStage();
});
});
});
};
this.nostage2 = function(){
Global.bimServerApi.login($(".setup .adminUsernameInput").val(), $(".setup .adminPasswordInput").val(), function(data){
othis.finalStage();
});
};
this.finalStage = function(){
Global.bimServerApi.resolveUser(function(user){
var address = $(".setup .siteAddressInput").val();
$(".indexcontainer").load(Global.baseDir + "main.html", function(){
new Main(address, user).show(false);
});
});
};
this.setup = function(event){
event.preventDefault(); // Required because the button is a "submit" button -> page refresh
if (othis.stage == 0) {
othis.stage1($(".setup .emailDiv").is(":visible") ? othis.stage2 : othis.nostage2);
} else {
othis.stage2();
}
};
$("[rel=tooltip]").tooltip();
$(".setup .setupButton").click(othis.setup);
}
</script>