Merge remote-tracking branch 'origin/develop' into new/dirSaveMgt

This commit is contained in:
Samuele Locatelli
2020-09-10 07:56:57 +02:00
29 changed files with 199 additions and 36 deletions
+92 -7
View File
@@ -38,12 +38,12 @@ namespace Active_Client.Browser_Tools
private static readonly string[] _validExtensions = {".json", ".rcp", ".tpl" };
//private static readonly string[] _validExtensions = { "", ".txt", ".cnc", ".cn", ".cno", ".ini", ".mpf", ".spf", ".tap", ".anc", ".iso" };
private static readonly string[] _validImages = { ".jpg", ".jpeg", ".png" };
private static readonly string[] _validImages = { ".jpg", ".jpeg", ".png", ".svg" };
private static string jobPath = "";
private static Dictionary<string, IntPtr> _editorOpened = new Dictionary<string, IntPtr>();
private static EditorVar _currentEditorObject = new EditorVar();
public static string RECENT_FOLDER_KEY = "RECENT";
private const string THERMO_RECIPE_PATH = @"C:\CMS\Recipes";
private const string THERMO_RECIPE_PATH = @"C:\CMS\Recipe";
public static FileSystemWatcher watcher = null;
public static DateTime _lastTimeFileWatcherEventRaised = DateTime.Now;
@@ -80,6 +80,11 @@ namespace Active_Client.Browser_Tools
AddFunction("getFileList").Execute += getFileList;
AddFunction("getProgramInfo").Execute += getProgramInfo;
AddFunction("editProgram").Execute += editProgram;
AddFunction("deleteFile").Execute += deleteFile;
AddFunction("deleteFolder").Execute += deleteFolder;
AddFunction("createFolder").Execute += createFolder;
AddFunction("uploadAndActivateProgram").Execute += uploadAndActivateProgram;
AddFunction("uploadAndAddToQueue").Execute += uploadAndAddToQueue;
@@ -360,6 +365,7 @@ namespace Active_Client.Browser_Tools
List<Drive> drivelist = new List<Drive>();
// USB & HD Drives
/*
foreach (var drive in DriveInfo.GetDrives())
{
if (drive.IsReady)
@@ -376,7 +382,7 @@ namespace Active_Client.Browser_Tools
}
}
}
// Desktop folder
drivelist.Add(new Drive()
{
@@ -384,6 +390,7 @@ namespace Active_Client.Browser_Tools
Path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\",
Type = "SPFO"
});
*/
if (Directory.Exists(THERMO_RECIPE_PATH))
{
@@ -394,7 +401,7 @@ namespace Active_Client.Browser_Tools
Type = "SPFO"
});
}
/*
try
{
// Network Folders
@@ -416,7 +423,7 @@ namespace Active_Client.Browser_Tools
catch (Exception ex)
{
}
}*/
e.SetReturnValue(JsonConvert.SerializeObject(drivelist));
}
@@ -485,6 +492,85 @@ namespace Active_Client.Browser_Tools
e.SetReturnValue(JsonConvert.SerializeObject(filelist));
}
public void deleteFile(object sender, CfrV8HandlerExecuteEventArgs e)
{
if (e.Arguments.Count() == 0)
{
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("error_arguments_not_ok")));
return;
}
// Get path
string p = e.Arguments[0].StringValue;
FileAttributes attr = File.GetAttributes(p);
if (!File.Exists(p) || attr.HasFlag(FileAttributes.Directory))
{
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("file_not_found")));
return;
}
if (attr.HasFlag(FileAttributes.ReadOnly))
{
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("file_not_editable")));
return;
}
try
{
File.Delete(p);
}
catch(Exception ex)
{
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("cannot_delete_file")));
}
}
public void deleteFolder(object sender, CfrV8HandlerExecuteEventArgs e)
{
if (e.Arguments.Count() == 0)
{
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("error_arguments_not_ok")));
return;
}
// Get path
string p = e.Arguments[0].StringValue;
FileAttributes attr = File.GetAttributes(p);
if (!Directory.Exists(p) || !attr.HasFlag(FileAttributes.Directory))
{
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("directory_not_found")));
return;
}
if (attr.HasFlag(FileAttributes.ReadOnly))
{
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("directory_not_editable")));
return;
}
try
{
Directory.Delete(p,true);
}
catch (Exception ex)
{
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("cannot_delete_directory")));
}
}
public void createFolder(object sender, CfrV8HandlerExecuteEventArgs e)
{
if (e.Arguments.Count() == 0)
{
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("error_arguments_not_ok")));
return;
}
string path = e.Arguments[0].StringValue;
try
{
Directory.CreateDirectory(path);
}
catch (Exception ex)
{
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("cannot_delete_directory")));
}
}
// Upload and activate the program
public async void uploadAndActivateProgram(object sender, CfrV8HandlerExecuteEventArgs e)
{
@@ -671,8 +757,7 @@ namespace Active_Client.Browser_Tools
// Read info of a file
public void getProgramInfo(object sender, CfrV8HandlerExecuteEventArgs e)
{
string line, imagePath, imageDirectory;
int counter = 0;
string imagePath, imageDirectory;
if (e.Arguments.Count() == 0)
{
@@ -70,6 +70,11 @@ namespace Thermo.Active.Controllers.WebApi
return Ok(currRecipe);
}
[Route("recipeNotes"), HttpGet]
public IHttpActionResult GetRecipeNotes()
{
return Ok(NcFileAdapter.RecipeLiveData.recipeNotes);
}
[Route("update"), HttpPut]
[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)]
+1 -1
View File
@@ -30,4 +30,4 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.13.74")]
[assembly: AssemblyVersion("0.13.75")]
@@ -2378,7 +2378,7 @@
line-height: 4px;
.title {
width: 110px;
min-width: 110px;
text-align: right;
color: @color-darkish-blue;
}
@@ -2523,7 +2523,7 @@ article .box .body {
.modal.modal-add-element-queue .modal-load-program-body .selected-item .selected-item-header .subtitle .title,
.modal.modal-load-program .modal-add-element-queue-body .selected-item .selected-item-header .subtitle .title,
.modal.modal-add-element-queue .modal-add-element-queue-body .selected-item .selected-item-header .subtitle .title {
width: 110px;
min-width: 110px;
text-align: right;
color: #002680;
}
@@ -2,7 +2,7 @@
"env": "development",
"api": {
"enabled": true,
"apiServerUrl": "http://seriate.steamware.net:9000/"
"apiServerUrl": "http://localhost:9000/"
},
"allUIVisible": true
"allUIVisible": false
}
+1 -1
View File
@@ -13,7 +13,7 @@
<script src="Scripts/jquery.mousewheel.js"></script>
<script src="Scripts/jquery.signalR-2.2.2.min.js"></script>
<script src="Scripts/raphael-2.1.4.min.js"></script>
<script src="http://seriate.steamware.net:9000/signalr/hubs" async></script>
<script src="http://localhost:9000/signalr/hubs" async></script>
<link href="assets/styles/style.css" rel="stylesheet" />
</head>
+2
View File
@@ -20,6 +20,7 @@ import Component from "vue-class-component";
import { Watch } from "vue-property-decorator";
import { UsersService } from "./services/usersService";
import { KeyboardHelper } from "./app_modules_thermo/components/KeyboardHelper";
import printGantt from "@/app_modules_thermo/processo/components/printProcesso.vue";
declare var cmsClient;
@@ -37,6 +38,7 @@ declare var cmsClient;
dashboard: Dashboard,
predashboard: PreDashboard,
alarmList,
printGantt
}
})
export default class app extends Vue {
+1
View File
@@ -18,6 +18,7 @@
<paddle></paddle>
<app-footer :class="{'blur':(applyBlur || applyBlurNc)}"></app-footer>
<print-gantt></print-gantt>
</div>
<modal-container containerName="modal-login" name="modal-login"></modal-container>
<keyboard></keyboard>
@@ -26,7 +26,6 @@ import { Hub } from '@/services';
})
export default class Dashboard extends Vue {
get panel() {
return (this.$store.state as AppModel).prod.panel;
}
@@ -66,7 +65,6 @@ export default class Dashboard extends Vue {
return (this.$store.state as AppModel).machineInfo.cmsConnectReady;
}
loading = false;
async loadMore() {
if (this.loading) return;
@@ -81,11 +79,11 @@ export default class Dashboard extends Vue {
getColor(nome, cognome) {
return getColorFromName(nome, cognome);
}
isDarkColor(color) {
return isDarkColor(color);
}
async mounted() {
prodService.GetProdPanel();
@@ -157,7 +155,6 @@ export default class Dashboard extends Vue {
close() {
appModelActions.ShowDashboard(this.$store);
};
}
enum ribbonStatusEnum {
@@ -149,7 +149,7 @@
</foreignObject>
</g>
<g v-if="value.showDelay">
<g v-if="value.showDelay && !ganttOptions.printing">
<line x1="0" y1="0" y2="0" :x2="actualDelay * ganttOptions.secondSize" class="progress-line" />
<foreignObject
width="30"
@@ -161,7 +161,10 @@
</foreignObject>
</g>
<g :transform="`translate(${delayDuration * ganttOptions.secondSize} 0)`">
<g
:transform="`translate(${delayDuration * ganttOptions.secondSize} 0)`"
v-if="!ganttOptions.printing"
>
<line
x1="0"
y1="0"
@@ -32,6 +32,14 @@ export default class GanttRow extends Vue {
return Array.from(this.blocks.values()).filter(i => i.section == this.section).sort((a, b) => a.priority - b.priority);
}
get maxVerticalPosition() {
return Math.max(...this.blocks.map(b => this.verticalPosition(b)))
}
get maxBlockPosition() {
return Math.max(...this.blocks.map(b => this.startPosition(b)))
}
startPosition(block: server.Modblock) {
return blockStartPosition(block, this.blocks, this.ganttOptions) * this.ganttOptions.secondSize;
}
@@ -4,10 +4,12 @@ import moment from "moment";
import ganttHeader from "./gantt-header.vue";
import ganttRow from "./gantt-row.vue"
import timeLine from "./timeline.vue";
import { recipeService } from "@/services/recipeService";
import { store, AppModel } from "@/store";
var ContainerElements = ["svg", "g", "foreignobject"];
var RelevantStyles = {
"rect": ["fill", "stroke", "stroke-width"],
"rect": ["fill", "stroke", "stroke-width", "rx", "ry"],
"path": ["fill", "stroke", "stroke-width"],
"circle": ["fill", "stroke", "stroke-width"],
"line": ["stroke", "stroke-width"],
@@ -34,6 +36,16 @@ export default class Gantt extends Vue {
padX: number = 0;
padY: number = 0;
get panel() {
return (this.$store.state as AppModel).prod.panel;
}
get ganttHeight() {
return (this.$refs.section1 as any).rowHeight +
(this.$refs.section2 as any).rowHeight +
(this.$refs.section3 as any).rowHeight;
}
public print() {
this.ganttOptions.printing = true;
@@ -48,10 +60,10 @@ export default class Gantt extends Vue {
var DOMURL = (window.URL || window.webkitURL);
var svgBlob = new Blob([data], { type: 'image/svg+xml;charset=utf-8' });
var url = DOMURL.createObjectURL(svgBlob);
// var url = DOMURL.createObjectURL(svgBlob);
recipeService.UploadImage(svgBlob, this.panel.nomeRicetta.replace('.rcp', '') + ".svg");
this.ganttOptions.printing = false;
window.open(url, '_blank')
// window.open(url, '_blank')
});
}
@@ -4,7 +4,7 @@
ref="mainContainer"
preserveAspectRation="xMinYMax"
width="100%"
height="100%"
:height="ganttOptions.printing ? `${ganttHeight}px` : '100%'"
@mousemove.capture="doPan"
v-on:touchmove="doPan"
@mousedown="startPan"
@@ -0,0 +1,23 @@
import Vue from "vue";
import Component from "vue-class-component";
import gantt from "./gantt/gantt.vue";
import { store } from "@/store";
import { messageService } from "@/_base";
@Component({
components: {
gantt
}
})
export default class PrintProcesso extends Vue {
get blocks(): server.Modblock[] {
return store.state.modules.blocks;
}
mounted() {
messageService.subscribeToChannel("print", () => {
(this.$refs.gantt as any).print();
})
}
}
@@ -0,0 +1,6 @@
<template>
<div class="printContainer">
<gantt ref="gantt" v-if="blocks" :blocks="blocks" :zoom-factor="1"></gantt>
</div>
</template>
<script src="./printProcesso.ts" lang="ts">
@@ -42,7 +42,6 @@
class="realign"
v-if="$refs.gantt"
@click="$refs.gantt.toggleFollow()"
@dblclick="$refs.gantt.print()"
:class="{active: $refs.gantt.follow}"
>
<img src="/assets/icons/png/recenter-time.png" />
@@ -4,13 +4,14 @@ import { Prop } from "vue-property-decorator";
import { Deferred } from "@/services";
import { Modal, ModalHelper } from "@/components/modals";
import { messageService } from "@/_base";
import { recipeService } from "@/services/recipeService";
@Component({ components: { modal: Modal } })
export default class Notes extends Vue {
@Prop()
deferred: Deferred<string>;
@Prop()
value: string;
note: string = null;
@@ -21,6 +22,10 @@ export default class Notes extends Vue {
this.note = value;
}
async mounted() {
this.Note = await recipeService.GetNote();
}
save(value: string) {
this.deferred.resolve(this.Note);
ModalHelper.HideModal();
@@ -89,7 +89,7 @@ export default class ShowCicloInfo extends Vue {
hasEnabledFields(...fields: string[]) {
let result = false;
for (const field of fields) {
if ((this.recipe[field] as Recipe.IValue).status.enabled) result = true;
if ((this.recipe[field] as Recipe.IValue).status.visible) result = true;
}
return result;
}
@@ -104,7 +104,7 @@ export default class ShowControstampoInfo extends Vue {
hasEnabledFields(...fields: string[]) {
let result = false;
for (const field of fields) {
if ((this.recipe[field] as Recipe.IValue).status.enabled) result = true;
if ((this.recipe[field] as Recipe.IValue).status.visible) result = true;
}
return result;
}
@@ -84,7 +84,7 @@ export default class ShowEstrazioneInfo extends Vue {
hasEnabledFields(...fields: string[]) {
let result = false;
for (const field of fields) {
if ((this.recipe[field] as Recipe.IValue).status.enabled) result = true;
if ((this.recipe[field] as Recipe.IValue).status.visible) result = true;
}
return result;
}
@@ -85,7 +85,7 @@ export default class ShowPirometroInfo extends Vue {
hasEnabledFields(...fields: string[]) {
let result = false;
for (const field of fields) {
if ((this.recipe[field] as Recipe.IValue).status.enabled) result = true;
if ((this.recipe[field] as Recipe.IValue).status.visible) result = true;
}
return result;
}
@@ -98,7 +98,7 @@ export default class ShowQuoteVelocitaInfo extends Vue {
hasEnabledFields(...fields: string[]) {
let result = false;
for (const field of fields) {
if ((this.recipe[field] as Recipe.IValue).status.enabled) result = true;
if ((this.recipe[field] as Recipe.IValue).status.visible) result = true;
}
return result;
}
@@ -109,7 +109,7 @@ export default class Raffreddamento extends Vue {
hasEnabledFields(...fields: string[]) {
let result = false;
for (const field of fields) {
if ((this.recipe[field] as Recipe.IValue).status.enabled) result = true;
if ((this.recipe[field] as Recipe.IValue).status.visible) result = true;
}
return result;
}
@@ -82,7 +82,7 @@ export default class ShowRiscaldamentoSuperioreInfo extends Vue {
hasEnabledFields(...fields: string[]) {
let result = false;
for (const field of fields) {
if ((this.recipe[field] as Recipe.IValue).status.enabled) result = true;
if ((this.recipe[field] as Recipe.IValue).status.visible) result = true;
}
return result;
}
@@ -110,7 +110,7 @@ export default class ShowVuotoInfo extends Vue {
hasEnabledFields(...fields: string[]) {
let result = false;
for (const field of fields) {
if ((this.recipe[field] as Recipe.IValue).status.enabled) result = true;
if ((this.recipe[field] as Recipe.IValue).status.visible) result = true;
}
return result;
}
@@ -131,6 +131,7 @@ export default class AppHeader extends Vue {
async saveRecipe() {
await recipeService.Save();
messageService.publishToChannel('print')
}
}
@@ -121,14 +121,14 @@
<label class="text">{{getDate(selectedFile.LastModDate)}}</label>
</div>
</div>
<div class="group-button">
<!-- <div class="group-button">
<button class="btn" v-if="false">
<i class="fa fa-clone"></i>
</button>
<button class="btn" :disabled="!selectedFile.CanEdit" @click="editprogram">
<i class="fa fa-pencil-square-o"></i>
</button>
</div>
</div>-->
</div>
<div class="selected-item-body" v-if="!selectedFile.IsJob" :class="{blur:fileIsChanged}">
@@ -20,6 +20,10 @@ export class RecipeService extends baseRestService {
return result;
}
async GetNote(): Promise<string> {
return this.Get((await this.BASE_URL()) + "recipeNotes");
}
async Update(model: { [id: string]: Recipe.IValue }) {
let payload = {}
@@ -93,5 +97,17 @@ export class RecipeService extends baseRestService {
return result;
}
async UploadImage(image: Blob, filename: string) {
const formData = new FormData();
formData.append('file', image, filename)
const config = {
headers: {
'content-type': 'multipart/form-data'
}
}
let result = await this.Post<any>((await this.BASE_URL()) + `uploadImage`, formData, true);
}
}
export const recipeService = new RecipeService();