Skip to content

Commit

Permalink
继续完善 Build 和 Download
Browse files Browse the repository at this point in the history
  • Loading branch information
leenjewel committed Sep 18, 2015
1 parent ce0a878 commit 2e3e8a4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
4 changes: 4 additions & 0 deletions apk.builder/pyMySDKAPKBuilder/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ def init_output_apk(self, output_name = None) :
self.context["output_apk"] = os.path.abspath(os.path.join(output_path, output_name))


def get_output_name(self) :
return os.path.split(self.context["output_apk"])[1]


def init_android_sdk(self) :
tools = ["aapt", "dx", "zipalign"]
for tool in tools :
Expand Down
41 changes: 34 additions & 7 deletions apk.builder/pyMySDKWebFrontEnd/templates/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ <h4 class="label label-info form-control">{{ workspace_project.context["apk_path
<div class="form-group">
<label for="outputAPK">Output APK Name:</label>
{% if is_build_project %}
<input type="text" class="form-control" name="project_output_apk" id="project-output-apk" placeholder="Output APK Name" value="{{ workspace_project.context['output_apk'] }}" readonly />
<input type="text" class="form-control" name="project_output_apk" id="project-output-apk" placeholder="Output APK Name" value="{{ workspace_project.get_output_name() }}" readonly />
{% else %}
<input type="text" class="form-control" name="project_output_apk" id="project-output-apk" placeholder="Output APK Name" value="{{ workspace_project.context['output_apk'] }}" />
<input type="text" class="form-control" name="project_output_apk" id="project-output-apk" placeholder="Output APK Name" value="{{ workspace_project.get_output_name() }}" />
{% end %}
</div>
<div class="form-group">
Expand Down Expand Up @@ -121,18 +121,18 @@ <h4 class="label label-info form-control">{{ workspace_project.context["keystore
</div>
<div class="form-group">
{% if is_build_project %}
<div class="btn btn-primary btn-lg" onclick="mysdkBuildProject()">
<div id="mysdk-build-btn" class="btn btn-primary btn-lg" onclick="mysdkBuildProject()">
<span class="glyphicon glyphicon-fire"></span>
<span class="btn-text">Build Project</span>
</div>
{% else %}
{% if is_create_project %}
<div class="btn btn-primary btn-lg" onclick="mysdkUpdateProject()">
<div id="mysdk-project-btn" class="btn btn-primary btn-lg" onclick="mysdkUpdateProject()">
<span class="glyphicon glyphicon-floppy-save"></span>
<span class="btn-text">Create Project</span>
</div>
{% else %}
<div class="btn btn-primary btn-lg" onclick="mysdkUpdateProject()">
<div id="mysdk-project-btn" class="btn btn-primary btn-lg" onclick="mysdkUpdateProject()">
<span class="glyphicon glyphicon-floppy-save"></span>
<span class="btn-text">Save Project</span>
</div>
Expand All @@ -151,17 +151,21 @@ <h4 class="modal-title" id="mysdk-build-modal-label">Build Project</h4>
</div>
<div class="modal-body">
<div class="form-group">
<textarea id="mysdk-build-log" class="form-control" rows="24" readonly>
<textarea id="mysdk-build-log" class="form-control" rows="16" readonly>
</textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary btn-lg" data-dismiss="modal">Close</button>
<button id="mysdk-build-modal-btn" type="button" class="btn btn-primary btn-lg">Get APK</button>
</div>
</div>
</div>
</div>
<!-- Build Modal End -->
<!-- Build Download Begin -->
<iframe id="mysdk-build-download-iframe" src="#" width="1" height="1" frameborder="0">
</iframe>
<!-- Build Download End -->
<script type="text/javascript">
function mysdkUpdateProject() {
var projectForm = $("#mysdk-project-form");
Expand Down Expand Up @@ -215,6 +219,12 @@ <h4 class="modal-title" id="mysdk-build-modal-label">Build Project</h4>
});
});
$("#mysdk-build-modal").on("shown.bs.modal", function(e){
if (!window.__mysdkBuildProgressSeek) {
var mysdkBuildLog = $("#mysdk-build-log");
mysdkBuildLog.text("");
mysdkBuildLog.scrollTop(0);
}
$("#mysdk-build-modal-btn").button("loading");
if (window.WebSocket) {
var hostAndPort = window.location.host;
if (window.__mysdkBuildProgressWS) {
Expand Down Expand Up @@ -243,6 +253,7 @@ <h4 class="modal-title" id="mysdk-build-modal-label">Build Project</h4>
if (window.__mysdkBuildProgressWS) {
window.__mysdkBuildProgressWS.close()
}
$("#mysdk-build-modal-btn").button("reset");
}
};
} else {
Expand All @@ -265,6 +276,7 @@ <h4 class="modal-title" id="mysdk-build-modal-label">Build Project</h4>
mysdkBuildProgressPS(data.seek);
} else {
window.__mysdkBuildProgressSeek = 0;
$("#mysdk-build-modal-btn").button("reset");
}
},
"json"
Expand All @@ -280,6 +292,21 @@ <h4 class="modal-title" id="mysdk-build-modal-label">Build Project</h4>
window.__mysdkBuildProgressWS = undefined;
}
window.__mysdkBuildProgressModalClose = true;
$("#mysdk-build-modal-btn").button("reset");
});
$("#mysdk-build-modal-btn").on("click", function(e){
var iframeDoc = (document.getElementById('mysdk-build-download-iframe').contentWindow.document);
var mysdkBuildDownloadForm = iframeDoc.getElementById("mysdk-build-download-form");
if (mysdkBuildDownloadForm) {
iframeDoc.removeChild(mysdkBuildDownloadForm);
}
mysdkBuildDownloadForm = iframeDoc.createElement("form");
mysdkBuildDownloadForm.setAttribute("id", "mysdk-build-download-form");
mysdkBuildDownloadForm.setAttribute("method", "get");
mysdkBuildDownloadForm.setAttribute("action", "/download/{{ workspace_name }}/{{ project_name }}");
iframeDoc.body.appendChild(mysdkBuildDownloadForm);
mysdkBuildDownloadForm.submit();
$("#mysdk-build-modal").modal("hide");
});
});
</script>

0 comments on commit 2e3e8a4

Please sign in to comment.