Skip to content

The Unified and Autonomous Development Platform

Add AccountPermission

stevedbe34cf4687e
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/WebModule.java b/gitop.web/src/main/java/com/pmease/gitop/web/WebModule.java
index 74508d4159..9ae7e9732f 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/WebModule.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/WebModule.java
@@ -1,13 +1,17 @@
package com.pmease.gitop.web;
+import java.util.Set;
+
import javax.inject.Singleton;
import com.codahale.dropwizard.jackson.Jackson;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableSet;
import com.google.inject.Provides;
import com.pmease.commons.jetty.ServletConfigurator;
import com.pmease.commons.loader.AbstractPluginModule;
import com.pmease.commons.wicket.AbstractWicketConfig;
+import com.pmease.gitop.core.validation.ProjectNameReservation;
import com.pmease.gitop.core.validation.UserNameReservation;
import com.pmease.gitop.web.resource.RestResourceModule;
@@ -29,8 +33,32 @@ public class WebModule extends AbstractPluginModule {
contribute(UserNameReservation.class, WebUserNameReservation.class);
install(new RestResourceModule());
+
+ contribute(ProjectNameReservation.class, DefaultProjectNameReservation.class);
+ contribute(UserNameReservation.class, DefaultUserNameReservation.class);
+ }
+
+ public static class DefaultProjectNameReservation implements ProjectNameReservation {
+
+ @Override
+ public Set<String> getReserved() {
+ return ImmutableSet.<String>of(
+ );
+ }
}
+
+ public static class DefaultUserNameReservation implements UserNameReservation {
+ @Override
+ public Set<String> getReserved() {
+ return ImmutableSet.<String>of(
+ "rest",
+ "assets"
+ );
+ }
+ }
+
+
@Provides
@Singleton
public ObjectMapper objectMapper() {
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/base.css b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/base.css
index 85d1be125f..d271017bd8 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/base.css
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/base.css
@@ -332,8 +332,6 @@ a > .icon-null, .icon-null { display: inline-block; width: 10px; }
section .head { border-style: solid; border-width: 1px 0; border-color: #ddd; }
section:first-child .head { border-top: none; }
-
-.content .head h3 { margin: 0; font-size: 18px; line-height: 24px; color: #888; font-weight: 300; }
-.content .padder { padding: 0px 20px 20px; margin-bottom: 18px; }
-.content .padder:nth-child(1) { padding-top: 0; }
+section .head h2, section .head h3 { margin: 0; font-size: 18px; line-height: 24px; color: #888; font-weight: 300; }
+section .padder, section > .body { padding: 0px 20px 20px; margin-bottom: 18px; }
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/DataGrid.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/DataGrid.java
new file mode 100644
index 0000000000..355a6a267e
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/DataGrid.java
@@ -0,0 +1,31 @@
+package com.pmease.gitop.web.common.component.datagrid;
+
+import java.util.List;
+
+import org.apache.wicket.event.IEvent;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.markup.repeater.data.IDataProvider;
+
+import com.pmease.gitop.web.common.component.datagrid.event.PageChanged;
+
+@SuppressWarnings("serial")
+public class DataGrid<T> extends DataTable<T, String>{
+
+ public DataGrid(String id, List<? extends IColumn<T, String>> columns,
+ IDataProvider<T> dataProvider, long rowsPerPage) {
+ super(id, columns, dataProvider, rowsPerPage);
+
+ setOutputMarkupId(true);
+ setVersioned(false);
+ }
+
+ @Override
+ public void onEvent(IEvent<?> event) {
+ if (event.getPayload() instanceof PageChanged) {
+ PageChanged payload = (PageChanged) event.getPayload();
+ setCurrentPage(payload.getPage());
+ payload.getTarget().add(this);
+ }
+ }
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/event/PageChanged.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/event/PageChanged.java
new file mode 100644
index 0000000000..fca6786a5f
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/event/PageChanged.java
@@ -0,0 +1,19 @@
+package com.pmease.gitop.web.common.component.datagrid.event;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+
+import com.pmease.gitop.web.common.event.AjaxEvent;
+
+public class PageChanged extends AjaxEvent {
+
+ private final int page;
+
+ public PageChanged(AjaxRequestTarget target, int page) {
+ super(target);
+ this.page = page;
+ }
+
+ public int getPage() {
+ return page;
+ }
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/event/SearchStringChanged.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/event/SearchStringChanged.java
new file mode 100644
index 0000000000..3e5319678e
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/event/SearchStringChanged.java
@@ -0,0 +1,19 @@
+package com.pmease.gitop.web.common.component.datagrid.event;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+
+import com.pmease.gitop.web.common.event.AjaxEvent;
+
+public class SearchStringChanged extends AjaxEvent {
+
+ private final String pattern;
+
+ public SearchStringChanged(AjaxRequestTarget target, String pattern) {
+ super(target);
+ this.pattern = pattern;
+ }
+
+ public String getPattern() {
+ return pattern;
+ }
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/hibernate/HibernateDataProvider.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/hibernate/HibernateDataProvider.java
new file mode 100644
index 0000000000..3a7ed4adbd
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/hibernate/HibernateDataProvider.java
@@ -0,0 +1,59 @@
+package com.pmease.gitop.web.common.component.datagrid.hibernate;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
+import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
+import org.apache.wicket.model.IModel;
+import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Order;
+
+import com.google.common.base.Splitter;
+import com.pmease.commons.hibernate.AbstractEntity;
+import com.pmease.commons.hibernate.dao.GeneralDao;
+import com.pmease.commons.loader.AppLoader;
+import com.pmease.gitop.web.model.EntityModel;
+
+public abstract class HibernateDataProvider<T extends AbstractEntity> extends SortableDataProvider<T, String> {
+ private static final long serialVersionUID = 9007657871051510330L;
+
+ abstract protected DetachedCriteria getCriteria();
+
+ protected GeneralDao getDao() {
+ return AppLoader.getInstance(GeneralDao.class);
+ }
+
+ @Override
+ public Iterator<? extends T> iterator(long first, long count) {
+ GeneralDao dao = getDao();
+ DetachedCriteria criteria = getCriteria();
+ SortParam<String> param = getSort();
+ if (param != null) {
+ DetachedCriteria crit = getCriteria();
+ Iterable<String> it = Splitter.on(",").trimResults().split(param.getProperty());
+ for (String each : it) {
+ if (param.isAscending())
+ crit.addOrder(Order.asc(each));
+ else
+ crit.addOrder(Order.desc(each));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ List<T> list = (List<T>) dao.query(criteria, (int) first, (int) count);
+
+ return list.iterator();
+ }
+
+ @Override
+ public long size() {
+ GeneralDao dao = getDao();
+ return dao.count(getCriteria());
+ }
+
+ @Override
+ public IModel<T> model(T object) {
+ return new EntityModel<T>(object);
+ }
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/AjaxPagingNavigator.html b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/AjaxPagingNavigator.html
new file mode 100644
index 0000000000..afa2dd9b76
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/AjaxPagingNavigator.html
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+<wicket:panel>
+ <ul class="pagination pagination-sm">
+ <li><a wicket:id="first" class="first"><i class="icon-double-angle-left"></i></a></li>
+ <li><a wicket:id="prev"><i class="icon-angle-left"></i></a></li>
+ <wicket:container wicket:id="navigation">
+ <li><a wicket:id="pageLink" href="#"><span wicket:id="pageNumber">5</span></a></li>
+ </wicket:container>
+ <li><a wicket:id="next"><i class="icon-angle-right"></i></a></li>
+ <li><a wicket:id="last" class="last"><i class="icon-double-angle-right"></i></a></li>
+ </ul>
+</wicket:panel>
+</body>
+</html>
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/AjaxPagingNavigator.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/AjaxPagingNavigator.java
new file mode 100644
index 0000000000..b2e4e4f209
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/AjaxPagingNavigator.java
@@ -0,0 +1,17 @@
+package com.pmease.gitop.web.common.component.datagrid.toolbar;
+
+import org.apache.wicket.markup.html.navigation.paging.IPageable;
+import org.apache.wicket.markup.html.navigation.paging.IPagingLabelProvider;
+
+public class AjaxPagingNavigator extends org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator {
+ private static final long serialVersionUID = 1L;
+
+ public AjaxPagingNavigator(String id, IPageable pageable) {
+ super(id, pageable);
+ }
+
+ public AjaxPagingNavigator(final String id, final IPageable pageable,
+ final IPagingLabelProvider labelProvider) {
+ super(id, pageable, labelProvider);
+ }
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/SearchNavToolbar.html b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/SearchNavToolbar.html
new file mode 100644
index 0000000000..3a21b6555d
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/SearchNavToolbar.html
@@ -0,0 +1,35 @@
+<html xmlns:wicket>
+<wicket:panel>
+ <tr class="search-nav-tr">
+ <td wicket:id="td" class="search-nav-td">
+ <div class="clearfix">
+ <div class="pull-left" wicket:id="search"></div>
+ <div class="pull-right" wicket:id="nav"></div>
+ </div>
+ </td>
+ </tr>
+
+ <wicket:fragment wicket:id="searchFrag">
+ <form class="form-inline search-form" wicket:id="searchForm">
+ <input type="text" class="form-control input-sm" wicket:id="input" />
+ <button type="button" class="search-icon" wicket:id="submit"><i class="icon-search"></i></button>
+ </form>
+ </wicket:fragment>
+
+ <wicket:fragment wicket:id="navFrag">
+ <form class="form-inline navigation-form" wicket:id="form">
+ <span>Show rows:</span>
+ <select class="form-control input-sm" wicket:id="rowsSelector"></select>
+ <span>Go to:</span>
+ <input class="form-control input-sm" type="text" value="1" autocomplete="off" wicket:id="pageInput" />
+ <span wicket:id="navlabel"></span>
+ <div class="btn-group">
+ <a class="btn btn-default btn-xs" wicket:id="previousLink"><i class="icon-chevron-left"></i></a>
+ <a class="btn btn-default btn-xs" wicket:id="nextLink"><i class="icon-chevron-right"></i></a>
+ </div>
+
+ <input type="hidden" value="go" wicket:id="submit" />
+ </form>
+ </wicket:fragment>
+</wicket:panel>
+</html>
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/SearchNavToolbar.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/SearchNavToolbar.java
new file mode 100644
index 0000000000..5e8446b5e8
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/datagrid/toolbar/SearchNavToolbar.java
@@ -0,0 +1,232 @@
+package com.pmease.gitop.web.common.component.datagrid.toolbar;
+
+import java.util.List;
+
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.event.IEvent;
+import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractToolbar;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.panel.Fragment;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+import org.apache.wicket.model.PropertyModel;
+
+import com.google.common.collect.ImmutableList;
+import com.pmease.gitop.web.common.component.datagrid.event.PageChanged;
+import com.pmease.gitop.web.common.component.datagrid.event.SearchStringChanged;
+
+public class SearchNavToolbar extends AbstractToolbar {
+
+ private static final long serialVersionUID = 1L;
+
+ public SearchNavToolbar(DataTable<?, ?> table) {
+ super(table);
+
+ setOutputMarkupId(true);
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ WebMarkupContainer span = new WebMarkupContainer("td");
+ add(span);
+ span.add(AttributeModifier.replace("colspan", new AbstractReadOnlyModel<String>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getObject() {
+ return String.valueOf(getTable().getColumns().size());
+ }
+ }));
+
+ span.add(newSearchForm("search"));
+ span.add(newNavigationForm("nav"));
+ }
+
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+
+ this.setVisibilityAllowed(getTable().getRowCount() > 0);
+ }
+
+ protected Component newSearchForm(String id) {
+ Fragment frag = new Fragment(id, "searchFrag", this);
+ frag.add(new SearchForm("searchForm"));
+ return frag;
+ }
+
+ @SuppressWarnings({"serial"})
+ private class SearchForm extends Form<Void> {
+
+ private String pattern;
+
+ public SearchForm(String id) {
+ super(id);
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ TextField<String> input = new TextField<String>("input", new PropertyModel<String>(this, "pattern"));
+ add(input);
+ IndicatingAjaxButton submit = new IndicatingAjaxButton("submit", this) {
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ send(getTable(), Broadcast.BREADTH, new SearchStringChanged(target, pattern));
+ }
+ };
+ add(submit);
+ setDefaultButton(submit);
+ }
+
+ @Override
+ public void onEvent(IEvent<?> event) {
+ if (event.getPayload() instanceof SearchStringChanged) {
+ SearchStringChanged e = (SearchStringChanged) event.getPayload();
+ this.pattern = e.getPattern();
+ e.getTarget().add(this);
+ }
+ }
+ }
+
+ protected void onPageChanged(AjaxRequestTarget target) {
+ target.add(getTable());
+ target.add(this);
+ }
+
+ protected Component newNavigationForm(String id) {
+ Fragment frag = new Fragment(id, "navFrag", this);
+ frag.add(new NavigationForm("form"));
+ return frag;
+ }
+
+ static final List<Integer> ROWS_PER_PAGE = ImmutableList.<Integer>of(10, 25, 50, 100, 250, 500);
+
+ @SuppressWarnings({"serial"})
+ private class NavigationForm extends Form<Void> {
+
+ private int rowsPerPage = 10;
+ private int currentPage = 1;
+
+ public NavigationForm(String id) {
+ super(id);
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ DropDownChoice<Integer> rowsSelector = new DropDownChoice<Integer>("rowsSelector",
+ new PropertyModel<Integer>(this, "rowsPerPage"), ROWS_PER_PAGE);
+ add(rowsSelector);
+ rowsSelector.add(new AjaxFormComponentUpdatingBehavior("onchange") {
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ currentPage = 1;
+ getTable().setItemsPerPage(rowsPerPage);
+ send(getTable(), Broadcast.BREADTH, new PageChanged(target, currentPage - 1));
+ }
+ });
+
+ add(new AjaxLink<Void>("previousLink") {
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ long current = getTable().getCurrentPage();
+ if (current == 0) {
+ return;
+ }
+
+ current--;
+ if (current < 0) {
+ current = 0;
+ }
+
+ send(getTable(), Broadcast.BREADTH, new PageChanged(target, (int) current));
+ }
+ });
+
+ add(new AjaxLink<Void>("nextLink") {
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ long current = getTable().getCurrentPage();
+ long totals = getTable().getPageCount();
+ if (current == totals) {
+ return;
+ }
+
+ current++;
+ if (current >= totals) {
+ current = totals - 1;
+ }
+
+ send(getTable(), Broadcast.BREADTH, new PageChanged(target, (int) current));
+ }
+
+ });
+
+ add(new TextField<Integer>("pageInput", new PropertyModel<Integer>(this, "currentPage")));
+
+ AjaxButton btn = new AjaxButton("submit", this) {
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ if (currentPage == getTable().getCurrentPage() + 1) {
+ return;
+ }
+
+ long totals = getTable().getPageCount();
+ currentPage = Math.min(currentPage, (int) totals);
+ currentPage = Math.max(currentPage, 0);
+
+ send(getTable(), Broadcast.BREADTH, new PageChanged(target, currentPage - 1));
+ }
+
+ @Override
+ protected void onError(AjaxRequestTarget target, Form<?> form) {
+ target.add(form);
+ }
+ };
+ add(btn);
+ setDefaultButton(btn);
+
+ add(new Label("navlabel", new AbstractReadOnlyModel<String>() {
+
+ @Override
+ public String getObject() {
+ long totals = getTable().getRowCount();
+ long items = getTable().getItemsPerPage();
+ long start = (currentPage - 1) * items + 1;
+ long end = start + items - 1;
+ end = Math.min(end, totals);
+ return start + " - " + end + " of " + totals;
+ }
+ }));
+ }
+
+ @Override
+ public void onEvent(IEvent<?> event) {
+ if (event.getPayload() instanceof PageChanged) {
+ PageChanged e = (PageChanged) event.getPayload();
+ currentPage = e.getPage() + 1;
+ rowsPerPage = (int) getTable().getItemsPerPage();
+ e.getTarget().add(this);
+ }
+ }
+ }
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/dropzone/DropZoneBehavior.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/dropzone/DropZoneBehavior.java
new file mode 100644
index 0000000000..be7a042c82
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/dropzone/DropZoneBehavior.java
@@ -0,0 +1,16 @@
+package com.pmease.gitop.web.common.component.dropzone;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.behavior.Behavior;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.JavaScriptHeaderItem;
+
+@SuppressWarnings("serial")
+public class DropZoneBehavior extends Behavior {
+
+ @Override
+ public void renderHead(Component component, IHeaderResponse response) {
+ super.renderHead(component, response);
+ response.render(JavaScriptHeaderItem.forReference(DropZoneResourceReference.get()));
+ }
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/dropzone/DropZoneResourceReference.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/dropzone/DropZoneResourceReference.java
new file mode 100644
index 0000000000..129865d592
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/dropzone/DropZoneResourceReference.java
@@ -0,0 +1,19 @@
+package com.pmease.gitop.web.common.component.dropzone;
+
+import org.apache.wicket.request.resource.JavaScriptResourceReference;
+
+public class DropZoneResourceReference extends JavaScriptResourceReference {
+
+ private static final long serialVersionUID = 1L;
+
+ public DropZoneResourceReference() {
+ super(DropZoneResourceReference.class, "dropzone.js");
+ }
+
+ private static final DropZoneResourceReference instance =
+ new DropZoneResourceReference();
+
+ public static DropZoneResourceReference get() {
+ return instance;
+ }
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/component/dropzone/dropzone.js b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/dropzone/dropzone.js
new file mode 100644
index 0000000000..e670cccf20
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/component/dropzone/dropzone.js
@@ -0,0 +1,1758 @@
+;(function(){
+
+/**
+ * Require the given path.
+ *
+ * @param {String} path
+ * @return {Object} exports
+ * @api public
+ */
+
+function require(path, parent, orig) {
+ var resolved = require.resolve(path);
+
+ // lookup failed
+ if (null == resolved) {
+ orig = orig || path;
+ parent = parent || 'root';
+ var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
+ err.path = orig;
+ err.parent = parent;
+ err.require = true;
+ throw err;
+ }
+
+ var module = require.modules[resolved];
+
+ // perform real require()
+ // by invoking the module's
+ // registered function
+ if (!module.exports) {
+ module.exports = {};
+ module.client = module.component = true;
+ module.call(this, module.exports, require.relative(resolved), module);
+ }
+
+ return module.exports;
+}
+
+/**
+ * Registered modules.
+ */
+
+require.modules = {};
+
+/**
+ * Registered aliases.
+ */
+
+require.aliases = {};
+
+/**
+ * Resolve `path`.
+ *
+ * Lookup:
+ *
+ * - PATH/index.js
+ * - PATH.js
+ * - PATH
+ *
+ * @param {String} path
+ * @return {String} path or null
+ * @api private
+ */
+
+require.resolve = function(path) {
+ if (path.charAt(0) === '/') path = path.slice(1);
+
+ var paths = [
+ path,
+ path + '.js',
+ path + '.json',
+ path + '/index.js',
+ path + '/index.json'
+ ];
+
+ for (var i = 0; i < paths.length; i++) {
+ var path = paths[i];
+ if (require.modules.hasOwnProperty(path)) return path;
+ if (require.aliases.hasOwnProperty(path)) return require.aliases[path];
+ }
+};
+
+/**
+ * Normalize `path` relative to the current path.
+ *
+ * @param {String} curr
+ * @param {String} path
+ * @return {String}
+ * @api private
+ */
+
+require.normalize = function(curr, path) {
+ var segs = [];
+
+ if ('.' != path.charAt(0)) return path;
+
+ curr = curr.split('/');
+ path = path.split('/');
+
+ for (var i = 0; i < path.length; ++i) {
+ if ('..' == path[i]) {
+ curr.pop();
+ } else if ('.' != path[i] && '' != path[i]) {
+ segs.push(path[i]);
+ }
+ }
+
+ return curr.concat(segs).join('/');
+};
+
+/**
+ * Register module at `path` with callback `definition`.
+ *
+ * @param {String} path
+ * @param {Function} definition
+ * @api private
+ */
+
+require.register = function(path, definition) {
+ require.modules[path] = definition;
+};
+
+/**
+ * Alias a module definition.
+ *
+ * @param {String} from
+ * @param {String} to
+ * @api private
+ */
+
+require.alias = function(from, to) {
+ if (!require.modules.hasOwnProperty(from)) {
+ throw new Error('Failed to alias "' + from + '", it does not exist');
+ }
+ require.aliases[to] = from;
+};
+
+/**
+ * Return a require function relative to the `parent` path.
+ *
+ * @param {String} parent
+ * @return {Function}
+ * @api private
+ */
+
+require.relative = function(parent) {
+ var p = require.normalize(parent, '..');
+
+ /**
+ * lastIndexOf helper.
+ */
+
+ function lastIndexOf(arr, obj) {
+ var i = arr.length;
+ while (i--) {
+ if (arr[i] === obj) return i;
+ }
+ return -1;
+ }
+
+ /**
+ * The relative require() itself.
+ */
+
+ function localRequire(path) {
+ var resolved = localRequire.resolve(path);
+ return require(resolved, parent, path);
+ }
+
+ /**
+ * Resolve relative to the parent.
+ */
+
+ localRequire.resolve = function(path) {
+ var c = path.charAt(0);
+ if ('/' == c) return path.slice(1);
+ if ('.' == c) return require.normalize(p, path);
+
+ // resolve deps by returning
+ // the dep in the nearest "deps"
+ // directory
+ var segs = parent.split('/');
+ var i = lastIndexOf(segs, 'deps') + 1;
+ if (!i) i = 0;
+ path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
+ return path;
+ };
+
+ /**
+ * Check if module is defined at `path`.
+ */
+
+ localRequire.exists = function(path) {
+ return require.modules.hasOwnProperty(localRequire.resolve(path));
+ };
+
+ return localRequire;
+};
+require.register("component-emitter/index.js", function(exports, require, module){
+
+/**
+ * Expose `Emitter`.
+ */
+
+module.exports = Emitter;
+
+/**
+ * Initialize a new `Emitter`.
+ *
+ * @api public
+ */
+
+function Emitter(obj) {
+ if (obj) return mixin(obj);
+};
+
+/**
+ * Mixin the emitter properties.
+ *
+ * @param {Object} obj
+ * @return {Object}
+ * @api private
+ */
+
+function mixin(obj) {
+ for (var key in Emitter.prototype) {
+ obj[key] = Emitter.prototype[key];
+ }
+ return obj;
+}
+
+/**
+ * Listen on the given `event` with `fn`.
+ *
+ * @param {String} event
+ * @param {Function} fn
+ * @return {Emitter}
+ * @api public
+ */
+
+Emitter.prototype.on = function(event, fn){
+ this._callbacks = this._callbacks || {};
+ (this._callbacks[event] = this._callbacks[event] || [])
+ .push(fn);
+ return this;
+};
+
+/**
+ * Adds an `event` listener that will be invoked a single
+ * time then automatically removed.
+ *
+ * @param {String} event
+ * @param {Function} fn
+ * @return {Emitter}
+ * @api public
+ */
+
+Emitter.prototype.once = function(event, fn){
+ var self = this;
+ this._callbacks = this._callbacks || {};
+
+ function on() {
+ self.off(event, on);
+ fn.apply(this, arguments);
+ }
+
+ fn._off = on;
+ this.on(event, on);
+ return this;
+};
+
+/**
+ * Remove the given callback for `event` or all
+ * registered callbacks.
+ *
+ * @param {String} event
+ * @param {Function} fn
+ * @return {Emitter}
+ * @api public
+ */
+
+Emitter.prototype.off =
+Emitter.prototype.removeListener =
+Emitter.prototype.removeAllListeners = function(event, fn){
+ this._callbacks = this._callbacks || {};
+ var callbacks = this._callbacks[event];
+ if (!callbacks) return this;
+
+ // remove all handlers
+ if (1 == arguments.length) {
+ delete this._callbacks[event];
+ return this;
+ }
+
+ // remove specific handler
+ var i = callbacks.indexOf(fn._off || fn);
+ if (~i) callbacks.splice(i, 1);
+ return this;
+};
+
+/**
+ * Emit `event` with the given args.
+ *
+ * @param {String} event
+ * @param {Mixed} ...
+ * @return {Emitter}
+ */
+
+Emitter.prototype.emit = function(event){
+ this._callbacks = this._callbacks || {};
+ var args = [].slice.call(arguments, 1)
+ , callbacks = this._callbacks[event];
+
+ if (callbacks) {
+ callbacks = callbacks.slice(0);
+ for (var i = 0, len = callbacks.length; i < len; ++i) {
+ callbacks[i].apply(this, args);
+ }
+ }
+
+ return this;
+};
+
+/**
+ * Return array of callbacks for `event`.
+ *
+ * @param {String} event
+ * @return {Array}
+ * @api public
+ */
+
+Emitter.prototype.listeners = function(event){
+ this._callbacks = this._callbacks || {};
+ return this._callbacks[event] || [];
+};
+
+/**
+ * Check if this emitter has `event` handlers.
+ *
+ * @param {String} event
+ * @return {Boolean}
+ * @api public
+ */
+
+Emitter.prototype.hasListeners = function(event){
+ return !! this.listeners(event).length;
+};
+
+});
+require.register("dropzone/index.js", function(exports, require, module){
+
+
+/**
+ * Exposing dropzone
+ */
+module.exports = require("./lib/dropzone.js");
+
+});
+require.register("dropzone/lib/dropzone.js", function(exports, require, module){
+/*
+#
+# More info at [www.dropzonejs.com](http://www.dropzonejs.com)
+#
+# Copyright (c) 2012, Matias Meno
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+*/
+
+
+(function() {
+ var Dropzone, Em, camelize, contentLoaded, noop, without,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
+ __slice = [].slice;
+
+ Em = typeof Emitter !== "undefined" && Emitter !== null ? Emitter : require("emitter");
+
+ noop = function() {};
+
+ Dropzone = (function(_super) {
+ var extend;
+
+ __extends(Dropzone, _super);
+
+ /*
+ This is a list of all available events you can register on a dropzone object.
+
+ You can register an event handler like this:
+
+ dropzone.on("dragEnter", function() { });
+ */
+
+
+ Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded"];
+
+ Dropzone.prototype.defaultOptions = {
+ url: null,
+ method: "post",
+ withCredentials: false,
+ parallelUploads: 2,
+ uploadMultiple: false,
+ maxFilesize: 256,
+ paramName: "file",
+ createImageThumbnails: true,
+ maxThumbnailFilesize: 10,
+ thumbnailWidth: 100,
+ thumbnailHeight: 100,
+ maxFiles: null,
+ params: {},
+ clickable: true,
+ ignoreHiddenFiles: true,
+ acceptedFiles: null,
+ acceptedMimeTypes: null,
+ autoProcessQueue: true,
+ addRemoveLinks: false,
+ previewsContainer: null,
+ dictDefaultMessage: "Drop files here to upload",
+ dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
+ dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
+ dictFileTooBig: "File is too big ({{filesize}}MB). Max filesize: {{maxFilesize}}MB.",
+ dictInvalidFileType: "You can't upload files of this type.",
+ dictResponseError: "Server responded with {{statusCode}} code.",
+ dictCancelUpload: "Cancel upload",
+ dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",
+ dictRemoveFile: "Remove file",
+ dictRemoveFileConfirmation: null,
+ dictMaxFilesExceeded: "You can only upload {{maxFiles}} files.",
+ accept: function(file, done) {
+ return done();
+ },
+ init: function() {
+ return noop;
+ },
+ forceFallback: false,
+ fallback: function() {
+ var child, messageElement, span, _i, _len, _ref;
+ this.element.className = "" + this.element.className + " dz-browser-not-supported";
+ _ref = this.element.getElementsByTagName("div");
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ child = _ref[_i];
+ if (/(^| )dz-message($| )/.test(child.className)) {
+ messageElement = child;
+ child.className = "dz-message";
+ continue;
+ }
+ }
+ if (!messageElement) {
+ messageElement = Dropzone.createElement("<div class=\"dz-message\"><span></span></div>");
+ this.element.appendChild(messageElement);
+ }
+ span = messageElement.getElementsByTagName("span")[0];
+ if (span) {
+ span.textContent = this.options.dictFallbackMessage;
+ }
+ return this.element.appendChild(this.getFallbackForm());
+ },
+ resize: function(file) {
+ var info, srcRatio, trgRatio;
+ info = {
+ srcX: 0,
+ srcY: 0,
+ srcWidth: file.width,
+ srcHeight: file.height
+ };
+ srcRatio = file.width / file.height;
+ trgRatio = this.options.thumbnailWidth / this.options.thumbnailHeight;
+ if (file.height < this.options.thumbnailHeight || file.width < this.options.thumbnailWidth) {
+ info.trgHeight = info.srcHeight;
+ info.trgWidth = info.srcWidth;
+ } else {
+ if (srcRatio > trgRatio) {
+ info.srcHeight = file.height;
+ info.srcWidth = info.srcHeight * trgRatio;
+ } else {
+ info.srcWidth = file.width;
+ info.srcHeight = info.srcWidth / trgRatio;
+ }
+ }
+ info.srcX = (file.width - info.srcWidth) / 2;
+ info.srcY = (file.height - info.srcHeight) / 2;
+ return info;
+ },
+ /*
+ Those functions register themselves to the events on init and handle all
+ the user interface specific stuff. Overwriting them won't break the upload
+ but can break the way it's displayed.
+ You can overwrite them if you don't like the default behavior. If you just
+ want to add an additional event handler, register it on the dropzone object
+ and don't overwrite those options.
+ */
+
+ drop: function(e) {
+ return this.element.classList.remove("dz-drag-hover");
+ },
+ dragstart: noop,
+ dragend: function(e) {
+ return this.element.classList.remove("dz-drag-hover");
+ },
+ dragenter: function(e) {
+ return this.element.classList.add("dz-drag-hover");
+ },
+ dragover: function(e) {
+ return this.element.classList.add("dz-drag-hover");
+ },
+ dragleave: function(e) {
+ return this.element.classList.remove("dz-drag-hover");
+ },
+ selectedfiles: function(files) {
+ if (this.element === this.previewsContainer) {
+ return this.element.classList.add("dz-started");
+ }
+ },
+ reset: function() {
+ return this.element.classList.remove("dz-started");
+ },
+ addedfile: function(file) {
+ var _this = this;
+ file.previewElement = Dropzone.createElement(this.options.previewTemplate);
+ file.previewTemplate = file.previewElement;
+ this.previewsContainer.appendChild(file.previewElement);
+ file.previewElement.querySelector("[data-dz-name]").textContent = file.name;
+ file.previewElement.querySelector("[data-dz-size]").innerHTML = this.filesize(file.size);
+ if (this.options.addRemoveLinks) {
+ file._removeLink = Dropzone.createElement("<a class=\"dz-remove\" href=\"javascript:undefined;\">" + this.options.dictRemoveFile + "</a>");
+ file._removeLink.addEventListener("click", function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (file.status === Dropzone.UPLOADING) {
+ return Dropzone.confirm(_this.options.dictCancelUploadConfirmation, function() {
+ return _this.removeFile(file);
+ });
+ } else {
+ if (_this.options.dictRemoveFileConfirmation) {
+ return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() {
+ return _this.removeFile(file);
+ });
+ } else {
+ return _this.removeFile(file);
+ }
+ }
+ });
+ file.previewElement.appendChild(file._removeLink);
+ }
+ return this._updateMaxFilesReachedClass();
+ },
+ removedfile: function(file) {
+ var _ref;
+ if ((_ref = file.previewElement) != null) {
+ _ref.parentNode.removeChild(file.previewElement);
+ }
+ return this._updateMaxFilesReachedClass();
+ },
+ thumbnail: function(file, dataUrl) {
+ var thumbnailElement;
+ file.previewElement.classList.remove("dz-file-preview");
+ file.previewElement.classList.add("dz-image-preview");
+ thumbnailElement = file.previewElement.querySelector("[data-dz-thumbnail]");
+ thumbnailElement.alt = file.name;
+ return thumbnailElement.src = dataUrl;
+ },
+ error: function(file, message) {
+ file.previewElement.classList.add("dz-error");
+ return file.previewElement.querySelector("[data-dz-errormessage]").textContent = message;
+ },
+ errormultiple: noop,
+ processing: function(file) {
+ file.previewElement.classList.add("dz-processing");
+ if (file._removeLink) {
+ return file._removeLink.textContent = this.options.dictCancelUpload;
+ }
+ },
+ processingmultiple: noop,
+ uploadprogress: function(file, progress, bytesSent) {
+ return file.previewElement.querySelector("[data-dz-uploadprogress]").style.width = "" + progress + "%";
+ },
+ totaluploadprogress: noop,
+ sending: noop,
+ sendingmultiple: noop,
+ success: function(file) {
+ return file.previewElement.classList.add("dz-success");
+ },
+ successmultiple: noop,
+ canceled: function(file) {
+ return this.emit("error", file, "Upload canceled.");
+ },
+ canceledmultiple: noop,
+ complete: function(file) {
+ if (file._removeLink) {
+ return file._removeLink.textContent = this.options.dictRemoveFile;
+ }
+ },
+ completemultiple: noop,
+ maxfilesexceeded: noop,
+ previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-success-mark\"><span>✔</span></div>\n <div class=\"dz-error-mark\"><span>✘</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>"
+ };
+
+ extend = function() {
+ var key, object, objects, target, val, _i, _len;
+ target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ for (_i = 0, _len = objects.length; _i < _len; _i++) {
+ object = objects[_i];
+ for (key in object) {
+ val = object[key];
+ target[key] = val;
+ }
+ }
+ return target;
+ };
+
+ function Dropzone(element, options) {
+ var elementOptions, fallback, _ref;
+ this.element = element;
+ this.version = Dropzone.version;
+ this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
+ this.clickableElements = [];
+ this.listeners = [];
+ this.files = [];
+ if (typeof this.element === "string") {
+ this.element = document.querySelector(this.element);
+ }
+ if (!(this.element && (this.element.nodeType != null))) {
+ throw new Error("Invalid dropzone element.");
+ }
+ if (this.element.dropzone) {
+ throw new Error("Dropzone already attached.");
+ }
+ Dropzone.instances.push(this);
+ element.dropzone = this;
+ elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {};
+ this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});
+ if (this.options.forceFallback || !Dropzone.isBrowserSupported()) {
+ return this.options.fallback.call(this);
+ }
+ if (this.options.url == null) {
+ this.options.url = this.element.getAttribute("action");
+ }
+ if (!this.options.url) {
+ throw new Error("No URL provided.");
+ }
+ if (this.options.acceptedFiles && this.options.acceptedMimeTypes) {
+ throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");
+ }
+ if (this.options.acceptedMimeTypes) {
+ this.options.acceptedFiles = this.options.acceptedMimeTypes;
+ delete this.options.acceptedMimeTypes;
+ }
+ this.options.method = this.options.method.toUpperCase();
+ if ((fallback = this.getExistingFallback()) && fallback.parentNode) {
+ fallback.parentNode.removeChild(fallback);
+ }
+ if (this.options.previewsContainer) {
+ this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer");
+ } else {
+ this.previewsContainer = this.element;
+ }
+ if (this.options.clickable) {
+ if (this.options.clickable === true) {
+ this.clickableElements = [this.element];
+ } else {
+ this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable");
+ }
+ }
+ this.init();
+ }
+
+ Dropzone.prototype.getAcceptedFiles = function() {
+ var file, _i, _len, _ref, _results;
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (file.accepted) {
+ _results.push(file);
+ }
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.getRejectedFiles = function() {
+ var file, _i, _len, _ref, _results;
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (!file.accepted) {
+ _results.push(file);
+ }
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.getQueuedFiles = function() {
+ var file, _i, _len, _ref, _results;
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (file.status === Dropzone.QUEUED) {
+ _results.push(file);
+ }
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.getUploadingFiles = function() {
+ var file, _i, _len, _ref, _results;
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (file.status === Dropzone.UPLOADING) {
+ _results.push(file);
+ }
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.init = function() {
+ var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1,
+ _this = this;
+ if (this.element.tagName === "form") {
+ this.element.setAttribute("enctype", "multipart/form-data");
+ }
+ if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) {
+ this.element.appendChild(Dropzone.createElement("<div class=\"dz-default dz-message\"><span>" + this.options.dictDefaultMessage + "</span></div>"));
+ }
+ if (this.clickableElements.length) {
+ setupHiddenFileInput = function() {
+ if (_this.hiddenFileInput) {
+ document.body.removeChild(_this.hiddenFileInput);
+ }
+ _this.hiddenFileInput = document.createElement("input");
+ _this.hiddenFileInput.setAttribute("type", "file");
+ _this.hiddenFileInput.setAttribute("multiple", "multiple");
+ if (_this.options.acceptedFiles != null) {
+ _this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles);
+ }
+ _this.hiddenFileInput.style.visibility = "hidden";
+ _this.hiddenFileInput.style.position = "absolute";
+ _this.hiddenFileInput.style.top = "0";
+ _this.hiddenFileInput.style.left = "0";
+ _this.hiddenFileInput.style.height = "0";
+ _this.hiddenFileInput.style.width = "0";
+ document.body.appendChild(_this.hiddenFileInput);
+ return _this.hiddenFileInput.addEventListener("change", function() {
+ var files;
+ files = _this.hiddenFileInput.files;
+ if (files.length) {
+ _this.emit("selectedfiles", files);
+ _this.handleFiles(files);
+ }
+ return setupHiddenFileInput();
+ });
+ };
+ setupHiddenFileInput();
+ }
+ this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;
+ _ref1 = this.events;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ eventName = _ref1[_i];
+ this.on(eventName, this.options[eventName]);
+ }
+ this.on("uploadprogress", function() {
+ return _this.updateTotalUploadProgress();
+ });
+ this.on("removedfile", function() {
+ return _this.updateTotalUploadProgress();
+ });
+ this.on("canceled", function(file) {
+ return _this.emit("complete", file);
+ });
+ noPropagation = function(e) {
+ e.stopPropagation();
+ if (e.preventDefault) {
+ return e.preventDefault();
+ } else {
+ return e.returnValue = false;
+ }
+ };
+ this.listeners = [
+ {
+ element: this.element,
+ events: {
+ "dragstart": function(e) {
+ return _this.emit("dragstart", e);
+ },
+ "dragenter": function(e) {
+ noPropagation(e);
+ return _this.emit("dragenter", e);
+ },
+ "dragover": function(e) {
+ noPropagation(e);
+ return _this.emit("dragover", e);
+ },
+ "dragleave": function(e) {
+ return _this.emit("dragleave", e);
+ },
+ "drop": function(e) {
+ noPropagation(e);
+ return _this.drop(e);
+ },
+ "dragend": function(e) {
+ return _this.emit("dragend", e);
+ }
+ }
+ }
+ ];
+ this.clickableElements.forEach(function(clickableElement) {
+ return _this.listeners.push({
+ element: clickableElement,
+ events: {
+ "click": function(evt) {
+ if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) {
+ return _this.hiddenFileInput.click();
+ }
+ }
+ }
+ });
+ });
+ this.enable();
+ return this.options.init.call(this);
+ };
+
+ Dropzone.prototype.destroy = function() {
+ var _ref;
+ this.disable();
+ this.removeAllFiles(true);
+ if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) {
+ this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
+ this.hiddenFileInput = null;
+ }
+ return delete this.element.dropzone;
+ };
+
+ Dropzone.prototype.updateTotalUploadProgress = function() {
+ var acceptedFiles, file, totalBytes, totalBytesSent, totalUploadProgress, _i, _len, _ref;
+ totalBytesSent = 0;
+ totalBytes = 0;
+ acceptedFiles = this.getAcceptedFiles();
+ if (acceptedFiles.length) {
+ _ref = this.getAcceptedFiles();
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ totalBytesSent += file.upload.bytesSent;
+ totalBytes += file.upload.total;
+ }
+ totalUploadProgress = 100 * totalBytesSent / totalBytes;
+ } else {
+ totalUploadProgress = 100;
+ }
+ return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent);
+ };
+
+ Dropzone.prototype.getFallbackForm = function() {
+ var existingFallback, fields, fieldsString, form;
+ if (existingFallback = this.getExistingFallback()) {
+ return existingFallback;
+ }
+ fieldsString = "<div class=\"dz-fallback\">";
+ if (this.options.dictFallbackText) {
+ fieldsString += "<p>" + this.options.dictFallbackText + "</p>";
+ }
+ fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + (this.options.uploadMultiple ? "[]" : "") + "\" " + (this.options.uploadMultiple ? 'multiple="multiple"' : void 0) + " /><button type=\"submit\">Upload!</button></div>";
+ fields = Dropzone.createElement(fieldsString);
+ if (this.element.tagName !== "FORM") {
+ form = Dropzone.createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");
+ form.appendChild(fields);
+ } else {
+ this.element.setAttribute("enctype", "multipart/form-data");
+ this.element.setAttribute("method", this.options.method);
+ }
+ return form != null ? form : fields;
+ };
+
+ Dropzone.prototype.getExistingFallback = function() {
+ var fallback, getFallback, tagName, _i, _len, _ref;
+ getFallback = function(elements) {
+ var el, _i, _len;
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
+ el = elements[_i];
+ if (/(^| )fallback($| )/.test(el.className)) {
+ return el;
+ }
+ }
+ };
+ _ref = ["div", "form"];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ tagName = _ref[_i];
+ if (fallback = getFallback(this.element.getElementsByTagName(tagName))) {
+ return fallback;
+ }
+ }
+ };
+
+ Dropzone.prototype.setupEventListeners = function() {
+ var elementListeners, event, listener, _i, _len, _ref, _results;
+ _ref = this.listeners;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ elementListeners = _ref[_i];
+ _results.push((function() {
+ var _ref1, _results1;
+ _ref1 = elementListeners.events;
+ _results1 = [];
+ for (event in _ref1) {
+ listener = _ref1[event];
+ _results1.push(elementListeners.element.addEventListener(event, listener, false));
+ }
+ return _results1;
+ })());
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.removeEventListeners = function() {
+ var elementListeners, event, listener, _i, _len, _ref, _results;
+ _ref = this.listeners;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ elementListeners = _ref[_i];
+ _results.push((function() {
+ var _ref1, _results1;
+ _ref1 = elementListeners.events;
+ _results1 = [];
+ for (event in _ref1) {
+ listener = _ref1[event];
+ _results1.push(elementListeners.element.removeEventListener(event, listener, false));
+ }
+ return _results1;
+ })());
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.disable = function() {
+ var file, _i, _len, _ref, _results;
+ this.clickableElements.forEach(function(element) {
+ return element.classList.remove("dz-clickable");
+ });
+ this.removeEventListeners();
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ _results.push(this.cancelUpload(file));
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.enable = function() {
+ this.clickableElements.forEach(function(element) {
+ return element.classList.add("dz-clickable");
+ });
+ return this.setupEventListeners();
+ };
+
+ Dropzone.prototype.filesize = function(size) {
+ var string;
+ if (size >= 100000000000) {
+ size = size / 100000000000;
+ string = "TB";
+ } else if (size >= 100000000) {
+ size = size / 100000000;
+ string = "GB";
+ } else if (size >= 100000) {
+ size = size / 100000;
+ string = "MB";
+ } else if (size >= 100) {
+ size = size / 100;
+ string = "KB";
+ } else {
+ size = size * 10;
+ string = "b";
+ }
+ return "<strong>" + (Math.round(size) / 10) + "</strong> " + string;
+ };
+
+ Dropzone.prototype._updateMaxFilesReachedClass = function() {
+ if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) {
+ return this.element.classList.add("dz-max-files-reached");
+ } else {
+ return this.element.classList.remove("dz-max-files-reached");
+ }
+ };
+
+ Dropzone.prototype.drop = function(e) {
+ var files, items;
+ if (!e.dataTransfer) {
+ return;
+ }
+ this.emit("drop", e);
+ files = e.dataTransfer.files;
+ this.emit("selectedfiles", files);
+ if (files.length) {
+ items = e.dataTransfer.items;
+ if (items && items.length && ((items[0].webkitGetAsEntry != null) || (items[0].getAsEntry != null))) {
+ this.handleItems(items);
+ } else {
+ this.handleFiles(files);
+ }
+ }
+ };
+
+ Dropzone.prototype.handleFiles = function(files) {
+ var file, _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ _results.push(this.addFile(file));
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.handleItems = function(items) {
+ var entry, item, _i, _len;
+ for (_i = 0, _len = items.length; _i < _len; _i++) {
+ item = items[_i];
+ if (item.webkitGetAsEntry != null) {
+ entry = item.webkitGetAsEntry();
+ if (entry.isFile) {
+ this.addFile(item.getAsFile());
+ } else if (entry.isDirectory) {
+ this.addDirectory(entry, entry.name);
+ }
+ } else {
+ this.addFile(item.getAsFile());
+ }
+ }
+ };
+
+ Dropzone.prototype.accept = function(file, done) {
+ if (file.size > this.options.maxFilesize * 1024 * 1024) {
+ return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
+ } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {
+ return done(this.options.dictInvalidFileType);
+ } else if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) {
+ done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
+ return this.emit("maxfilesexceeded", file);
+ } else {
+ return this.options.accept.call(this, file, done);
+ }
+ };
+
+ Dropzone.prototype.addFile = function(file) {
+ var _this = this;
+ file.upload = {
+ progress: 0,
+ total: file.size,
+ bytesSent: 0
+ };
+ this.files.push(file);
+ file.status = Dropzone.ADDED;
+ this.emit("addedfile", file);
+ if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {
+ this.createThumbnail(file);
+ }
+ return this.accept(file, function(error) {
+ if (error) {
+ file.accepted = false;
+ return _this._errorProcessing([file], error);
+ } else {
+ return _this.enqueueFile(file);
+ }
+ });
+ };
+
+ Dropzone.prototype.enqueueFiles = function(files) {
+ var file, _i, _len;
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ this.enqueueFile(file);
+ }
+ return null;
+ };
+
+ Dropzone.prototype.enqueueFile = function(file) {
+ var _this = this;
+ file.accepted = true;
+ if (file.status === Dropzone.ADDED) {
+ file.status = Dropzone.QUEUED;
+ if (this.options.autoProcessQueue) {
+ return setTimeout((function() {
+ return _this.processQueue();
+ }), 1);
+ }
+ } else {
+ throw new Error("This file can't be queued because it has already been processed or was rejected.");
+ }
+ };
+
+ Dropzone.prototype.addDirectory = function(entry, path) {
+ var dirReader, entriesReader,
+ _this = this;
+ dirReader = entry.createReader();
+ entriesReader = function(entries) {
+ var _i, _len;
+ for (_i = 0, _len = entries.length; _i < _len; _i++) {
+ entry = entries[_i];
+ if (entry.isFile) {
+ entry.file(function(file) {
+ if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') {
+ return;
+ }
+ file.fullPath = "" + path + "/" + file.name;
+ return _this.addFile(file);
+ });
+ } else if (entry.isDirectory) {
+ _this.addDirectory(entry, "" + path + "/" + entry.name);
+ }
+ }
+ };
+ return dirReader.readEntries(entriesReader, function(error) {
+ return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0;
+ });
+ };
+
+ Dropzone.prototype.removeFile = function(file) {
+ if (file.status === Dropzone.UPLOADING) {
+ this.cancelUpload(file);
+ }
+ this.files = without(this.files, file);
+ this.emit("removedfile", file);
+ if (this.files.length === 0) {
+ return this.emit("reset");
+ }
+ };
+
+ Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) {
+ var file, _i, _len, _ref;
+ if (cancelIfNecessary == null) {
+ cancelIfNecessary = false;
+ }
+ _ref = this.files.slice();
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) {
+ this.removeFile(file);
+ }
+ }
+ return null;
+ };
+
+ Dropzone.prototype.createThumbnail = function(file) {
+ var fileReader,
+ _this = this;
+ fileReader = new FileReader;
+ fileReader.onload = function() {
+ var img;
+ img = new Image;
+ img.onload = function() {
+ var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3;
+ file.width = img.width;
+ file.height = img.height;
+ resizeInfo = _this.options.resize.call(_this, file);
+ if (resizeInfo.trgWidth == null) {
+ resizeInfo.trgWidth = _this.options.thumbnailWidth;
+ }
+ if (resizeInfo.trgHeight == null) {
+ resizeInfo.trgHeight = _this.options.thumbnailHeight;
+ }
+ canvas = document.createElement("canvas");
+ ctx = canvas.getContext("2d");
+ canvas.width = resizeInfo.trgWidth;
+ canvas.height = resizeInfo.trgHeight;
+ ctx.drawImage(img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
+ thumbnail = canvas.toDataURL("image/png");
+ return _this.emit("thumbnail", file, thumbnail);
+ };
+ return img.src = fileReader.result;
+ };
+ return fileReader.readAsDataURL(file);
+ };
+
+ Dropzone.prototype.processQueue = function() {
+ var i, parallelUploads, processingLength, queuedFiles;
+ parallelUploads = this.options.parallelUploads;
+ processingLength = this.getUploadingFiles().length;
+ i = processingLength;
+ if (processingLength >= parallelUploads) {
+ return;
+ }
+ queuedFiles = this.getQueuedFiles();
+ if (!(queuedFiles.length > 0)) {
+ return;
+ }
+ if (this.options.uploadMultiple) {
+ return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength));
+ } else {
+ while (i < parallelUploads) {
+ if (!queuedFiles.length) {
+ return;
+ }
+ this.processFile(queuedFiles.shift());
+ i++;
+ }
+ }
+ };
+
+ Dropzone.prototype.processFile = function(file) {
+ return this.processFiles([file]);
+ };
+
+ Dropzone.prototype.processFiles = function(files) {
+ var file, _i, _len;
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ file.processing = true;
+ file.status = Dropzone.UPLOADING;
+ this.emit("processing", file);
+ }
+ if (this.options.uploadMultiple) {
+ this.emit("processingmultiple", files);
+ }
+ return this.uploadFiles(files);
+ };
+
+ Dropzone.prototype._getFilesWithXhr = function(xhr) {
+ var file, files;
+ return files = (function() {
+ var _i, _len, _ref, _results;
+ _ref = this.files;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (file.xhr === xhr) {
+ _results.push(file);
+ }
+ }
+ return _results;
+ }).call(this);
+ };
+
+ Dropzone.prototype.cancelUpload = function(file) {
+ var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref;
+ if (file.status === Dropzone.UPLOADING) {
+ groupedFiles = this._getFilesWithXhr(file.xhr);
+ for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) {
+ groupedFile = groupedFiles[_i];
+ groupedFile.status = Dropzone.CANCELED;
+ }
+ file.xhr.abort();
+ for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) {
+ groupedFile = groupedFiles[_j];
+ this.emit("canceled", groupedFile);
+ }
+ if (this.options.uploadMultiple) {
+ this.emit("canceledmultiple", groupedFiles);
+ }
+ } else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) {
+ file.status = Dropzone.CANCELED;
+ this.emit("canceled", file);
+ if (this.options.uploadMultiple) {
+ this.emit("canceledmultiple", [file]);
+ }
+ }
+ if (this.options.autoProcessQueue) {
+ return this.processQueue();
+ }
+ };
+
+ Dropzone.prototype.uploadFile = function(file) {
+ return this.uploadFiles([file]);
+ };
+
+ Dropzone.prototype.uploadFiles = function(files) {
+ var file, formData, handleError, headerName, headerValue, headers, input, inputName, inputType, key, progressObj, response, updateProgress, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3,
+ _this = this;
+ xhr = new XMLHttpRequest();
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ file.xhr = xhr;
+ }
+ xhr.open(this.options.method, this.options.url, true);
+ xhr.withCredentials = !!this.options.withCredentials;
+ response = null;
+ handleError = function() {
+ var _j, _len1, _results;
+ _results = [];
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
+ file = files[_j];
+ _results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr));
+ }
+ return _results;
+ };
+ updateProgress = function(e) {
+ var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results;
+ if (e != null) {
+ progress = 100 * e.loaded / e.total;
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
+ file = files[_j];
+ file.upload = {
+ progress: progress,
+ total: e.total,
+ bytesSent: e.loaded
+ };
+ }
+ } else {
+ allFilesFinished = true;
+ progress = 100;
+ for (_k = 0, _len2 = files.length; _k < _len2; _k++) {
+ file = files[_k];
+ if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) {
+ allFilesFinished = false;
+ }
+ file.upload.progress = progress;
+ file.upload.bytesSent = file.upload.total;
+ }
+ if (allFilesFinished) {
+ return;
+ }
+ }
+ _results = [];
+ for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
+ file = files[_l];
+ _results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent));
+ }
+ return _results;
+ };
+ xhr.onload = function(e) {
+ var _ref;
+ if (files[0].status === Dropzone.CANCELED) {
+ return;
+ }
+ if (xhr.readyState !== 4) {
+ return;
+ }
+ response = xhr.responseText;
+ if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) {
+ try {
+ response = JSON.parse(response);
+ } catch (_error) {
+ e = _error;
+ response = "Invalid JSON response from server.";
+ }
+ }
+ updateProgress();
+ if (!((200 <= (_ref = xhr.status) && _ref < 300))) {
+ return handleError();
+ } else {
+ return _this._finished(files, response, e);
+ }
+ };
+ xhr.onerror = function() {
+ if (files[0].status === Dropzone.CANCELED) {
+ return;
+ }
+ return handleError();
+ };
+ progressObj = (_ref = xhr.upload) != null ? _ref : xhr;
+ progressObj.onprogress = updateProgress;
+ headers = {
+ "Accept": "application/json",
+ "Cache-Control": "no-cache",
+ "X-Requested-With": "XMLHttpRequest"
+ };
+ if (this.options.headers) {
+ extend(headers, this.options.headers);
+ }
+ for (headerName in headers) {
+ headerValue = headers[headerName];
+ xhr.setRequestHeader(headerName, headerValue);
+ }
+ formData = new FormData();
+ if (this.options.params) {
+ _ref1 = this.options.params;
+ for (key in _ref1) {
+ value = _ref1[key];
+ formData.append(key, value);
+ }
+ }
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
+ file = files[_j];
+ this.emit("sending", file, xhr, formData);
+ }
+ if (this.options.uploadMultiple) {
+ this.emit("sendingmultiple", files, xhr, formData);
+ }
+ if (this.element.tagName === "FORM") {
+ _ref2 = this.element.querySelectorAll("input, textarea, select, button");
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+ input = _ref2[_k];
+ inputName = input.getAttribute("name");
+ inputType = input.getAttribute("type");
+ if (!inputType || ((_ref3 = inputType.toLowerCase()) !== "checkbox" && _ref3 !== "radio") || input.checked) {
+ formData.append(inputName, input.value);
+ }
+ }
+ }
+ for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
+ file = files[_l];
+ formData.append("" + this.options.paramName + (this.options.uploadMultiple ? "[]" : ""), file, file.name);
+ }
+ return xhr.send(formData);
+ };
+
+ Dropzone.prototype._finished = function(files, responseText, e) {
+ var file, _i, _len;
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ file.status = Dropzone.SUCCESS;
+ this.emit("success", file, responseText, e);
+ this.emit("complete", file);
+ }
+ if (this.options.uploadMultiple) {
+ this.emit("successmultiple", files, responseText, e);
+ this.emit("completemultiple", files);
+ }
+ if (this.options.autoProcessQueue) {
+ return this.processQueue();
+ }
+ };
+
+ Dropzone.prototype._errorProcessing = function(files, message, xhr) {
+ var file, _i, _len;
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ file.status = Dropzone.ERROR;
+ this.emit("error", file, message, xhr);
+ this.emit("complete", file);
+ }
+ if (this.options.uploadMultiple) {
+ this.emit("errormultiple", files, message, xhr);
+ this.emit("completemultiple", files);
+ }
+ if (this.options.autoProcessQueue) {
+ return this.processQueue();
+ }
+ };
+
+ return Dropzone;
+
+ })(Em);
+
+ Dropzone.version = "3.7.1";
+
+ Dropzone.options = {};
+
+ Dropzone.optionsForElement = function(element) {
+ if (element.id) {
+ return Dropzone.options[camelize(element.id)];
+ } else {
+ return void 0;
+ }
+ };
+
+ Dropzone.instances = [];
+
+ Dropzone.forElement = function(element) {
+ if (typeof element === "string") {
+ element = document.querySelector(element);
+ }
+ if ((element != null ? element.dropzone : void 0) == null) {
+ throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");
+ }
+ return element.dropzone;
+ };
+
+ Dropzone.autoDiscover = true;
+
+ Dropzone.discover = function() {
+ var checkElements, dropzone, dropzones, _i, _len, _results;
+ if (document.querySelectorAll) {
+ dropzones = document.querySelectorAll(".dropzone");
+ } else {
+ dropzones = [];
+ checkElements = function(elements) {
+ var el, _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
+ el = elements[_i];
+ if (/(^| )dropzone($| )/.test(el.className)) {
+ _results.push(dropzones.push(el));
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+ checkElements(document.getElementsByTagName("div"));
+ checkElements(document.getElementsByTagName("form"));
+ }
+ _results = [];
+ for (_i = 0, _len = dropzones.length; _i < _len; _i++) {
+ dropzone = dropzones[_i];
+ if (Dropzone.optionsForElement(dropzone) !== false) {
+ _results.push(new Dropzone(dropzone));
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+
+ Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];
+
+ Dropzone.isBrowserSupported = function() {
+ var capableBrowser, regex, _i, _len, _ref;
+ capableBrowser = true;
+ if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
+ if (!("classList" in document.createElement("a"))) {
+ capableBrowser = false;
+ } else {
+ _ref = Dropzone.blacklistedBrowsers;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ regex = _ref[_i];
+ if (regex.test(navigator.userAgent)) {
+ capableBrowser = false;
+ continue;
+ }
+ }
+ }
+ } else {
+ capableBrowser = false;
+ }
+ return capableBrowser;
+ };
+
+ without = function(list, rejectedItem) {
+ var item, _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = list.length; _i < _len; _i++) {
+ item = list[_i];
+ if (item !== rejectedItem) {
+ _results.push(item);
+ }
+ }
+ return _results;
+ };
+
+ camelize = function(str) {
+ return str.replace(/[\-_](\w)/g, function(match) {
+ return match[1].toUpperCase();
+ });
+ };
+
+ Dropzone.createElement = function(string) {
+ var div;
+ div = document.createElement("div");
+ div.innerHTML = string;
+ return div.childNodes[0];
+ };
+
+ Dropzone.elementInside = function(element, container) {
+ if (element === container) {
+ return true;
+ }
+ while (element = element.parentNode) {
+ if (element === container) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+ Dropzone.getElement = function(el, name) {
+ var element;
+ if (typeof el === "string") {
+ element = document.querySelector(el);
+ } else if (el.nodeType != null) {
+ element = el;
+ }
+ if (element == null) {
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element.");
+ }
+ return element;
+ };
+
+ Dropzone.getElements = function(els, name) {
+ var e, el, elements, _i, _j, _len, _len1, _ref;
+ if (els instanceof Array) {
+ elements = [];
+ try {
+ for (_i = 0, _len = els.length; _i < _len; _i++) {
+ el = els[_i];
+ elements.push(this.getElement(el, name));
+ }
+ } catch (_error) {
+ e = _error;
+ elements = null;
+ }
+ } else if (typeof els === "string") {
+ elements = [];
+ _ref = document.querySelectorAll(els);
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
+ el = _ref[_j];
+ elements.push(el);
+ }
+ } else if (els.nodeType != null) {
+ elements = [els];
+ }
+ if (!((elements != null) && elements.length)) {
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");
+ }
+ return elements;
+ };
+
+ Dropzone.confirm = function(question, accepted, rejected) {
+ if (window.confirm(question)) {
+ return accepted();
+ } else if (rejected != null) {
+ return rejected();
+ }
+ };
+
+ Dropzone.isValidFile = function(file, acceptedFiles) {
+ var baseMimeType, mimeType, validType, _i, _len;
+ if (!acceptedFiles) {
+ return true;
+ }
+ acceptedFiles = acceptedFiles.split(",");
+ mimeType = file.type;
+ baseMimeType = mimeType.replace(/\/.*$/, "");
+ for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) {
+ validType = acceptedFiles[_i];
+ validType = validType.trim();
+ if (validType.charAt(0) === ".") {
+ if (file.name.indexOf(validType, file.name.length - validType.length) !== -1) {
+ return true;
+ }
+ } else if (/\/\*$/.test(validType)) {
+ if (baseMimeType === validType.replace(/\/.*$/, "")) {
+ return true;
+ }
+ } else {
+ if (mimeType === validType) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+
+ if (typeof jQuery !== "undefined" && jQuery !== null) {
+ jQuery.fn.dropzone = function(options) {
+ return this.each(function() {
+ return new Dropzone(this, options);
+ });
+ };
+ }
+
+ if (typeof module !== "undefined" && module !== null) {
+ module.exports = Dropzone;
+ } else {
+ window.Dropzone = Dropzone;
+ }
+
+ Dropzone.ADDED = "added";
+
+ Dropzone.QUEUED = "queued";
+
+ Dropzone.ACCEPTED = Dropzone.QUEUED;
+
+ Dropzone.UPLOADING = "uploading";
+
+ Dropzone.PROCESSING = Dropzone.UPLOADING;
+
+ Dropzone.CANCELED = "canceled";
+
+ Dropzone.ERROR = "error";
+
+ Dropzone.SUCCESS = "success";
+
+ /*
+ # contentloaded.js
+ #
+ # Author: Diego Perini (diego.perini at gmail.com)
+ # Summary: cross-browser wrapper for DOMContentLoaded
+ # Updated: 20101020
+ # License: MIT
+ # Version: 1.2
+ #
+ # URL:
+ # http://javascript.nwbox.com/ContentLoaded/
+ # http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
+ */
+
+
+ contentLoaded = function(win, fn) {
+ var add, doc, done, init, poll, pre, rem, root, top;
+ done = false;
+ top = true;
+ doc = win.document;
+ root = doc.documentElement;
+ add = (doc.addEventListener ? "addEventListener" : "attachEvent");
+ rem = (doc.addEventListener ? "removeEventListener" : "detachEvent");
+ pre = (doc.addEventListener ? "" : "on");
+ init = function(e) {
+ if (e.type === "readystatechange" && doc.readyState !== "complete") {
+ return;
+ }
+ (e.type === "load" ? win : doc)[rem](pre + e.type, init, false);
+ if (!done && (done = true)) {
+ return fn.call(win, e.type || e);
+ }
+ };
+ poll = function() {
+ var e;
+ try {
+ root.doScroll("left");
+ } catch (_error) {
+ e = _error;
+ setTimeout(poll, 50);
+ return;
+ }
+ return init("poll");
+ };
+ if (doc.readyState !== "complete") {
+ if (doc.createEventObject && root.doScroll) {
+ try {
+ top = !win.frameElement;
+ } catch (_error) {}
+ if (top) {
+ poll();
+ }
+ }
+ doc[add](pre + "DOMContentLoaded", init, false);
+ doc[add](pre + "readystatechange", init, false);
+ return win[add](pre + "load", init, false);
+ }
+ };
+
+ Dropzone._autoDiscoverFunction = function() {
+ if (Dropzone.autoDiscover) {
+ return Dropzone.discover();
+ }
+ };
+
+ contentLoaded(window, Dropzone._autoDiscoverFunction);
+
+}).call(this);
+
+});
+require.alias("component-emitter/index.js", "dropzone/deps/emitter/index.js");
+require.alias("component-emitter/index.js", "emitter/index.js");
+if (typeof exports == "object") {
+ module.exports = require("dropzone");
+} else if (typeof define == "function" && define.amd) {
+ define(function(){ return require("dropzone"); });
+} else {
+ this["Dropzone"] = require("dropzone");
+}})();
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/model/EntityModel.java b/gitop.web/src/main/java/com/pmease/gitop/web/model/EntityModel.java
index ff96565a40..b51cb2b691 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/model/EntityModel.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/model/EntityModel.java
@@ -4,18 +4,24 @@ package com.pmease.gitop.web.model;
import org.apache.wicket.model.LoadableDetachableModel;
import com.pmease.commons.hibernate.AbstractEntity;
-import com.pmease.commons.hibernate.dao.GenericDao;
+import com.pmease.commons.hibernate.dao.GeneralDao;
+import com.pmease.commons.loader.AppLoader;
-public abstract class EntityModel<T extends AbstractEntity> extends LoadableDetachableModel<T> {
+public class EntityModel<T extends AbstractEntity> extends LoadableDetachableModel<T> {
private static final long serialVersionUID = 1L;
protected T entity;
+ private final Class<T> entityClass;
- abstract protected GenericDao<T> getDao();
+ protected GeneralDao getDao() {
+ return AppLoader.getInstance(GeneralDao.class);
+ }
- public EntityModel(T entity) {
+ @SuppressWarnings("unchecked")
+public EntityModel(T entity) {
this.entity = entity;
+ this.entityClass = (Class<T>) entity.getClass();
}
@Override
@@ -23,7 +29,7 @@ public abstract class EntityModel<T extends AbstractEntity> extends LoadableDeta
if (entity.isNew()) {
return entity;
} else {
- return getDao().get(entity.getId());
+ return getDao().get(entityClass, entity.getId());
}
}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/model/ProjectModel.java b/gitop.web/src/main/java/com/pmease/gitop/web/model/ProjectModel.java
new file mode 100644
index 0000000000..cb8331813d
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/model/ProjectModel.java
@@ -0,0 +1,13 @@
+package com.pmease.gitop.web.model;
+
+import com.pmease.gitop.core.model.Project;
+
+/** Shortcut for {@link EntityModel}<Project> */
+public class ProjectModel extends EntityModel<Project> {
+ private static final long serialVersionUID = 1L;
+
+ public ProjectModel(Project entity) {
+ super(entity);
+ }
+
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/model/UserModel.java b/gitop.web/src/main/java/com/pmease/gitop/web/model/UserModel.java
index e794055416..df11198184 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/model/UserModel.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/model/UserModel.java
@@ -1,10 +1,8 @@
package com.pmease.gitop.web.model;
-import com.pmease.commons.hibernate.dao.GenericDao;
-import com.pmease.commons.loader.AppLoader;
-import com.pmease.gitop.core.manager.UserManager;
import com.pmease.gitop.core.model.User;
+/** shortcut to {@link EntityModel}<User> */
public class UserModel extends EntityModel<User> {
private static final long serialVersionUID = 1L;
@@ -13,9 +11,4 @@ public class UserModel extends EntityModel<User> {
super(entity);
}
- @Override
- protected GenericDao<User> getDao() {
- return AppLoader.getInstance(UserManager.class);
- }
-
}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/account/setting/permission/AccountPermissionPage.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/account/setting/permission/AccountPermissionPage.html
new file mode 100644
index 0000000000..a556d8d5fa
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/account/setting/permission/AccountPermissionPage.html
@@ -0,0 +1,21 @@
+<html xmlns:wicket>
+<wicket:extend>
+ <section>
+ <div class="head">
+ <h2>Account Permissions</h2>
+ </div>
+ <div class="body">
+ <h4>Anonymous Users</h4>
+ <p><a>Anonymous users can browse and pull any repositories under this account </a></p>
+ <hr/>
+
+ <h4>Logged-in Users</h4>
+ <p class="text-muted">Logged-in users can access any repositories under this account with permission:</p>
+ <hr/>
+
+ <h4>Teams</h4>
+ <p class="text-muted"></p>
+ </div>
+ </section>
+</wicket:extend>
+</html>
\ No newline at end of file
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.html
index d24a0b63ed..0771816dbd 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.html
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.html
@@ -1,27 +1,11 @@
<html xmlns:wicket>
<wicket:extend>
<div class="container">
- <h2>Messenger Test</h2>
- <div class="btn-group">
- <a class="btn btn-info" wicket:id="ajaxinfo">ajax info</a>
- <a class="btn btn-danger" wicket:id="ajaxerror">ajax error</a>
- <a class="btn btn-success" wicket:id="ajaxsuccess">ajax success</a>
- </div>
- <p></p>
-
- <h3>Flat UI Form</h3>
- <form class="custom-form" wicket:id="form">
- <div wicket:id="feedback" class="form-feedback"></div>
- <div wicket:id="check"></div>
-
- <wicket:container wicket:id="group">
- <wicket:container wicket:id="radio">
- <wicket:container wicket:id="element"></wicket:container>
- </wicket:container>
- </wicket:container>
-
- <button class="btn btn-primary" wicket:id="btn">Submit</button>
- </form>
+ <form class="dropzone" enctype="multipart/form-data" action="/rest/file/upload">
+ <div class="fallback">
+ <input name="file" type="file" multiple />
+ </div>
+ </form>
</div>
</wicket:extend>
</html>
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.java
index 43ae3514cc..593ed4bb6d 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/home/HomePage.java
@@ -1,21 +1,7 @@
package com.pmease.gitop.web.page.home;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.RadioGroup;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.PropertyModel;
-
-import com.google.common.collect.ImmutableList;
-import com.pmease.gitop.web.common.component.messenger.Messenger;
-import com.pmease.gitop.web.common.component.vex.AjaxConfirmButton;
+import com.pmease.gitop.web.common.component.dropzone.DropZoneBehavior;
import com.pmease.gitop.web.common.component.vex.VexLinkBehavior.VexIcon;
-import com.pmease.gitop.web.common.form.FeedbackPanel;
-import com.pmease.gitop.web.common.form.flatcheckbox.FlatCheckBoxElement;
-import com.pmease.gitop.web.common.form.flatradio.FlatRadioElement;
import com.pmease.gitop.web.page.AbstractLayoutPage;
public class HomePage extends AbstractLayoutPage {
@@ -27,67 +13,11 @@ public class HomePage extends AbstractLayoutPage {
return "Gitop - Home";
}
- @SuppressWarnings("serial")
@Override
protected void onInitialize() {
super.onInitialize();
-// add(new BookmarkablePageLink<>("accountLink", AccountHomePage.class, AccountHomePage.paramsOf(Gitop.getInstance(UserManager.class).getRootUser())));
-// add(new BookmarkablePageLink<>("projectLink", ProjectHomePage.class, ProjectHomePage.paramsOf(Gitop.getInstance(ProjectManager.class).load(1L))));
-
- add(new AjaxLink<Void>("ajaxinfo") {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- Messenger.info("ajax info clicked").execute(target);;
- }
- });
-
- add(new AjaxLink<Void>("ajaxerror") {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- Messenger.error("ajax error clicked").execute(target);;
- }
- });
-
- add(new AjaxLink<Void>("ajaxsuccess") {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- Messenger.success("ajax success clicked!").execute(target);;
- }
- });
-
- Form<?> form = new Form<Void>("form");
- add(form);
- form.add(new FeedbackPanel("feedback"));
- form.add(new FlatCheckBoxElement("check", new PropertyModel<Boolean>(this, "displayed"),
- Model.of("Displayed screen")));
- form.add(new AjaxConfirmButton("btn", form, Model.of("Are you want to save this form?")) {
- @Override
- protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
- if (displayed) {
- form.info("yes");
- target.add(form);
- return;
- }
-
- System.out.println("Here is " + vexIcon);
- target.add(form);
- }
- });
-
- RadioGroup<VexIcon> group = new RadioGroup<VexIcon>("group", new PropertyModel<VexIcon>(this, "vexIcon"));
- form.add(group);
- group.add(new ListView<VexIcon>("radio", ImmutableList.<VexIcon>copyOf(VexIcon.values())) {
-
- @Override
- protected void populateItem(ListItem<VexIcon> item) {
-// item.add(new Radio<VexIcon>("element", item.getModel()));
- item.add(new FlatRadioElement<VexIcon>("element", item.getModel(), item.getDefaultModelObjectAsString()));
- }
- });
+ add(new DropZoneBehavior());
}
VexIcon vexIcon = VexIcon.INFO;
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectHomePage.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectHomePage.java
index 77295e700d..cee1f89a28 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectHomePage.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectHomePage.java
@@ -69,7 +69,9 @@ public class ProjectHomePage extends AbstractLayoutPage {
@Override
public void detachModels() {
- projectModel.detach();
+ if (projectModel != null)
+ projectModel.detach();
+
super.detachModels();
}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/resource/TestResource.java b/gitop.web/src/main/java/com/pmease/gitop/web/resource/TestResource.java
index 217252f0b1..a1f370f7ad 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/resource/TestResource.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/resource/TestResource.java
@@ -33,6 +33,12 @@ public class TestResource {
@Inject ObjectMapper objectMapper;
+ @GET
+ @Path("test")
+ public String test() {
+ return "Hello, Jersey";
+ }
+
@GET
public String getResult() throws JsonProcessingException {
Result result = new Result();