/** * Calls {@link #getCallbackFunction(CallbackParameter...)} by passing {@link CallbackParameter}{@code s} from {@link #getCallbackParameters()} * * @return the javascript function. */ public String getCallbackFunction() { return super.getCallbackFunction(this.getCallbackParameters()).toString(); } }
/** * Calls {@link #getCallbackFunction(CallbackParameter...)} by passing {@link CallbackParameter}<code>s</code> from {@link #getCallbackParameters()} * * @return the javascript function. */ public String getCallbackFunction() { return super.getCallbackFunction(this.getCallbackParameters()).toString(); }
/** * Calls {@link #getCallbackFunction(CallbackParameter...)} by passing {@link CallbackParameter}{@code s} from {@link #getCallbackParameters()} * * @return the javascript function. */ public String getCallbackFunction() { return super.getCallbackFunction(this.getCallbackParameters()).toString(); } }
@Override public void renderHead(IHeaderResponse response) { super.renderHead(response); CommitInfoManager commitInfoManager = OneDev.getInstance(CommitInfoManager.class); Map<Long, Integer[]> data = new HashMap<>(); Map<Day, Contribution> overallContributions = commitInfoManager.getOverallContributions(getProject()); for (Map.Entry<Day, Contribution> entry: overallContributions.entrySet()) { Contribution contribution = entry.getValue(); Integer[] dataValue = new Integer[] {contribution.getCommits(), contribution.getAdditions(), contribution.getDeletions()}; data.put(entry.getKey().getDate().getTime(), dataValue); } PageParameters params = TopContributorsResource.paramsOf(getProject()); String topContributorsUrl = urlFor(new TopContributorsResourceReference(), params).toString(); String jsonOfData; try { jsonOfData = OneDev.getInstance(ObjectMapper.class).writeValueAsString(data); } catch (JsonProcessingException e) { throw new RuntimeException(e); } CharSequence callback = userDetailBehavior.getCallbackFunction(CallbackParameter.explicit("userIdent")); String script = String.format("onedev.server.stats.contribs.onDomReady(%s, '%s', %s);", jsonOfData, topContributorsUrl, callback); response.render(OnDomReadyHeaderItem.forScript(script)); }
@Override public void onEvent(IEvent<?> event) { super.onEvent(event); if (event.getPayload() instanceof BlobNameChanging) { /* * Blob name is changing and current editor might be inappropriate for current * blob name, so we need to re-create the editor if the form does not have * any change yet */ BlobNameChanging payload = (BlobNameChanging) event.getPayload(); String script = String.format("onedev.server.blobEdit.onNameChanging('%s', %s, %s);", getMarkupId(), context.getMode() == Mode.ADD, recreateBehavior.getCallbackFunction()); payload.getHandler().appendJavaScript(script); } }
@Override public void renderHead(IHeaderResponse response) { super.renderHead(response); response.render(JavaScriptHeaderItem.forReference(new FolderViewResourceReference())); PageParameters params = LastCommitsResource.paramsOf(context.getProject(), context.getBlobIdent().revision, context.getBlobIdent().path); String lastCommitsUrl = urlFor(new LastCommitsResourceReference(), params).toString(); CharSequence callback = userDetailBehavior.getCallbackFunction(CallbackParameter.explicit("userIdent")); String script = String.format("onedev.server.folderView.onDomReady('%s', '%s', %s)", getMarkupId(), lastCommitsUrl, callback); response.render(OnDomReadyHeaderItem.forScript(script)); }