Skip to content

Commit

Permalink
use codemirror for JSON editing
Browse files Browse the repository at this point in the history
  • Loading branch information
j-wangminghui committed Aug 7, 2018
1 parent 4ce0402 commit 17bcb73
Show file tree
Hide file tree
Showing 352 changed files with 75,663 additions and 14 deletions.
26 changes: 18 additions & 8 deletions static/js/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var dkron = angular.module('dkron', ['angular-rickshaw']);
var dkron = angular.module('dkron', ['angular-rickshaw', 'ui.codemirror']);

dkron.filter('statusClass', function() {
var friendlyStatusFilter = function(job) {
Expand All @@ -23,7 +23,10 @@ dkron.filter('statusClass', function() {
dkron.constant('hideDelay', 2000);

dkron.controller('JobListCtrl', function ($scope, $http, $interval, hideDelay) {
$scope.jobTemplateId = "job_template"
// pretty json func
$scope.toJson = function (str) {
return angular.toJson(str, true);
}
$scope.jobTemplate = {
name: "child_job",
schedule: "",
Expand All @@ -44,6 +47,15 @@ dkron.controller('JobListCtrl', function ($scope, $http, $interval, hideDelay) {
command: ""
}
}
$scope.jobTemplateJson = $scope.toJson($scope.jobTemplate);

$scope.editorOptions = {
lineWrapping : true,
autoCloseBrackets: true,
autoRefresh:true,
height:"auto",
mode: "application/json",
};

$scope.runJob = function(jobName) {
$scope["running_" + jobName] = true;
Expand All @@ -62,10 +74,9 @@ dkron.controller('JobListCtrl', function ($scope, $http, $interval, hideDelay) {
});
};

$scope.createJob = function() {
jsonJob = document.getElementById($scope.jobTemplateId).innerHTML;
$scope.createJob = function(jobTemplateJson) {
try {
job = angular.fromJson(jsonJob);
job = angular.fromJson(jobTemplateJson);
} catch (err) {
window.alert('Json Format Error');
return
Expand All @@ -86,10 +97,9 @@ dkron.controller('JobListCtrl', function ($scope, $http, $interval, hideDelay) {
});
};

$scope.updateJob = function(job) {
jsonJob = document.getElementById(job.name).innerHTML;
$scope.updateJob = function(jobJson) {
try {
job = angular.fromJson(jsonJob);
job = angular.fromJson(jobJson);
} catch (err) {
window.alert('Json Format Error');
return
Expand Down
1 change: 1 addition & 0 deletions static/node_modules/angular-ui-codemirror/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions static/node_modules/angular-ui-codemirror/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions static/node_modules/angular-ui-codemirror/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions static/node_modules/angular-ui-codemirror/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions static/node_modules/angular-ui-codemirror/.idea/ui-codemirror.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions static/node_modules/angular-ui-codemirror/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 17bcb73

Please sign in to comment.