Commit 56a3d433 authored by Elias Nahum's avatar Elias Nahum

Add a few Zimbra examples

parent 9e423343
......@@ -5,24 +5,24 @@ test:
@npm run check
.npminstall: package.json
install: package.json
@echo Getting dependencies using npm
@npm install
@touch $@
build: | .npminstall test
build: | install test
@echo Building ZBox Manager Webapp
@npm run build
run: .npminstall
run: install
@echo Running ZBox Manager Webapp for development
@npm run run &
run-fullmap: .npminstall
run-fullmap: install
@echo FULL SOURCE MAP Running ZBox Manager Webapp for development FULL SOURCE MAP
@npm run run-fullmap &
......@@ -38,8 +38,8 @@ stop:
clean:
@echo Cleaning Webapp
@rm -rf webapp/dist
@rm -rf dist
@rm -f .npminstall
nuke:
nuke: clean
@rm -rf node_modules
{
"zimbraUrl": "https://zimbra.zboxapp.dev:7071/service/admin/soap"
}
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
import './sass/styles.scss';
import $ from 'jquery';
import * as Client from './utils/client.jsx';
function preRenderSetup(callwhendone) {
const d1 = Client.getClientConfig(
(data) => {
if (!data) {
return;
}
global.window.manager_config = data;
},
(err) => {
console.error(err); //eslint-disable-line no-console
}
);
$.when(d1).done(callwhendone);
}
function renderRootComponent() {
console.log('eliminar'); //eslint-disable-line no-console
}
global.window.setup_root = () => {
// Do the pre-render setup and call renderRootComponent when done
preRenderSetup(renderRootComponent);
};
global.window.Zimbra = Client;
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
import './sass/styles.scss';
global.window.setup_root = () => {
// Do the pre-render setup and call renderRootComponent when done
// preRenderSetup(renderRootComponent);
};
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
import $ from 'jquery';
import jszimbra from 'js-zimbra';
import Domain from '../zimbra/domain.jsx';
let domain;
// función que maneja el error como corresponde
function handleError(methodName, err) {
var e = null;
try {
e = JSON.parse(err);
} catch (parseError) {
e = null;
}
console.error(methodName, e); //eslint-disable-line no-console
// Aqui deberiamos revisar si falta hacer login nuevamente
return e;
}
export function getClientConfig(success, error) {
return $.ajax({
url: 'config/config.json',
dataType: 'json',
success,
error: function onError(xhr, status, err) {
var e = handleError('getClientConfig', err);
error(e);
}
});
}
export function login(username, secret, success, error) {
const zimbra = new jszimbra.Communication({
url: global.window.manager_config.zimbraUrl
});
zimbra.auth({
username,
secret,
isPassword: true,
isAdmin: true
}, (err) => {
if (err) {
var e = handleError('login', err);
return error(e);
}
// aqui deberiamos inicializar todas las apis
domain = new Domain(zimbra);
return success();
});
}
export function getDomain(name, by, attrs, success, error) {
if (domain) {
return domain.get(name, by, attrs,
(data) => {
return success(data);
},
(err) => {
var e = handleError('getDomain', err);
error(e);
});
}
// probablemente esto lo que deba hacer es forzar un login
return error({message: 'Domain not initialized'});
}
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
export default class Domain {
constructor(connection) {
this.zimbra = connection;
}
get(name, by, attrs, success, error) {
if (this.zimbra) {
this.zimbra.getRequest({}, (err, req) => {
if (err) {
return error(err);
}
return req.addRequest({
name: 'GetDomainRequest',
namespace: 'zimbraAdmin',
params: {
domain: {
attrs,
by,
_content: name
}
}
}, (er) => {
if (er) {
return error(er);
}
return this.zimbra.send(req, (err2, response) => {
if (err2) {
return error(err2);
}
return success(response.get().GetAccountInfoResponse);
});
});
});
}
}
}
......@@ -17,9 +17,9 @@ if (NPM_TARGET === 'run' || NPM_TARGET === 'run-fullmap') {
}
var config = {
entry: ['babel-polyfill', './webapp/index.jsx', 'webapp/index.html'],
entry: ['babel-polyfill', './src/index.jsx', 'src/index.html'],
output: {
path: 'webapp/dist',
path: 'dist',
publicPath: '/',
filename: 'bundle.js'
},
......@@ -73,7 +73,7 @@ var config = {
},
plugins: [
new CopyWebpackPlugin([
{from: 'webapp/config', to: 'config'}
{from: 'src/config', to: 'config'}
]),
new webpack.ProvidePlugin({
'window.jQuery': 'jquery'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment