unserver-unify
Version:
48 lines (46 loc) • 1.44 kB
JavaScript
;
angular.module('bamboo.topic')
.controller('ClassTopicEditCtrl', function(TopicApi, CommonService, ApiService, $state, $stateParams) {
var self = this;
this.classid = $stateParams.classid;
this.topic = {
groupId:this.classid,
content:"",
action:'create',
};
this.submit = function() {
if (!self.topic.title||self.topic.title.length<2) {
CommonService.showError("Not enough length!");
return;
}
console.log(self.topic);
TopicApi.GroupApi(self.topic, function(result) {
// console.log(result);
$state.go('^');
});
};
var forumurl = ApiService.PSURL + '/grouptopic/' + self.classid + "/";
var wikiImgSetting = {
image: true,
promise: true,
s3: true,
title: "Image",
maxheight: 400,
maxwidth: 400,
randomFlag: true,
resPath: "public/" + ApiService.RES + '/grouptopic/' + self.classid + "/",
};
this.uploadFile = function(uploadSetting, index) {
// initImageUrl(uploadSetting, index);
CommonService.uploadFile(wikiImgSetting).then(function(data) {
if (data.result) {
console.log(data.fileName);
var imgstr = '<img src="' + forumurl + data.fileName + '" width="50%"/>';
//console.log(imgstr);
self.topic.content += imgstr;
} else {
CommonService.showError("Update failed: " + data.message);
}
});
};
});