Skip to content

Commit

Permalink
add schedule name dobule check
Browse files Browse the repository at this point in the history
  • Loading branch information
skadefro committed Aug 12, 2023
1 parent 2ab5498 commit d504cb6
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions OpenFlow/src/public/Controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8218,13 +8218,20 @@ export class AgentCtrl extends entityCtrl<any> {
if(this.newpackage._id == "") return;
var cron = this.newcron;
if(this.newpackage.daemon == true) cron = "";
this.model.schedules.push({
var nameexists = this.model.schedules.find(x => x.name == this.newpackage.name)
const schedule = {
name: this.newpackage.name,
packageid: this.newpackage._id,
enabled: true,
cron,
"env": {}
})
}
if(nameexists != null) {
schedule.name = this.newpackage.name + "_" + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)
return;
}
this.model.schedules.push(schedule)
this.newcron = "* * * * *"
}
removepackage(schedule) {
var index = this.model.schedules.indexOf(schedule);
Expand Down Expand Up @@ -8273,6 +8280,15 @@ export class AgentCtrl extends entityCtrl<any> {
if (image != null && image != "") {
this.model.docker = true;
}
if(this.model.schedules == null) this.model.schedules = [];
var schedulenames = this.model.schedules.map(x => x.name);
// does schedulenames has doubles?
var doubles = schedulenames.filter((item, index) => schedulenames.indexOf(item) != index)
if(doubles.length > 0) {
this.errormessage = "Schedule names must be unique"
return;
}

if (this.model._id) {
await NoderedUtil.UpdateOne({ collectionname: this.collection, item: this.model });
if(this.instances.length == 0 && this.model.image != null && this.model.image != "") {
Expand Down Expand Up @@ -8658,6 +8674,9 @@ export class RunPackageCtrl extends entityCtrl<Base> {
async addprocess(streamid:string, schedulename:string = undefined): Promise<void> {
var _a = this.agents.find(x => x._id == this.id);
if (_a == null) return;
var pretest = document.getElementById(streamid);
if(pretest != null) return;

var payload ={
"command": "setstreamid",
"id": streamid,
Expand Down

0 comments on commit d504cb6

Please sign in to comment.