1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 05:09:42 +02:00
documize/gui/app/components/onboard/share-folder.js
Harvey Kandola b31ab712c1 upgraded Ember and integrated Bootstrap 4
Upgraded to Ember JS 2.16.x release. This upgrade uses the new JavaScript modules API syntax.

Integrated Bootstrap 4 Beta 2 via package.json and associated popper.js library. Overridden Bootstrap styles using bootstrap.scss -- this file selectively imports the modules we need.
2017-11-16 13:28:05 +00:00

129 lines
4.9 KiB
JavaScript

// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
import { inject as service } from '@ember/service';
import Component from '@ember/component';
export default Component.extend({
folderService: service('folder'),
serial: "",
folderId: "",
slug: "",
processing: false,
didRender() {
let self = this;
$("#stage-1-firstname").focus();
// Stage 1 - person name keypress handler
$("#stage-1-firstname, #stage-1-lastname").keyup(function() {
if (!$("#stage-1-firstname").val() || !$("#stage-1-lastname").val()) {
$(".name-status").attr("src", "/assets/img/onboard/person-red.png");
} else {
$(".name-status").attr("src", "/assets/img/onboard/person-green.png");
}
});
// Stage 1 - finish
$("#stage-1-next").off('click').on('click', function() {
if (!$("#stage-1-firstname").val()) {
$("#stage-1-firstname").focus();
$("#stage-1-firstname").addClass("error");
$(".name-status").attr("src", "/assets/img/onboard/person-red.png");
return;
}
if (!$("#stage-1-lastname").val()) {
$("#stage-1-lastname").focus();
$("#stage-1-lastname").addClass("error");
$(".name-status").attr("src", "/assets/img/onboard/person-red.png");
return;
}
self.set('processing', false);
$(".stage-1").fadeOut("slow", function() {
if (self.get('processing')) {
return;
}
self.set('processing', true);
$(".stage-2").fadeIn();
$("#stage-2-password").focus();
// Stage 2 - password keypress handler
$("#stage-2-password-confirm").keyup(function() {
if ($("#stage-2-password").val().length < 6 || $("#stage-2-password").val().length > 50 ||
($("#stage-2-password").val() !== $("#stage-2-password-confirm").val())) {
$(".password-status").attr("src", "/assets/img/onboard/lock-red.png");
} else {
$(".password-status").attr("src", "/assets/img/onboard/lock-green.png");
}
});
});
});
// Stage 2 - finish
$("#stage-2-next").off('click').on('click', function() {
if (!$("#stage-2-password").val() || $("#stage-2-password").val().length < 6 || $("#stage-2-password").val().length > 50) {
$("#stage-2-password").focus();
$("#stage-2-password").addClass("error");
return;
}
if (!$("#stage-2-password-confirm").val()) {
$("#stage-2-password-confirm").focus();
$("#stage-2-password-confirm").addClass("error");
return;
}
if ($("#stage-2-password-confirm").val() !== $("#stage-2-password").val()) {
$(".mismatch").show();
$(".password-status").attr("src", "/assets/img/onboard/lock-red.png");
return;
}
self.set('processing', false);
$(".stage-2").fadeOut("slow", function() {
if (self.get('processing')) {
return;
}
self.set('processing', true);
$(".stage-3").fadeIn();
$("#spinner-1").show();
var payload = '{ "Password": "' + $("#stage-2-password").val() + '", "Serial": "' + self.serial + '", "Firstname": "' + $("#stage-1-firstname").val() + '", "Lastname": "' + $("#stage-1-lastname").val() + '" }';
var password = $("#stage-2-password").val();
self.get('folderService').onboard(self.folderId, payload).then(function(user) {
let creds = { password: password, email: user.email };
self.get('session').authenticate('authenticator:documize', creds).then(() => {
window.location.href = 's/' + self.folderId + "/" + self.slug;
});
// var credentials = encodingUtil.Base64.encode(netUtil.getSubdomain() + ":" + user.email + ":" + password);
// self.session.sso(credentials).then(function() {
// window.location.href = 's/' + self.folderId + "/" + self.slug;
// });
}, function() {
window.location.href = "/";
});
});
});
},
});